Time to get rid of the horrible coding style

This commit is contained in:
pd 2008-08-01 18:31:43 +02:00
parent 534ee610d8
commit efc594f888
53 changed files with 1137 additions and 1136 deletions

View file

@ -9,15 +9,15 @@
using namespace std;
static const char* ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char* ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
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 )
EchoClient::EchoClient(DBus::Connection &connection, const char *path, const char *name)
: DBus::ObjectProxy(connection, path, name)
{
}
void EchoClient::Echoed( const DBus::Variant& value )
void EchoClient::Echoed(const DBus::Variant &value)
{
cout << "!";
}
@ -26,13 +26,13 @@ void EchoClient::Echoed( const DBus::Variant& value )
* For some strange reason, libdbus frequently dies with an OOM
*/
static const int THREADS = 16;
static const int THREADS = 3;
static bool spin = true;
void* greeter_thread( void* arg )
void *greeter_thread(void *arg)
{
DBus::Connection* conn = reinterpret_cast<DBus::Connection*>(arg);
DBus::Connection *conn = reinterpret_cast<DBus::Connection *>(arg);
EchoClient client(*conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME);
@ -40,7 +40,7 @@ void* greeter_thread( void* arg )
snprintf(idstr, sizeof(idstr), "%lu", pthread_self());
for(int i = 0; i < 100 && spin; ++i)
for (int i = 0; i < 30 && spin; ++i)
{
cout << client.Hello(idstr) << endl;
}
@ -52,7 +52,7 @@ void* greeter_thread( void* arg )
DBus::BusDispatcher dispatcher;
void niam( int sig )
void niam(int sig)
{
spin = false;
@ -76,7 +76,7 @@ int main()
pthread_t threads[THREADS];
for(int i = 0; i < THREADS; ++i)
for (int i = 0; i < THREADS; ++i)
{
pthread_create(threads+i, NULL, greeter_thread, &conn);
}
@ -85,7 +85,7 @@ int main()
cout << "terminating" << endl;
for(int i = 0; i < THREADS; ++i)
for (int i = 0; i < THREADS; ++i)
{
pthread_join(threads[i], NULL);
}

View file

@ -11,9 +11,9 @@ class EchoClient
{
public:
EchoClient( DBus::Connection& connection, const char* path, const char* name );
EchoClient(DBus::Connection &connection, const char *path, const char *name);
void Echoed( const DBus::Variant& value );
void Echoed(const DBus::Variant &value);
};
#endif//__DEMO_ECHO_CLIENT_H

View file

@ -5,10 +5,10 @@
#include <stdio.h>
#include <limits.h>
static const char* ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
static const char* ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
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 )
EchoServer::EchoServer(DBus::Connection &connection)
: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH)
{
}
@ -18,23 +18,24 @@ DBus::Int32 EchoServer::Random()
return rand();
}
DBus::String EchoServer::Hello( const DBus::String& name )
DBus::String EchoServer::Hello(const DBus::String &name)
{
sleep (10);
return "Hello " + name + "!";
}
DBus::Variant EchoServer::Echo( const DBus::Variant& value )
DBus::Variant EchoServer::Echo(const DBus::Variant &value)
{
this->Echoed(value);
return value;
}
std::vector< DBus::Byte > EchoServer::Cat( const DBus::String & file )
std::vector< DBus::Byte > EchoServer::Cat(const DBus::String &file)
{
FILE* handle = fopen(file.c_str(), "rb");
FILE *handle = fopen(file.c_str(), "rb");
if(!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found");
if (!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found");
DBus::Byte buff[1024];
@ -45,11 +46,11 @@ std::vector< DBus::Byte > EchoServer::Cat( const DBus::String & file )
return std::vector< DBus::Byte > (buff, buff + nread);
}
DBus::Int32 EchoServer::Sum( const std::vector<DBus::Int32>& ints )
DBus::Int32 EchoServer::Sum(const std::vector<DBus::Int32>& ints)
{
DBus::Int32 sum = 0;
for(size_t i = 0; i < ints.size(); ++i) sum += ints[i];
for (size_t i = 0; i < ints.size(); ++i) sum += ints[i];
return sum;
}
@ -69,7 +70,7 @@ std::map< DBus::String, DBus::String > EchoServer::Info()
DBus::BusDispatcher dispatcher;
void niam( int sig )
void niam(int sig)
{
dispatcher.leave();
}

View file

@ -11,17 +11,17 @@ class EchoServer
{
public:
EchoServer( DBus::Connection& connection );
EchoServer(DBus::Connection &connection);
DBus::Int32 Random();
DBus::String Hello( const DBus::String & name );
DBus::String Hello(const DBus::String &name);
DBus::Variant Echo( const DBus::Variant & value );
DBus::Variant Echo(const DBus::Variant &value);
std::vector< DBus::Byte > Cat( const DBus::String & file );
std::vector< DBus::Byte > Cat(const DBus::String &file);
DBus::Int32 Sum( const std::vector<DBus::Int32> & ints );
DBus::Int32 Sum(const std::vector<DBus::Int32> & ints);
std::map< DBus::String, DBus::String > Info();
};

View file

@ -5,10 +5,10 @@
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";
DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
DBusBrowser::DBusBrowser(::DBus::Connection &conn)
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
{
set_title("D-Bus Browser");
@ -19,12 +19,12 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
Names names = ListNames();
for(Names::iterator it = names.begin(); it != names.end(); ++it)
for (Names::iterator it = names.begin(); it != names.end(); ++it)
{
_cb_busnames.append_text(*it);
}
_cb_busnames.signal_changed().connect( sigc::mem_fun(*this, &DBusBrowser::on_select_busname) );
_cb_busnames.signal_changed().connect(sigc::mem_fun(*this, &DBusBrowser::on_select_busname));
_tm_inspect = Gtk::TreeStore::create(_records);
_tv_inspect.set_model(_tm_inspect);
@ -42,17 +42,17 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
}
void DBusBrowser::NameOwnerChanged(
const ::DBus::String& name, const ::DBus::String& old_owner, const ::DBus::String& new_owner )
const ::DBus::String &name, const ::DBus::String &old_owner, const ::DBus::String &new_owner)
{
cout << name << ": " << old_owner << " -> " << new_owner << endl;
}
void DBusBrowser::NameLost( const ::DBus::String& name )
void DBusBrowser::NameLost(const ::DBus::String &name)
{
cout << name << " lost" << endl;
}
void DBusBrowser::NameAcquired( const ::DBus::String& name )
void DBusBrowser::NameAcquired(const ::DBus::String &name)
{
cout << name << " acquired" << endl;
}
@ -60,24 +60,24 @@ void DBusBrowser::NameAcquired( const ::DBus::String& name )
void DBusBrowser::on_select_busname()
{
Glib::ustring busname = _cb_busnames.get_active_text();
if(busname.empty()) return;
if (busname.empty()) return;
_tm_inspect->clear();
_inspect_append(NULL, "", busname);
}
void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string& buspath, const std::string& busname )
void DBusBrowser::_inspect_append(Gtk::TreeModel::Row *row, const std::string &buspath, const std::string &busname)
{
DBusInspector inspector(conn(), buspath.empty() ? "/" : buspath.c_str(), busname.c_str());
::DBus::Xml::Document doc(inspector.Introspect());
::DBus::Xml::Node& root = *(doc.root);
::DBus::Xml::Node &root = *(doc.root);
::DBus::Xml::Nodes ifaces = root["interface"];
for(::DBus::Xml::Nodes::iterator ii = ifaces.begin(); ii != ifaces.end(); ++ii)
for (::DBus::Xml::Nodes::iterator ii = ifaces.begin(); ii != ifaces.end(); ++ii)
{
::DBus::Xml::Node& iface = **ii;
::DBus::Xml::Node &iface = **ii;
Gtk::TreeModel::Row i_row = row
? *(_tm_inspect->append(row->children()))
@ -86,7 +86,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string&
::DBus::Xml::Nodes methods = iface["method"];
for(::DBus::Xml::Nodes::iterator im = methods.begin(); im != methods.end(); ++im)
for (::DBus::Xml::Nodes::iterator im = methods.begin(); im != methods.end(); ++im)
{
Gtk::TreeModel::Row m_row = *(_tm_inspect->append(i_row.children()));
m_row[_records.name] = "method: " + (*im)->get("name");
@ -94,7 +94,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string&
::DBus::Xml::Nodes signals = iface["signal"];
for(::DBus::Xml::Nodes::iterator is = signals.begin(); is != signals.end(); ++is)
for (::DBus::Xml::Nodes::iterator is = signals.begin(); is != signals.end(); ++is)
{
Gtk::TreeModel::Row s_row = *(_tm_inspect->append(i_row.children()));
s_row[_records.name] = "signal: " + (*is)->get("name");
@ -103,7 +103,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string&
::DBus::Xml::Nodes nodes = root["node"];
for(::DBus::Xml::Nodes::iterator in = nodes.begin(); in != nodes.end(); ++in)
for (::DBus::Xml::Nodes::iterator in = nodes.begin(); in != nodes.end(); ++in)
{
std::string name = (*in)->get("name");
@ -118,7 +118,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string&
DBus::Glib::BusDispatcher dispatcher;
int main(int argc, char* argv[])
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);

View file

@ -13,7 +13,7 @@ class DBusInspector
{
public:
DBusInspector( DBus::Connection& conn, const char* path, const char* service )
DBusInspector(DBus::Connection &conn, const char *path, const char *service)
: DBus::ObjectProxy(conn, path, service)
{}
};
@ -26,19 +26,19 @@ class DBusBrowser
{
public:
DBusBrowser( ::DBus::Connection& );
DBusBrowser(::DBus::Connection &);
private:
void NameOwnerChanged( const ::DBus::String&, const ::DBus::String&, const ::DBus::String& );
void NameOwnerChanged(const ::DBus::String &, const ::DBus::String &, const ::DBus::String &);
void NameLost( const ::DBus::String& );
void NameLost(const ::DBus::String &);
void NameAcquired( const ::DBus::String& );
void NameAcquired(const ::DBus::String &);
void on_select_busname();
void _inspect_append( Gtk::TreeModel::Row*, const std::string&, const std::string& );
void _inspect_append(Gtk::TreeModel::Row *, const std::string &, const std::string &);
private:

View file

@ -3,7 +3,7 @@
#include <signal.h>
#include <iostream>
HalManagerProxy::HalManagerProxy( DBus::Connection& connection )
HalManagerProxy::HalManagerProxy(DBus::Connection &connection)
: DBus::InterfaceProxy("org.freedesktop.Hal.Manager"),
DBus::ObjectProxy(connection, "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal")
{
@ -13,7 +13,7 @@ HalManagerProxy::HalManagerProxy( DBus::Connection& connection )
std::vector< DBus::String > devices = GetAllDevices();
std::vector< DBus::String >::iterator it;
for(it = devices.begin(); it != devices.end(); ++it)
for (it = devices.begin(); it != devices.end(); ++it)
{
DBus::Path udi = *it;
@ -37,7 +37,7 @@ std::vector< DBus::String > HalManagerProxy::GetAllDevices()
return udis;
}
void HalManagerProxy::DeviceAddedCb( const DBus::SignalMessage& sig )
void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig)
{
DBus::MessageIter it = sig.reader();
DBus::String devname;
@ -50,7 +50,7 @@ void HalManagerProxy::DeviceAddedCb( const DBus::SignalMessage& sig )
std::cout << "added device " << udi << std::endl;
}
void HalManagerProxy::DeviceRemovedCb( const DBus::SignalMessage& sig )
void HalManagerProxy::DeviceRemovedCb(const DBus::SignalMessage &sig)
{
DBus::MessageIter it = sig.reader();
DBus::String devname;
@ -62,7 +62,7 @@ void HalManagerProxy::DeviceRemovedCb( const DBus::SignalMessage& sig )
_devices.erase(devname);
}
HalDeviceProxy::HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi )
HalDeviceProxy::HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi)
: DBus::InterfaceProxy("org.freedesktop.Hal.Device"),
DBus::ObjectProxy(connection, udi, "org.freedesktop.Hal")
{
@ -70,7 +70,7 @@ HalDeviceProxy::HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi )
connect_signal(HalDeviceProxy, Condition, ConditionCb);
}
void HalDeviceProxy::PropertyModifiedCb( const DBus::SignalMessage& sig )
void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig)
{
typedef DBus::Struct< DBus::String, DBus::Bool, DBus::Bool > HalProperty;
@ -81,7 +81,7 @@ void HalDeviceProxy::PropertyModifiedCb( const DBus::SignalMessage& sig )
DBus::MessageIter arr = it.recurse();
for(int i = 0; i < number; ++i, ++arr)
for (int i = 0; i < number; ++i, ++arr)
{
HalProperty hp;
@ -91,7 +91,7 @@ void HalDeviceProxy::PropertyModifiedCb( const DBus::SignalMessage& sig )
}
}
void HalDeviceProxy::ConditionCb( const DBus::SignalMessage& sig )
void HalDeviceProxy::ConditionCb(const DBus::SignalMessage &sig)
{
DBus::MessageIter it = sig.reader();
DBus::String condition;
@ -103,7 +103,7 @@ void HalDeviceProxy::ConditionCb( const DBus::SignalMessage& sig )
DBus::BusDispatcher dispatcher;
void niam( int sig )
void niam(int sig)
{
dispatcher.leave();
}

View file

@ -13,15 +13,15 @@ class HalManagerProxy
{
public:
HalManagerProxy( DBus::Connection& connection );
HalManagerProxy(DBus::Connection &connection);
std::vector< DBus::String > GetAllDevices();
private:
void DeviceAddedCb( const DBus::SignalMessage& sig );
void DeviceAddedCb(const DBus::SignalMessage &sig);
void DeviceRemovedCb( const DBus::SignalMessage& sig );
void DeviceRemovedCb(const DBus::SignalMessage &sig);
std::map< DBus::String, DBus::RefPtr< HalDeviceProxy > > _devices;
};
@ -32,13 +32,13 @@ class HalDeviceProxy
{
public:
HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi );
HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi);
private:
void PropertyModifiedCb( const DBus::SignalMessage& sig );
void PropertyModifiedCb(const DBus::SignalMessage &sig);
void ConditionCb( const DBus::SignalMessage& sig );
void ConditionCb(const DBus::SignalMessage &sig);
};
#endif//__DEMO_HAL_LISTEN_H

View file

@ -1,10 +1,10 @@
#include "props-server.h"
#include <signal.h>
static const char* PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties";
static const char* PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties";
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 )
PropsServer::PropsServer(DBus::Connection &connection)
: DBus::ObjectAdaptor(connection, PROPS_SERVER_PATH)
{
Version = 1;
@ -12,9 +12,9 @@ PropsServer::PropsServer( DBus::Connection& connection )
}
void PropsServer::on_set_property
( DBus::InterfaceAdaptor& interface, const DBus::String& property, const DBus::Variant& value )
(DBus::InterfaceAdaptor &interface, const DBus::String &property, const DBus::Variant &value)
{
if(property == "Message")
if (property == "Message")
{
DBus::String msg = value;
this->MessageChanged(msg);
@ -23,7 +23,7 @@ void PropsServer::on_set_property
DBus::BusDispatcher dispatcher;
void niam( int sig )
void niam(int sig)
{
dispatcher.leave();
}

View file

@ -12,10 +12,10 @@ class PropsServer
{
public:
PropsServer( DBus::Connection& connection );
PropsServer(DBus::Connection &connection);
void on_set_property
( DBus::InterfaceAdaptor& interface, const DBus::String& property, const DBus::Variant& value );
(DBus::InterfaceAdaptor &interface, const DBus::String &property, const DBus::Variant &value);
};
#endif//__DEMO_PROPS_SERVER_H