Merge branch 'master' of git://anongit.freedesktop.org/git/dbus/dbus-c++
Merge branch 'master' of git://anongit.freedesktop.org/git/dbus/dbus-c++ Conflicts: include/dbus-c++/connection.h include/dbus-c++/dispatcher.h include/dbus-c++/pendingcall.h src/dispatcher.cpp
This commit is contained in:
commit
c1970e2352
57 changed files with 1642 additions and 1638 deletions
|
@ -203,8 +203,8 @@ AC_OUTPUT(
|
||||||
examples/Makefile
|
examples/Makefile
|
||||||
examples/properties/Makefile
|
examples/properties/Makefile
|
||||||
examples/echo/Makefile
|
examples/echo/Makefile
|
||||||
examples/ecore/Makefile
|
examples/ecore/Makefile
|
||||||
examples/hal/Makefile
|
examples/hal/Makefile
|
||||||
examples/glib/Makefile
|
examples/glib/Makefile
|
||||||
dbus-c++-1.pc
|
dbus-c++-1.pc
|
||||||
dbus-c++-1-uninstalled.pc
|
dbus-c++-1-uninstalled.pc
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
SUBDIRS = properties echo hal glib ecore
|
SUBDIRS = properties echo hal glib ecore
|
||||||
|
|
||||||
MAINTAINERCLEANFILES = \
|
MAINTAINERCLEANFILES = \
|
||||||
Makefile.in
|
Makefile.in
|
||||||
|
|
|
@ -9,15 +9,15 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static const char* ECHO_SERVER_NAME = "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";
|
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)
|
: DBus::ObjectProxy(connection, path, name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void EchoClient::Echoed( const DBus::Variant& value )
|
void EchoClient::Echoed(const DBus::Variant &value)
|
||||||
{
|
{
|
||||||
cout << "!";
|
cout << "!";
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,13 @@ void EchoClient::Echoed( const DBus::Variant& value )
|
||||||
* For some strange reason, libdbus frequently dies with an OOM
|
* For some strange reason, libdbus frequently dies with an OOM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const int THREADS = 16;
|
static const int THREADS = 3;
|
||||||
|
|
||||||
static bool spin = true;
|
static bool spin = true;
|
||||||
|
|
||||||
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);
|
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());
|
snprintf(idstr, sizeof(idstr), "%lu", pthread_self());
|
||||||
|
|
||||||
for(int i = 0; i < 100 && spin; ++i)
|
for (int i = 0; i < 30 && spin; ++i)
|
||||||
{
|
{
|
||||||
cout << client.Hello(idstr) << endl;
|
cout << client.Hello(idstr) << endl;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ void* greeter_thread( void* arg )
|
||||||
|
|
||||||
DBus::BusDispatcher dispatcher;
|
DBus::BusDispatcher dispatcher;
|
||||||
|
|
||||||
void niam( int sig )
|
void niam(int sig)
|
||||||
{
|
{
|
||||||
spin = false;
|
spin = false;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ int main()
|
||||||
|
|
||||||
pthread_t threads[THREADS];
|
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);
|
pthread_create(threads+i, NULL, greeter_thread, &conn);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ int main()
|
||||||
|
|
||||||
cout << "terminating" << endl;
|
cout << "terminating" << endl;
|
||||||
|
|
||||||
for(int i = 0; i < THREADS; ++i)
|
for (int i = 0; i < THREADS; ++i)
|
||||||
{
|
{
|
||||||
pthread_join(threads[i], NULL);
|
pthread_join(threads[i], NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ class EchoClient
|
||||||
{
|
{
|
||||||
public:
|
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
|
#endif//__DEMO_ECHO_CLIENT_H
|
||||||
|
|
|
@ -9,58 +9,59 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
static const char* ECHO_SERVER_NAME = "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";
|
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)
|
: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DBus::Int32 EchoServer::Random()
|
int32_t EchoServer::Random()
|
||||||
{
|
{
|
||||||
return rand();
|
return rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
DBus::String EchoServer::Hello( const DBus::String& name )
|
std::string EchoServer::Hello(const std::string &name)
|
||||||
{
|
{
|
||||||
|
sleep (10);
|
||||||
return "Hello " + name + "!";
|
return "Hello " + name + "!";
|
||||||
}
|
}
|
||||||
|
|
||||||
DBus::Variant EchoServer::Echo( const DBus::Variant& value )
|
DBus::Variant EchoServer::Echo(const DBus::Variant &value)
|
||||||
{
|
{
|
||||||
this->Echoed(value);
|
this->Echoed(value);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< DBus::Byte > EchoServer::Cat( const DBus::String & file )
|
std::vector< uint8_t > EchoServer::Cat(const std::string &file)
|
||||||
{
|
{
|
||||||
FILE* handle = fopen(file.c_str(), "rb");
|
FILE *handle = fopen(file.c_str(), "rb");
|
||||||
|
|
||||||
if(!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found");
|
if (!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found");
|
||||||
|
|
||||||
DBus::Byte buff[1024];
|
uint8_t buff[1024];
|
||||||
|
|
||||||
size_t nread = fread(buff, 1, sizeof(buff), handle);
|
size_t nread = fread(buff, 1, sizeof(buff), handle);
|
||||||
|
|
||||||
fclose(handle);
|
fclose(handle);
|
||||||
|
|
||||||
return std::vector< DBus::Byte > (buff, buff + nread);
|
return std::vector< uint8_t > (buff, buff + nread);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBus::Int32 EchoServer::Sum( const std::vector<DBus::Int32>& ints )
|
int32_t EchoServer::Sum(const std::vector<int32_t>& ints)
|
||||||
{
|
{
|
||||||
DBus::Int32 sum = 0;
|
int32_t sum = 0;
|
||||||
|
|
||||||
for(size_t i = 0; i < ints.size(); ++i) sum += ints[i];
|
for (size_t i = 0; i < ints.size(); ++i) sum += ints[i];
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map< DBus::String, DBus::String > EchoServer::Info()
|
std::map< std::string, std::string > EchoServer::Info()
|
||||||
{
|
{
|
||||||
std::map< DBus::String, DBus::String > info;
|
std::map< std::string, std::string > info;
|
||||||
char hostname[HOST_NAME_MAX];
|
char hostname[HOST_NAME_MAX];
|
||||||
|
|
||||||
gethostname(hostname, sizeof(hostname));
|
gethostname(hostname, sizeof(hostname));
|
||||||
|
@ -73,7 +74,7 @@ std::map< DBus::String, DBus::String > EchoServer::Info()
|
||||||
|
|
||||||
DBus::BusDispatcher dispatcher;
|
DBus::BusDispatcher dispatcher;
|
||||||
|
|
||||||
void niam( int sig )
|
void niam(int sig)
|
||||||
{
|
{
|
||||||
dispatcher.leave();
|
dispatcher.leave();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,19 +11,19 @@ class EchoServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EchoServer( DBus::Connection& connection );
|
EchoServer(DBus::Connection &connection);
|
||||||
|
|
||||||
DBus::Int32 Random();
|
int32_t Random();
|
||||||
|
|
||||||
DBus::String Hello( const DBus::String & name );
|
std::string Hello(const std::string &name);
|
||||||
|
|
||||||
DBus::Variant Echo( const DBus::Variant & value );
|
DBus::Variant Echo(const DBus::Variant &value);
|
||||||
|
|
||||||
std::vector< DBus::Byte > Cat( const DBus::String & file );
|
std::vector< uint8_t > Cat(const std::string &file);
|
||||||
|
|
||||||
DBus::Int32 Sum( const std::vector<DBus::Int32> & ints );
|
int32_t Sum(const std::vector<int32_t> & ints);
|
||||||
|
|
||||||
std::map< DBus::String, DBus::String > Info();
|
std::map< std::string, std::string > Info();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif//__DEMO_ECHO_SERVER_H
|
#endif//__DEMO_ECHO_SERVER_H
|
||||||
|
|
|
@ -15,7 +15,7 @@ static const char* DBUS_SERVER_PATH = "/org/freedesktop/DBus";
|
||||||
DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
|
DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
|
||||||
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
|
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
|
||||||
{
|
{
|
||||||
typedef std::vector< ::DBus::String > Names;
|
typedef std::vector< std::string > Names;
|
||||||
|
|
||||||
Names names = ListNames();
|
Names names = ListNames();
|
||||||
|
|
||||||
|
@ -26,17 +26,17 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusBrowser::NameOwnerChanged(
|
void DBusBrowser::NameOwnerChanged(
|
||||||
const ::DBus::String& name, const ::DBus::String& old_owner, const ::DBus::String& new_owner )
|
const std::string& name, const std::string& old_owner, const std::string& new_owner )
|
||||||
{
|
{
|
||||||
cout << name << ": " << old_owner << " -> " << new_owner << endl;
|
cout << name << ": " << old_owner << " -> " << new_owner << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusBrowser::NameLost( const ::DBus::String& name )
|
void DBusBrowser::NameLost( const std::string& name )
|
||||||
{
|
{
|
||||||
cout << name << " lost" << endl;
|
cout << name << " lost" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusBrowser::NameAcquired( const ::DBus::String& name )
|
void DBusBrowser::NameAcquired( const std::string& name )
|
||||||
{
|
{
|
||||||
cout << name << " acquired" << endl;
|
cout << name << " acquired" << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void NameOwnerChanged( const ::DBus::String&, const ::DBus::String&, const ::DBus::String& );
|
void NameOwnerChanged( const std::string&, const std::string&, const std::string& );
|
||||||
|
|
||||||
void NameLost( const ::DBus::String& );
|
void NameLost( const std::string& );
|
||||||
|
|
||||||
void NameAcquired( const ::DBus::String& );
|
void NameAcquired( const std::string& );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -9,26 +9,26 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static const char* DBUS_SERVER_NAME = "org.freedesktop.DBus";
|
static const char *DBUS_SERVER_NAME = "org.freedesktop.DBus";
|
||||||
static const char* DBUS_SERVER_PATH = "/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)
|
: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME)
|
||||||
{
|
{
|
||||||
set_title("D-Bus Browser");
|
set_title("D-Bus Browser");
|
||||||
set_border_width(5);
|
set_border_width(5);
|
||||||
set_default_size(400, 500);
|
set_default_size(400, 500);
|
||||||
|
|
||||||
typedef std::vector< ::DBus::String > Names;
|
typedef std::vector< std::string > Names;
|
||||||
|
|
||||||
Names names = ListNames();
|
Names names = ListNames();
|
||||||
|
|
||||||
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.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);
|
_tm_inspect = Gtk::TreeStore::create(_records);
|
||||||
_tv_inspect.set_model(_tm_inspect);
|
_tv_inspect.set_model(_tm_inspect);
|
||||||
|
@ -46,17 +46,17 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn )
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusBrowser::NameOwnerChanged(
|
void DBusBrowser::NameOwnerChanged(
|
||||||
const ::DBus::String& name, const ::DBus::String& old_owner, const ::DBus::String& new_owner )
|
const std::string &name, const std::string &old_owner, const std::string &new_owner)
|
||||||
{
|
{
|
||||||
cout << name << ": " << old_owner << " -> " << new_owner << endl;
|
cout << name << ": " << old_owner << " -> " << new_owner << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusBrowser::NameLost( const ::DBus::String& name )
|
void DBusBrowser::NameLost(const std::string &name)
|
||||||
{
|
{
|
||||||
cout << name << " lost" << endl;
|
cout << name << " lost" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusBrowser::NameAcquired( const ::DBus::String& name )
|
void DBusBrowser::NameAcquired(const std::string &name)
|
||||||
{
|
{
|
||||||
cout << name << " acquired" << endl;
|
cout << name << " acquired" << endl;
|
||||||
}
|
}
|
||||||
|
@ -64,24 +64,24 @@ void DBusBrowser::NameAcquired( const ::DBus::String& name )
|
||||||
void DBusBrowser::on_select_busname()
|
void DBusBrowser::on_select_busname()
|
||||||
{
|
{
|
||||||
Glib::ustring busname = _cb_busnames.get_active_text();
|
Glib::ustring busname = _cb_busnames.get_active_text();
|
||||||
if(busname.empty()) return;
|
if (busname.empty()) return;
|
||||||
|
|
||||||
_tm_inspect->clear();
|
_tm_inspect->clear();
|
||||||
_inspect_append(NULL, "", busname);
|
_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());
|
DBusInspector inspector(conn(), buspath.empty() ? "/" : buspath.c_str(), busname.c_str());
|
||||||
|
|
||||||
::DBus::Xml::Document doc(inspector.Introspect());
|
::DBus::Xml::Document doc(inspector.Introspect());
|
||||||
::DBus::Xml::Node& root = *(doc.root);
|
::DBus::Xml::Node &root = *(doc.root);
|
||||||
|
|
||||||
::DBus::Xml::Nodes ifaces = root["interface"];
|
::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
|
Gtk::TreeModel::Row i_row = row
|
||||||
? *(_tm_inspect->append(row->children()))
|
? *(_tm_inspect->append(row->children()))
|
||||||
|
@ -90,7 +90,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string&
|
||||||
|
|
||||||
::DBus::Xml::Nodes methods = iface["method"];
|
::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()));
|
Gtk::TreeModel::Row m_row = *(_tm_inspect->append(i_row.children()));
|
||||||
m_row[_records.name] = "method: " + (*im)->get("name");
|
m_row[_records.name] = "method: " + (*im)->get("name");
|
||||||
|
@ -98,7 +98,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string&
|
||||||
|
|
||||||
::DBus::Xml::Nodes signals = iface["signal"];
|
::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()));
|
Gtk::TreeModel::Row s_row = *(_tm_inspect->append(i_row.children()));
|
||||||
s_row[_records.name] = "signal: " + (*is)->get("name");
|
s_row[_records.name] = "signal: " + (*is)->get("name");
|
||||||
|
@ -107,7 +107,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string&
|
||||||
|
|
||||||
::DBus::Xml::Nodes nodes = root["node"];
|
::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");
|
std::string name = (*in)->get("name");
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string&
|
||||||
|
|
||||||
DBus::Glib::BusDispatcher dispatcher;
|
DBus::Glib::BusDispatcher dispatcher;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Gtk::Main kit(argc, argv);
|
Gtk::Main kit(argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class DBusInspector
|
||||||
{
|
{
|
||||||
public:
|
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)
|
: DBus::ObjectProxy(conn, path, service)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
@ -26,19 +26,19 @@ class DBusBrowser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DBusBrowser( ::DBus::Connection& );
|
DBusBrowser(::DBus::Connection &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void NameOwnerChanged( const ::DBus::String&, const ::DBus::String&, const ::DBus::String& );
|
void NameOwnerChanged(const std::string &, const std::string &, const std::string &);
|
||||||
|
|
||||||
void NameLost( const ::DBus::String& );
|
void NameLost(const std::string &);
|
||||||
|
|
||||||
void NameAcquired( const ::DBus::String& );
|
void NameAcquired(const std::string &);
|
||||||
|
|
||||||
void on_select_busname();
|
void on_select_busname();
|
||||||
|
|
||||||
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:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,17 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
HalManagerProxy::HalManagerProxy( DBus::Connection& connection )
|
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")
|
DBus::ObjectProxy(connection, "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal")
|
||||||
{
|
{
|
||||||
connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb);
|
connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb);
|
||||||
connect_signal(HalManagerProxy, DeviceRemoved, DeviceRemovedCb);
|
connect_signal(HalManagerProxy, DeviceRemoved, DeviceRemovedCb);
|
||||||
|
|
||||||
std::vector< DBus::String > devices = GetAllDevices();
|
std::vector< std::string > devices = GetAllDevices();
|
||||||
|
|
||||||
std::vector< DBus::String >::iterator it;
|
std::vector< std::string >::iterator it;
|
||||||
for(it = devices.begin(); it != devices.end(); ++it)
|
for (it = devices.begin(); it != devices.end(); ++it)
|
||||||
{
|
{
|
||||||
DBus::Path udi = *it;
|
DBus::Path udi = *it;
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ HalManagerProxy::HalManagerProxy( DBus::Connection& connection )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< DBus::String > HalManagerProxy::GetAllDevices()
|
std::vector< std::string > HalManagerProxy::GetAllDevices()
|
||||||
{
|
{
|
||||||
std::vector< DBus::String > udis;
|
std::vector< std::string > udis;
|
||||||
DBus::CallMessage call;
|
DBus::CallMessage call;
|
||||||
|
|
||||||
call.member("GetAllDevices");
|
call.member("GetAllDevices");
|
||||||
|
@ -41,10 +41,10 @@ std::vector< DBus::String > HalManagerProxy::GetAllDevices()
|
||||||
return udis;
|
return udis;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HalManagerProxy::DeviceAddedCb( const DBus::SignalMessage& sig )
|
void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig)
|
||||||
{
|
{
|
||||||
DBus::MessageIter it = sig.reader();
|
DBus::MessageIter it = sig.reader();
|
||||||
DBus::String devname;
|
std::string devname;
|
||||||
|
|
||||||
it >> devname;
|
it >> devname;
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ void HalManagerProxy::DeviceAddedCb( const DBus::SignalMessage& sig )
|
||||||
std::cout << "added device " << udi << std::endl;
|
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::MessageIter it = sig.reader();
|
||||||
DBus::String devname;
|
std::string devname;
|
||||||
|
|
||||||
it >> devname;
|
it >> devname;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void HalManagerProxy::DeviceRemovedCb( const DBus::SignalMessage& sig )
|
||||||
_devices.erase(devname);
|
_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::InterfaceProxy("org.freedesktop.Hal.Device"),
|
||||||
DBus::ObjectProxy(connection, udi, "org.freedesktop.Hal")
|
DBus::ObjectProxy(connection, udi, "org.freedesktop.Hal")
|
||||||
{
|
{
|
||||||
|
@ -74,18 +74,18 @@ HalDeviceProxy::HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi )
|
||||||
connect_signal(HalDeviceProxy, Condition, ConditionCb);
|
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;
|
typedef DBus::Struct< std::string, bool, bool > HalProperty;
|
||||||
|
|
||||||
DBus::MessageIter it = sig.reader();
|
DBus::MessageIter it = sig.reader();
|
||||||
DBus::Int32 number;
|
int32_t number;
|
||||||
|
|
||||||
it >> number;
|
it >> number;
|
||||||
|
|
||||||
DBus::MessageIter arr = it.recurse();
|
DBus::MessageIter arr = it.recurse();
|
||||||
|
|
||||||
for(int i = 0; i < number; ++i, ++arr)
|
for (int i = 0; i < number; ++i, ++arr)
|
||||||
{
|
{
|
||||||
HalProperty hp;
|
HalProperty hp;
|
||||||
|
|
||||||
|
@ -95,10 +95,10 @@ void HalDeviceProxy::PropertyModifiedCb( const DBus::SignalMessage& sig )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HalDeviceProxy::ConditionCb( const DBus::SignalMessage& sig )
|
void HalDeviceProxy::ConditionCb(const DBus::SignalMessage &sig)
|
||||||
{
|
{
|
||||||
DBus::MessageIter it = sig.reader();
|
DBus::MessageIter it = sig.reader();
|
||||||
DBus::String condition;
|
std::string condition;
|
||||||
|
|
||||||
it >> condition;
|
it >> condition;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void HalDeviceProxy::ConditionCb( const DBus::SignalMessage& sig )
|
||||||
|
|
||||||
DBus::BusDispatcher dispatcher;
|
DBus::BusDispatcher dispatcher;
|
||||||
|
|
||||||
void niam( int sig )
|
void niam(int sig)
|
||||||
{
|
{
|
||||||
dispatcher.leave();
|
dispatcher.leave();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,17 +13,17 @@ class HalManagerProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HalManagerProxy( DBus::Connection& connection );
|
HalManagerProxy(DBus::Connection &connection);
|
||||||
|
|
||||||
std::vector< DBus::String > GetAllDevices();
|
std::vector< std::string > GetAllDevices();
|
||||||
|
|
||||||
private:
|
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;
|
std::map< std::string, DBus::RefPtr< HalDeviceProxy > > _devices;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HalDeviceProxy
|
class HalDeviceProxy
|
||||||
|
@ -32,13 +32,13 @@ class HalDeviceProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi );
|
HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi);
|
||||||
|
|
||||||
private:
|
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
|
#endif//__DEMO_HAL_LISTEN_H
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#include "props-server.h"
|
#include "props-server.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
static const char* PROPS_SERVER_NAME = "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";
|
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)
|
: DBus::ObjectAdaptor(connection, PROPS_SERVER_PATH)
|
||||||
{
|
{
|
||||||
Version = 1;
|
Version = 1;
|
||||||
|
@ -16,18 +16,18 @@ PropsServer::PropsServer( DBus::Connection& connection )
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropsServer::on_set_property
|
void PropsServer::on_set_property
|
||||||
( DBus::InterfaceAdaptor& interface, const DBus::String& property, const DBus::Variant& value )
|
(DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value)
|
||||||
{
|
{
|
||||||
if(property == "Message")
|
if (property == "Message")
|
||||||
{
|
{
|
||||||
DBus::String msg = value;
|
std::string msg = value;
|
||||||
this->MessageChanged(msg);
|
this->MessageChanged(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBus::BusDispatcher dispatcher;
|
DBus::BusDispatcher dispatcher;
|
||||||
|
|
||||||
void niam( int sig )
|
void niam(int sig)
|
||||||
{
|
{
|
||||||
dispatcher.leave();
|
dispatcher.leave();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@ class PropsServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PropsServer( DBus::Connection& connection );
|
PropsServer(DBus::Connection &connection);
|
||||||
|
|
||||||
void on_set_property
|
void on_set_property
|
||||||
( DBus::InterfaceAdaptor& interface, const DBus::String& property, const DBus::Variant& value );
|
(DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif//__DEMO_PROPS_SERVER_H
|
#endif//__DEMO_PROPS_SERVER_H
|
||||||
|
|
|
@ -72,377 +72,377 @@ public:
|
||||||
|
|
||||||
bool operator == ( const Connection& ) const;
|
bool operator == ( const Connection& ) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Adds a match rule to match messages going through the message bus.
|
* \brief Adds a match rule to match messages going through the message bus.
|
||||||
*
|
*
|
||||||
* The "rule" argument is the string form of a match rule.
|
* The "rule" argument is the string form of a match rule.
|
||||||
*
|
*
|
||||||
* If you pass NULL for the error, this function will not block; the match
|
* If you pass NULL for the error, this function will not block; the match
|
||||||
* thus won't be added until you flush the connection, and if there's an error
|
* thus won't be added until you flush the connection, and if there's an error
|
||||||
* adding the match (only possible error is lack of resources in the bus), you
|
* adding the match (only possible error is lack of resources in the bus), you
|
||||||
* won't find out about it.
|
* won't find out about it.
|
||||||
*
|
*
|
||||||
* Normal API conventions would have the function return a boolean value
|
* Normal API conventions would have the function return a boolean value
|
||||||
* indicating whether the error was set, but that would require blocking always
|
* indicating whether the error was set, but that would require blocking always
|
||||||
* to determine the return value.
|
* to determine the return value.
|
||||||
*
|
*
|
||||||
* The AddMatch method is fully documented in the D-Bus specification. For
|
* The AddMatch method is fully documented in the D-Bus specification. For
|
||||||
* quick reference, the format of the match rules is discussed here, but the
|
* quick reference, the format of the match rules is discussed here, but the
|
||||||
* specification is the canonical version of this information.
|
* specification is the canonical version of this information.
|
||||||
*
|
*
|
||||||
* Rules are specified as a string of comma separated key/value pairs. An
|
* Rules are specified as a string of comma separated key/value pairs. An
|
||||||
* example is "type='signal',sender='org.freedesktop.DBus',
|
* example is "type='signal',sender='org.freedesktop.DBus',
|
||||||
* interface='org.freedesktop.DBus',member='Foo', path='/bar/foo',destination=':452345.34'"
|
* interface='org.freedesktop.DBus',member='Foo', path='/bar/foo',destination=':452345.34'"
|
||||||
*
|
*
|
||||||
* Possible keys you can match on are type, sender, interface, member, path,
|
* Possible keys you can match on are type, sender, interface, member, path,
|
||||||
* destination and numbered keys to match message args (keys are 'arg0', 'arg1', etc.).
|
* destination and numbered keys to match message args (keys are 'arg0', 'arg1', etc.).
|
||||||
* Omitting a key from the rule indicates a wildcard match. For instance omitting
|
* Omitting a key from the rule indicates a wildcard match. For instance omitting
|
||||||
* the member from a match rule but adding a sender would let all messages from
|
* the member from a match rule but adding a sender would let all messages from
|
||||||
* that sender through regardless of the member.
|
* that sender through regardless of the member.
|
||||||
*
|
*
|
||||||
* Matches are inclusive not exclusive so as long as one rule matches the
|
* Matches are inclusive not exclusive so as long as one rule matches the
|
||||||
* message will get through. It is important to note this because every time a
|
* message will get through. It is important to note this because every time a
|
||||||
* essage is received the application will be paged into memory to process it.
|
* essage is received the application will be paged into memory to process it.
|
||||||
* This can cause performance problems such as draining batteries on embedded platforms.
|
* This can cause performance problems such as draining batteries on embedded platforms.
|
||||||
*
|
*
|
||||||
* If you match message args ('arg0', 'arg1', and so forth) only string arguments
|
* If you match message args ('arg0', 'arg1', and so forth) only string arguments
|
||||||
* will match. That is, arg0='5' means match the string "5" not the integer 5.
|
* will match. That is, arg0='5' means match the string "5" not the integer 5.
|
||||||
*
|
*
|
||||||
* Currently there is no way to match against non-string arguments.
|
* Currently there is no way to match against non-string arguments.
|
||||||
*
|
*
|
||||||
* Matching on interface is tricky because method call messages only optionally
|
* Matching on interface is tricky because method call messages only optionally
|
||||||
* specify the interface. If a message omits the interface, then it will NOT
|
* specify the interface. If a message omits the interface, then it will NOT
|
||||||
* match if the rule specifies an interface name. This means match rules on
|
* match if the rule specifies an interface name. This means match rules on
|
||||||
* method calls should not usually give an interface.
|
* method calls should not usually give an interface.
|
||||||
*
|
*
|
||||||
* However, signal messages are required to include the interface so when
|
* However, signal messages are required to include the interface so when
|
||||||
* matching signals usually you should specify the interface in the match rule.
|
* matching signals usually you should specify the interface in the match rule.
|
||||||
*
|
*
|
||||||
* For security reasons, you can match arguments only up to DBUS_MAXIMUM_MATCH_RULE_ARG_NUMBER.
|
* For security reasons, you can match arguments only up to DBUS_MAXIMUM_MATCH_RULE_ARG_NUMBER.
|
||||||
*
|
*
|
||||||
* Match rules have a maximum length of DBUS_MAXIMUM_MATCH_RULE_LENGTH bytes.
|
* Match rules have a maximum length of DBUS_MAXIMUM_MATCH_RULE_LENGTH bytes.
|
||||||
*
|
*
|
||||||
* Both of these maximums are much higher than you're likely to need, they only
|
* Both of these maximums are much higher than you're likely to need, they only
|
||||||
* exist because the D-Bus bus daemon has fixed limits on all resource usage.
|
* exist because the D-Bus bus daemon has fixed limits on all resource usage.
|
||||||
*
|
*
|
||||||
* \param rule Textual form of match rule.
|
* \param rule Textual form of match rule.
|
||||||
* \throw Error
|
* \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
|
* \brief Removes a previously-added match rule "by value" (the most
|
||||||
* recently-added identical rule gets removed).
|
* recently-added identical rule gets removed).
|
||||||
*
|
*
|
||||||
* The "rule" argument is the string form of a match rule.
|
* The "rule" argument is the string form of a match rule.
|
||||||
*
|
*
|
||||||
* The bus compares match rules semantically, not textually, so whitespace and
|
* The bus compares match rules semantically, not textually, so whitespace and
|
||||||
* ordering don't have to be identical to the rule you passed to add_match().
|
* ordering don't have to be identical to the rule you passed to add_match().
|
||||||
*
|
*
|
||||||
* \param rule Textual form of match rule.
|
* \param rule Textual form of match rule.
|
||||||
* \throw Error
|
* \throw Error
|
||||||
*/
|
*/
|
||||||
void remove_match( const char* rule );
|
void remove_match( const char* rule );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Adds a message filter.
|
* \brief Adds a message filter.
|
||||||
*
|
*
|
||||||
* Filters are handlers that are run on all incoming messages, prior to the
|
* Filters are handlers that are run on all incoming messages, prior to the
|
||||||
* objects registered with ObjectAdaptor::register_obj(). Filters are
|
* objects registered with ObjectAdaptor::register_obj(). Filters are
|
||||||
* run in the order that they were added. The same handler can be added as a
|
* run in the order that they were added. The same handler can be added as a
|
||||||
* filter more than once, in which case it will be run more than once. Filters
|
* filter more than once, in which case it will be run more than once. Filters
|
||||||
* added during a filter callback won't be run on the message being processed.
|
* added during a filter callback won't be run on the message being processed.
|
||||||
*
|
*
|
||||||
* \param s The MessageSlot to add.
|
* \param s The MessageSlot to add.
|
||||||
*/
|
*/
|
||||||
bool add_filter( MessageSlot& s);
|
bool add_filter( MessageSlot& s);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Removes a previously-added message filter.
|
* \brief Removes a previously-added message filter.
|
||||||
*
|
*
|
||||||
* It is a programming error to call this function for a handler that has not
|
* It is a programming error to call this function for a handler that has not
|
||||||
* been added as a filter. If the given handler was added more than once, only
|
* been added as a filter. If the given handler was added more than once, only
|
||||||
* one instance of it will be removed (the most recently-added instance).
|
* one instance of it will be removed (the most recently-added instance).
|
||||||
*
|
*
|
||||||
* \param s The MessageSlot to remove.
|
* \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.
|
* \brief Sets the unique name of the connection, as assigned by the message bus.
|
||||||
*
|
*
|
||||||
* Can only be used if you registered with the bus manually (i.e. if you did
|
* Can only be used if you registered with the bus manually (i.e. if you did
|
||||||
* not call register_bus()). Can only be called once per connection. After
|
* not call register_bus()). Can only be called once per connection. After
|
||||||
* the unique name is set, you can get it with unique_name(void).
|
* the unique name is set, you can get it with unique_name(void).
|
||||||
*
|
*
|
||||||
* The only reason to use this function is to re-implement the equivalent of
|
* The only reason to use this function is to re-implement the equivalent of
|
||||||
* register_bus() yourself. One (probably unusual) reason to do that might
|
* register_bus() yourself. One (probably unusual) reason to do that might
|
||||||
* be to do the bus registration call asynchronously instead of synchronously.
|
* be to do the bus registration call asynchronously instead of synchronously.
|
||||||
*
|
*
|
||||||
* \note Just use dbus_bus_get() or dbus_bus_get_private(), or worst case
|
* \note Just use dbus_bus_get() or dbus_bus_get_private(), or worst case
|
||||||
* register_bus(), instead of messing with this function. There's
|
* register_bus(), instead of messing with this function. There's
|
||||||
* really no point creating pain for yourself by doing things manually.
|
* really no point creating pain for yourself by doing things manually.
|
||||||
* (Not sure if this is yet wrapped.)
|
* (Not sure if this is yet wrapped.)
|
||||||
*
|
*
|
||||||
* It's hard to use this function safely on shared connections (created by
|
* It's hard to use this function safely on shared connections (created by
|
||||||
* Connection()) in a multithreaded application, because only one
|
* Connection()) in a multithreaded application, because only one
|
||||||
* registration attempt can be sent to the bus. If two threads are both
|
* registration attempt can be sent to the bus. If two threads are both
|
||||||
* sending the registration message, there is no mechanism in libdbus itself
|
* sending the registration message, there is no mechanism in libdbus itself
|
||||||
* to avoid sending it twice.
|
* to avoid sending it twice.
|
||||||
*
|
*
|
||||||
* Thus, you need a way to coordinate which thread sends the registration
|
* Thus, you need a way to coordinate which thread sends the registration
|
||||||
* attempt; which also means you know which thread will call
|
* attempt; which also means you know which thread will call
|
||||||
* unique_name(const char*). If you don't know about all threads in the app
|
* unique_name(const char*). If you don't know about all threads in the app
|
||||||
* (for example, if some libraries you're using might start libdbus-using
|
* (for example, if some libraries you're using might start libdbus-using
|
||||||
* threads), then you need to avoid using this function on shared connections.
|
* threads), then you need to avoid using this function on shared connections.
|
||||||
*
|
*
|
||||||
* \param n The unique name.
|
* \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.
|
* \brief Gets the unique name of the connection as assigned by the message bus.
|
||||||
*
|
*
|
||||||
* Only possible after the connection has been registered with the message bus.
|
* Only possible after the connection has been registered with the message bus.
|
||||||
* All connections returned by dbus_bus_get() or dbus_bus_get_private() have
|
* All connections returned by dbus_bus_get() or dbus_bus_get_private() have
|
||||||
* been successfully registered. (Not sure if this is yet wrapped.)
|
* been successfully registered. (Not sure if this is yet wrapped.)
|
||||||
*
|
*
|
||||||
* The name remains valid until the connection is freed, and should not be
|
* The name remains valid until the connection is freed, and should not be
|
||||||
* freed by the caller.
|
* freed by the caller.
|
||||||
*
|
*
|
||||||
* Other than dbus_bus_get(), there are two ways to set the unique name; one
|
* Other than dbus_bus_get(), there are two ways to set the unique name; one
|
||||||
* is register_bus(), the other is unique_name(const char*). You are
|
* is register_bus(), the other is unique_name(const char*). You are
|
||||||
* responsible for calling unique_name(const char*) if you register by hand
|
* responsible for calling unique_name(const char*) if you register by hand
|
||||||
* instead of using register_bus().
|
* instead of using register_bus().
|
||||||
*/
|
*/
|
||||||
const char* unique_name() const;
|
const char* unique_name() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Registers a connection with the bus.
|
* \brief Registers a connection with the bus.
|
||||||
*
|
*
|
||||||
* This must be the first thing an application does when connecting to the
|
* This must be the first thing an application does when connecting to the
|
||||||
* message bus. If registration succeeds, the unique name will be set, and
|
* message bus. If registration succeeds, the unique name will be set, and
|
||||||
* can be obtained using unique_name(void).
|
* can be obtained using unique_name(void).
|
||||||
*
|
*
|
||||||
* This function will block until registration is complete.
|
* This function will block until registration is complete.
|
||||||
*
|
*
|
||||||
* If the connection has already registered with the bus (determined by
|
* If the connection has already registered with the bus (determined by
|
||||||
* checking whether unique_name(void) returns a non-NULL value),
|
* checking whether unique_name(void) returns a non-NULL value),
|
||||||
* then this function does nothing.
|
* then this function does nothing.
|
||||||
*
|
*
|
||||||
* If you use dbus_bus_get() or dbus_bus_get_private() this function will be
|
* If you use dbus_bus_get() or dbus_bus_get_private() this function will be
|
||||||
* called for you. (Not sure if this is yet wrapped.)
|
* called for you. (Not sure if this is yet wrapped.)
|
||||||
*
|
*
|
||||||
* \note Just use dbus_bus_get() or dbus_bus_get_private() instead of
|
* \note Just use dbus_bus_get() or dbus_bus_get_private() instead of
|
||||||
* register_bus() and save yourself some pain. Using register_bus()
|
* register_bus() and save yourself some pain. Using register_bus()
|
||||||
* manually is only useful if you have your own custom message bus not found
|
* manually is only useful if you have your own custom message bus not found
|
||||||
* in DBusBusType.
|
* in DBusBusType.
|
||||||
*
|
*
|
||||||
* If you open a bus connection by the contructor of Connection() you will have to register_bus()
|
* If you open a bus connection by the contructor of Connection() you will have to register_bus()
|
||||||
* yourself, or make the appropriate registration method calls yourself. If
|
* yourself, or make the appropriate registration method calls yourself. If
|
||||||
* you send the method calls yourself, call unique_name(const char*) with
|
* you send the method calls yourself, call unique_name(const char*) with
|
||||||
* the unique bus name you get from the bus.
|
* the unique bus name you get from the bus.
|
||||||
*
|
*
|
||||||
* For shared connections (created with dbus_connection_open()) in a
|
* For shared connections (created with dbus_connection_open()) in a
|
||||||
* multithreaded application, you can't really make the registration calls
|
* multithreaded application, you can't really make the registration calls
|
||||||
* yourself, because you don't know whether some other thread is also
|
* yourself, because you don't know whether some other thread is also
|
||||||
* registering, and the bus will kick you off if you send two registration
|
* registering, and the bus will kick you off if you send two registration
|
||||||
* messages. (TODO: how is this done in the wrapper?)
|
* messages. (TODO: how is this done in the wrapper?)
|
||||||
*
|
*
|
||||||
* If you use register_bus() however, there is a lock that keeps both
|
* If you use register_bus() however, there is a lock that keeps both
|
||||||
* apps from registering at the same time.
|
* apps from registering at the same time.
|
||||||
*
|
*
|
||||||
* The rule in a multithreaded app, then, is that register_bus() must be
|
* The rule in a multithreaded app, then, is that register_bus() must be
|
||||||
* used to register, or you need to have your own locks that all threads in
|
* used to register, or you need to have your own locks that all threads in
|
||||||
* the app will respect.
|
* the app will respect.
|
||||||
*
|
*
|
||||||
* In a single-threaded application you can register by hand instead of using
|
* In a single-threaded application you can register by hand instead of using
|
||||||
* register_bus(), as long as you check unique_name(void) to
|
* register_bus(), as long as you check unique_name(void) to
|
||||||
* see if a unique name has already been stored by another thread before you
|
* see if a unique name has already been stored by another thread before you
|
||||||
* send the registration messages.
|
* send the registration messages.
|
||||||
*/
|
*/
|
||||||
bool register_bus();
|
bool register_bus();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets whether the connection is currently open.
|
* \brief Gets whether the connection is currently open.
|
||||||
*
|
*
|
||||||
* A connection may become disconnected when the remote application closes its
|
* A connection may become disconnected when the remote application closes its
|
||||||
* end, or exits; a connection may also be disconnected with disconnect().
|
* end, or exits; a connection may also be disconnected with disconnect().
|
||||||
*
|
*
|
||||||
* There are not separate states for "closed" and "disconnected," the two
|
* There are not separate states for "closed" and "disconnected," the two
|
||||||
* terms are synonymous.
|
* terms are synonymous.
|
||||||
*
|
*
|
||||||
* \return true If the connection is still alive.
|
* \return true If the connection is still alive.
|
||||||
*/
|
*/
|
||||||
bool connected() const;
|
bool connected() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Closes a private connection, so no further data can be sent or received.
|
* \brief Closes a private connection, so no further data can be sent or received.
|
||||||
*
|
*
|
||||||
* This disconnects the transport (such as a socket) underlying the connection.
|
* This disconnects the transport (such as a socket) underlying the connection.
|
||||||
*
|
*
|
||||||
* Attempts to send messages after closing a connection are safe, but will
|
* Attempts to send messages after closing a connection are safe, but will
|
||||||
* result in error replies generated locally in libdbus.
|
* result in error replies generated locally in libdbus.
|
||||||
*
|
*
|
||||||
* This function does not affect the connection's reference count. It's safe
|
* This function does not affect the connection's reference count. It's safe
|
||||||
* to close a connection more than once; all calls after the first do nothing.
|
* to close a connection more than once; all calls after the first do nothing.
|
||||||
* It's impossible to "reopen" a connection, a new connection must be created.
|
* It's impossible to "reopen" a connection, a new connection must be created.
|
||||||
* This function may result in a call to the DBusDispatchStatusFunction set
|
* This function may result in a call to the DBusDispatchStatusFunction set
|
||||||
* with Private::init(), as the disconnect
|
* with Private::init(), as the disconnect
|
||||||
* message it generates needs to be dispatched.
|
* message it generates needs to be dispatched.
|
||||||
*
|
*
|
||||||
* If a connection is dropped by the remote application, it will close itself.
|
* If a connection is dropped by the remote application, it will close itself.
|
||||||
*
|
*
|
||||||
* You must close a connection prior to releasing the last reference to the
|
* You must close a connection prior to releasing the last reference to the
|
||||||
* connection.
|
* connection.
|
||||||
*
|
*
|
||||||
* You may not close a shared connection. Connections created with
|
* You may not close a shared connection. Connections created with
|
||||||
* dbus_connection_open() or dbus_bus_get() are shared. These connections are
|
* dbus_connection_open() or dbus_bus_get() are shared. These connections are
|
||||||
* owned by libdbus, and applications should only unref them, never close them.
|
* owned by libdbus, and applications should only unref them, never close them.
|
||||||
* Applications can know it is safe to unref these connections because libdbus
|
* Applications can know it is safe to unref these connections because libdbus
|
||||||
* will be holding a reference as long as the connection is open. Thus, either
|
* will be holding a reference as long as the connection is open. Thus, either
|
||||||
* the connection is closed and it is OK to drop the last reference, or the
|
* the connection is closed and it is OK to drop the last reference, or the
|
||||||
* connection is open and the app knows it does not have the last reference.
|
* connection is open and the app knows it does not have the last reference.
|
||||||
*
|
*
|
||||||
* Connections created with dbus_connection_open_private() or
|
* Connections created with dbus_connection_open_private() or
|
||||||
* dbus_bus_get_private() are not kept track of or referenced by libdbus.
|
* dbus_bus_get_private() are not kept track of or referenced by libdbus.
|
||||||
* The creator of these connections is responsible for calling
|
* The creator of these connections is responsible for calling
|
||||||
* dbus_connection_close() prior to releasing the last reference, if the
|
* dbus_connection_close() prior to releasing the last reference, if the
|
||||||
* connection is not already disconnected.
|
* connection is not already disconnected.
|
||||||
*
|
*
|
||||||
* \todo dbus_connection_disconnect() was removed in dbus 0.9x. Maybe this
|
* \todo dbus_connection_disconnect() was removed in dbus 0.9x. Maybe this
|
||||||
* function should be renamed to close().
|
* function should be renamed to close().
|
||||||
*/
|
*/
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set whether _exit() should be called when the connection receives a
|
* \brief Set whether _exit() should be called when the connection receives a
|
||||||
* disconnect signal.
|
* disconnect signal.
|
||||||
*
|
*
|
||||||
* The call to _exit() comes after any handlers for the disconnect signal run;
|
* The call to _exit() comes after any handlers for the disconnect signal run;
|
||||||
* handlers can cancel the exit by calling this function.
|
* handlers can cancel the exit by calling this function.
|
||||||
*
|
*
|
||||||
* By default, exit_on_disconnect is false; but for message bus connections
|
* By default, exit_on_disconnect is false; but for message bus connections
|
||||||
* returned from dbus_bus_get() it will be toggled on by default.
|
* returned from dbus_bus_get() it will be toggled on by default.
|
||||||
*
|
*
|
||||||
* \param exit true If _exit() should be called after a disconnect signal.
|
* \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.
|
* \brief Blocks until the outgoing message queue is empty.
|
||||||
*/
|
*/
|
||||||
void flush();
|
void flush();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Adds a message to the outgoing message queue.
|
* \brief Adds a message to the outgoing message queue.
|
||||||
*
|
*
|
||||||
* Does not block to write the message to the network; that happens
|
* Does not block to write the message to the network; that happens
|
||||||
* asynchronously. To force the message to be written, call
|
* asynchronously. To force the message to be written, call
|
||||||
* dbus_connection_flush(). Because this only queues the message, the only
|
* dbus_connection_flush(). Because this only queues the message, the only
|
||||||
* reason it can fail is lack of memory. Even if the connection is disconnected,
|
* reason it can fail is lack of memory. Even if the connection is disconnected,
|
||||||
* no error will be returned.
|
* no error will be returned.
|
||||||
*
|
*
|
||||||
* If the function fails due to lack of memory, it returns FALSE. The function
|
* If the function fails due to lack of memory, it returns FALSE. The function
|
||||||
* will never fail for other reasons; even if the connection is disconnected,
|
* will never fail for other reasons; even if the connection is disconnected,
|
||||||
* you can queue an outgoing message, though obviously it won't be sent.
|
* you can queue an outgoing message, though obviously it won't be sent.
|
||||||
*
|
*
|
||||||
* The message serial is used by the remote application to send a reply; see
|
* The message serial is used by the remote application to send a reply; see
|
||||||
* Message::serial() or the D-Bus specification.
|
* Message::serial() or the D-Bus specification.
|
||||||
*
|
*
|
||||||
* \param msg The Message to write.
|
* \param msg The Message to write.
|
||||||
* \param serial Return location for message serial, or NULL if you don't care.
|
* \param serial Return location for message serial, or NULL if you don't care.
|
||||||
* \return true On success.
|
* \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.
|
* \brief Sends a message and blocks a certain time period while waiting for a reply.
|
||||||
*
|
*
|
||||||
* This function does not reenter the main loop, i.e. messages other than the
|
* This function does not reenter the main loop, i.e. messages other than the
|
||||||
* reply are queued up but not processed. This function is used to invoke
|
* reply are queued up but not processed. This function is used to invoke
|
||||||
* method calls on a remote object.
|
* method calls on a remote object.
|
||||||
*
|
*
|
||||||
* If a normal reply is received, it is returned, and removed from the
|
* If a normal reply is received, it is returned, and removed from the
|
||||||
* incoming message queue. If it is not received, NULL is returned and the
|
* incoming message queue. If it is not received, NULL is returned and the
|
||||||
* error is set to DBUS_ERROR_NO_REPLY. If an error reply is received, it is
|
* error is set to DBUS_ERROR_NO_REPLY. If an error reply is received, it is
|
||||||
* converted to a DBusError and returned as an error, then the reply message
|
* converted to a DBusError and returned as an error, then the reply message
|
||||||
* is deleted and NULL is returned. If something else goes wrong, result is
|
* is deleted and NULL is returned. If something else goes wrong, result is
|
||||||
* set to whatever is appropriate, such as DBUS_ERROR_NO_MEMORY or DBUS_ERROR_DISCONNECTED.
|
* set to whatever is appropriate, such as DBUS_ERROR_NO_MEMORY or DBUS_ERROR_DISCONNECTED.
|
||||||
*
|
*
|
||||||
* \warning While this function blocks the calling thread will not be
|
* \warning While this function blocks the calling thread will not be
|
||||||
* processing the incoming message queue. This means you can end up
|
* processing the incoming message queue. This means you can end up
|
||||||
* deadlocked if the application you're talking to needs you to reply
|
* deadlocked if the application you're talking to needs you to reply
|
||||||
* to a method. To solve this, either avoid the situation, block in a
|
* to a method. To solve this, either avoid the situation, block in a
|
||||||
* separate thread from the main connection-dispatching thread, or
|
* separate thread from the main connection-dispatching thread, or
|
||||||
* use PendingCall to avoid blocking.
|
* use PendingCall to avoid blocking.
|
||||||
*
|
*
|
||||||
* \param msg The Message to write.
|
* \param msg The Message to write.
|
||||||
* \param timeout Timeout in milliseconds (omit for default).
|
* \param timeout Timeout in milliseconds (omit for default).
|
||||||
* \throw Error
|
* \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
|
* \brief Queues a message to send, as with send(), but also
|
||||||
* returns a DBusPendingCall used to receive a reply to the message.
|
* returns a DBusPendingCall used to receive a reply to the message.
|
||||||
*
|
*
|
||||||
* If no reply is received in the given timeout_milliseconds, this function
|
* If no reply is received in the given timeout_milliseconds, this function
|
||||||
* expires the pending reply and generates a synthetic error reply (generated
|
* expires the pending reply and generates a synthetic error reply (generated
|
||||||
* in-process, not by the remote application) indicating that a timeout occurred.
|
* in-process, not by the remote application) indicating that a timeout occurred.
|
||||||
*
|
*
|
||||||
* A PendingCall will see a reply message before any filters or registered
|
* A PendingCall will see a reply message before any filters or registered
|
||||||
* object path handlers. See Connection::Private::do_dispatch() in dbus documentation
|
* object path handlers. See Connection::Private::do_dispatch() in dbus documentation
|
||||||
* for details on when handlers are run. (here: Connection::Private::do_dispatch())
|
* for details on when handlers are run. (here: Connection::Private::do_dispatch())
|
||||||
*
|
*
|
||||||
* A PendingCall will always see exactly one reply message, unless it's
|
* A PendingCall will always see exactly one reply message, unless it's
|
||||||
* cancelled with PendingCall::cancel().
|
* cancelled with PendingCall::cancel().
|
||||||
*
|
*
|
||||||
* If -1 is passed for the timeout, a sane default timeout is used. -1 is
|
* If -1 is passed for the timeout, a sane default timeout is used. -1 is
|
||||||
* typically the best value for the timeout for this reason, unless you want
|
* typically the best value for the timeout for this reason, unless you want
|
||||||
* a very short or very long timeout. There is no way to avoid a timeout
|
* a very short or very long timeout. There is no way to avoid a timeout
|
||||||
* entirely, other than passing INT_MAX for the timeout to mean "very long
|
* entirely, other than passing INT_MAX for the timeout to mean "very long
|
||||||
* timeout." libdbus clamps an INT_MAX timeout down to a few hours timeout though.
|
* timeout." libdbus clamps an INT_MAX timeout down to a few hours timeout though.
|
||||||
*
|
*
|
||||||
* \param msg The Message to write.
|
* \param msg The Message to write.
|
||||||
* \param timeout Timeout in milliseconds (omit for default).
|
* \param timeout Timeout in milliseconds (omit for default).
|
||||||
* \throw ErrorNoMemory
|
* \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 );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Asks the bus whether a certain name has an owner.
|
* \brief Asks the bus whether a certain name has an owner.
|
||||||
*
|
*
|
||||||
* Using this can easily result in a race condition, since an owner can appear
|
* Using this can easily result in a race condition, since an owner can appear
|
||||||
* or disappear after you call this.
|
* or disappear after you call this.
|
||||||
*
|
*
|
||||||
* If you want to request a name, just request it; if you want to avoid
|
* If you want to request a name, just request it; if you want to avoid
|
||||||
* replacing a current owner, don't specify DBUS_NAME_FLAG_REPLACE_EXISTING
|
* replacing a current owner, don't specify DBUS_NAME_FLAG_REPLACE_EXISTING
|
||||||
* and you will get an error if there's already an owner.
|
* and you will get an error if there's already an owner.
|
||||||
*
|
*
|
||||||
* \param name The name.
|
* \param name The name.
|
||||||
* \throw Error
|
* \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.
|
* \brief Starts a service that will request ownership of the given name.
|
||||||
*
|
*
|
||||||
* The returned result will be one of be one of DBUS_START_REPLY_SUCCESS or
|
* The returned result will be one of be one of DBUS_START_REPLY_SUCCESS or
|
||||||
* DBUS_START_REPLY_ALREADY_RUNNING if successful. Pass NULL if you don't
|
* DBUS_START_REPLY_ALREADY_RUNNING if successful. Pass NULL if you don't
|
||||||
* care about the result.
|
* care about the result.
|
||||||
*
|
*
|
||||||
* The flags parameter is for future expansion, currently you should specify 0.
|
* The flags parameter is for future expansion, currently you should specify 0.
|
||||||
*
|
*
|
||||||
* It's often easier to avoid explicitly starting services, and just send a
|
* It's often easier to avoid explicitly starting services, and just send a
|
||||||
* method call to the service's bus name instead. Method calls start a service
|
* method call to the service's bus name instead. Method calls start a service
|
||||||
* to handle them by default unless you call dbus_message_set_auto_start() to
|
* to handle them by default unless you call dbus_message_set_auto_start() to
|
||||||
* disable this behavior.
|
* disable this behavior.
|
||||||
*
|
*
|
||||||
* \todo dbus_message_set_auto_start() not yet wrapped!
|
* \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();
|
const std::vector<std::string>& names();
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
namespace DBus {
|
namespace DBus {
|
||||||
|
|
||||||
typedef void (*LogFunction)(const char* format, ...);
|
typedef void (*LogFunction)(const char *format, ...);
|
||||||
|
|
||||||
extern DXXAPI LogFunction debug_log;
|
extern DXXAPI LogFunction debug_log;
|
||||||
|
|
||||||
|
|
|
@ -38,49 +38,49 @@ public:
|
||||||
|
|
||||||
class Internal;
|
class Internal;
|
||||||
|
|
||||||
Timeout( Internal* i );
|
Timeout(Internal *i);
|
||||||
|
|
||||||
virtual ~Timeout(){}
|
virtual ~Timeout(){}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the timeout interval.
|
* \brief Gets the timeout interval.
|
||||||
*
|
*
|
||||||
* The dbus_timeout_handle() should be called each time this interval elapses,
|
* The dbus_timeout_handle() should be called each time this interval elapses,
|
||||||
* starting after it elapses once.
|
* starting after it elapses once.
|
||||||
*
|
*
|
||||||
* The interval may change during the life of the timeout; if so, the timeout
|
* The interval may change during the life of the timeout; if so, the timeout
|
||||||
* will be disabled and re-enabled (calling the "timeout toggled function") to
|
* will be disabled and re-enabled (calling the "timeout toggled function") to
|
||||||
* notify you of the change.
|
* notify you of the change.
|
||||||
*
|
*
|
||||||
* return The interval in miliseconds.
|
* return The interval in miliseconds.
|
||||||
*/
|
*/
|
||||||
int interval() const;
|
int interval() const;
|
||||||
|
|
||||||
bool enabled() const;
|
bool enabled() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Calls the timeout handler for this timeout.
|
* \brief Calls the timeout handler for this timeout.
|
||||||
*
|
*
|
||||||
* This function should be called when the timeout occurs.
|
* This function should be called when the timeout occurs.
|
||||||
*
|
*
|
||||||
* If this function returns FALSE, then there wasn't enough memory to handle
|
* If this function returns FALSE, then there wasn't enough memory to handle
|
||||||
* the timeout. Typically just letting the timeout fire again next time it
|
* the timeout. Typically just letting the timeout fire again next time it
|
||||||
* naturally times out is an adequate response to that problem, but you could
|
* naturally times out is an adequate response to that problem, but you could
|
||||||
* try to do more if you wanted.
|
* try to do more if you wanted.
|
||||||
*
|
*
|
||||||
* return false If there wasn't enough memory.
|
* return false If there wasn't enough memory.
|
||||||
*/
|
*/
|
||||||
bool handle();
|
bool handle();
|
||||||
|
|
||||||
virtual void toggle() = 0;
|
virtual void toggle() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DXXAPILOCAL Timeout( const Timeout& );
|
DXXAPILOCAL Timeout(const Timeout &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Internal* _int;
|
Internal *_int;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DXXAPI Watch
|
class DXXAPI Watch
|
||||||
|
@ -89,63 +89,63 @@ public:
|
||||||
|
|
||||||
class Internal;
|
class Internal;
|
||||||
|
|
||||||
Watch( Internal* i );
|
Watch(Internal *i);
|
||||||
|
|
||||||
virtual ~Watch(){}
|
virtual ~Watch(){}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief A main loop could poll this descriptor to integrate dbus-c++.
|
* \brief A main loop could poll this descriptor to integrate dbus-c++.
|
||||||
*
|
*
|
||||||
* This function calls dbus_watch_get_socket() on win32 and
|
* This function calls dbus_watch_get_socket() on win32 and
|
||||||
* dbus_watch_get_unix_fd() on all other systems. (see dbus documentation)
|
* dbus_watch_get_unix_fd() on all other systems. (see dbus documentation)
|
||||||
*
|
*
|
||||||
* @return The file descriptor.
|
* @return The file descriptor.
|
||||||
*/
|
*/
|
||||||
int descriptor() const;
|
int descriptor() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets flags from DBusWatchFlags indicating what conditions should be
|
* \brief Gets flags from DBusWatchFlags indicating what conditions should be
|
||||||
* monitored on the file descriptor.
|
* monitored on the file descriptor.
|
||||||
*
|
*
|
||||||
* The flags returned will only contain DBUS_WATCH_READABLE and DBUS_WATCH_WRITABLE,
|
* The flags returned will only contain DBUS_WATCH_READABLE and DBUS_WATCH_WRITABLE,
|
||||||
* never DBUS_WATCH_HANGUP or DBUS_WATCH_ERROR; all watches implicitly include
|
* never DBUS_WATCH_HANGUP or DBUS_WATCH_ERROR; all watches implicitly include
|
||||||
* a watch for hangups, errors, and other exceptional conditions.
|
* a watch for hangups, errors, and other exceptional conditions.
|
||||||
*
|
*
|
||||||
* @return The conditions to watch.
|
* @return The conditions to watch.
|
||||||
*/
|
*/
|
||||||
int flags() const;
|
int flags() const;
|
||||||
|
|
||||||
bool enabled() const;
|
bool enabled() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Called to notify the D-Bus library when a previously-added watch
|
* \brief Called to notify the D-Bus library when a previously-added watch
|
||||||
* is ready for reading or writing, or has an exception such as a hangup.
|
* is ready for reading or writing, or has an exception such as a hangup.
|
||||||
*
|
*
|
||||||
* If this function returns FALSE, then the file descriptor may still be
|
* If this function returns FALSE, then the file descriptor may still be
|
||||||
* ready for reading or writing, but more memory is needed in order to do the
|
* ready for reading or writing, but more memory is needed in order to do the
|
||||||
* reading or writing. If you ignore the FALSE return, your application may
|
* reading or writing. If you ignore the FALSE return, your application may
|
||||||
* spin in a busy loop on the file descriptor until memory becomes available,
|
* spin in a busy loop on the file descriptor until memory becomes available,
|
||||||
* but nothing more catastrophic should happen.
|
* but nothing more catastrophic should happen.
|
||||||
*
|
*
|
||||||
* dbus_watch_handle() cannot be called during the DBusAddWatchFunction, as the
|
* dbus_watch_handle() cannot be called during the DBusAddWatchFunction, as the
|
||||||
* connection will not be ready to handle that watch yet.
|
* connection will not be ready to handle that watch yet.
|
||||||
*
|
*
|
||||||
* It is not allowed to reference a DBusWatch after it has been passed to remove_function.
|
* It is not allowed to reference a DBusWatch after it has been passed to remove_function.
|
||||||
*
|
*
|
||||||
* @param flags The poll condition using DBusWatchFlags values.
|
* @param flags The poll condition using DBusWatchFlags values.
|
||||||
* @return false If there wasn't enough memory.
|
* @return false If there wasn't enough memory.
|
||||||
*/
|
*/
|
||||||
bool handle( int flags );
|
bool handle(int flags);
|
||||||
|
|
||||||
virtual void toggle() = 0;
|
virtual void toggle() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DXXAPILOCAL Watch( const Watch& );
|
DXXAPILOCAL Watch(const Watch &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Internal* _int;
|
Internal *_int;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DXXAPI Dispatcher
|
class DXXAPI Dispatcher
|
||||||
|
@ -155,7 +155,7 @@ public:
|
||||||
virtual ~Dispatcher()
|
virtual ~Dispatcher()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void queue_connection( Connection::Private* );
|
void queue_connection(Connection::Private *);
|
||||||
|
|
||||||
void dispatch_pending();
|
void dispatch_pending();
|
||||||
|
|
||||||
|
@ -163,13 +163,13 @@ public:
|
||||||
|
|
||||||
virtual void leave() = 0;
|
virtual void leave() = 0;
|
||||||
|
|
||||||
virtual Timeout* add_timeout( Timeout::Internal* ) = 0;
|
virtual Timeout *add_timeout(Timeout::Internal *) = 0;
|
||||||
|
|
||||||
virtual void rem_timeout( Timeout* ) = 0;
|
virtual void rem_timeout(Timeout *) = 0;
|
||||||
|
|
||||||
virtual Watch* add_watch( Watch::Internal* ) = 0;
|
virtual Watch *add_watch(Watch::Internal *) = 0;
|
||||||
|
|
||||||
virtual void rem_watch( Watch* ) = 0;
|
virtual void rem_watch(Watch *) = 0;
|
||||||
|
|
||||||
struct Private;
|
struct Private;
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ private:
|
||||||
Connection::PrivatePList _pending_queue;
|
Connection::PrivatePList _pending_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern DXXAPI Dispatcher* default_dispatcher;
|
extern DXXAPI Dispatcher *default_dispatcher;
|
||||||
|
|
||||||
/* classes for multithreading support
|
/* classes for multithreading support
|
||||||
*/
|
*/
|
||||||
|
@ -198,7 +198,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Internal* _int;
|
Internal *_int;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DXXAPI CondVar
|
class DXXAPI CondVar
|
||||||
|
@ -207,9 +207,9 @@ public:
|
||||||
|
|
||||||
virtual ~CondVar() {}
|
virtual ~CondVar() {}
|
||||||
|
|
||||||
virtual void wait( Mutex* ) = 0;
|
virtual void wait(Mutex *) = 0;
|
||||||
|
|
||||||
virtual bool wait_timeout( Mutex*, int timeout ) = 0;
|
virtual bool wait_timeout(Mutex *, int timeout) = 0;
|
||||||
|
|
||||||
virtual void wake_one() = 0;
|
virtual void wake_one() = 0;
|
||||||
|
|
||||||
|
@ -219,27 +219,27 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Internal* _int;
|
Internal *_int;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef DBUS_HAS_RECURSIVE_MUTEX
|
#ifndef DBUS_HAS_RECURSIVE_MUTEX
|
||||||
typedef Mutex* (*MutexNewFn)();
|
typedef Mutex *(*MutexNewFn)();
|
||||||
typedef bool (*MutexFreeFn)( Mutex* mx );
|
typedef bool (*MutexFreeFn)(Mutex *mx);
|
||||||
typedef bool (*MutexLockFn)( Mutex* mx );
|
typedef bool (*MutexLockFn)(Mutex *mx);
|
||||||
typedef void (*MutexUnlockFn)( Mutex* mx );
|
typedef void (*MutexUnlockFn)(Mutex *mx);
|
||||||
#else
|
#else
|
||||||
typedef Mutex* (*MutexNewFn)();
|
typedef Mutex *(*MutexNewFn)();
|
||||||
typedef void (*MutexFreeFn)( Mutex* mx );
|
typedef void (*MutexFreeFn)(Mutex *mx);
|
||||||
typedef void (*MutexLockFn)( Mutex* mx );
|
typedef void (*MutexLockFn)(Mutex *mx);
|
||||||
typedef void (*MutexUnlockFn)( Mutex* mx );
|
typedef void (*MutexUnlockFn)(Mutex *mx);
|
||||||
#endif//DBUS_HAS_RECURSIVE_MUTEX
|
#endif//DBUS_HAS_RECURSIVE_MUTEX
|
||||||
|
|
||||||
typedef CondVar* (*CondVarNewFn)();
|
typedef CondVar *(*CondVarNewFn)();
|
||||||
typedef void (*CondVarFreeFn)( CondVar* cv );
|
typedef void (*CondVarFreeFn)(CondVar *cv);
|
||||||
typedef void (*CondVarWaitFn)( CondVar* cv, Mutex* mx );
|
typedef void (*CondVarWaitFn)(CondVar *cv, Mutex *mx);
|
||||||
typedef bool (*CondVarWaitTimeoutFn)( CondVar* cv, Mutex* mx, int timeout );
|
typedef bool (*CondVarWaitTimeoutFn)(CondVar *cv, Mutex *mx, int timeout);
|
||||||
typedef void (*CondVarWakeOneFn)( CondVar* cv );
|
typedef void (*CondVarWakeOneFn)(CondVar *cv);
|
||||||
typedef void (*CondVarWakeAllFn)( CondVar* cv );
|
typedef void (*CondVarWakeAllFn)(CondVar *cv);
|
||||||
|
|
||||||
#ifdef DBUS_HAS_THREADS_INIT_DEFAULT
|
#ifdef DBUS_HAS_THREADS_INIT_DEFAULT
|
||||||
void DXXAPI _init_threading();
|
void DXXAPI _init_threading();
|
||||||
|
@ -261,52 +261,52 @@ struct Threading
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Mutex* mutex_new()
|
static Mutex *mutex_new()
|
||||||
{
|
{
|
||||||
return new Mx;
|
return new Mx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mutex_free( Mutex* mx )
|
static void mutex_free(Mutex *mx)
|
||||||
{
|
{
|
||||||
delete mx;
|
delete mx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mutex_lock( Mutex* mx )
|
static void mutex_lock(Mutex *mx)
|
||||||
{
|
{
|
||||||
mx->lock();
|
mx->lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mutex_unlock( Mutex* mx )
|
static void mutex_unlock(Mutex *mx)
|
||||||
{
|
{
|
||||||
mx->unlock();
|
mx->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static CondVar* condvar_new()
|
static CondVar *condvar_new()
|
||||||
{
|
{
|
||||||
return new Cv;
|
return new Cv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void condvar_free( CondVar* cv )
|
static void condvar_free(CondVar *cv)
|
||||||
{
|
{
|
||||||
delete cv;
|
delete cv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void condvar_wait( CondVar* cv, Mutex* mx )
|
static void condvar_wait(CondVar *cv, Mutex *mx)
|
||||||
{
|
{
|
||||||
cv->wait(mx);
|
cv->wait(mx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool condvar_wait_timeout( CondVar* cv, Mutex* mx, int timeout )
|
static bool condvar_wait_timeout(CondVar *cv, Mutex *mx, int timeout)
|
||||||
{
|
{
|
||||||
return cv->wait_timeout(mx, timeout);
|
return cv->wait_timeout(mx, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void condvar_wake_one( CondVar* cv )
|
static void condvar_wake_one(CondVar *cv)
|
||||||
{
|
{
|
||||||
cv->wake_one();
|
cv->wake_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void condvar_wake_all( CondVar* cv )
|
static void condvar_wake_all(CondVar *cv)
|
||||||
{
|
{
|
||||||
cv->wake_all();
|
cv->wake_all();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,21 +42,21 @@ public:
|
||||||
|
|
||||||
Error();
|
Error();
|
||||||
|
|
||||||
Error( InternalError& );
|
Error(InternalError &);
|
||||||
|
|
||||||
Error( const char* name, const char* message );
|
Error(const char *name, const char *message);
|
||||||
|
|
||||||
Error( Message& );
|
Error(Message &);
|
||||||
|
|
||||||
~Error() throw();
|
~Error() throw();
|
||||||
|
|
||||||
const char* what() const throw();
|
const char *what() const throw();
|
||||||
|
|
||||||
const char* name() const;
|
const char *name() const;
|
||||||
|
|
||||||
const char* message() const;
|
const char *message() const;
|
||||||
|
|
||||||
void set( const char* name, const char* message );
|
void set(const char *name, const char *message);
|
||||||
// parameters MUST be static strings
|
// parameters MUST be static strings
|
||||||
|
|
||||||
bool is_set() const;
|
bool is_set() const;
|
||||||
|
@ -73,210 +73,210 @@ private:
|
||||||
|
|
||||||
struct DXXAPI ErrorFailed : public Error
|
struct DXXAPI ErrorFailed : public Error
|
||||||
{
|
{
|
||||||
ErrorFailed( const char* message )
|
ErrorFailed(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.Failed", message)
|
: Error("org.freedesktop.DBus.Error.Failed", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorNoMemory : public Error
|
struct DXXAPI ErrorNoMemory : public Error
|
||||||
{
|
{
|
||||||
ErrorNoMemory( const char* message )
|
ErrorNoMemory(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.NoMemory", message)
|
: Error("org.freedesktop.DBus.Error.NoMemory", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorServiceUnknown : public Error
|
struct DXXAPI ErrorServiceUnknown : public Error
|
||||||
{
|
{
|
||||||
ErrorServiceUnknown( const char* message )
|
ErrorServiceUnknown(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.ServiceUnknown", message)
|
: Error("org.freedesktop.DBus.Error.ServiceUnknown", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorNameHasNoOwner : public Error
|
struct DXXAPI ErrorNameHasNoOwner : public Error
|
||||||
{
|
{
|
||||||
ErrorNameHasNoOwner( const char* message )
|
ErrorNameHasNoOwner(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.NameHasNoOwner", message)
|
: Error("org.freedesktop.DBus.Error.NameHasNoOwner", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorNoReply : public Error
|
struct DXXAPI ErrorNoReply : public Error
|
||||||
{
|
{
|
||||||
ErrorNoReply( const char* message )
|
ErrorNoReply(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.NoReply", message)
|
: Error("org.freedesktop.DBus.Error.NoReply", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorIOError : public Error
|
struct DXXAPI ErrorIOError : public Error
|
||||||
{
|
{
|
||||||
ErrorIOError( const char* message )
|
ErrorIOError(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.IOError", message)
|
: Error("org.freedesktop.DBus.Error.IOError", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorBadAddress : public Error
|
struct DXXAPI ErrorBadAddress : public Error
|
||||||
{
|
{
|
||||||
ErrorBadAddress( const char* message )
|
ErrorBadAddress(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.BadAddress", message)
|
: Error("org.freedesktop.DBus.Error.BadAddress", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorNotSupported : public Error
|
struct DXXAPI ErrorNotSupported : public Error
|
||||||
{
|
{
|
||||||
ErrorNotSupported( const char* message )
|
ErrorNotSupported(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.NotSupported", message)
|
: Error("org.freedesktop.DBus.Error.NotSupported", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorLimitsExceeded : public Error
|
struct DXXAPI ErrorLimitsExceeded : public Error
|
||||||
{
|
{
|
||||||
ErrorLimitsExceeded( const char* message )
|
ErrorLimitsExceeded(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.LimitsExceeded", message)
|
: Error("org.freedesktop.DBus.Error.LimitsExceeded", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorAccessDenied : public Error
|
struct DXXAPI ErrorAccessDenied : public Error
|
||||||
{
|
{
|
||||||
ErrorAccessDenied( const char* message )
|
ErrorAccessDenied(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.AccessDenied", message)
|
: Error("org.freedesktop.DBus.Error.AccessDenied", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorAuthFailed : public Error
|
struct DXXAPI ErrorAuthFailed : public Error
|
||||||
{
|
{
|
||||||
ErrorAuthFailed( const char* message )
|
ErrorAuthFailed(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.AuthFailed", message)
|
: Error("org.freedesktop.DBus.Error.AuthFailed", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorNoServer : public Error
|
struct DXXAPI ErrorNoServer : public Error
|
||||||
{
|
{
|
||||||
ErrorNoServer( const char* message )
|
ErrorNoServer(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.NoServer", message)
|
: Error("org.freedesktop.DBus.Error.NoServer", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorTimeout : public Error
|
struct DXXAPI ErrorTimeout : public Error
|
||||||
{
|
{
|
||||||
ErrorTimeout( const char* message )
|
ErrorTimeout(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.Timeout", message)
|
: Error("org.freedesktop.DBus.Error.Timeout", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorNoNetwork : public Error
|
struct DXXAPI ErrorNoNetwork : public Error
|
||||||
{
|
{
|
||||||
ErrorNoNetwork( const char* message )
|
ErrorNoNetwork(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.NoNetwork", message)
|
: Error("org.freedesktop.DBus.Error.NoNetwork", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorAddressInUse : public Error
|
struct DXXAPI ErrorAddressInUse : public Error
|
||||||
{
|
{
|
||||||
ErrorAddressInUse( const char* message )
|
ErrorAddressInUse(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.AddressInUse", message)
|
: Error("org.freedesktop.DBus.Error.AddressInUse", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorDisconnected : public Error
|
struct DXXAPI ErrorDisconnected : public Error
|
||||||
{
|
{
|
||||||
ErrorDisconnected( const char* message )
|
ErrorDisconnected(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.Disconnected", message)
|
: Error("org.freedesktop.DBus.Error.Disconnected", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorInvalidArgs : public Error
|
struct DXXAPI ErrorInvalidArgs : public Error
|
||||||
{
|
{
|
||||||
ErrorInvalidArgs( const char* message )
|
ErrorInvalidArgs(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.InvalidArgs", message)
|
: Error("org.freedesktop.DBus.Error.InvalidArgs", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorFileNotFound : public Error
|
struct DXXAPI ErrorFileNotFound : public Error
|
||||||
{
|
{
|
||||||
ErrorFileNotFound( const char* message )
|
ErrorFileNotFound(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.FileNotFound", message)
|
: Error("org.freedesktop.DBus.Error.FileNotFound", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorUnknownMethod : public Error
|
struct DXXAPI ErrorUnknownMethod : public Error
|
||||||
{
|
{
|
||||||
ErrorUnknownMethod( const char* message )
|
ErrorUnknownMethod(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.UnknownMethod", message)
|
: Error("org.freedesktop.DBus.Error.UnknownMethod", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorTimedOut : public Error
|
struct DXXAPI ErrorTimedOut : public Error
|
||||||
{
|
{
|
||||||
ErrorTimedOut( const char* message )
|
ErrorTimedOut(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.TimedOut", message)
|
: Error("org.freedesktop.DBus.Error.TimedOut", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorMatchRuleNotFound : public Error
|
struct DXXAPI ErrorMatchRuleNotFound : public Error
|
||||||
{
|
{
|
||||||
ErrorMatchRuleNotFound( const char* message )
|
ErrorMatchRuleNotFound(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.MatchRuleNotFound", message)
|
: Error("org.freedesktop.DBus.Error.MatchRuleNotFound", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorMatchRuleInvalid : public Error
|
struct DXXAPI ErrorMatchRuleInvalid : public Error
|
||||||
{
|
{
|
||||||
ErrorMatchRuleInvalid( const char* message )
|
ErrorMatchRuleInvalid(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.MatchRuleInvalid", message)
|
: Error("org.freedesktop.DBus.Error.MatchRuleInvalid", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorSpawnExecFailed : public Error
|
struct DXXAPI ErrorSpawnExecFailed : public Error
|
||||||
{
|
{
|
||||||
ErrorSpawnExecFailed( const char* message )
|
ErrorSpawnExecFailed(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.Spawn.ExecFailed", message)
|
: Error("org.freedesktop.DBus.Error.Spawn.ExecFailed", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorSpawnForkFailed : public Error
|
struct DXXAPI ErrorSpawnForkFailed : public Error
|
||||||
{
|
{
|
||||||
ErrorSpawnForkFailed( const char* message )
|
ErrorSpawnForkFailed(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.Spawn.ForkFailed", message)
|
: Error("org.freedesktop.DBus.Error.Spawn.ForkFailed", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorSpawnChildExited : public Error
|
struct DXXAPI ErrorSpawnChildExited : public Error
|
||||||
{
|
{
|
||||||
ErrorSpawnChildExited( const char* message )
|
ErrorSpawnChildExited(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.Spawn.ChildExited", message)
|
: Error("org.freedesktop.DBus.Error.Spawn.ChildExited", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorSpawnChildSignaled : public Error
|
struct DXXAPI ErrorSpawnChildSignaled : public Error
|
||||||
{
|
{
|
||||||
ErrorSpawnChildSignaled( const char* message )
|
ErrorSpawnChildSignaled(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.Spawn.ChildSignaled", message)
|
: Error("org.freedesktop.DBus.Error.Spawn.ChildSignaled", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorSpawnFailed : public Error
|
struct DXXAPI ErrorSpawnFailed : public Error
|
||||||
{
|
{
|
||||||
ErrorSpawnFailed( const char* message )
|
ErrorSpawnFailed(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.Spawn.Failed", message)
|
: Error("org.freedesktop.DBus.Error.Spawn.Failed", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorInvalidSignature : public Error
|
struct DXXAPI ErrorInvalidSignature : public Error
|
||||||
{
|
{
|
||||||
ErrorInvalidSignature( const char* message )
|
ErrorInvalidSignature(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.InvalidSignature", message)
|
: Error("org.freedesktop.DBus.Error.InvalidSignature", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorUnixProcessIdUnknown : public Error
|
struct DXXAPI ErrorUnixProcessIdUnknown : public Error
|
||||||
{
|
{
|
||||||
ErrorUnixProcessIdUnknown( const char* message )
|
ErrorUnixProcessIdUnknown(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.UnixProcessIdUnknown", message)
|
: Error("org.freedesktop.DBus.Error.UnixProcessIdUnknown", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI ErrorSELinuxSecurityContextUnknown : public Error
|
struct DXXAPI ErrorSELinuxSecurityContextUnknown : public Error
|
||||||
{
|
{
|
||||||
ErrorSELinuxSecurityContextUnknown( const char* message )
|
ErrorSELinuxSecurityContextUnknown(const char *message)
|
||||||
: Error("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", message)
|
: Error("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", message)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,7 @@ class BusDispatcher;
|
||||||
|
|
||||||
class DXXAPI BusTimeout : public Timeout, public DefaultTimeout
|
class DXXAPI BusTimeout : public Timeout, public DefaultTimeout
|
||||||
{
|
{
|
||||||
BusTimeout( Timeout::Internal*, BusDispatcher* );
|
BusTimeout(Timeout::Internal *, BusDispatcher *);
|
||||||
|
|
||||||
void toggle();
|
void toggle();
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ friend class BusDispatcher;
|
||||||
|
|
||||||
class DXXAPI BusWatch : public Watch, public DefaultWatch
|
class DXXAPI BusWatch : public Watch, public DefaultWatch
|
||||||
{
|
{
|
||||||
BusWatch( Watch::Internal*, BusDispatcher* );
|
BusWatch(Watch::Internal *, BusDispatcher *);
|
||||||
|
|
||||||
void toggle();
|
void toggle();
|
||||||
|
|
||||||
|
@ -73,17 +73,17 @@ public:
|
||||||
|
|
||||||
virtual void do_iteration();
|
virtual void do_iteration();
|
||||||
|
|
||||||
virtual Timeout* add_timeout( Timeout::Internal* );
|
virtual Timeout *add_timeout(Timeout::Internal *);
|
||||||
|
|
||||||
virtual void rem_timeout( Timeout* );
|
virtual void rem_timeout(Timeout *);
|
||||||
|
|
||||||
virtual Watch* add_watch( Watch::Internal* );
|
virtual Watch *add_watch(Watch::Internal *);
|
||||||
|
|
||||||
virtual void rem_watch( Watch* );
|
virtual void rem_watch(Watch *);
|
||||||
|
|
||||||
void watch_ready( DefaultWatch& );
|
void watch_ready(DefaultWatch &);
|
||||||
|
|
||||||
void timeout_expired( DefaultTimeout& );
|
void timeout_expired(DefaultTimeout &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
namespace DBus {
|
namespace DBus {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* these Default* classes implement a very simple event loop which
|
* these Default *classes implement a very simple event loop which
|
||||||
* is used here as the default main loop, if you want to hook
|
* is used here as the default main loop, if you want to hook
|
||||||
* a different one use the Bus* classes in eventloop-integration.h
|
* a different one use the Bus *classes in eventloop-integration.h
|
||||||
* or the Glib::Bus* classes as a reference
|
* or the Glib::Bus *classes as a reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class DefaultMainLoop;
|
class DefaultMainLoop;
|
||||||
|
@ -51,7 +51,7 @@ class DXXAPI DefaultTimeout
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DefaultTimeout( int interval, bool repeat, DefaultMainLoop* );
|
DefaultTimeout(int interval, bool repeat, DefaultMainLoop *);
|
||||||
|
|
||||||
virtual ~DefaultTimeout();
|
virtual ~DefaultTimeout();
|
||||||
|
|
||||||
|
@ -64,10 +64,10 @@ public:
|
||||||
bool repeat(){ return _repeat; }
|
bool repeat(){ return _repeat; }
|
||||||
void repeat(bool r){ _repeat = r; }
|
void repeat(bool r){ _repeat = r; }
|
||||||
|
|
||||||
void* data(){ return _data; }
|
void *data(){ return _data; }
|
||||||
void data(void* d){ _data = d; }
|
void data(void *d){ _data = d; }
|
||||||
|
|
||||||
Slot<void, DefaultTimeout&> expired;
|
Slot<void, DefaultTimeout &> expired;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -78,20 +78,20 @@ private:
|
||||||
|
|
||||||
double _expiration;
|
double _expiration;
|
||||||
|
|
||||||
void* _data;
|
void *_data;
|
||||||
|
|
||||||
DefaultMainLoop* _disp;
|
DefaultMainLoop *_disp;
|
||||||
|
|
||||||
friend class DefaultMainLoop;
|
friend class DefaultMainLoop;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::list< DefaultTimeout* > DefaultTimeouts;
|
typedef std::list< DefaultTimeout *> DefaultTimeouts;
|
||||||
|
|
||||||
class DXXAPI DefaultWatch
|
class DXXAPI DefaultWatch
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DefaultWatch( int fd, int flags, DefaultMainLoop* );
|
DefaultWatch(int fd, int flags, DefaultMainLoop *);
|
||||||
|
|
||||||
virtual ~DefaultWatch();
|
virtual ~DefaultWatch();
|
||||||
|
|
||||||
|
@ -101,14 +101,14 @@ public:
|
||||||
int descriptor(){ return _fd; }
|
int descriptor(){ return _fd; }
|
||||||
|
|
||||||
int flags(){ return _flags; }
|
int flags(){ return _flags; }
|
||||||
void flags( int f ){ _flags = f; }
|
void flags(int f){ _flags = f; }
|
||||||
|
|
||||||
int state(){ return _state; }
|
int state(){ return _state; }
|
||||||
|
|
||||||
void* data(){ return _data; }
|
void *data(){ return _data; }
|
||||||
void data(void* d){ _data = d; }
|
void data(void *d){ _data = d; }
|
||||||
|
|
||||||
Slot<void, DefaultWatch&> ready;
|
Slot<void, DefaultWatch &> ready;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -118,14 +118,14 @@ private:
|
||||||
int _flags;
|
int _flags;
|
||||||
int _state;
|
int _state;
|
||||||
|
|
||||||
void* _data;
|
void *_data;
|
||||||
|
|
||||||
DefaultMainLoop* _disp;
|
DefaultMainLoop *_disp;
|
||||||
|
|
||||||
friend class DefaultMainLoop;
|
friend class DefaultMainLoop;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::list< DefaultWatch* > DefaultWatches;
|
typedef std::list< DefaultWatch *> DefaultWatches;
|
||||||
|
|
||||||
class DXXAPI DefaultMutex
|
class DXXAPI DefaultMutex
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,13 +41,13 @@ class DXXAPI BusTimeout : public Timeout
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
BusTimeout( Timeout::Internal*, GMainContext* );
|
BusTimeout(Timeout::Internal *, GMainContext *, int);
|
||||||
|
|
||||||
~BusTimeout();
|
~BusTimeout();
|
||||||
|
|
||||||
void toggle();
|
void toggle();
|
||||||
|
|
||||||
static gboolean timeout_handler( gpointer );
|
static gboolean timeout_handler(gpointer);
|
||||||
|
|
||||||
void _enable();
|
void _enable();
|
||||||
|
|
||||||
|
@ -55,8 +55,9 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GSource* _source;
|
GSource *_source;
|
||||||
GMainContext* _ctx;
|
GMainContext *_ctx;
|
||||||
|
int _priority;
|
||||||
|
|
||||||
friend class BusDispatcher;
|
friend class BusDispatcher;
|
||||||
};
|
};
|
||||||
|
@ -65,13 +66,13 @@ class DXXAPI BusWatch : public Watch
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
BusWatch( Watch::Internal*, GMainContext* );
|
BusWatch(Watch::Internal *, GMainContext *, int);
|
||||||
|
|
||||||
~BusWatch();
|
~BusWatch();
|
||||||
|
|
||||||
void toggle();
|
void toggle();
|
||||||
|
|
||||||
static gboolean watch_handler( gpointer );
|
static gboolean watch_handler(gpointer);
|
||||||
|
|
||||||
void _enable();
|
void _enable();
|
||||||
|
|
||||||
|
@ -79,8 +80,9 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GSource* _source;
|
GSource *_source;
|
||||||
GMainContext* _ctx;
|
GMainContext *_ctx;
|
||||||
|
int _priority;
|
||||||
|
|
||||||
friend class BusDispatcher;
|
friend class BusDispatcher;
|
||||||
};
|
};
|
||||||
|
@ -88,25 +90,29 @@ friend class BusDispatcher;
|
||||||
class DXXAPI BusDispatcher : public Dispatcher
|
class DXXAPI BusDispatcher : public Dispatcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BusDispatcher() : _ctx(NULL) {}
|
|
||||||
|
|
||||||
void attach( GMainContext* );
|
BusDispatcher() : _ctx(NULL), _priority(G_PRIORITY_DEFAULT) {}
|
||||||
|
|
||||||
|
void attach(GMainContext *);
|
||||||
|
|
||||||
void enter() {}
|
void enter() {}
|
||||||
|
|
||||||
void leave() {}
|
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 *);
|
||||||
|
|
||||||
|
void set_priority(int priority);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GMainContext* _ctx;
|
GMainContext *_ctx;
|
||||||
|
int _priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace Glib */
|
} /* namespace Glib */
|
||||||
|
|
|
@ -54,22 +54,22 @@ class ObjectAdaptor;
|
||||||
class InterfaceAdaptor;
|
class InterfaceAdaptor;
|
||||||
class SignalMessage;
|
class SignalMessage;
|
||||||
|
|
||||||
typedef std::map<std::string, InterfaceAdaptor*> InterfaceAdaptorTable;
|
typedef std::map<std::string, InterfaceAdaptor *> InterfaceAdaptorTable;
|
||||||
|
|
||||||
class DXXAPI AdaptorBase
|
class DXXAPI AdaptorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual const ObjectAdaptor* object() const = 0 ;
|
virtual const ObjectAdaptor *object() const = 0 ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
InterfaceAdaptor* find_interface( const std::string& name );
|
InterfaceAdaptor *find_interface(const std::string &name);
|
||||||
|
|
||||||
virtual ~AdaptorBase()
|
virtual ~AdaptorBase()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void _emit_signal( SignalMessage& ) = 0;
|
virtual void _emit_signal(SignalMessage &) = 0;
|
||||||
|
|
||||||
InterfaceAdaptorTable _interfaces;
|
InterfaceAdaptorTable _interfaces;
|
||||||
};
|
};
|
||||||
|
@ -81,22 +81,22 @@ class ObjectProxy;
|
||||||
class InterfaceProxy;
|
class InterfaceProxy;
|
||||||
class CallMessage;
|
class CallMessage;
|
||||||
|
|
||||||
typedef std::map<std::string, InterfaceProxy*> InterfaceProxyTable;
|
typedef std::map<std::string, InterfaceProxy *> InterfaceProxyTable;
|
||||||
|
|
||||||
class DXXAPI ProxyBase
|
class DXXAPI ProxyBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual const ObjectProxy* object() const = 0 ;
|
virtual const ObjectProxy *object() const = 0 ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
InterfaceProxy* find_interface( const std::string& name );
|
InterfaceProxy *find_interface(const std::string &name);
|
||||||
|
|
||||||
virtual ~ProxyBase()
|
virtual ~ProxyBase()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual Message _invoke_method( CallMessage& ) = 0;
|
virtual Message _invoke_method(CallMessage &) = 0;
|
||||||
|
|
||||||
InterfaceProxyTable _interfaces;
|
InterfaceProxyTable _interfaces;
|
||||||
};
|
};
|
||||||
|
@ -105,11 +105,11 @@ class DXXAPI Interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Interface( const std::string& name );
|
Interface(const std::string &name);
|
||||||
|
|
||||||
virtual ~Interface();
|
virtual ~Interface();
|
||||||
|
|
||||||
inline const std::string& name() const;
|
inline const std::string &name() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ private:
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const std::string& Interface::name() const
|
const std::string &Interface::name() const
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
@ -127,23 +127,23 @@ const std::string& Interface::name() const
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef std::map< std::string, Slot<Message, const CallMessage&> > MethodTable;
|
typedef std::map< std::string, Slot<Message, const CallMessage &> > MethodTable;
|
||||||
|
|
||||||
class DXXAPI InterfaceAdaptor : public Interface, public virtual AdaptorBase
|
class DXXAPI InterfaceAdaptor : public Interface, public virtual AdaptorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InterfaceAdaptor( const std::string& name );
|
InterfaceAdaptor(const std::string &name);
|
||||||
|
|
||||||
Message dispatch_method( const CallMessage& );
|
Message dispatch_method(const CallMessage &);
|
||||||
|
|
||||||
void emit_signal( const SignalMessage& );
|
void emit_signal(const SignalMessage &);
|
||||||
|
|
||||||
Variant* get_property( const std::string& name );
|
Variant *get_property(const std::string &name);
|
||||||
|
|
||||||
void set_property( const std::string& name, Variant& value );
|
void set_property(const std::string &name, Variant &value);
|
||||||
|
|
||||||
virtual IntrospectedInterface* const introspect() const
|
virtual IntrospectedInterface *const introspect() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -157,17 +157,17 @@ protected:
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef std::map< std::string, Slot<void, const SignalMessage&> > SignalTable;
|
typedef std::map< std::string, Slot<void, const SignalMessage &> > SignalTable;
|
||||||
|
|
||||||
class DXXAPI InterfaceProxy : public Interface, public virtual ProxyBase
|
class DXXAPI InterfaceProxy : public Interface, public virtual ProxyBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InterfaceProxy( const std::string& name );
|
InterfaceProxy(const std::string &name);
|
||||||
|
|
||||||
Message invoke_method( const CallMessage& );
|
Message invoke_method(const CallMessage &);
|
||||||
|
|
||||||
bool dispatch_signal( const SignalMessage& );
|
bool dispatch_signal(const SignalMessage &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -176,17 +176,17 @@ protected:
|
||||||
|
|
||||||
# define register_method(interface, method, callback) \
|
# define register_method(interface, method, callback) \
|
||||||
InterfaceAdaptor::_methods[ #method ] = \
|
InterfaceAdaptor::_methods[ #method ] = \
|
||||||
new ::DBus::Callback< interface, ::DBus::Message, const ::DBus::CallMessage& >(this, & interface :: callback );
|
new ::DBus::Callback< interface, ::DBus::Message, const ::DBus::CallMessage &>(this, & interface :: callback);
|
||||||
|
|
||||||
# define bind_property(variable, type, can_read, can_write) \
|
# define bind_property(variable, type, can_read, can_write) \
|
||||||
InterfaceAdaptor::_properties[ #variable ].read = can_read; \
|
InterfaceAdaptor::_properties[ #variable ].read = can_read; \
|
||||||
InterfaceAdaptor::_properties[ #variable ].write = can_write; \
|
InterfaceAdaptor::_properties[ #variable ].write = can_write; \
|
||||||
InterfaceAdaptor::_properties[ #variable ].sig = type; \
|
InterfaceAdaptor::_properties[ #variable ].sig = type; \
|
||||||
variable.bind( InterfaceAdaptor::_properties[ #variable ] );
|
variable.bind(InterfaceAdaptor::_properties[ #variable ]);
|
||||||
|
|
||||||
# define connect_signal(interface, signal, callback) \
|
# define connect_signal(interface, signal, callback) \
|
||||||
InterfaceProxy::_signals[ #signal ] = \
|
InterfaceProxy::_signals[ #signal ] = \
|
||||||
new ::DBus::Callback< interface, void, const ::DBus::SignalMessage& >(this, & interface :: callback );
|
new ::DBus::Callback< interface, void, const ::DBus::SignalMessage &>(this, & interface :: callback);
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
||||||
|
|
|
@ -34,31 +34,31 @@ namespace DBus {
|
||||||
|
|
||||||
struct DXXAPI IntrospectedArgument
|
struct DXXAPI IntrospectedArgument
|
||||||
{
|
{
|
||||||
const char* name;
|
const char *name;
|
||||||
const char* type;
|
const char *type;
|
||||||
const bool in;
|
const bool in;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI IntrospectedMethod
|
struct DXXAPI IntrospectedMethod
|
||||||
{
|
{
|
||||||
const char* name;
|
const char *name;
|
||||||
const IntrospectedArgument* args;
|
const IntrospectedArgument *args;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI IntrospectedProperty
|
struct DXXAPI IntrospectedProperty
|
||||||
{
|
{
|
||||||
const char* name;
|
const char *name;
|
||||||
const char* type;
|
const char *type;
|
||||||
const bool read;
|
const bool read;
|
||||||
const bool write;
|
const bool write;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DXXAPI IntrospectedInterface
|
struct DXXAPI IntrospectedInterface
|
||||||
{
|
{
|
||||||
const char* name;
|
const char *name;
|
||||||
const IntrospectedMethod* methods;
|
const IntrospectedMethod *methods;
|
||||||
const IntrospectedMethod* signals;
|
const IntrospectedMethod *signals;
|
||||||
const IntrospectedProperty* properties;
|
const IntrospectedProperty *properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DXXAPI IntrospectableAdaptor : public InterfaceAdaptor
|
class DXXAPI IntrospectableAdaptor : public InterfaceAdaptor
|
||||||
|
@ -67,11 +67,11 @@ public:
|
||||||
|
|
||||||
IntrospectableAdaptor();
|
IntrospectableAdaptor();
|
||||||
|
|
||||||
Message Introspect( const CallMessage& );
|
Message Introspect(const CallMessage &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
IntrospectedInterface* const introspect() const;
|
IntrospectedInterface *const introspect() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DXXAPI IntrospectableProxy : public InterfaceProxy
|
class DXXAPI IntrospectableProxy : public InterfaceProxy
|
||||||
|
|
|
@ -54,104 +54,104 @@ public:
|
||||||
|
|
||||||
bool has_next();
|
bool has_next();
|
||||||
|
|
||||||
MessageIter& operator ++();
|
MessageIter &operator ++();
|
||||||
|
|
||||||
MessageIter operator ++(int);
|
MessageIter operator ++(int);
|
||||||
|
|
||||||
bool append_byte( unsigned char byte );
|
bool append_byte(unsigned char byte);
|
||||||
|
|
||||||
unsigned char get_byte();
|
unsigned char get_byte();
|
||||||
|
|
||||||
bool append_bool( bool b );
|
bool append_bool(bool b);
|
||||||
|
|
||||||
bool get_bool();
|
bool get_bool();
|
||||||
|
|
||||||
bool append_int16( signed short i );
|
bool append_int16(signed short i);
|
||||||
|
|
||||||
signed short get_int16();
|
signed short get_int16();
|
||||||
|
|
||||||
bool append_uint16( unsigned short u );
|
bool append_uint16(unsigned short u);
|
||||||
|
|
||||||
unsigned short get_uint16();
|
unsigned short get_uint16();
|
||||||
|
|
||||||
bool append_int32( signed int i );
|
bool append_int32(signed int i);
|
||||||
|
|
||||||
signed int get_int32();
|
signed int get_int32();
|
||||||
|
|
||||||
bool append_uint32( unsigned int u );
|
bool append_uint32(unsigned int u);
|
||||||
|
|
||||||
unsigned int get_uint32();
|
unsigned int get_uint32();
|
||||||
|
|
||||||
bool append_int64( signed long long i );
|
bool append_int64(signed long long i);
|
||||||
|
|
||||||
signed long long get_int64();
|
signed long long get_int64();
|
||||||
|
|
||||||
bool append_uint64( unsigned long long i );
|
bool append_uint64(unsigned long long i);
|
||||||
|
|
||||||
unsigned long long get_uint64();
|
unsigned long long get_uint64();
|
||||||
|
|
||||||
bool append_double( double d );
|
bool append_double(double d);
|
||||||
|
|
||||||
double get_double();
|
double get_double();
|
||||||
|
|
||||||
bool append_string( const char* chars );
|
bool append_string(const char *chars);
|
||||||
|
|
||||||
const char* get_string();
|
const char *get_string();
|
||||||
|
|
||||||
bool append_path( const char* chars );
|
bool append_path(const char *chars);
|
||||||
|
|
||||||
const char* get_path();
|
const char *get_path();
|
||||||
|
|
||||||
bool append_signature( const char* chars );
|
bool append_signature(const char *chars);
|
||||||
|
|
||||||
const char* get_signature();
|
const char *get_signature();
|
||||||
|
|
||||||
char* signature() const; //returned string must be manually free()'d
|
char *signature() const; //returned string must be manually free()'d
|
||||||
|
|
||||||
MessageIter recurse();
|
MessageIter recurse();
|
||||||
|
|
||||||
bool append_array( char type, const void* ptr, size_t length );
|
bool append_array(char type, const void *ptr, size_t length);
|
||||||
|
|
||||||
int array_type();
|
int array_type();
|
||||||
|
|
||||||
int get_array( void* ptr );
|
int get_array(void *ptr);
|
||||||
|
|
||||||
bool is_array();
|
bool is_array();
|
||||||
|
|
||||||
bool is_dict();
|
bool is_dict();
|
||||||
|
|
||||||
MessageIter new_array( const char* sig );
|
MessageIter new_array(const char *sig);
|
||||||
|
|
||||||
MessageIter new_variant( const char* sig );
|
MessageIter new_variant(const char *sig);
|
||||||
|
|
||||||
MessageIter new_struct();
|
MessageIter new_struct();
|
||||||
|
|
||||||
MessageIter new_dict_entry();
|
MessageIter new_dict_entry();
|
||||||
|
|
||||||
void close_container( MessageIter& container );
|
void close_container(MessageIter &container);
|
||||||
|
|
||||||
void copy_data( MessageIter& to );
|
void copy_data(MessageIter &to);
|
||||||
|
|
||||||
Message& msg() const
|
Message &msg() const
|
||||||
{
|
{
|
||||||
return *_msg;
|
return *_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DXXAPILOCAL MessageIter(Message& msg) : _msg(&msg) {}
|
DXXAPILOCAL MessageIter(Message &msg) : _msg(&msg) {}
|
||||||
|
|
||||||
DXXAPILOCAL bool append_basic( int type_id, void* value );
|
DXXAPILOCAL bool append_basic(int type_id, void *value);
|
||||||
|
|
||||||
DXXAPILOCAL void get_basic( int type_id, void* ptr );
|
DXXAPILOCAL void get_basic(int type_id, void *ptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* I'm sorry, but don't want to include dbus.h in the public api
|
/* 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;
|
Message *_msg;
|
||||||
|
|
||||||
friend class Message;
|
friend class Message;
|
||||||
};
|
};
|
||||||
|
@ -162,13 +162,13 @@ public:
|
||||||
|
|
||||||
struct Private;
|
struct Private;
|
||||||
|
|
||||||
Message( Private*, bool incref = true );
|
Message(Private *, bool incref = true);
|
||||||
|
|
||||||
Message( const Message& m );
|
Message(const Message &m);
|
||||||
|
|
||||||
~Message();
|
~Message();
|
||||||
|
|
||||||
Message& operator = ( const Message& m );
|
Message &operator = (const Message &m);
|
||||||
|
|
||||||
Message copy();
|
Message copy();
|
||||||
|
|
||||||
|
@ -178,25 +178,25 @@ public:
|
||||||
|
|
||||||
int reply_serial() const;
|
int reply_serial() const;
|
||||||
|
|
||||||
bool reply_serial( int );
|
bool reply_serial(int);
|
||||||
|
|
||||||
const char* sender() const;
|
const char *sender() const;
|
||||||
|
|
||||||
bool sender( const char* s );
|
bool sender(const char *s);
|
||||||
|
|
||||||
const char* destination() const;
|
const char *destination() const;
|
||||||
|
|
||||||
bool destination( const char* s );
|
bool destination(const char *s);
|
||||||
|
|
||||||
bool is_error() const;
|
bool is_error() const;
|
||||||
|
|
||||||
bool is_signal( const char* interface, const char* member ) const;
|
bool is_signal(const char *interface, const char *member) const;
|
||||||
|
|
||||||
MessageIter reader() const;
|
MessageIter reader() const;
|
||||||
|
|
||||||
MessageIter writer();
|
MessageIter writer();
|
||||||
|
|
||||||
bool append( int first_type, ... );
|
bool append(int first_type, ...);
|
||||||
|
|
||||||
void terminate();
|
void terminate();
|
||||||
|
|
||||||
|
@ -226,13 +226,13 @@ public:
|
||||||
|
|
||||||
ErrorMessage();
|
ErrorMessage();
|
||||||
|
|
||||||
ErrorMessage( const Message&, const char* name, const char* message );
|
ErrorMessage(const Message &, const char *name, const char *message);
|
||||||
|
|
||||||
const char* name() const;
|
const char *name() const;
|
||||||
|
|
||||||
bool name( const char* n );
|
bool name(const char *n);
|
||||||
|
|
||||||
bool operator == ( const ErrorMessage& ) const;
|
bool operator == (const ErrorMessage &) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -242,25 +242,25 @@ class DXXAPI SignalMessage : public Message
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SignalMessage( const char* name );
|
SignalMessage(const char *name);
|
||||||
|
|
||||||
SignalMessage( const char* path, const char* interface, const char* name );
|
SignalMessage(const char *path, const char *interface, const char *name);
|
||||||
|
|
||||||
const char* interface() const;
|
const char *interface() const;
|
||||||
|
|
||||||
bool interface( const char* i );
|
bool interface(const char *i);
|
||||||
|
|
||||||
const char* member() const;
|
const char *member() const;
|
||||||
|
|
||||||
bool member( const char* m );
|
bool member(const char *m);
|
||||||
|
|
||||||
const char* path() const;
|
const char *path() const;
|
||||||
|
|
||||||
char** path_split() const;
|
char ** path_split() const;
|
||||||
|
|
||||||
bool path( const char* p );
|
bool path(const char *p);
|
||||||
|
|
||||||
bool operator == ( const SignalMessage& ) const;
|
bool operator == (const SignalMessage &) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -272,25 +272,25 @@ public:
|
||||||
|
|
||||||
CallMessage();
|
CallMessage();
|
||||||
|
|
||||||
CallMessage( const char* dest, const char* path, const char* iface, const char* method );
|
CallMessage(const char *dest, const char *path, const char *iface, const char *method);
|
||||||
|
|
||||||
const char* interface() const;
|
const char *interface() const;
|
||||||
|
|
||||||
bool interface( const char* i );
|
bool interface(const char *i);
|
||||||
|
|
||||||
const char* member() const;
|
const char *member() const;
|
||||||
|
|
||||||
bool member( const char* m );
|
bool member(const char *m);
|
||||||
|
|
||||||
const char* path() const;
|
const char *path() const;
|
||||||
|
|
||||||
char** path_split() const;
|
char ** path_split() const;
|
||||||
|
|
||||||
bool path( const char* p );
|
bool path(const char *p);
|
||||||
|
|
||||||
const char* signature() const;
|
const char *signature() const;
|
||||||
|
|
||||||
bool operator == ( const CallMessage& ) const;
|
bool operator == (const CallMessage &) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -300,9 +300,9 @@ class DXXAPI ReturnMessage : public Message
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ReturnMessage( const CallMessage& callee );
|
ReturnMessage(const CallMessage &callee);
|
||||||
|
|
||||||
const char* signature() const;
|
const char *signature() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
|
@ -42,21 +42,21 @@ class DXXAPI Object
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Object( Connection& conn, const Path& path, const char* service );
|
Object(Connection &conn, const Path &path, const char *service);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~Object();
|
virtual ~Object();
|
||||||
|
|
||||||
inline const DBus::Path& path() const;
|
inline const DBus::Path &path() const;
|
||||||
|
|
||||||
inline const std::string& service() const;
|
inline const std::string &service() const;
|
||||||
|
|
||||||
inline Connection& conn();
|
inline Connection &conn();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DXXAPILOCAL virtual bool handle_message( const Message& ) = 0;
|
DXXAPILOCAL virtual bool handle_message(const Message &) = 0;
|
||||||
DXXAPILOCAL virtual void register_obj() = 0;
|
DXXAPILOCAL virtual void register_obj() = 0;
|
||||||
DXXAPILOCAL virtual void unregister_obj() = 0;
|
DXXAPILOCAL virtual void unregister_obj() = 0;
|
||||||
|
|
||||||
|
@ -70,17 +70,17 @@ private:
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Connection& Object::conn()
|
Connection &Object::conn()
|
||||||
{
|
{
|
||||||
return _conn;
|
return _conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DBus::Path& Object::path() const
|
const DBus::Path &Object::path() const
|
||||||
{
|
{
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& Object::service() const
|
const std::string &Object::service() const
|
||||||
{
|
{
|
||||||
return _service;
|
return _service;
|
||||||
}
|
}
|
||||||
|
@ -101,26 +101,26 @@ public:
|
||||||
|
|
||||||
class ObjectAdaptor;
|
class ObjectAdaptor;
|
||||||
|
|
||||||
typedef std::list<ObjectAdaptor*> ObjectAdaptorPList;
|
typedef std::list<ObjectAdaptor *> ObjectAdaptorPList;
|
||||||
typedef std::list<std::string> ObjectPathList;
|
typedef std::list<std::string> ObjectPathList;
|
||||||
|
|
||||||
class DXXAPI ObjectAdaptor : public Object, public virtual AdaptorBase
|
class DXXAPI ObjectAdaptor : public Object, public virtual AdaptorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static ObjectAdaptor* from_path( const Path& path );
|
static ObjectAdaptor *from_path(const Path &path);
|
||||||
|
|
||||||
static ObjectAdaptorPList from_path_prefix( const std::string& prefix );
|
static ObjectAdaptorPList from_path_prefix(const std::string &prefix);
|
||||||
|
|
||||||
static ObjectPathList child_nodes_from_prefix( const std::string& prefix );
|
static ObjectPathList child_nodes_from_prefix(const std::string &prefix);
|
||||||
|
|
||||||
struct Private;
|
struct Private;
|
||||||
|
|
||||||
ObjectAdaptor( Connection& conn, const Path& path );
|
ObjectAdaptor(Connection &conn, const Path &path);
|
||||||
|
|
||||||
~ObjectAdaptor();
|
~ObjectAdaptor();
|
||||||
|
|
||||||
inline const ObjectAdaptor* object() const;
|
inline const ObjectAdaptor *object() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -128,57 +128,57 @@ protected:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline MessageIter& writer();
|
inline MessageIter &writer();
|
||||||
|
|
||||||
inline Tag* tag();
|
inline Tag *tag();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Continuation( Connection& conn, const CallMessage& call, const Tag* tag );
|
Continuation(Connection &conn, const CallMessage &call, const Tag *tag);
|
||||||
|
|
||||||
Connection _conn;
|
Connection _conn;
|
||||||
CallMessage _call;
|
CallMessage _call;
|
||||||
MessageIter _writer;
|
MessageIter _writer;
|
||||||
ReturnMessage _return;
|
ReturnMessage _return;
|
||||||
const Tag* _tag;
|
const Tag *_tag;
|
||||||
|
|
||||||
friend class ObjectAdaptor;
|
friend class ObjectAdaptor;
|
||||||
};
|
};
|
||||||
|
|
||||||
void return_later( const Tag* tag );
|
void return_later(const Tag *tag);
|
||||||
|
|
||||||
void return_now( Continuation* ret );
|
void return_now(Continuation *ret);
|
||||||
|
|
||||||
void return_error( Continuation* ret, const Error error );
|
void return_error(Continuation *ret, const Error error);
|
||||||
|
|
||||||
Continuation* find_continuation( const Tag* tag );
|
Continuation *find_continuation(const Tag *tag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void _emit_signal( SignalMessage& );
|
void _emit_signal(SignalMessage &);
|
||||||
|
|
||||||
bool handle_message( const Message& );
|
bool handle_message(const Message &);
|
||||||
|
|
||||||
void register_obj();
|
void register_obj();
|
||||||
void unregister_obj();
|
void unregister_obj();
|
||||||
|
|
||||||
typedef std::map<const Tag*, Continuation*> ContinuationMap;
|
typedef std::map<const Tag *, Continuation *> ContinuationMap;
|
||||||
ContinuationMap _continuations;
|
ContinuationMap _continuations;
|
||||||
|
|
||||||
friend struct Private;
|
friend struct Private;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ObjectAdaptor* ObjectAdaptor::object() const
|
const ObjectAdaptor *ObjectAdaptor::object() const
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag* ObjectAdaptor::Continuation::tag()
|
Tag *ObjectAdaptor::Continuation::tag()
|
||||||
{
|
{
|
||||||
return const_cast<Tag*>(_tag);
|
return const_cast<Tag *>(_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIter& ObjectAdaptor::Continuation::writer()
|
MessageIter &ObjectAdaptor::Continuation::writer()
|
||||||
{
|
{
|
||||||
return _writer;
|
return _writer;
|
||||||
}
|
}
|
||||||
|
@ -188,23 +188,23 @@ MessageIter& ObjectAdaptor::Continuation::writer()
|
||||||
|
|
||||||
class ObjectProxy;
|
class ObjectProxy;
|
||||||
|
|
||||||
typedef std::list<ObjectProxy*> ObjectProxyPList;
|
typedef std::list<ObjectProxy *> ObjectProxyPList;
|
||||||
|
|
||||||
class DXXAPI ObjectProxy : public Object, public virtual ProxyBase
|
class DXXAPI ObjectProxy : public Object, public virtual ProxyBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ObjectProxy( Connection& conn, const Path& path, const char* service = "" );
|
ObjectProxy(Connection &conn, const Path &path, const char *service = "");
|
||||||
|
|
||||||
~ObjectProxy();
|
~ObjectProxy();
|
||||||
|
|
||||||
inline const ObjectProxy* object() const;
|
inline const ObjectProxy *object() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Message _invoke_method( CallMessage& );
|
Message _invoke_method(CallMessage &);
|
||||||
|
|
||||||
bool handle_message( const Message& );
|
bool handle_message(const Message &);
|
||||||
|
|
||||||
void register_obj();
|
void register_obj();
|
||||||
void unregister_obj();
|
void unregister_obj();
|
||||||
|
@ -214,7 +214,7 @@ private:
|
||||||
MessageSlot _filtered;
|
MessageSlot _filtered;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ObjectProxy* ObjectProxy::object() const
|
const ObjectProxy *ObjectProxy::object() const
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,85 +41,85 @@ public:
|
||||||
|
|
||||||
struct Private;
|
struct Private;
|
||||||
|
|
||||||
PendingCall( Private* );
|
PendingCall(Private *);
|
||||||
|
|
||||||
PendingCall( const PendingCall& );
|
PendingCall(const PendingCall &);
|
||||||
|
|
||||||
virtual ~PendingCall();
|
virtual ~PendingCall();
|
||||||
|
|
||||||
PendingCall& operator = ( const PendingCall& );
|
PendingCall &operator = (const PendingCall &);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Checks whether the pending call has received a reply yet, or not.
|
* \brief Checks whether the pending call has received a reply yet, or not.
|
||||||
*
|
*
|
||||||
* \return true If a reply has been received.
|
* \return true If a reply has been received.
|
||||||
*/
|
*/
|
||||||
bool completed();
|
bool completed();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Cancels the pending call, such that any reply or error received will
|
* \brief Cancels the pending call, such that any reply or error received will
|
||||||
* just be ignored.
|
* just be ignored.
|
||||||
*
|
*
|
||||||
* Drops the dbus library's internal reference to the DBusPendingCall so will
|
* Drops the dbus library's internal reference to the DBusPendingCall so will
|
||||||
* free the call if nobody else is holding a reference. However you usually
|
* free the call if nobody else is holding a reference. However you usually
|
||||||
* get a reference from Connection::send_async() so probably your app
|
* get a reference from Connection::send_async() so probably your app
|
||||||
* owns a ref also.
|
* owns a ref also.
|
||||||
*
|
*
|
||||||
* Note that canceling a pending call will not simulate a timed-out call; if a
|
* Note that canceling a pending call will not simulate a timed-out call; if a
|
||||||
* call times out, then a timeout error reply is received. If you cancel the
|
* call times out, then a timeout error reply is received. If you cancel the
|
||||||
* call, no reply is received unless the the reply was already received before
|
* call, no reply is received unless the the reply was already received before
|
||||||
* you canceled.
|
* you canceled.
|
||||||
*/
|
*/
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Block until the pending call is completed.
|
* \brief Block until the pending call is completed.
|
||||||
*
|
*
|
||||||
* The blocking is as with Connection::send_blocking(); it
|
* The blocking is as with Connection::send_blocking(); it
|
||||||
* does not enter the main loop or process other messages, it simply waits for
|
* does not enter the main loop or process other messages, it simply waits for
|
||||||
* the reply in question.
|
* the reply in question.
|
||||||
*
|
*
|
||||||
* If the pending call is already completed, this function returns immediately.
|
* If the pending call is already completed, this function returns immediately.
|
||||||
*/
|
*/
|
||||||
void block();
|
void block();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Stores a pointer on a PendingCall, along with an optional function to
|
* \brief Stores a pointer on a PendingCall, along with an optional function to
|
||||||
* be used for freeing the data when the data is set again, or when the
|
* be used for freeing the data when the data is set again, or when the
|
||||||
* pending call is finalized.
|
* pending call is finalized.
|
||||||
*
|
*
|
||||||
* The slot is allocated automatic.
|
* The slot is allocated automatic.
|
||||||
*
|
*
|
||||||
* \param data The data to store.
|
* \param data The data to store.
|
||||||
* \throw ErrorNoMemory
|
* \throw ErrorNoMemory
|
||||||
*/
|
*/
|
||||||
void data( void* data );
|
void data( void* data );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Retrieves data previously set with dbus_pending_call_set_data().
|
* \brief Retrieves data previously set with dbus_pending_call_set_data().
|
||||||
*
|
*
|
||||||
* The slot must still be allocated (must not have been freed).
|
* The slot must still be allocated (must not have been freed).
|
||||||
*
|
*
|
||||||
* \return The data, or NULL if not found.
|
* \return The data, or NULL if not found.
|
||||||
*/
|
|
||||||
void* data();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \return The data slot.
|
|
||||||
*/
|
|
||||||
Slot<void, PendingCall&>& slot();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Gets the reply
|
|
||||||
*
|
|
||||||
* Ownership of the reply message passes to the caller. This function can only
|
|
||||||
* be called once per pending call, since the reply message is tranferred to
|
|
||||||
* the caller.
|
|
||||||
*
|
|
||||||
* \return The reply Message.
|
|
||||||
* \throw ErrorNoReply
|
|
||||||
*/
|
*/
|
||||||
Message steal_reply();
|
void *data();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \return The data slot.
|
||||||
|
*/
|
||||||
|
Slot<void, PendingCall &>& slot();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the reply
|
||||||
|
*
|
||||||
|
* Ownership of the reply message passes to the caller. This function can only
|
||||||
|
* be called once per pending call, since the reply message is tranferred to
|
||||||
|
* the caller.
|
||||||
|
*
|
||||||
|
* \return The reply Message.
|
||||||
|
* \throw ErrorNoReply
|
||||||
|
*/
|
||||||
|
Message steal_reply();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
PropertyAdaptor() : _data(0)
|
PropertyAdaptor() : _data(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void bind( PropertyData& data )
|
void bind(PropertyData &data)
|
||||||
{
|
{
|
||||||
_data = &data;
|
_data = &data;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public:
|
||||||
return (T)_data->value;
|
return (T)_data->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyAdaptor& operator = ( const T& t )
|
PropertyAdaptor &operator = (const T &t)
|
||||||
{
|
{
|
||||||
_data->value.clear();
|
_data->value.clear();
|
||||||
MessageIter wi = _data->value.writer();
|
MessageIter wi = _data->value.writer();
|
||||||
|
@ -61,7 +61,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
PropertyData* _data;
|
PropertyData *_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IntrospectedInterface;
|
struct IntrospectedInterface;
|
||||||
|
@ -72,19 +72,19 @@ public:
|
||||||
|
|
||||||
PropertiesAdaptor();
|
PropertiesAdaptor();
|
||||||
|
|
||||||
Message Get( const CallMessage& );
|
Message Get(const CallMessage &);
|
||||||
|
|
||||||
Message Set( const CallMessage& );
|
Message Set(const CallMessage &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void on_get_property( InterfaceAdaptor& interface, const String& property, Variant& value )
|
virtual void on_get_property(InterfaceAdaptor &interface, const std::string &property, Variant &value)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void on_set_property( InterfaceAdaptor& interface, const String& property, const Variant& value )
|
virtual void on_set_property(InterfaceAdaptor &interface, const std::string &property, const Variant &value)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
IntrospectedInterface* const introspect() const;
|
IntrospectedInterface *const introspect() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DXXAPI PropertiesProxy : public InterfaceProxy
|
class DXXAPI PropertiesProxy : public InterfaceProxy
|
||||||
|
@ -93,9 +93,9 @@ public:
|
||||||
|
|
||||||
PropertiesProxy();
|
PropertiesProxy();
|
||||||
|
|
||||||
Variant Get( const String& interface, const String& property );
|
Variant Get(const std::string &interface, const std::string &property);
|
||||||
|
|
||||||
void Set( const String& interface, const String& property, const Variant& value );
|
void Set(const std::string &interface, const std::string &property, const Variant &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
|
@ -33,14 +33,14 @@
|
||||||
namespace DBus {
|
namespace DBus {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
RefPtrI<T>::RefPtrI( T* ptr )
|
RefPtrI<T>::RefPtrI(T *ptr)
|
||||||
: __ptr(ptr)
|
: __ptr(ptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
RefPtrI<T>::~RefPtrI()
|
RefPtrI<T>::~RefPtrI()
|
||||||
{
|
{
|
||||||
if(__cnt.one()) delete __ptr;
|
if (__cnt.one()) delete __ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
|
@ -45,15 +45,15 @@ class DXXAPI Server
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Server( const char* address );
|
Server(const char *address);
|
||||||
|
|
||||||
Dispatcher* setup( Dispatcher* );
|
Dispatcher *setup(Dispatcher *);
|
||||||
|
|
||||||
virtual ~Server();
|
virtual ~Server();
|
||||||
|
|
||||||
bool listening() const;
|
bool listening() const;
|
||||||
|
|
||||||
bool operator == ( const Server& ) const;
|
bool operator == (const Server &) const;
|
||||||
|
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
|
@ -61,10 +61,10 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Server( const Server& s )
|
Server(const Server &s)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void on_new_connection( Connection& c ) = 0;
|
virtual void on_new_connection(Connection &c) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "dbus-c++-config.h"
|
#include "dbus-c++-config.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -38,23 +39,12 @@
|
||||||
|
|
||||||
namespace DBus {
|
namespace DBus {
|
||||||
|
|
||||||
typedef unsigned char Byte;
|
|
||||||
typedef bool Bool;
|
|
||||||
typedef signed short Int16;
|
|
||||||
typedef unsigned short UInt16;
|
|
||||||
typedef signed int Int32;
|
|
||||||
typedef unsigned int UInt32;
|
|
||||||
typedef signed long long Int64;
|
|
||||||
typedef unsigned long long UInt64;
|
|
||||||
typedef double Double;
|
|
||||||
typedef std::string String;
|
|
||||||
|
|
||||||
struct DXXAPI Path : public std::string
|
struct DXXAPI Path : public std::string
|
||||||
{
|
{
|
||||||
Path() {}
|
Path() {}
|
||||||
Path( const std::string& s ) : std::string(s) {}
|
Path(const std::string &s) : std::string(s) {}
|
||||||
Path( const char* c ) : std::string(c) {}
|
Path(const char *c) : std::string(c) {}
|
||||||
Path& operator = ( std::string& s )
|
Path &operator = (std::string &s)
|
||||||
{
|
{
|
||||||
std::string::operator = (s);
|
std::string::operator = (s);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -64,9 +54,9 @@ struct DXXAPI Path : public std::string
|
||||||
struct DXXAPI Signature : public std::string
|
struct DXXAPI Signature : public std::string
|
||||||
{
|
{
|
||||||
Signature() {}
|
Signature() {}
|
||||||
Signature( const std::string& s ) : std::string(s) {}
|
Signature(const std::string &s) : std::string(s) {}
|
||||||
Signature( const char* c ) : std::string(c) {}
|
Signature(const char *c) : std::string(c) {}
|
||||||
Signature& operator = ( std::string& s )
|
Signature &operator = (std::string &s)
|
||||||
{
|
{
|
||||||
std::string::operator = (s);
|
std::string::operator = (s);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -81,9 +71,9 @@ public:
|
||||||
|
|
||||||
Variant();
|
Variant();
|
||||||
|
|
||||||
Variant( MessageIter& it );
|
Variant(MessageIter &it);
|
||||||
|
|
||||||
Variant& operator = ( const Variant& v );
|
Variant &operator = (const Variant &v);
|
||||||
|
|
||||||
const Signature signature() const;
|
const Signature signature() const;
|
||||||
|
|
||||||
|
@ -129,7 +119,7 @@ struct Struct
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename K, typename V>
|
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();
|
return map.find(key) != map.end();
|
||||||
}
|
}
|
||||||
|
@ -144,17 +134,17 @@ struct type
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct type<Variant> { static std::string sig(){ return "v"; } };
|
template <> struct type<Variant> { static std::string sig(){ return "v"; } };
|
||||||
template <> struct type<Byte> { static std::string sig(){ return "y"; } };
|
template <> struct type<uint8_t> { static std::string sig(){ return "y"; } };
|
||||||
template <> struct type<Bool> { static std::string sig(){ return "b"; } };
|
template <> struct type<bool> { static std::string sig(){ return "b"; } };
|
||||||
template <> struct type<Int16> { static std::string sig(){ return "n"; } };
|
template <> struct type<int16_t> { static std::string sig(){ return "n"; } };
|
||||||
template <> struct type<UInt16> { static std::string sig(){ return "q"; } };
|
template <> struct type<uint16_t> { static std::string sig(){ return "q"; } };
|
||||||
template <> struct type<Int32> { static std::string sig(){ return "i"; } };
|
template <> struct type<int32_t> { static std::string sig(){ return "i"; } };
|
||||||
template <> struct type<UInt32> { static std::string sig(){ return "u"; } };
|
template <> struct type<uint32_t> { static std::string sig(){ return "u"; } };
|
||||||
template <> struct type<Int64> { static std::string sig(){ return "x"; } };
|
template <> struct type<int64_t> { static std::string sig(){ return "x"; } };
|
||||||
template <> struct type<UInt64> { static std::string sig(){ return "t"; } };
|
template <> struct type<uint64_t> { static std::string sig(){ return "t"; } };
|
||||||
template <> struct type<Double> { static std::string sig(){ return "d"; } };
|
template <> struct type<double> { static std::string sig(){ return "d"; } };
|
||||||
template <> struct type<String> { static std::string sig(){ return "s"; } };
|
template <> struct type<std::string> { static std::string sig(){ return "s"; } };
|
||||||
template <> struct type<Path> { static std::string sig(){ return "o"; } };
|
template <> struct type<Path> { static std::string sig(){ return "o"; } };
|
||||||
template <> struct type<Signature> { static std::string sig(){ return "g"; } };
|
template <> struct type<Signature> { static std::string sig(){ return "g"; } };
|
||||||
template <> struct type<Invalid> { static std::string sig(){ return ""; } };
|
template <> struct type<Invalid> { static std::string sig(){ return ""; } };
|
||||||
|
@ -196,91 +186,91 @@ struct type< Struct<T1,T2,T3,T4,T5,T6,T7,T8> >
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Invalid& )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Invalid &)
|
||||||
{
|
{
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Byte& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint8_t &val)
|
||||||
{
|
{
|
||||||
iter.append_byte(val);
|
iter.append_byte(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Bool& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const bool &val)
|
||||||
{
|
{
|
||||||
iter.append_bool(val);
|
iter.append_bool(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int16& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int16_t& val)
|
||||||
{
|
{
|
||||||
iter.append_int16(val);
|
iter.append_int16(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt16& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint16_t& val)
|
||||||
{
|
{
|
||||||
iter.append_uint16(val);
|
iter.append_uint16(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int32& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int32_t& val)
|
||||||
{
|
{
|
||||||
iter.append_int32(val);
|
iter.append_int32(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt32& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint32_t& val)
|
||||||
{
|
{
|
||||||
iter.append_uint32(val);
|
iter.append_uint32(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int64& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int64_t& val)
|
||||||
{
|
{
|
||||||
iter.append_int64(val);
|
iter.append_int64(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt64& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint64_t& val)
|
||||||
{
|
{
|
||||||
iter.append_uint64(val);
|
iter.append_uint64(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Double& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const double &val)
|
||||||
{
|
{
|
||||||
iter.append_double(val);
|
iter.append_double(val);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::String& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::string &val)
|
||||||
{
|
{
|
||||||
iter.append_string(val.c_str());
|
iter.append_string(val.c_str());
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Path& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Path &val)
|
||||||
{
|
{
|
||||||
iter.append_path(val.c_str());
|
iter.append_path(val.c_str());
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Signature& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Signature &val)
|
||||||
{
|
{
|
||||||
iter.append_signature(val.c_str());
|
iter.append_signature(val.c_str());
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename E>
|
template<typename E>
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vector<E>& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector<E>& val)
|
||||||
{
|
{
|
||||||
const std::string sig = DBus::type<E>::sig();
|
const std::string sig = DBus::type<E>::sig();
|
||||||
DBus::MessageIter ait = iter.new_array(sig.c_str());
|
DBus::MessageIter ait = iter.new_array(sig.c_str());
|
||||||
|
|
||||||
typename std::vector<E>::const_iterator vit;
|
typename std::vector<E>::const_iterator vit;
|
||||||
for(vit = val.begin(); vit != val.end(); ++vit)
|
for (vit = val.begin(); vit != val.end(); ++vit)
|
||||||
{
|
{
|
||||||
ait << *vit;
|
ait << *vit;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +280,7 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vect
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vector<DBus::Byte>& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector<uint8_t>& val)
|
||||||
{
|
{
|
||||||
DBus::MessageIter ait = iter.new_array("y");
|
DBus::MessageIter ait = iter.new_array("y");
|
||||||
ait.append_array('y', &val.front(), val.size());
|
ait.append_array('y', &val.front(), val.size());
|
||||||
|
@ -299,13 +289,13 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vect
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename K, typename V>
|
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() + "}";
|
const std::string sig = "{" + DBus::type<K>::sig() + DBus::type<V>::sig() + "}";
|
||||||
DBus::MessageIter ait = iter.new_array(sig.c_str());
|
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)
|
for (mit = val.begin(); mit != val.end(); ++mit)
|
||||||
{
|
{
|
||||||
DBus::MessageIter eit = ait.new_dict_entry();
|
DBus::MessageIter eit = ait.new_dict_entry();
|
||||||
|
|
||||||
|
@ -328,7 +318,7 @@ template <
|
||||||
typename T7,
|
typename T7,
|
||||||
typename T8
|
typename T8
|
||||||
>
|
>
|
||||||
inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Struct<T1,T2,T3,T4,T5,T6,T7,T8>& val )
|
inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Struct<T1,T2,T3,T4,T5,T6,T7,T8>& val)
|
||||||
{
|
{
|
||||||
/* const std::string sig =
|
/* const std::string sig =
|
||||||
DBus::type<T1>::sig() + DBus::type<T2>::sig() + DBus::type<T3>::sig() + DBus::type<T4>::sig() +
|
DBus::type<T1>::sig() + DBus::type<T2>::sig() + DBus::type<T3>::sig() + DBus::type<T4>::sig() +
|
||||||
|
@ -343,97 +333,97 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Str
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern DXXAPI DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Variant& val );
|
extern DXXAPI DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Variant &val);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Invalid& )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Invalid &)
|
||||||
{
|
{
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Byte& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint8_t &val)
|
||||||
{
|
{
|
||||||
val = iter.get_byte();
|
val = iter.get_byte();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Bool& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, bool &val)
|
||||||
{
|
{
|
||||||
val = iter.get_bool();
|
val = iter.get_bool();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int16& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int16_t& val)
|
||||||
{
|
{
|
||||||
val = iter.get_int16();
|
val = iter.get_int16();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt16& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint16_t& val)
|
||||||
{
|
{
|
||||||
val = iter.get_uint16();
|
val = iter.get_uint16();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int32& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int32_t& val)
|
||||||
{
|
{
|
||||||
val = iter.get_int32();
|
val = iter.get_int32();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt32& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint32_t& val)
|
||||||
{
|
{
|
||||||
val = iter.get_uint32();
|
val = iter.get_uint32();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int64& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int64_t& val)
|
||||||
{
|
{
|
||||||
val = iter.get_int64();
|
val = iter.get_int64();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt64& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint64_t& val)
|
||||||
{
|
{
|
||||||
val = iter.get_uint64();
|
val = iter.get_uint64();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Double& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, double &val)
|
||||||
{
|
{
|
||||||
val = iter.get_double();
|
val = iter.get_double();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::String& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::string &val)
|
||||||
{
|
{
|
||||||
val = iter.get_string();
|
val = iter.get_string();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Path& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Path &val)
|
||||||
{
|
{
|
||||||
val = iter.get_path();
|
val = iter.get_path();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Signature& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Signature &val)
|
||||||
{
|
{
|
||||||
val = iter.get_signature();
|
val = iter.get_signature();
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename E>
|
template<typename E>
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector<E>& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector<E>& val)
|
||||||
{
|
{
|
||||||
if(!iter.is_array())
|
if (!iter.is_array())
|
||||||
throw DBus::ErrorInvalidArgs("array expected");
|
throw DBus::ErrorInvalidArgs("array expected");
|
||||||
|
|
||||||
DBus::MessageIter ait = iter.recurse();
|
DBus::MessageIter ait = iter.recurse();
|
||||||
|
|
||||||
while(!ait.at_end())
|
while (!ait.at_end())
|
||||||
{
|
{
|
||||||
E elem;
|
E elem;
|
||||||
|
|
||||||
|
@ -445,17 +435,17 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector<E>&
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector<DBus::Byte>& val )
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector<uint8_t>& val)
|
||||||
{
|
{
|
||||||
if(!iter.is_array())
|
if (!iter.is_array())
|
||||||
throw DBus::ErrorInvalidArgs("array expected");
|
throw DBus::ErrorInvalidArgs("array expected");
|
||||||
|
|
||||||
if(iter.array_type() != 'y')
|
if (iter.array_type() != 'y')
|
||||||
throw DBus::ErrorInvalidArgs("byte-array expected");
|
throw DBus::ErrorInvalidArgs("byte-array expected");
|
||||||
|
|
||||||
DBus::MessageIter ait = iter.recurse();
|
DBus::MessageIter ait = iter.recurse();
|
||||||
|
|
||||||
DBus::Byte* array;
|
uint8_t *array;
|
||||||
size_t length = ait.get_array(&array);
|
size_t length = ait.get_array(&array);
|
||||||
|
|
||||||
val.insert(val.end(), array, array+length);
|
val.insert(val.end(), array, array+length);
|
||||||
|
@ -464,14 +454,14 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector<DBu
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename K, typename V>
|
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())
|
if (!iter.is_dict())
|
||||||
throw DBus::ErrorInvalidArgs("dictionary value expected");
|
throw DBus::ErrorInvalidArgs("dictionary value expected");
|
||||||
|
|
||||||
DBus::MessageIter mit = iter.recurse();
|
DBus::MessageIter mit = iter.recurse();
|
||||||
|
|
||||||
while(!mit.at_end())
|
while (!mit.at_end())
|
||||||
{
|
{
|
||||||
K key; V value;
|
K key; V value;
|
||||||
|
|
||||||
|
@ -497,7 +487,7 @@ template <
|
||||||
typename T7,
|
typename T7,
|
||||||
typename T8
|
typename T8
|
||||||
>
|
>
|
||||||
inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Struct<T1,T2,T3,T4,T5,T6,T7,T8>& val)
|
inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Struct<T1,T2,T3,T4,T5,T6,T7,T8>& val)
|
||||||
{
|
{
|
||||||
DBus::MessageIter sit = iter.recurse();
|
DBus::MessageIter sit = iter.recurse();
|
||||||
|
|
||||||
|
@ -506,7 +496,7 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Struct<T1
|
||||||
return ++iter;
|
return ++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern DXXAPI DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Variant& val );
|
extern DXXAPI DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Variant &val);
|
||||||
|
|
||||||
#endif//__DBUSXX_TYPES_H
|
#endif//__DBUSXX_TYPES_H
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
(*__ref) = 1;
|
(*__ref) = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefCnt( const RefCnt& rc )
|
RefCnt(const RefCnt &rc)
|
||||||
{
|
{
|
||||||
__ref = rc.__ref;
|
__ref = rc.__ref;
|
||||||
ref();
|
ref();
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
unref();
|
unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
RefCnt& operator = ( const RefCnt& ref )
|
RefCnt &operator = (const RefCnt &ref)
|
||||||
{
|
{
|
||||||
ref.ref();
|
ref.ref();
|
||||||
unref();
|
unref();
|
||||||
|
@ -85,12 +85,12 @@ private:
|
||||||
{
|
{
|
||||||
-- (*__ref);
|
-- (*__ref);
|
||||||
|
|
||||||
if( (*__ref) < 0 )
|
if ((*__ref) < 0)
|
||||||
{
|
{
|
||||||
debug_log("%p: refcount dropped below zero!", __ref);
|
debug_log("%p: refcount dropped below zero!", __ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( noref() )
|
if (noref())
|
||||||
{
|
{
|
||||||
delete __ref;
|
delete __ref;
|
||||||
}
|
}
|
||||||
|
@ -110,15 +110,15 @@ class RefPtrI // RefPtr to incomplete type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RefPtrI( T* ptr = 0 );
|
RefPtrI(T *ptr = 0);
|
||||||
|
|
||||||
~RefPtrI();
|
~RefPtrI();
|
||||||
|
|
||||||
RefPtrI& operator = ( const RefPtrI& ref )
|
RefPtrI &operator = (const RefPtrI &ref)
|
||||||
{
|
{
|
||||||
if( this != &ref )
|
if (this != &ref)
|
||||||
{
|
{
|
||||||
if(__cnt.one()) delete __ptr;
|
if (__cnt.one()) delete __ptr;
|
||||||
|
|
||||||
__ptr = ref.__ptr;
|
__ptr = ref.__ptr;
|
||||||
__cnt = ref.__cnt;
|
__cnt = ref.__cnt;
|
||||||
|
@ -126,28 +126,28 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator *() const
|
T &operator *() const
|
||||||
{
|
{
|
||||||
return *__ptr;
|
return *__ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
T* operator ->() const
|
T *operator ->() const
|
||||||
{
|
{
|
||||||
if(__cnt.noref()) return 0;
|
if (__cnt.noref()) return 0;
|
||||||
|
|
||||||
return __ptr;
|
return __ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
T* get() const
|
T *get() const
|
||||||
{
|
{
|
||||||
if(__cnt.noref()) return 0;
|
if (__cnt.noref()) return 0;
|
||||||
|
|
||||||
return __ptr;
|
return __ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
T* __ptr;
|
T *__ptr;
|
||||||
RefCnt __cnt;
|
RefCnt __cnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -156,20 +156,20 @@ class RefPtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RefPtr( T* ptr = 0)
|
RefPtr(T *ptr = 0)
|
||||||
: __ptr(ptr)
|
: __ptr(ptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~RefPtr()
|
~RefPtr()
|
||||||
{
|
{
|
||||||
if(__cnt.one()) delete __ptr;
|
if (__cnt.one()) delete __ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr& operator = ( const RefPtr& ref )
|
RefPtr &operator = (const RefPtr &ref)
|
||||||
{
|
{
|
||||||
if( this != &ref )
|
if (this != &ref)
|
||||||
{
|
{
|
||||||
if(__cnt.one()) delete __ptr;
|
if (__cnt.one()) delete __ptr;
|
||||||
|
|
||||||
__ptr = ref.__ptr;
|
__ptr = ref.__ptr;
|
||||||
__cnt = ref.__cnt;
|
__cnt = ref.__cnt;
|
||||||
|
@ -177,28 +177,28 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator *() const
|
T &operator *() const
|
||||||
{
|
{
|
||||||
return *__ptr;
|
return *__ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
T* operator ->() const
|
T *operator ->() const
|
||||||
{
|
{
|
||||||
if(__cnt.noref()) return 0;
|
if (__cnt.noref()) return 0;
|
||||||
|
|
||||||
return __ptr;
|
return __ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
T* get() const
|
T *get() const
|
||||||
{
|
{
|
||||||
if(__cnt.noref()) return 0;
|
if (__cnt.noref()) return 0;
|
||||||
|
|
||||||
return __ptr;
|
return __ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
T* __ptr;
|
T *__ptr;
|
||||||
RefCnt __cnt;
|
RefCnt __cnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class Callback_Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual R call( P param ) const = 0;
|
virtual R call(P param) const = 0;
|
||||||
|
|
||||||
virtual ~Callback_Base()
|
virtual ~Callback_Base()
|
||||||
{}
|
{}
|
||||||
|
@ -222,21 +222,21 @@ class Slot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Slot& operator = ( Callback_Base<R,P>* s )
|
Slot &operator = (Callback_Base<R,P>* s)
|
||||||
{
|
{
|
||||||
_cb = s;
|
_cb = s;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
R operator()( P param ) const
|
R operator()(P param) const
|
||||||
{
|
{
|
||||||
/*if(_cb.get())*/ return _cb->call(param);
|
/*if (_cb.get())*/ return _cb->call(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
R call( P param ) const
|
R call(P param) const
|
||||||
{
|
{
|
||||||
/*if(_cb.get())*/ return _cb->call(param);
|
/*if (_cb.get())*/ return _cb->call(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty()
|
bool empty()
|
||||||
|
@ -256,18 +256,18 @@ public:
|
||||||
|
|
||||||
typedef R (C::*M)(P);
|
typedef R (C::*M)(P);
|
||||||
|
|
||||||
Callback( C* c, M m )
|
Callback(C *c, M m)
|
||||||
: _c(c), _m(m)
|
: _c(c), _m(m)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
R call( P param ) const
|
R call(P param) const
|
||||||
{
|
{
|
||||||
/*if(_c)*/ return (_c->*_m)(param);
|
/*if (_c)*/ return (_c->*_m)(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
C* _c; M _m;
|
C *_c; M _m;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
|
@ -44,19 +44,19 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
Connection::Private::Private( DBusConnection* c, Server::Private* s )
|
Connection::Private::Private(DBusConnection *c, Server::Private *s)
|
||||||
: conn(c) , dispatcher(0), server(s)
|
: conn(c) , dispatcher(0), server(s)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::Private::Private( DBusBusType type )
|
Connection::Private::Private(DBusBusType type)
|
||||||
{
|
{
|
||||||
InternalError e;
|
InternalError e;
|
||||||
|
|
||||||
conn = dbus_bus_get_private(type, e);
|
conn = dbus_bus_get_private(type, e);
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -67,11 +67,11 @@ Connection::Private::~Private()
|
||||||
|
|
||||||
detach_server();
|
detach_server();
|
||||||
|
|
||||||
if(dbus_connection_get_is_connected(conn))
|
if (dbus_connection_get_is_connected(conn))
|
||||||
{
|
{
|
||||||
std::vector<std::string>::iterator i = names.begin();
|
std::vector<std::string>::iterator i = names.begin();
|
||||||
|
|
||||||
while(i != names.end())
|
while (i != names.end())
|
||||||
{
|
{
|
||||||
debug_log("%s: releasing bus name %s", dbus_bus_get_unique_name(conn), i->c_str());
|
debug_log("%s: releasing bus name %s", dbus_bus_get_unique_name(conn), i->c_str());
|
||||||
dbus_bus_release_name(conn, i->c_str(), NULL);
|
dbus_bus_release_name(conn, i->c_str(), NULL);
|
||||||
|
@ -87,7 +87,7 @@ void Connection::Private::init()
|
||||||
dbus_connection_ref(conn);
|
dbus_connection_ref(conn);
|
||||||
dbus_connection_ref(conn); //todo: the library has to own another reference
|
dbus_connection_ref(conn); //todo: the library has to own another reference
|
||||||
|
|
||||||
disconn_filter = new Callback<Connection::Private, bool, const Message&>(
|
disconn_filter = new Callback<Connection::Private, bool, const Message &>(
|
||||||
this, &Connection::Private::disconn_filter_function
|
this, &Connection::Private::disconn_filter_function
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -99,17 +99,17 @@ void Connection::Private::init()
|
||||||
|
|
||||||
void Connection::Private::detach_server()
|
void Connection::Private::detach_server()
|
||||||
{
|
{
|
||||||
/* Server::Private* tmp = server;
|
/* Server::Private *tmp = server;
|
||||||
|
|
||||||
server = NULL;
|
server = NULL;
|
||||||
|
|
||||||
if(tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
ConnectionList::iterator i;
|
ConnectionList::iterator i;
|
||||||
|
|
||||||
for(i = tmp->connections.begin(); i != tmp->connections.end(); ++i)
|
for (i = tmp->connections.begin(); i != tmp->connections.end(); ++i)
|
||||||
{
|
{
|
||||||
if(i->_pvt.get() == this)
|
if (i->_pvt.get() == this)
|
||||||
{
|
{
|
||||||
tmp->connections.erase(i);
|
tmp->connections.erase(i);
|
||||||
break;
|
break;
|
||||||
|
@ -122,7 +122,7 @@ bool Connection::Private::do_dispatch()
|
||||||
{
|
{
|
||||||
debug_log("dispatching on %p", conn);
|
debug_log("dispatching on %p", conn);
|
||||||
|
|
||||||
if(!dbus_connection_get_is_connected(conn))
|
if (!dbus_connection_get_is_connected(conn))
|
||||||
{
|
{
|
||||||
debug_log("connection terminated");
|
debug_log("connection terminated");
|
||||||
|
|
||||||
|
@ -134,11 +134,11 @@ bool Connection::Private::do_dispatch()
|
||||||
return dbus_connection_dispatch(conn) != DBUS_DISPATCH_DATA_REMAINS;
|
return dbus_connection_dispatch(conn) != DBUS_DISPATCH_DATA_REMAINS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::Private::dispatch_status_stub( DBusConnection* dc, DBusDispatchStatus status, void* data )
|
void Connection::Private::dispatch_status_stub(DBusConnection *dc, DBusDispatchStatus status, void *data)
|
||||||
{
|
{
|
||||||
Private* p = static_cast<Private*>(data);
|
Private *p = static_cast<Private *>(data);
|
||||||
|
|
||||||
switch(status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case DBUS_DISPATCH_DATA_REMAINS:
|
case DBUS_DISPATCH_DATA_REMAINS:
|
||||||
debug_log("some dispatching to do on %p", dc);
|
debug_log("some dispatching to do on %p", dc);
|
||||||
|
@ -155,9 +155,9 @@ void Connection::Private::dispatch_status_stub( DBusConnection* dc, DBusDispatch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBusHandlerResult Connection::Private::message_filter_stub( DBusConnection* conn, DBusMessage* dmsg, void* data )
|
DBusHandlerResult Connection::Private::message_filter_stub(DBusConnection *conn, DBusMessage *dmsg, void *data)
|
||||||
{
|
{
|
||||||
MessageSlot* slot = static_cast<MessageSlot*>(data);
|
MessageSlot *slot = static_cast<MessageSlot *>(data);
|
||||||
|
|
||||||
Message msg = Message(new Message::Private(dmsg));
|
Message msg = Message(new Message::Private(dmsg));
|
||||||
|
|
||||||
|
@ -166,9 +166,9 @@ DBusHandlerResult Connection::Private::message_filter_stub( DBusConnection* conn
|
||||||
: DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
: DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::Private::disconn_filter_function( const Message& msg )
|
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);
|
debug_log("%p disconnected by local bus", conn);
|
||||||
dbus_connection_close(conn);
|
dbus_connection_close(conn);
|
||||||
|
@ -193,14 +193,14 @@ Connection Connection::ActivationBus()
|
||||||
return Connection(new Private(DBUS_BUS_STARTER));
|
return Connection(new Private(DBUS_BUS_STARTER));
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::Connection( const char* address, bool priv )
|
Connection::Connection(const char *address, bool priv)
|
||||||
{
|
{
|
||||||
InternalError e;
|
InternalError e;
|
||||||
DBusConnection* conn = priv
|
DBusConnection *conn = priv
|
||||||
? dbus_connection_open_private(address, e)
|
? dbus_connection_open_private(address, e)
|
||||||
: dbus_connection_open(address, e);
|
: dbus_connection_open(address, e);
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
|
|
||||||
_pvt = new Private(conn);
|
_pvt = new Private(conn);
|
||||||
|
|
||||||
|
@ -209,13 +209,13 @@ Connection::Connection( const char* address, bool priv )
|
||||||
debug_log("connected to %s", address);
|
debug_log("connected to %s", address);
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::Connection( Connection::Private* p )
|
Connection::Connection(Connection::Private *p)
|
||||||
: _pvt(p)
|
: _pvt(p)
|
||||||
{
|
{
|
||||||
setup(default_dispatcher);
|
setup(default_dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::Connection( const Connection& c )
|
Connection::Connection(const Connection &c)
|
||||||
: _pvt(c._pvt)
|
: _pvt(c._pvt)
|
||||||
{
|
{
|
||||||
dbus_connection_ref(_pvt->conn);
|
dbus_connection_ref(_pvt->conn);
|
||||||
|
@ -226,15 +226,15 @@ Connection::~Connection()
|
||||||
dbus_connection_unref(_pvt->conn);
|
dbus_connection_unref(_pvt->conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dispatcher* Connection::setup( Dispatcher* dispatcher )
|
Dispatcher *Connection::setup(Dispatcher *dispatcher)
|
||||||
{
|
{
|
||||||
debug_log("registering stubs for connection %p", _pvt->conn);
|
debug_log("registering stubs for connection %p", _pvt->conn);
|
||||||
|
|
||||||
if(!dispatcher) dispatcher = default_dispatcher;
|
if (!dispatcher) dispatcher = default_dispatcher;
|
||||||
|
|
||||||
if(!dispatcher) throw ErrorFailed("no default dispatcher set for new connection");
|
if (!dispatcher) throw ErrorFailed("no default dispatcher set for new connection");
|
||||||
|
|
||||||
Dispatcher* prev = _pvt->dispatcher;
|
Dispatcher *prev = _pvt->dispatcher;
|
||||||
|
|
||||||
_pvt->dispatcher = dispatcher;
|
_pvt->dispatcher = dispatcher;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ Dispatcher* Connection::setup( Dispatcher* dispatcher )
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::operator == ( const Connection& c ) const
|
bool Connection::operator == (const Connection &c) const
|
||||||
{
|
{
|
||||||
return _pvt->conn == c._pvt->conn;
|
return _pvt->conn == c._pvt->conn;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ bool Connection::register_bus()
|
||||||
|
|
||||||
bool r = dbus_bus_register(_pvt->conn, e);
|
bool r = dbus_bus_register(_pvt->conn, e);
|
||||||
|
|
||||||
if(e) throw (e);
|
if (e) throw (e);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -288,17 +288,17 @@ void Connection::disconnect()
|
||||||
dbus_connection_close(_pvt->conn);
|
dbus_connection_close(_pvt->conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::exit_on_disconnect( bool exit )
|
void Connection::exit_on_disconnect(bool exit)
|
||||||
{
|
{
|
||||||
dbus_connection_set_exit_on_disconnect(_pvt->conn, exit);
|
dbus_connection_set_exit_on_disconnect(_pvt->conn, exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::unique_name( const char* n )
|
bool Connection::unique_name(const char *n)
|
||||||
{
|
{
|
||||||
return dbus_bus_set_unique_name(_pvt->conn, n);
|
return dbus_bus_set_unique_name(_pvt->conn, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Connection::unique_name() const
|
const char *Connection::unique_name() const
|
||||||
{
|
{
|
||||||
return dbus_bus_get_unique_name(_pvt->conn);
|
return dbus_bus_get_unique_name(_pvt->conn);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ void Connection::flush()
|
||||||
dbus_connection_flush(_pvt->conn);
|
dbus_connection_flush(_pvt->conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::add_match( const char* rule )
|
void Connection::add_match(const char *rule)
|
||||||
{
|
{
|
||||||
InternalError e;
|
InternalError e;
|
||||||
|
|
||||||
|
@ -316,10 +316,10 @@ void Connection::add_match( const char* rule )
|
||||||
|
|
||||||
debug_log("%s: added match rule %s", unique_name(), rule);
|
debug_log("%s: added match rule %s", unique_name(), rule);
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::remove_match( const char* rule )
|
void Connection::remove_match(const char *rule)
|
||||||
{
|
{
|
||||||
InternalError e;
|
InternalError e;
|
||||||
|
|
||||||
|
@ -327,50 +327,50 @@ void Connection::remove_match( const char* rule )
|
||||||
|
|
||||||
debug_log("%s: removed match rule %s", unique_name(), rule);
|
debug_log("%s: removed match rule %s", unique_name(), rule);
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::add_filter( MessageSlot& s )
|
bool Connection::add_filter(MessageSlot &s)
|
||||||
{
|
{
|
||||||
debug_log("%s: adding filter", unique_name());
|
debug_log("%s: adding filter", unique_name());
|
||||||
return dbus_connection_add_filter(_pvt->conn, Private::message_filter_stub, &s, NULL);
|
return dbus_connection_add_filter(_pvt->conn, Private::message_filter_stub, &s, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::remove_filter( MessageSlot& s )
|
void Connection::remove_filter(MessageSlot &s)
|
||||||
{
|
{
|
||||||
debug_log("%s: removing filter", unique_name());
|
debug_log("%s: removing filter", unique_name());
|
||||||
dbus_connection_remove_filter(_pvt->conn, Private::message_filter_stub, &s);
|
dbus_connection_remove_filter(_pvt->conn, Private::message_filter_stub, &s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::send( const Message& msg, unsigned int* serial )
|
bool Connection::send(const Message &msg, unsigned int *serial)
|
||||||
{
|
{
|
||||||
return dbus_connection_send(_pvt->conn, msg._pvt->msg, serial);
|
return dbus_connection_send(_pvt->conn, msg._pvt->msg, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
Message Connection::send_blocking( Message& msg, int timeout )
|
Message Connection::send_blocking(Message &msg, int timeout)
|
||||||
{
|
{
|
||||||
DBusMessage* reply;
|
DBusMessage *reply;
|
||||||
InternalError e;
|
InternalError e;
|
||||||
|
|
||||||
reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e);
|
reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e);
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
|
|
||||||
return Message(new Message::Private(reply), false);
|
return Message(new Message::Private(reply), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCall Connection::send_async( Message& msg, int timeout )
|
PendingCall Connection::send_async(Message &msg, int timeout)
|
||||||
{
|
{
|
||||||
DBusPendingCall* pending;
|
DBusPendingCall *pending;
|
||||||
|
|
||||||
if(!dbus_connection_send_with_reply(_pvt->conn, msg._pvt->msg, &pending, timeout))
|
if (!dbus_connection_send_with_reply(_pvt->conn, msg._pvt->msg, &pending, timeout))
|
||||||
{
|
{
|
||||||
throw ErrorNoMemory("Unable to start asynchronous call");
|
throw ErrorNoMemory("Unable to start asynchronous call");
|
||||||
}
|
}
|
||||||
return PendingCall(new PendingCall::Private(pending));
|
return PendingCall(new PendingCall::Private(pending));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::request_name( const char* name, int flags )
|
void Connection::request_name(const char *name, int flags)
|
||||||
{
|
{
|
||||||
InternalError e;
|
InternalError e;
|
||||||
|
|
||||||
|
@ -378,11 +378,11 @@ void Connection::request_name( const char* name, int flags )
|
||||||
|
|
||||||
dbus_bus_request_name(_pvt->conn, name, flags, e); //we deliberately don't check return value
|
dbus_bus_request_name(_pvt->conn, name, flags, e); //we deliberately don't check return value
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
|
|
||||||
// this->remove_match("destination");
|
// this->remove_match("destination");
|
||||||
|
|
||||||
if(name)
|
if (name)
|
||||||
{
|
{
|
||||||
_pvt->names.push_back(name);
|
_pvt->names.push_back(name);
|
||||||
std::string match = "destination='" + _pvt->names.back() + "'";
|
std::string match = "destination='" + _pvt->names.back() + "'";
|
||||||
|
@ -390,13 +390,13 @@ void Connection::request_name( const char* name, int flags )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::has_name( const char* name )
|
bool Connection::has_name(const char *name)
|
||||||
{
|
{
|
||||||
InternalError e;
|
InternalError e;
|
||||||
|
|
||||||
bool b = dbus_bus_name_has_owner(_pvt->conn, name, e);
|
bool b = dbus_bus_name_has_owner(_pvt->conn, name, e);
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
@ -406,13 +406,13 @@ const std::vector<std::string>& Connection::names()
|
||||||
return _pvt->names;
|
return _pvt->names;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::start_service( const char* name, unsigned long flags )
|
bool Connection::start_service(const char *name, unsigned long flags)
|
||||||
{
|
{
|
||||||
InternalError e;
|
InternalError e;
|
||||||
|
|
||||||
bool b = dbus_bus_start_service_by_name(_pvt->conn, name, flags, NULL, e);
|
bool b = dbus_bus_start_service_by_name(_pvt->conn, name, flags, NULL, e);
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,30 +43,30 @@ namespace DBus {
|
||||||
|
|
||||||
struct DXXAPILOCAL Connection::Private
|
struct DXXAPILOCAL Connection::Private
|
||||||
{
|
{
|
||||||
DBusConnection* conn;
|
DBusConnection * conn;
|
||||||
|
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
|
|
||||||
Dispatcher* dispatcher;
|
Dispatcher *dispatcher;
|
||||||
bool do_dispatch();
|
bool do_dispatch();
|
||||||
|
|
||||||
MessageSlot disconn_filter;
|
MessageSlot disconn_filter;
|
||||||
bool disconn_filter_function( const Message& );
|
bool disconn_filter_function(const Message &);
|
||||||
|
|
||||||
Server::Private* server;
|
Server::Private *server;
|
||||||
void detach_server();
|
void detach_server();
|
||||||
|
|
||||||
Private( DBusConnection*, Server::Private* = NULL );
|
Private(DBusConnection *, Server::Private * = NULL);
|
||||||
|
|
||||||
Private( DBusBusType );
|
Private(DBusBusType);
|
||||||
|
|
||||||
~Private();
|
~Private();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
static void dispatch_status_stub( DBusConnection*, DBusDispatchStatus, void* );
|
static void dispatch_status_stub(DBusConnection *, DBusDispatchStatus, void *);
|
||||||
|
|
||||||
static DBusHandlerResult message_filter_stub( DBusConnection*, DBusMessage*, void* );
|
static DBusHandlerResult message_filter_stub(DBusConnection *, DBusMessage *, void *);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
|
@ -32,13 +32,13 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void _debug_log_default(const char* format, ...)
|
static void _debug_log_default(const char *format, ...)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
static int debug_env = getenv("DBUSXX_VERBOSE") ? 1 : 0;
|
static int debug_env = getenv("DBUSXX_VERBOSE") ? 1 : 0;
|
||||||
|
|
||||||
if(debug_env)
|
if (debug_env)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
|
@ -34,38 +34,38 @@
|
||||||
#include "server_p.h"
|
#include "server_p.h"
|
||||||
#include "connection_p.h"
|
#include "connection_p.h"
|
||||||
|
|
||||||
DBus::Dispatcher* DBus::default_dispatcher = NULL;
|
DBus::Dispatcher *DBus::default_dispatcher = NULL;
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
Timeout::Timeout( Timeout::Internal* i )
|
Timeout::Timeout(Timeout::Internal *i)
|
||||||
: _int(i)
|
: _int(i)
|
||||||
{
|
{
|
||||||
dbus_timeout_set_data((DBusTimeout*)i, this, NULL);
|
dbus_timeout_set_data((DBusTimeout *)i, this, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Timeout::interval() const
|
int Timeout::interval() const
|
||||||
{
|
{
|
||||||
return dbus_timeout_get_interval((DBusTimeout*)_int);
|
return dbus_timeout_get_interval((DBusTimeout *)_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timeout::enabled() const
|
bool Timeout::enabled() const
|
||||||
{
|
{
|
||||||
return dbus_timeout_get_enabled((DBusTimeout*)_int);
|
return dbus_timeout_get_enabled((DBusTimeout *)_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timeout::handle()
|
bool Timeout::handle()
|
||||||
{
|
{
|
||||||
return dbus_timeout_handle((DBusTimeout*)_int);
|
return dbus_timeout_handle((DBusTimeout *)_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Watch::Watch( Watch::Internal* i )
|
Watch::Watch(Watch::Internal *i)
|
||||||
: _int(i)
|
: _int(i)
|
||||||
{
|
{
|
||||||
dbus_watch_set_data((DBusWatch*)i, this, NULL);
|
dbus_watch_set_data((DBusWatch *)i, this, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Watch::descriptor() const
|
int Watch::descriptor() const
|
||||||
|
@ -79,77 +79,77 @@ int Watch::descriptor() const
|
||||||
|
|
||||||
int Watch::flags() const
|
int Watch::flags() const
|
||||||
{
|
{
|
||||||
return dbus_watch_get_flags((DBusWatch*)_int);
|
return dbus_watch_get_flags((DBusWatch *)_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Watch::enabled() const
|
bool Watch::enabled() const
|
||||||
{
|
{
|
||||||
return dbus_watch_get_enabled((DBusWatch*)_int);
|
return dbus_watch_get_enabled((DBusWatch *)_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Watch::handle( int flags )
|
bool Watch::handle(int flags)
|
||||||
{
|
{
|
||||||
return dbus_watch_handle((DBusWatch*)_int, flags);
|
return dbus_watch_handle((DBusWatch *)_int, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dbus_bool_t Dispatcher::Private::on_add_watch( DBusWatch* watch, void* data )
|
dbus_bool_t Dispatcher::Private::on_add_watch(DBusWatch *watch, void *data)
|
||||||
{
|
{
|
||||||
Dispatcher* d = static_cast<Dispatcher*>(data);
|
Dispatcher *d = static_cast<Dispatcher *>(data);
|
||||||
|
|
||||||
Watch::Internal* w = reinterpret_cast<Watch::Internal*>(watch);
|
Watch::Internal *w = reinterpret_cast<Watch::Internal *>(watch);
|
||||||
|
|
||||||
d->add_watch(w);
|
d->add_watch(w);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispatcher::Private::on_rem_watch( DBusWatch* watch, void* data )
|
void Dispatcher::Private::on_rem_watch(DBusWatch *watch, void *data)
|
||||||
{
|
{
|
||||||
Dispatcher* d = static_cast<Dispatcher*>(data);
|
Dispatcher *d = static_cast<Dispatcher *>(data);
|
||||||
|
|
||||||
Watch* w = static_cast<Watch*>(dbus_watch_get_data(watch));
|
Watch *w = static_cast<Watch *>(dbus_watch_get_data(watch));
|
||||||
|
|
||||||
d->rem_watch(w);
|
d->rem_watch(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispatcher::Private::on_toggle_watch( DBusWatch* watch, void* data )
|
void Dispatcher::Private::on_toggle_watch(DBusWatch *watch, void *data)
|
||||||
{
|
{
|
||||||
Watch* w = static_cast<Watch*>(dbus_watch_get_data(watch));
|
Watch *w = static_cast<Watch *>(dbus_watch_get_data(watch));
|
||||||
|
|
||||||
w->toggle();
|
w->toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_bool_t Dispatcher::Private::on_add_timeout( DBusTimeout* timeout, void* data )
|
dbus_bool_t Dispatcher::Private::on_add_timeout(DBusTimeout *timeout, void *data)
|
||||||
{
|
{
|
||||||
Dispatcher* d = static_cast<Dispatcher*>(data);
|
Dispatcher *d = static_cast<Dispatcher *>(data);
|
||||||
|
|
||||||
Timeout::Internal* t = reinterpret_cast<Timeout::Internal*>(timeout);
|
Timeout::Internal *t = reinterpret_cast<Timeout::Internal *>(timeout);
|
||||||
|
|
||||||
d->add_timeout(t);
|
d->add_timeout(t);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispatcher::Private::on_rem_timeout( DBusTimeout* timeout, void* data )
|
void Dispatcher::Private::on_rem_timeout(DBusTimeout *timeout, void *data)
|
||||||
{
|
{
|
||||||
Dispatcher* d = static_cast<Dispatcher*>(data);
|
Dispatcher *d = static_cast<Dispatcher *>(data);
|
||||||
|
|
||||||
Timeout* t = static_cast<Timeout*>(dbus_timeout_get_data(timeout));
|
Timeout *t = static_cast<Timeout *>(dbus_timeout_get_data(timeout));
|
||||||
|
|
||||||
d->rem_timeout(t);
|
d->rem_timeout(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispatcher::Private::on_toggle_timeout( DBusTimeout* timeout, void* data )
|
void Dispatcher::Private::on_toggle_timeout(DBusTimeout *timeout, void *data)
|
||||||
{
|
{
|
||||||
Timeout* t = static_cast<Timeout*>(dbus_timeout_get_data(timeout));
|
Timeout *t = static_cast<Timeout *>(dbus_timeout_get_data(timeout));
|
||||||
|
|
||||||
t->toggle();
|
t->toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispatcher::queue_connection( Connection::Private* cp )
|
void Dispatcher::queue_connection(Connection::Private *cp)
|
||||||
{
|
{
|
||||||
_mutex_p.lock();
|
_mutex_p.lock();
|
||||||
_pending_queue.push_back(cp);
|
_pending_queue.push_back(cp);
|
||||||
|
@ -160,19 +160,19 @@ void Dispatcher::dispatch_pending()
|
||||||
{
|
{
|
||||||
_mutex_p.lock();
|
_mutex_p.lock();
|
||||||
|
|
||||||
while(_pending_queue.size() > 0)
|
while (_pending_queue.size() > 0)
|
||||||
{
|
{
|
||||||
Connection::PrivatePList::iterator i, j;
|
Connection::PrivatePList::iterator i, j;
|
||||||
|
|
||||||
i = _pending_queue.begin();
|
i = _pending_queue.begin();
|
||||||
|
|
||||||
while(i != _pending_queue.end())
|
while (i != _pending_queue.end())
|
||||||
{
|
{
|
||||||
j = i;
|
j = i;
|
||||||
|
|
||||||
++j;
|
++j;
|
||||||
|
|
||||||
if((*i)->do_dispatch())
|
if ((*i)->do_dispatch())
|
||||||
_pending_queue.erase(i);
|
_pending_queue.erase(i);
|
||||||
|
|
||||||
i = j;
|
i = j;
|
||||||
|
|
|
@ -40,17 +40,17 @@ namespace DBus {
|
||||||
|
|
||||||
struct DXXAPILOCAL Dispatcher::Private
|
struct DXXAPILOCAL Dispatcher::Private
|
||||||
{
|
{
|
||||||
static dbus_bool_t on_add_watch( DBusWatch* watch, void* data );
|
static dbus_bool_t on_add_watch(DBusWatch *watch, void *data);
|
||||||
|
|
||||||
static void on_rem_watch( DBusWatch* watch, void* data );
|
static void on_rem_watch(DBusWatch *watch, void *data);
|
||||||
|
|
||||||
static void on_toggle_watch( DBusWatch* watch, void* data );
|
static void on_toggle_watch(DBusWatch *watch, void *data);
|
||||||
|
|
||||||
static dbus_bool_t on_add_timeout( DBusTimeout* timeout, void* data );
|
static dbus_bool_t on_add_timeout(DBusTimeout *timeout, void *data);
|
||||||
|
|
||||||
static void on_rem_timeout( DBusTimeout* timeout, void* data );
|
static void on_rem_timeout(DBusTimeout *timeout, void *data);
|
||||||
|
|
||||||
static void on_toggle_timeout( DBusTimeout* timeout, void* data );
|
static void on_toggle_timeout(DBusTimeout *timeout, void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
|
@ -43,17 +43,17 @@ Error::Error()
|
||||||
: _int(new InternalError)
|
: _int(new InternalError)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Error::Error(InternalError& i)
|
Error::Error(InternalError &i)
|
||||||
: _int(new InternalError(i))
|
: _int(new InternalError(i))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Error::Error( const char* name, const char* message )
|
Error::Error(const char *name, const char *message)
|
||||||
: _int(new InternalError)
|
: _int(new InternalError)
|
||||||
{
|
{
|
||||||
set(name, message);
|
set(name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error::Error( Message& m )
|
Error::Error(Message &m)
|
||||||
: _int(new InternalError)
|
: _int(new InternalError)
|
||||||
{
|
{
|
||||||
dbus_set_error_from_message(&(_int->error), m._pvt->msg);
|
dbus_set_error_from_message(&(_int->error), m._pvt->msg);
|
||||||
|
@ -63,12 +63,12 @@ Error::~Error() throw()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Error::name() const
|
const char *Error::name() const
|
||||||
{
|
{
|
||||||
return _int->error.name;
|
return _int->error.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Error::message() const
|
const char *Error::message() const
|
||||||
{
|
{
|
||||||
return _int->error.message;
|
return _int->error.message;
|
||||||
}
|
}
|
||||||
|
@ -78,12 +78,12 @@ bool Error::is_set() const
|
||||||
return *(_int);
|
return *(_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Error::set( const char* name, const char* message )
|
void Error::set(const char *name, const char *message)
|
||||||
{
|
{
|
||||||
dbus_set_error_const(&(_int->error), name, message);
|
dbus_set_error_const(&(_int->error), name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Error::what() const throw()
|
const char *Error::what() const throw()
|
||||||
{
|
{
|
||||||
return _int->error.message;
|
return _int->error.message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
BusTimeout::BusTimeout( Timeout::Internal* ti, BusDispatcher* bd )
|
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());
|
DefaultTimeout::enabled(Timeout::enabled());
|
||||||
|
@ -48,14 +48,14 @@ void BusTimeout::toggle()
|
||||||
DefaultTimeout::enabled(Timeout::enabled());
|
DefaultTimeout::enabled(Timeout::enabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
BusWatch::BusWatch( Watch::Internal* wi, BusDispatcher* bd )
|
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;
|
int flags = POLLHUP | POLLERR;
|
||||||
|
|
||||||
if(Watch::flags() & DBUS_WATCH_READABLE)
|
if (Watch::flags() & DBUS_WATCH_READABLE)
|
||||||
flags |= POLLIN;
|
flags |= POLLIN;
|
||||||
if(Watch::flags() & DBUS_WATCH_WRITABLE)
|
if (Watch::flags() & DBUS_WATCH_WRITABLE)
|
||||||
flags |= POLLOUT;
|
flags |= POLLOUT;
|
||||||
|
|
||||||
DefaultWatch::flags(flags);
|
DefaultWatch::flags(flags);
|
||||||
|
@ -75,7 +75,7 @@ void BusDispatcher::enter()
|
||||||
|
|
||||||
_running = true;
|
_running = true;
|
||||||
|
|
||||||
while(_running)
|
while (_running)
|
||||||
{
|
{
|
||||||
do_iteration();
|
do_iteration();
|
||||||
}
|
}
|
||||||
|
@ -94,72 +94,72 @@ void BusDispatcher::do_iteration()
|
||||||
dispatch();
|
dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timeout* BusDispatcher::add_timeout( Timeout::Internal* ti )
|
Timeout *BusDispatcher::add_timeout(Timeout::Internal *ti)
|
||||||
{
|
{
|
||||||
BusTimeout* bt = new BusTimeout(ti, this);
|
BusTimeout *bt = new BusTimeout(ti, this);
|
||||||
|
|
||||||
bt->expired = new Callback<BusDispatcher, void, DefaultTimeout&>(this, &BusDispatcher::timeout_expired);
|
bt->expired = new Callback<BusDispatcher, void, DefaultTimeout &>(this, &BusDispatcher::timeout_expired);
|
||||||
bt->data(bt);
|
bt->data(bt);
|
||||||
|
|
||||||
debug_log("added timeout %p (%s)", bt, ((Timeout*)bt)->enabled() ? "on":"off");
|
debug_log("added timeout %p (%s)", bt, ((Timeout *)bt)->enabled() ? "on":"off");
|
||||||
|
|
||||||
return bt;
|
return bt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BusDispatcher::rem_timeout( Timeout* t )
|
void BusDispatcher::rem_timeout(Timeout *t)
|
||||||
{
|
{
|
||||||
debug_log("removed timeout %p", t);
|
debug_log("removed timeout %p", t);
|
||||||
|
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
|
|
||||||
Watch* BusDispatcher::add_watch( Watch::Internal* wi )
|
Watch *BusDispatcher::add_watch(Watch::Internal *wi)
|
||||||
{
|
{
|
||||||
BusWatch* bw = new BusWatch(wi, this);
|
BusWatch *bw = new BusWatch(wi, this);
|
||||||
|
|
||||||
bw->ready = new Callback<BusDispatcher, void, DefaultWatch&>(this, &BusDispatcher::watch_ready);
|
bw->ready = new Callback<BusDispatcher, void, DefaultWatch &>(this, &BusDispatcher::watch_ready);
|
||||||
bw->data(bw);
|
bw->data(bw);
|
||||||
|
|
||||||
debug_log("added watch %p (%s) fd=%d flags=%d",
|
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;
|
return bw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BusDispatcher::rem_watch( Watch* w )
|
void BusDispatcher::rem_watch(Watch *w)
|
||||||
{
|
{
|
||||||
debug_log("removed watch %p", w);
|
debug_log("removed watch %p", w);
|
||||||
|
|
||||||
delete w;
|
delete w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BusDispatcher::timeout_expired( DefaultTimeout& et )
|
void BusDispatcher::timeout_expired(DefaultTimeout &et)
|
||||||
{
|
{
|
||||||
debug_log("timeout %p expired", &et);
|
debug_log("timeout %p expired", &et);
|
||||||
|
|
||||||
BusTimeout* timeout = reinterpret_cast<BusTimeout*>(et.data());
|
BusTimeout *timeout = reinterpret_cast<BusTimeout *>(et.data());
|
||||||
|
|
||||||
timeout->handle();
|
timeout->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BusDispatcher::watch_ready( DefaultWatch& ew )
|
void BusDispatcher::watch_ready(DefaultWatch &ew)
|
||||||
{
|
{
|
||||||
BusWatch* watch = reinterpret_cast<BusWatch*>(ew.data());
|
BusWatch *watch = reinterpret_cast<BusWatch *>(ew.data());
|
||||||
|
|
||||||
debug_log("watch %p ready, flags=%d state=%d",
|
debug_log("watch %p ready, flags=%d state=%d",
|
||||||
watch, ((Watch*)watch)->flags(), watch->state()
|
watch, ((Watch *)watch)->flags(), watch->state()
|
||||||
);
|
);
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
if(watch->state() & POLLIN)
|
if (watch->state() & POLLIN)
|
||||||
flags |= DBUS_WATCH_READABLE;
|
flags |= DBUS_WATCH_READABLE;
|
||||||
if(watch->state() & POLLOUT)
|
if (watch->state() & POLLOUT)
|
||||||
flags |= DBUS_WATCH_WRITABLE;
|
flags |= DBUS_WATCH_WRITABLE;
|
||||||
if(watch->state() & POLLHUP)
|
if (watch->state() & POLLHUP)
|
||||||
flags |= DBUS_WATCH_HANGUP;
|
flags |= DBUS_WATCH_HANGUP;
|
||||||
if(watch->state() & POLLERR)
|
if (watch->state() & POLLERR)
|
||||||
flags |= DBUS_WATCH_ERROR;
|
flags |= DBUS_WATCH_ERROR;
|
||||||
|
|
||||||
watch->handle(flags);
|
watch->handle(flags);
|
||||||
|
|
|
@ -36,12 +36,12 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
static double millis( timeval tv )
|
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 )
|
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;
|
timeval now;
|
||||||
|
@ -61,7 +61,7 @@ DefaultTimeout::~DefaultTimeout()
|
||||||
_disp->_mutex_t.unlock();
|
_disp->_mutex_t.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultWatch::DefaultWatch( int fd, int flags, DefaultMainLoop* ed )
|
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->_mutex_w.lock();
|
||||||
|
@ -125,7 +125,7 @@ DefaultMainLoop::~DefaultMainLoop()
|
||||||
_mutex_w.lock();
|
_mutex_w.lock();
|
||||||
|
|
||||||
DefaultWatches::iterator wi = _watches.begin();
|
DefaultWatches::iterator wi = _watches.begin();
|
||||||
while(wi != _watches.end())
|
while (wi != _watches.end())
|
||||||
{
|
{
|
||||||
DefaultWatches::iterator wmp = wi;
|
DefaultWatches::iterator wmp = wi;
|
||||||
++wmp;
|
++wmp;
|
||||||
|
@ -139,7 +139,7 @@ DefaultMainLoop::~DefaultMainLoop()
|
||||||
_mutex_t.lock();
|
_mutex_t.lock();
|
||||||
|
|
||||||
DefaultTimeouts::iterator ti = _timeouts.begin();
|
DefaultTimeouts::iterator ti = _timeouts.begin();
|
||||||
while(ti != _timeouts.end())
|
while (ti != _timeouts.end())
|
||||||
{
|
{
|
||||||
DefaultTimeouts::iterator tmp = ti;
|
DefaultTimeouts::iterator tmp = ti;
|
||||||
++tmp;
|
++tmp;
|
||||||
|
@ -161,9 +161,9 @@ void DefaultMainLoop::dispatch()
|
||||||
|
|
||||||
DefaultWatches::iterator wi = _watches.begin();
|
DefaultWatches::iterator wi = _watches.begin();
|
||||||
|
|
||||||
for(nfd = 0; wi != _watches.end(); ++wi)
|
for (nfd = 0; wi != _watches.end(); ++wi)
|
||||||
{
|
{
|
||||||
if((*wi)->enabled())
|
if ((*wi)->enabled())
|
||||||
{
|
{
|
||||||
fds[nfd].fd = (*wi)->descriptor();
|
fds[nfd].fd = (*wi)->descriptor();
|
||||||
fds[nfd].events = (*wi)->flags();
|
fds[nfd].events = (*wi)->flags();
|
||||||
|
@ -180,9 +180,9 @@ void DefaultMainLoop::dispatch()
|
||||||
|
|
||||||
_mutex_t.lock();
|
_mutex_t.lock();
|
||||||
|
|
||||||
for(ti = _timeouts.begin(); ti != _timeouts.end(); ++ti)
|
for (ti = _timeouts.begin(); ti != _timeouts.end(); ++ti)
|
||||||
{
|
{
|
||||||
if((*ti)->enabled() && (*ti)->interval() < wait_min)
|
if ((*ti)->enabled() && (*ti)->interval() < wait_min)
|
||||||
wait_min = (*ti)->interval();
|
wait_min = (*ti)->interval();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,16 +199,16 @@ void DefaultMainLoop::dispatch()
|
||||||
|
|
||||||
ti = _timeouts.begin();
|
ti = _timeouts.begin();
|
||||||
|
|
||||||
while(ti != _timeouts.end())
|
while (ti != _timeouts.end())
|
||||||
{
|
{
|
||||||
DefaultTimeouts::iterator tmp = ti;
|
DefaultTimeouts::iterator tmp = ti;
|
||||||
++tmp;
|
++tmp;
|
||||||
|
|
||||||
if((*ti)->enabled() && now_millis >= (*ti)->_expiration)
|
if ((*ti)->enabled() && now_millis >= (*ti)->_expiration)
|
||||||
{
|
{
|
||||||
(*ti)->expired(*(*ti));
|
(*ti)->expired(*(*ti));
|
||||||
|
|
||||||
if((*ti)->_repeat)
|
if ((*ti)->_repeat)
|
||||||
{
|
{
|
||||||
(*ti)->_expiration = now_millis + (*ti)->_interval;
|
(*ti)->_expiration = now_millis + (*ti)->_interval;
|
||||||
}
|
}
|
||||||
|
@ -222,18 +222,18 @@ void DefaultMainLoop::dispatch()
|
||||||
|
|
||||||
_mutex_w.lock();
|
_mutex_w.lock();
|
||||||
|
|
||||||
for(int j = 0; j < nfd; ++j)
|
for (int j = 0; j < nfd; ++j)
|
||||||
{
|
{
|
||||||
DefaultWatches::iterator wi;
|
DefaultWatches::iterator wi;
|
||||||
|
|
||||||
for(wi = _watches.begin(); wi != _watches.end();)
|
for (wi = _watches.begin(); wi != _watches.end();)
|
||||||
{
|
{
|
||||||
DefaultWatches::iterator tmp = wi;
|
DefaultWatches::iterator tmp = wi;
|
||||||
++tmp;
|
++tmp;
|
||||||
|
|
||||||
if((*wi)->enabled() && (*wi)->_fd == fds[j].fd)
|
if ((*wi)->enabled() && (*wi)->_fd == fds[j].fd)
|
||||||
{
|
{
|
||||||
if(fds[j].revents)
|
if (fds[j].revents)
|
||||||
{
|
{
|
||||||
(*wi)->_state = fds[j].revents;
|
(*wi)->_state = fds[j].revents;
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
Glib::BusTimeout::BusTimeout( Timeout::Internal* ti, GMainContext* ctx )
|
Glib::BusTimeout::BusTimeout(Timeout::Internal *ti, GMainContext *ctx, int priority)
|
||||||
: Timeout(ti), _ctx(ctx)
|
: Timeout(ti), _ctx(ctx), _priority(priority)
|
||||||
{
|
{
|
||||||
_enable();
|
_enable();
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,13 @@ 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();
|
if (Timeout::enabled()) _enable();
|
||||||
else _disable();
|
else _disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean Glib::BusTimeout::timeout_handler( gpointer data )
|
gboolean Glib::BusTimeout::timeout_handler(gpointer data)
|
||||||
{
|
{
|
||||||
Glib::BusTimeout* t = reinterpret_cast<Glib::BusTimeout*>(data);
|
Glib::BusTimeout *t = reinterpret_cast<Glib::BusTimeout *>(data);
|
||||||
|
|
||||||
t->handle();
|
t->handle();
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ gboolean Glib::BusTimeout::timeout_handler( gpointer data )
|
||||||
void Glib::BusTimeout::_enable()
|
void Glib::BusTimeout::_enable()
|
||||||
{
|
{
|
||||||
_source = g_timeout_source_new(Timeout::interval());
|
_source = g_timeout_source_new(Timeout::interval());
|
||||||
|
g_source_set_priority(_source, _priority);
|
||||||
g_source_set_callback(_source, timeout_handler, this, NULL);
|
g_source_set_callback(_source, timeout_handler, this, NULL);
|
||||||
g_source_attach(_source, _ctx);
|
g_source_attach(_source, _ctx);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ struct BusSource
|
||||||
GPollFD poll;
|
GPollFD poll;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gboolean watch_prepare( GSource *source, gint *timeout )
|
static gboolean watch_prepare(GSource *source, gint *timeout)
|
||||||
{
|
{
|
||||||
// debug_log("glib: watch_prepare");
|
// debug_log("glib: watch_prepare");
|
||||||
|
|
||||||
|
@ -85,15 +86,15 @@ static gboolean watch_prepare( GSource *source, gint *timeout )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean watch_check( GSource *source )
|
static gboolean watch_check(GSource *source)
|
||||||
{
|
{
|
||||||
// debug_log("glib: watch_check");
|
// debug_log("glib: watch_check");
|
||||||
|
|
||||||
BusSource* io = (BusSource*)source;
|
BusSource *io = (BusSource *)source;
|
||||||
return io->poll.revents ? TRUE : FALSE;
|
return io->poll.revents ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean watch_dispatch( GSource *source, GSourceFunc callback, gpointer data )
|
static gboolean watch_dispatch(GSource *source, GSourceFunc callback, gpointer data)
|
||||||
{
|
{
|
||||||
debug_log("glib: watch_dispatch");
|
debug_log("glib: watch_dispatch");
|
||||||
|
|
||||||
|
@ -109,8 +110,8 @@ static GSourceFuncs watch_funcs = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
Glib::BusWatch::BusWatch( Watch::Internal* wi, GMainContext* ctx )
|
Glib::BusWatch::BusWatch(Watch::Internal *wi, GMainContext *ctx, int priority)
|
||||||
: Watch(wi), _ctx(ctx)
|
: Watch(wi), _ctx(ctx), _priority(priority)
|
||||||
{
|
{
|
||||||
_enable();
|
_enable();
|
||||||
}
|
}
|
||||||
|
@ -124,24 +125,24 @@ 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();
|
if (Watch::enabled()) _enable();
|
||||||
else _disable();
|
else _disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean Glib::BusWatch::watch_handler( gpointer data )
|
gboolean Glib::BusWatch::watch_handler(gpointer data)
|
||||||
{
|
{
|
||||||
Glib::BusWatch* w = reinterpret_cast<Glib::BusWatch*>(data);
|
Glib::BusWatch *w = reinterpret_cast<Glib::BusWatch *>(data);
|
||||||
|
|
||||||
BusSource* io = (BusSource*)(w->_source);
|
BusSource *io = (BusSource *)(w->_source);
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if(io->poll.revents & G_IO_IN)
|
if (io->poll.revents &G_IO_IN)
|
||||||
flags |= DBUS_WATCH_READABLE;
|
flags |= DBUS_WATCH_READABLE;
|
||||||
if(io->poll.revents & G_IO_OUT)
|
if (io->poll.revents &G_IO_OUT)
|
||||||
flags |= DBUS_WATCH_WRITABLE;
|
flags |= DBUS_WATCH_WRITABLE;
|
||||||
if(io->poll.revents & G_IO_ERR)
|
if (io->poll.revents &G_IO_ERR)
|
||||||
flags |= DBUS_WATCH_ERROR;
|
flags |= DBUS_WATCH_ERROR;
|
||||||
if(io->poll.revents & G_IO_HUP)
|
if (io->poll.revents &G_IO_HUP)
|
||||||
flags |= DBUS_WATCH_HANGUP;
|
flags |= DBUS_WATCH_HANGUP;
|
||||||
|
|
||||||
w->handle(flags);
|
w->handle(flags);
|
||||||
|
@ -152,21 +153,22 @@ gboolean Glib::BusWatch::watch_handler( gpointer data )
|
||||||
void Glib::BusWatch::_enable()
|
void Glib::BusWatch::_enable()
|
||||||
{
|
{
|
||||||
_source = g_source_new(&watch_funcs, sizeof(BusSource));
|
_source = g_source_new(&watch_funcs, sizeof(BusSource));
|
||||||
|
g_source_set_priority(_source, _priority);
|
||||||
g_source_set_callback(_source, watch_handler, this, NULL);
|
g_source_set_callback(_source, watch_handler, this, NULL);
|
||||||
|
|
||||||
int flags = Watch::flags();
|
int flags = Watch::flags();
|
||||||
int condition = 0;
|
int condition = 0;
|
||||||
|
|
||||||
if(flags & DBUS_WATCH_READABLE)
|
if (flags &DBUS_WATCH_READABLE)
|
||||||
condition |= G_IO_IN;
|
condition |= G_IO_IN;
|
||||||
// if(flags & DBUS_WATCH_WRITABLE)
|
// if (flags &DBUS_WATCH_WRITABLE)
|
||||||
// condition |= G_IO_OUT;
|
// condition |= G_IO_OUT;
|
||||||
if(flags & DBUS_WATCH_ERROR)
|
if (flags &DBUS_WATCH_ERROR)
|
||||||
condition |= G_IO_ERR;
|
condition |= G_IO_ERR;
|
||||||
if(flags & DBUS_WATCH_HANGUP)
|
if (flags &DBUS_WATCH_HANGUP)
|
||||||
condition |= G_IO_HUP;
|
condition |= G_IO_HUP;
|
||||||
|
|
||||||
GPollFD* poll = &(((BusSource*)_source)->poll);
|
GPollFD *poll = &(((BusSource *)_source)->poll);
|
||||||
poll->fd = Watch::descriptor();
|
poll->fd = Watch::descriptor();
|
||||||
poll->events = condition;
|
poll->events = condition;
|
||||||
poll->revents = 0;
|
poll->revents = 0;
|
||||||
|
@ -177,35 +179,35 @@ void Glib::BusWatch::_enable()
|
||||||
|
|
||||||
void Glib::BusWatch::_disable()
|
void Glib::BusWatch::_disable()
|
||||||
{
|
{
|
||||||
GPollFD* poll = &(((BusSource*)_source)->poll);
|
GPollFD *poll = &(((BusSource *)_source)->poll);
|
||||||
g_source_remove_poll(_source, poll);
|
g_source_remove_poll(_source, poll);
|
||||||
g_source_destroy(_source);
|
g_source_destroy(_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Glib::BusDispatcher::attach( GMainContext* ctx )
|
void Glib::BusDispatcher::attach(GMainContext *ctx)
|
||||||
{
|
{
|
||||||
_ctx = ctx ? ctx : g_main_context_default();
|
_ctx = ctx ? ctx : g_main_context_default();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timeout* Glib::BusDispatcher::add_timeout( Timeout::Internal* wi )
|
Timeout *Glib::BusDispatcher::add_timeout(Timeout::Internal *wi)
|
||||||
{
|
{
|
||||||
Timeout* t = new Glib::BusTimeout(wi, _ctx);
|
Timeout *t = new Glib::BusTimeout(wi, _ctx, _priority);
|
||||||
|
|
||||||
debug_log("glib: added timeout %p (%s)", t, t->enabled() ? "on":"off");
|
debug_log("glib: added timeout %p (%s)", t, t->enabled() ? "on":"off");
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Glib::BusDispatcher::rem_timeout( Timeout* t )
|
void Glib::BusDispatcher::rem_timeout(Timeout *t)
|
||||||
{
|
{
|
||||||
debug_log("glib: removed timeout %p", t);
|
debug_log("glib: removed timeout %p", t);
|
||||||
|
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
|
|
||||||
Watch* Glib::BusDispatcher::add_watch( Watch::Internal* wi )
|
Watch *Glib::BusDispatcher::add_watch(Watch::Internal *wi)
|
||||||
{
|
{
|
||||||
Watch* w = new Glib::BusWatch(wi, _ctx);
|
Watch *w = new Glib::BusWatch(wi, _ctx, _priority);
|
||||||
|
|
||||||
debug_log("glib: added watch %p (%s) fd=%d flags=%d",
|
debug_log("glib: added watch %p (%s) fd=%d flags=%d",
|
||||||
w, w->enabled() ? "on":"off", w->descriptor(), w->flags()
|
w, w->enabled() ? "on":"off", w->descriptor(), w->flags()
|
||||||
|
@ -213,9 +215,14 @@ Watch* Glib::BusDispatcher::add_watch( Watch::Internal* wi )
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Glib::BusDispatcher::rem_watch( Watch* w )
|
void Glib::BusDispatcher::rem_watch(Watch *w)
|
||||||
{
|
{
|
||||||
debug_log("glib: removed watch %p", w);
|
debug_log("glib: removed watch %p", w);
|
||||||
|
|
||||||
delete w;
|
delete w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Glib::BusDispatcher::set_priority(int priority)
|
||||||
|
{
|
||||||
|
_priority = priority;
|
||||||
|
}
|
||||||
|
|
|
@ -33,21 +33,21 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
Interface::Interface( const std::string& name )
|
Interface::Interface(const std::string &name)
|
||||||
: _name(name)
|
: _name(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Interface::~Interface()
|
Interface::~Interface()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
InterfaceAdaptor* AdaptorBase::find_interface( const std::string& name )
|
InterfaceAdaptor *AdaptorBase::find_interface(const std::string &name)
|
||||||
{
|
{
|
||||||
InterfaceAdaptorTable::const_iterator ii = _interfaces.find(name);
|
InterfaceAdaptorTable::const_iterator ii = _interfaces.find(name);
|
||||||
|
|
||||||
return ii != _interfaces.end() ? ii->second : NULL;
|
return ii != _interfaces.end() ? ii->second : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceAdaptor::InterfaceAdaptor( const std::string& name )
|
InterfaceAdaptor::InterfaceAdaptor(const std::string &name)
|
||||||
: Interface(name)
|
: Interface(name)
|
||||||
{
|
{
|
||||||
debug_log("adding interface %s", name.c_str());
|
debug_log("adding interface %s", name.c_str());
|
||||||
|
@ -55,14 +55,14 @@ InterfaceAdaptor::InterfaceAdaptor( const std::string& name )
|
||||||
_interfaces[name] = this;
|
_interfaces[name] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message InterfaceAdaptor::dispatch_method( const CallMessage& msg )
|
Message InterfaceAdaptor::dispatch_method(const CallMessage &msg)
|
||||||
{
|
{
|
||||||
const char* name = msg.member();
|
const char *name = msg.member();
|
||||||
|
|
||||||
MethodTable::iterator mi = _methods.find(name);
|
MethodTable::iterator mi = _methods.find(name);
|
||||||
if( mi != _methods.end() )
|
if (mi != _methods.end())
|
||||||
{
|
{
|
||||||
return mi->second.call( msg );
|
return mi->second.call(msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -70,21 +70,21 @@ Message InterfaceAdaptor::dispatch_method( const CallMessage& msg )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterfaceAdaptor::emit_signal( const SignalMessage& sig )
|
void InterfaceAdaptor::emit_signal(const SignalMessage &sig)
|
||||||
{
|
{
|
||||||
SignalMessage& sig2 = const_cast<SignalMessage&>(sig);
|
SignalMessage &sig2 = const_cast<SignalMessage &>(sig);
|
||||||
|
|
||||||
sig2.interface( name().c_str() );
|
sig2.interface(name().c_str());
|
||||||
_emit_signal(sig2);
|
_emit_signal(sig2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant* InterfaceAdaptor::get_property( const std::string& name )
|
Variant *InterfaceAdaptor::get_property(const std::string &name)
|
||||||
{
|
{
|
||||||
PropertyTable::iterator pti = _properties.find(name);
|
PropertyTable::iterator pti = _properties.find(name);
|
||||||
|
|
||||||
if( pti != _properties.end() )
|
if (pti != _properties.end())
|
||||||
{
|
{
|
||||||
if( !pti->second.read )
|
if (!pti->second.read)
|
||||||
throw ErrorAccessDenied("property is not readable");
|
throw ErrorAccessDenied("property is not readable");
|
||||||
|
|
||||||
return &(pti->second.value);
|
return &(pti->second.value);
|
||||||
|
@ -92,18 +92,18 @@ Variant* InterfaceAdaptor::get_property( const std::string& name )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterfaceAdaptor::set_property( const std::string& name, Variant& value )
|
void InterfaceAdaptor::set_property(const std::string &name, Variant &value)
|
||||||
{
|
{
|
||||||
PropertyTable::iterator pti = _properties.find(name);
|
PropertyTable::iterator pti = _properties.find(name);
|
||||||
|
|
||||||
if( pti != _properties.end() )
|
if (pti != _properties.end())
|
||||||
{
|
{
|
||||||
if( !pti->second.write )
|
if (!pti->second.write)
|
||||||
throw ErrorAccessDenied("property is not writeable");
|
throw ErrorAccessDenied("property is not writeable");
|
||||||
|
|
||||||
Signature sig = value.signature();
|
Signature sig = value.signature();
|
||||||
|
|
||||||
if( pti->second.sig != sig )
|
if (pti->second.sig != sig)
|
||||||
throw ErrorInvalidSignature("property expects a different type");
|
throw ErrorInvalidSignature("property expects a different type");
|
||||||
|
|
||||||
pti->second.value = value;
|
pti->second.value = value;
|
||||||
|
@ -112,14 +112,14 @@ void InterfaceAdaptor::set_property( const std::string& name, Variant& value )
|
||||||
throw ErrorFailed("requested property not found");
|
throw ErrorFailed("requested property not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceProxy* ProxyBase::find_interface( const std::string& name )
|
InterfaceProxy *ProxyBase::find_interface(const std::string &name)
|
||||||
{
|
{
|
||||||
InterfaceProxyTable::const_iterator ii = _interfaces.find(name);
|
InterfaceProxyTable::const_iterator ii = _interfaces.find(name);
|
||||||
|
|
||||||
return ii != _interfaces.end() ? ii->second : NULL;
|
return ii != _interfaces.end() ? ii->second : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceProxy::InterfaceProxy( const std::string& name )
|
InterfaceProxy::InterfaceProxy(const std::string &name)
|
||||||
: Interface(name)
|
: Interface(name)
|
||||||
{
|
{
|
||||||
debug_log("adding interface %s", name.c_str());
|
debug_log("adding interface %s", name.c_str());
|
||||||
|
@ -127,14 +127,14 @@ InterfaceProxy::InterfaceProxy( const std::string& name )
|
||||||
_interfaces[name] = this;
|
_interfaces[name] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterfaceProxy::dispatch_signal( const SignalMessage& msg )
|
bool InterfaceProxy::dispatch_signal(const SignalMessage &msg)
|
||||||
{
|
{
|
||||||
const char* name = msg.member();
|
const char *name = msg.member();
|
||||||
|
|
||||||
SignalTable::iterator si = _signals.find(name);
|
SignalTable::iterator si = _signals.find(name);
|
||||||
if( si != _signals.end() )
|
if (si != _signals.end())
|
||||||
{
|
{
|
||||||
si->second.call( msg );
|
si->second.call(msg);
|
||||||
// Here we always return false because there might be
|
// Here we always return false because there might be
|
||||||
// another InterfaceProxy listening for the same signal.
|
// another InterfaceProxy listening for the same signal.
|
||||||
// This way we instruct libdbus-1 to go on dispatching
|
// This way we instruct libdbus-1 to go on dispatching
|
||||||
|
@ -147,10 +147,10 @@ bool InterfaceProxy::dispatch_signal( const SignalMessage& msg )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Message InterfaceProxy::invoke_method( const CallMessage& call )
|
Message InterfaceProxy::invoke_method(const CallMessage &call)
|
||||||
{
|
{
|
||||||
CallMessage& call2 = const_cast<CallMessage&>(call);
|
CallMessage &call2 = const_cast<CallMessage &>(call);
|
||||||
|
|
||||||
call2.interface( name().c_str() );
|
call2.interface(name().c_str());
|
||||||
return _invoke_method(call2);
|
return _invoke_method(call2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,16 +45,16 @@ struct DXXAPI InternalError
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit InternalError( DBusError* e )
|
explicit InternalError(DBusError *e)
|
||||||
{
|
{
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
dbus_move_error(e, &error);
|
dbus_move_error(e, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
InternalError(const InternalError& ie)
|
InternalError(const InternalError &ie)
|
||||||
{
|
{
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
dbus_move_error(const_cast<DBusError*>(&(ie.error)), &error);
|
dbus_move_error(const_cast<DBusError *>(&(ie.error)), &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
~InternalError()
|
~InternalError()
|
||||||
|
@ -62,7 +62,7 @@ struct DXXAPI InternalError
|
||||||
dbus_error_free(&error);
|
dbus_error_free(&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator DBusError*()
|
operator DBusError *()
|
||||||
{
|
{
|
||||||
return &error;
|
return &error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
static const char* introspectable_name = "org.freedesktop.DBus.Introspectable";
|
static const char *introspectable_name = "org.freedesktop.DBus.Introspectable";
|
||||||
|
|
||||||
IntrospectableAdaptor::IntrospectableAdaptor()
|
IntrospectableAdaptor::IntrospectableAdaptor()
|
||||||
: InterfaceAdaptor(introspectable_name)
|
: InterfaceAdaptor(introspectable_name)
|
||||||
|
@ -44,7 +44,7 @@ IntrospectableAdaptor::IntrospectableAdaptor()
|
||||||
register_method(IntrospectableAdaptor, Introspect, Introspect);
|
register_method(IntrospectableAdaptor, Introspect, Introspect);
|
||||||
}
|
}
|
||||||
|
|
||||||
Message IntrospectableAdaptor::Introspect( const CallMessage& call )
|
Message IntrospectableAdaptor::Introspect(const CallMessage &call)
|
||||||
{
|
{
|
||||||
debug_log("requested introspection data");
|
debug_log("requested introspection data");
|
||||||
|
|
||||||
|
@ -58,37 +58,37 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
|
||||||
|
|
||||||
InterfaceAdaptorTable::const_iterator iti;
|
InterfaceAdaptorTable::const_iterator iti;
|
||||||
|
|
||||||
for(iti = _interfaces.begin(); iti != _interfaces.end(); ++iti)
|
for (iti = _interfaces.begin(); iti != _interfaces.end(); ++iti)
|
||||||
{
|
{
|
||||||
debug_log("introspecting interface %s", iti->first.c_str());
|
debug_log("introspecting interface %s", iti->first.c_str());
|
||||||
|
|
||||||
IntrospectedInterface* const intro = iti->second->introspect();
|
IntrospectedInterface *const intro = iti->second->introspect();
|
||||||
if(intro)
|
if (intro)
|
||||||
{
|
{
|
||||||
xml << "\n\t<interface name=\"" << intro->name << "\">";
|
xml << "\n\t<interface name=\"" << intro->name << "\">";
|
||||||
|
|
||||||
for(const IntrospectedProperty* p = intro->properties; p->name; ++p)
|
for (const IntrospectedProperty *p = intro->properties; p->name; ++p)
|
||||||
{
|
{
|
||||||
std::string access;
|
std::string access;
|
||||||
|
|
||||||
if(p->read) access += "read";
|
if (p->read) access += "read";
|
||||||
if(p->write) access += "write";
|
if (p->write) access += "write";
|
||||||
|
|
||||||
xml << "\n\t\t<property name=\"" << p->name << "\""
|
xml << "\n\t\t<property name=\"" << p->name << "\""
|
||||||
<< " type=\"" << p->type << "\""
|
<< " type=\"" << p->type << "\""
|
||||||
<< " access=\"" << access << "\"/>";
|
<< " access=\"" << access << "\"/>";
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const IntrospectedMethod* m = intro->methods; m->args; ++m)
|
for (const IntrospectedMethod *m = intro->methods; m->args; ++m)
|
||||||
{
|
{
|
||||||
xml << "\n\t\t<method name=\"" << m->name << "\">";
|
xml << "\n\t\t<method name=\"" << m->name << "\">";
|
||||||
|
|
||||||
for(const IntrospectedArgument* a = m->args; a->type; ++a)
|
for (const IntrospectedArgument *a = m->args; a->type; ++a)
|
||||||
{
|
{
|
||||||
xml << "\n\t\t\t<arg direction=\"" << (a->in ? "in" : "out") << "\""
|
xml << "\n\t\t\t<arg direction=\"" << (a->in ? "in" : "out") << "\""
|
||||||
<< " type=\"" << a->type << "\"";
|
<< " type=\"" << a->type << "\"";
|
||||||
|
|
||||||
if(a->name) xml << " name=\"" << a->name << "\"";
|
if (a->name) xml << " name=\"" << a->name << "\"";
|
||||||
|
|
||||||
xml << "/>";
|
xml << "/>";
|
||||||
}
|
}
|
||||||
|
@ -96,15 +96,15 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
|
||||||
xml << "\n\t\t</method>";
|
xml << "\n\t\t</method>";
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const IntrospectedMethod* m = intro->signals; m->args; ++m)
|
for (const IntrospectedMethod *m = intro->signals; m->args; ++m)
|
||||||
{
|
{
|
||||||
xml << "\n\t\t<signal name=\"" << m->name << "\">";
|
xml << "\n\t\t<signal name=\"" << m->name << "\">";
|
||||||
|
|
||||||
for(const IntrospectedArgument* a = m->args; a->type; ++a)
|
for (const IntrospectedArgument *a = m->args; a->type; ++a)
|
||||||
{
|
{
|
||||||
xml << "<arg type=\"" << a->type << "\"";
|
xml << "<arg type=\"" << a->type << "\"";
|
||||||
|
|
||||||
if(a->name) xml << " name=\"" << a->name << "\"";
|
if (a->name) xml << " name=\"" << a->name << "\"";
|
||||||
|
|
||||||
xml << "/>";
|
xml << "/>";
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
|
||||||
const ObjectPathList nodes = ObjectAdaptor::child_nodes_from_prefix(path + '/');
|
const ObjectPathList nodes = ObjectAdaptor::child_nodes_from_prefix(path + '/');
|
||||||
ObjectPathList::const_iterator oni;
|
ObjectPathList::const_iterator oni;
|
||||||
|
|
||||||
for(oni = nodes.begin(); oni != nodes.end(); ++oni)
|
for (oni = nodes.begin(); oni != nodes.end(); ++oni)
|
||||||
{
|
{
|
||||||
xml << "\n\t<node name=\"" << (*oni) << "\"/>";
|
xml << "\n\t<node name=\"" << (*oni) << "\"/>";
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
|
||||||
|
|
||||||
ObjectAdaptorPList::const_iterator oci;
|
ObjectAdaptorPList::const_iterator oci;
|
||||||
|
|
||||||
for(oci = children.begin(); oci != children.end(); ++oci)
|
for (oci = children.begin(); oci != children.end(); ++oci)
|
||||||
{
|
{
|
||||||
std::string name = (*oci)->path().substr(path.length()+1);
|
std::string name = (*oci)->path().substr(path.length()+1);
|
||||||
name.substr(name.find('/'));
|
name.substr(name.find('/'));
|
||||||
|
@ -145,7 +145,7 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrospectedInterface* const IntrospectableAdaptor::introspect() const
|
IntrospectedInterface *const IntrospectableAdaptor::introspect() const
|
||||||
{
|
{
|
||||||
static IntrospectedArgument Introspect_args[] =
|
static IntrospectedArgument Introspect_args[] =
|
||||||
{
|
{
|
||||||
|
@ -188,7 +188,7 @@ std::string IntrospectableProxy::Introspect()
|
||||||
DBus::Message ret = invoke_method(call);
|
DBus::Message ret = invoke_method(call);
|
||||||
|
|
||||||
DBus::MessageIter ri = ret.reader();
|
DBus::MessageIter ri = ret.reader();
|
||||||
const char* str = ri.get_string();
|
const char *str = ri.get_string();
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
192
src/message.cpp
192
src/message.cpp
|
@ -41,7 +41,7 @@ using namespace DBus;
|
||||||
|
|
||||||
int MessageIter::type()
|
int MessageIter::type()
|
||||||
{
|
{
|
||||||
return dbus_message_iter_get_arg_type((DBusMessageIter*)&_iter);
|
return dbus_message_iter_get_arg_type((DBusMessageIter *)&_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::at_end()
|
bool MessageIter::at_end()
|
||||||
|
@ -51,12 +51,12 @@ bool MessageIter::at_end()
|
||||||
|
|
||||||
bool MessageIter::has_next()
|
bool MessageIter::has_next()
|
||||||
{
|
{
|
||||||
return dbus_message_iter_has_next((DBusMessageIter*)&_iter);
|
return dbus_message_iter_has_next((DBusMessageIter *)&_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIter& MessageIter::operator ++()
|
MessageIter &MessageIter::operator ++()
|
||||||
{
|
{
|
||||||
dbus_message_iter_next((DBusMessageIter*)&_iter);
|
dbus_message_iter_next((DBusMessageIter *)&_iter);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,20 +67,20 @@ MessageIter MessageIter::operator ++(int)
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_basic( int type_id, void* value )
|
bool MessageIter::append_basic(int type_id, void *value)
|
||||||
{
|
{
|
||||||
return dbus_message_iter_append_basic((DBusMessageIter*)&_iter, type_id, value);
|
return dbus_message_iter_append_basic((DBusMessageIter *)&_iter, type_id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageIter::get_basic( int type_id, void* ptr )
|
void MessageIter::get_basic(int type_id, void *ptr)
|
||||||
{
|
{
|
||||||
if(type() != type_id)
|
if (type() != type_id)
|
||||||
throw ErrorInvalidArgs("type mismatch");
|
throw ErrorInvalidArgs("type mismatch");
|
||||||
|
|
||||||
dbus_message_iter_get_basic((DBusMessageIter*)_iter, ptr);
|
dbus_message_iter_get_basic((DBusMessageIter *)_iter, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_byte( unsigned char b )
|
bool MessageIter::append_byte(unsigned char b)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_BYTE, &b);
|
return append_basic(DBUS_TYPE_BYTE, &b);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ unsigned char MessageIter::get_byte()
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_bool( bool b )
|
bool MessageIter::append_bool(bool b)
|
||||||
{
|
{
|
||||||
dbus_bool_t db = b;
|
dbus_bool_t db = b;
|
||||||
return append_basic(DBUS_TYPE_BOOLEAN, &db);
|
return append_basic(DBUS_TYPE_BOOLEAN, &db);
|
||||||
|
@ -105,7 +105,7 @@ bool MessageIter::get_bool()
|
||||||
return (bool)db;
|
return (bool)db;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_int16( signed short i )
|
bool MessageIter::append_int16(signed short i)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_INT16, &i);
|
return append_basic(DBUS_TYPE_INT16, &i);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ signed short MessageIter::get_int16()
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_uint16( unsigned short u )
|
bool MessageIter::append_uint16(unsigned short u)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_UINT16, &u);
|
return append_basic(DBUS_TYPE_UINT16, &u);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ unsigned short MessageIter::get_uint16()
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_int32( signed int i )
|
bool MessageIter::append_int32(signed int i)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_INT32, &i);
|
return append_basic(DBUS_TYPE_INT32, &i);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ signed int MessageIter::get_int32()
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_uint32( unsigned int u )
|
bool MessageIter::append_uint32(unsigned int u)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_UINT32, &u);
|
return append_basic(DBUS_TYPE_UINT32, &u);
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ signed long long MessageIter::get_int64()
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_int64( signed long long i )
|
bool MessageIter::append_int64(signed long long i)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_INT64, &i);
|
return append_basic(DBUS_TYPE_INT64, &i);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ unsigned long long MessageIter::get_uint64()
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_uint64( unsigned long long u )
|
bool MessageIter::append_uint64(unsigned long long u)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_UINT64, &u);
|
return append_basic(DBUS_TYPE_UINT64, &u);
|
||||||
}
|
}
|
||||||
|
@ -184,43 +184,43 @@ double MessageIter::get_double()
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_double( double d )
|
bool MessageIter::append_double(double d)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_DOUBLE, &d);
|
return append_basic(DBUS_TYPE_DOUBLE, &d);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_string( const char* chars )
|
bool MessageIter::append_string(const char *chars)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_STRING, &chars);
|
return append_basic(DBUS_TYPE_STRING, &chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MessageIter::get_string()
|
const char *MessageIter::get_string()
|
||||||
{
|
{
|
||||||
char* chars;
|
char *chars;
|
||||||
get_basic(DBUS_TYPE_STRING, &chars);
|
get_basic(DBUS_TYPE_STRING, &chars);
|
||||||
return chars;
|
return chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_path( const char* chars )
|
bool MessageIter::append_path(const char *chars)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_OBJECT_PATH, &chars);
|
return append_basic(DBUS_TYPE_OBJECT_PATH, &chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MessageIter::get_path()
|
const char *MessageIter::get_path()
|
||||||
{
|
{
|
||||||
char* chars;
|
char *chars;
|
||||||
get_basic(DBUS_TYPE_OBJECT_PATH, &chars);
|
get_basic(DBUS_TYPE_OBJECT_PATH, &chars);
|
||||||
return chars;
|
return chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_signature( const char* chars )
|
bool MessageIter::append_signature(const char *chars)
|
||||||
{
|
{
|
||||||
return append_basic(DBUS_TYPE_SIGNATURE, &chars);
|
return append_basic(DBUS_TYPE_SIGNATURE, &chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MessageIter::get_signature()
|
const char *MessageIter::get_signature()
|
||||||
{
|
{
|
||||||
char* chars;
|
char *chars;
|
||||||
get_basic(DBUS_TYPE_SIGNATURE, &chars);
|
get_basic(DBUS_TYPE_SIGNATURE, &chars);
|
||||||
return chars;
|
return chars;
|
||||||
}
|
}
|
||||||
|
@ -228,56 +228,56 @@ const char* MessageIter::get_signature()
|
||||||
MessageIter MessageIter::recurse()
|
MessageIter MessageIter::recurse()
|
||||||
{
|
{
|
||||||
MessageIter iter(msg());
|
MessageIter iter(msg());
|
||||||
dbus_message_iter_recurse((DBusMessageIter*)&_iter, (DBusMessageIter*)&(iter._iter));
|
dbus_message_iter_recurse((DBusMessageIter *)&_iter, (DBusMessageIter *)&(iter._iter));
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* MessageIter::signature() const
|
char *MessageIter::signature() const
|
||||||
{
|
{
|
||||||
return dbus_message_iter_get_signature((DBusMessageIter*)&_iter);
|
return dbus_message_iter_get_signature((DBusMessageIter *)&_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::append_array( char type, const void* ptr, size_t length )
|
bool MessageIter::append_array(char type, const void *ptr, size_t length)
|
||||||
{
|
{
|
||||||
return dbus_message_iter_append_fixed_array((DBusMessageIter*)&_iter, type, &ptr, length);
|
return dbus_message_iter_append_fixed_array((DBusMessageIter *)&_iter, type, &ptr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessageIter::array_type()
|
int MessageIter::array_type()
|
||||||
{
|
{
|
||||||
return dbus_message_iter_get_element_type((DBusMessageIter*)&_iter);
|
return dbus_message_iter_get_element_type((DBusMessageIter *)&_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessageIter::get_array( void* ptr )
|
int MessageIter::get_array(void *ptr)
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
dbus_message_iter_get_fixed_array((DBusMessageIter*)&_iter, ptr, &length);
|
dbus_message_iter_get_fixed_array((DBusMessageIter *)&_iter, ptr, &length);
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::is_array()
|
bool MessageIter::is_array()
|
||||||
{
|
{
|
||||||
return dbus_message_iter_get_arg_type((DBusMessageIter*)&_iter) == DBUS_TYPE_ARRAY;
|
return dbus_message_iter_get_arg_type((DBusMessageIter *)&_iter) == DBUS_TYPE_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageIter::is_dict()
|
bool MessageIter::is_dict()
|
||||||
{
|
{
|
||||||
return is_array() && dbus_message_iter_get_element_type((DBusMessageIter*)_iter) == DBUS_TYPE_DICT_ENTRY;
|
return is_array() && dbus_message_iter_get_element_type((DBusMessageIter *)_iter) == DBUS_TYPE_DICT_ENTRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIter MessageIter::new_array( const char* sig )
|
MessageIter MessageIter::new_array(const char *sig)
|
||||||
{
|
{
|
||||||
MessageIter arr(msg());
|
MessageIter arr(msg());
|
||||||
dbus_message_iter_open_container(
|
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;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIter MessageIter::new_variant( const char* sig )
|
MessageIter MessageIter::new_variant(const char *sig)
|
||||||
{
|
{
|
||||||
MessageIter var(msg());
|
MessageIter var(msg());
|
||||||
dbus_message_iter_open_container(
|
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;
|
return var;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ MessageIter MessageIter::new_struct()
|
||||||
{
|
{
|
||||||
MessageIter stu(msg());
|
MessageIter stu(msg());
|
||||||
dbus_message_iter_open_container(
|
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;
|
return stu;
|
||||||
}
|
}
|
||||||
|
@ -295,19 +295,19 @@ MessageIter MessageIter::new_dict_entry()
|
||||||
{
|
{
|
||||||
MessageIter ent(msg());
|
MessageIter ent(msg());
|
||||||
dbus_message_iter_open_container(
|
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;
|
return ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageIter::close_container( MessageIter& container )
|
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)
|
static bool is_basic_type(int typecode)
|
||||||
{
|
{
|
||||||
switch(typecode)
|
switch (typecode)
|
||||||
{
|
{
|
||||||
case 'y':
|
case 'y':
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -327,11 +327,11 @@ static bool is_basic_type(int typecode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageIter::copy_data( MessageIter& to )
|
void MessageIter::copy_data(MessageIter &to)
|
||||||
{
|
{
|
||||||
for(MessageIter& from = *this; !from.at_end(); ++from)
|
for (MessageIter &from = *this; !from.at_end(); ++from)
|
||||||
{
|
{
|
||||||
if(is_basic_type(from.type()))
|
if (is_basic_type(from.type()))
|
||||||
{
|
{
|
||||||
debug_log("copying basic type: %c", from.type());
|
debug_log("copying basic type: %c", from.type());
|
||||||
|
|
||||||
|
@ -342,17 +342,17 @@ void MessageIter::copy_data( MessageIter& to )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageIter from_container = from.recurse();
|
MessageIter from_container = from.recurse();
|
||||||
char* sig = from_container.signature();
|
char *sig = from_container.signature();
|
||||||
|
|
||||||
debug_log("copying compound type: %c[%s]", from.type(), sig);
|
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
|
dbus_message_iter_open_container
|
||||||
(
|
(
|
||||||
(DBusMessageIter*)&(to._iter),
|
(DBusMessageIter *)&(to._iter),
|
||||||
from.type(),
|
from.type(),
|
||||||
from.type() == DBUS_TYPE_VARIANT ? NULL : sig,
|
from.type() == DBUS_TYPE_VARIANT ? NULL : sig,
|
||||||
(DBusMessageIter*)&(to_container._iter)
|
(DBusMessageIter *)&(to_container._iter)
|
||||||
);
|
);
|
||||||
|
|
||||||
from_container.copy_data(to_container);
|
from_container.copy_data(to_container);
|
||||||
|
@ -370,13 +370,13 @@ Message::Message()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::Message( Message::Private* p, bool incref )
|
Message::Message(Message::Private *p, bool incref)
|
||||||
: _pvt(p)
|
: _pvt(p)
|
||||||
{
|
{
|
||||||
if(_pvt->msg && incref) dbus_message_ref(_pvt->msg);
|
if (_pvt->msg && incref) dbus_message_ref(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::Message( const Message& m )
|
Message::Message(const Message &m)
|
||||||
: _pvt(m._pvt)
|
: _pvt(m._pvt)
|
||||||
{
|
{
|
||||||
dbus_message_ref(_pvt->msg);
|
dbus_message_ref(_pvt->msg);
|
||||||
|
@ -387,9 +387,9 @@ Message::~Message()
|
||||||
dbus_message_unref(_pvt->msg);
|
dbus_message_unref(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Message& Message::operator = ( const Message& m )
|
Message &Message::operator = (const Message &m)
|
||||||
{
|
{
|
||||||
if(&m != this)
|
if (&m != this)
|
||||||
{
|
{
|
||||||
dbus_message_unref(_pvt->msg);
|
dbus_message_unref(_pvt->msg);
|
||||||
_pvt = m._pvt;
|
_pvt = m._pvt;
|
||||||
|
@ -400,11 +400,11 @@ Message& Message::operator = ( const Message& m )
|
||||||
|
|
||||||
Message Message::copy()
|
Message Message::copy()
|
||||||
{
|
{
|
||||||
Private* pvt = new Private(dbus_message_copy(_pvt->msg));
|
Private *pvt = new Private(dbus_message_copy(_pvt->msg));
|
||||||
return Message(pvt);
|
return Message(pvt);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::append( int first_type, ... )
|
bool Message::append(int first_type, ...)
|
||||||
{
|
{
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, first_type);
|
va_start(vl, first_type);
|
||||||
|
@ -435,27 +435,27 @@ int Message::reply_serial() const
|
||||||
return dbus_message_get_reply_serial(_pvt->msg);
|
return dbus_message_get_reply_serial(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::reply_serial( int s )
|
bool Message::reply_serial(int s)
|
||||||
{
|
{
|
||||||
return dbus_message_set_reply_serial(_pvt->msg, s);
|
return dbus_message_set_reply_serial(_pvt->msg, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Message::sender() const
|
const char *Message::sender() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_sender(_pvt->msg);
|
return dbus_message_get_sender(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::sender( const char* s )
|
bool Message::sender(const char *s)
|
||||||
{
|
{
|
||||||
return dbus_message_set_sender(_pvt->msg, s);
|
return dbus_message_set_sender(_pvt->msg, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Message::destination() const
|
const char *Message::destination() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_destination(_pvt->msg);
|
return dbus_message_get_destination(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::destination( const char* s )
|
bool Message::destination(const char *s)
|
||||||
{
|
{
|
||||||
return dbus_message_set_destination(_pvt->msg, s);
|
return dbus_message_set_destination(_pvt->msg, s);
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ bool Message::is_error() const
|
||||||
return type() == DBUS_MESSAGE_TYPE_ERROR;
|
return type() == DBUS_MESSAGE_TYPE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::is_signal( const char* interface, const char* member ) const
|
bool Message::is_signal(const char *interface, const char *member) const
|
||||||
{
|
{
|
||||||
return dbus_message_is_signal(_pvt->msg, interface, member);
|
return dbus_message_is_signal(_pvt->msg, interface, member);
|
||||||
}
|
}
|
||||||
|
@ -473,14 +473,14 @@ bool Message::is_signal( const char* interface, const char* member ) const
|
||||||
MessageIter Message::writer()
|
MessageIter Message::writer()
|
||||||
{
|
{
|
||||||
MessageIter iter(*this);
|
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;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIter Message::reader() const
|
MessageIter Message::reader() const
|
||||||
{
|
{
|
||||||
MessageIter iter(const_cast<Message&>(*this));
|
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;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,22 +492,22 @@ ErrorMessage::ErrorMessage()
|
||||||
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR);
|
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorMessage::ErrorMessage( const Message& to_reply, const char* name, const char* message )
|
ErrorMessage::ErrorMessage(const Message &to_reply, const char *name, const char *message)
|
||||||
{
|
{
|
||||||
_pvt->msg = dbus_message_new_error(to_reply._pvt->msg, name, message);
|
_pvt->msg = dbus_message_new_error(to_reply._pvt->msg, name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ErrorMessage::operator == ( const ErrorMessage& m ) const
|
bool ErrorMessage::operator == (const ErrorMessage &m) const
|
||||||
{
|
{
|
||||||
return dbus_message_is_error(_pvt->msg, m.name());
|
return dbus_message_is_error(_pvt->msg, m.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ErrorMessage::name() const
|
const char *ErrorMessage::name() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_error_name(_pvt->msg);
|
return dbus_message_get_error_name(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ErrorMessage::name( const char* n )
|
bool ErrorMessage::name(const char *n)
|
||||||
{
|
{
|
||||||
return dbus_message_set_error_name(_pvt->msg, n);
|
return dbus_message_set_error_name(_pvt->msg, n);
|
||||||
}
|
}
|
||||||
|
@ -515,55 +515,55 @@ bool ErrorMessage::name( const char* n )
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SignalMessage::SignalMessage( const char* name )
|
SignalMessage::SignalMessage(const char *name)
|
||||||
{
|
{
|
||||||
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
|
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
|
||||||
member(name);
|
member(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalMessage::SignalMessage( const char* path, const char* interface, const char* name )
|
SignalMessage::SignalMessage(const char *path, const char *interface, const char *name)
|
||||||
{
|
{
|
||||||
_pvt->msg = dbus_message_new_signal(path, interface, name);
|
_pvt->msg = dbus_message_new_signal(path, interface, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SignalMessage::operator == ( const SignalMessage& m ) const
|
bool SignalMessage::operator == (const SignalMessage &m) const
|
||||||
{
|
{
|
||||||
return dbus_message_is_signal(_pvt->msg, m.interface(), m.member());
|
return dbus_message_is_signal(_pvt->msg, m.interface(), m.member());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SignalMessage::interface() const
|
const char *SignalMessage::interface() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_interface(_pvt->msg);
|
return dbus_message_get_interface(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SignalMessage::interface( const char* i )
|
bool SignalMessage::interface(const char *i)
|
||||||
{
|
{
|
||||||
return dbus_message_set_interface(_pvt->msg, i);
|
return dbus_message_set_interface(_pvt->msg, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SignalMessage::member() const
|
const char *SignalMessage::member() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_member(_pvt->msg);
|
return dbus_message_get_member(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SignalMessage::member( const char* m )
|
bool SignalMessage::member(const char *m)
|
||||||
{
|
{
|
||||||
return dbus_message_set_member(_pvt->msg, m);
|
return dbus_message_set_member(_pvt->msg, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SignalMessage::path() const
|
const char *SignalMessage::path() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_path(_pvt->msg);
|
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 ?
|
dbus_message_get_path_decomposed(_pvt->msg, &p); //todo: return as a std::vector ?
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SignalMessage::path( const char* p )
|
bool SignalMessage::path(const char *p)
|
||||||
{
|
{
|
||||||
return dbus_message_set_path(_pvt->msg, p);
|
return dbus_message_set_path(_pvt->msg, p);
|
||||||
}
|
}
|
||||||
|
@ -576,54 +576,54 @@ CallMessage::CallMessage()
|
||||||
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL);
|
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallMessage::CallMessage( const char* dest, const char* path, const char* iface, const char* method )
|
CallMessage::CallMessage(const char *dest, const char *path, const char *iface, const char *method)
|
||||||
{
|
{
|
||||||
_pvt->msg = dbus_message_new_method_call(dest, path, iface, method);
|
_pvt->msg = dbus_message_new_method_call(dest, path, iface, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallMessage::operator == ( const CallMessage& m ) const
|
bool CallMessage::operator == (const CallMessage &m) const
|
||||||
{
|
{
|
||||||
return dbus_message_is_method_call(_pvt->msg, m.interface(), m.member());
|
return dbus_message_is_method_call(_pvt->msg, m.interface(), m.member());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CallMessage::interface() const
|
const char *CallMessage::interface() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_interface(_pvt->msg);
|
return dbus_message_get_interface(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallMessage::interface( const char* i )
|
bool CallMessage::interface(const char *i)
|
||||||
{
|
{
|
||||||
return dbus_message_set_interface(_pvt->msg, i);
|
return dbus_message_set_interface(_pvt->msg, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CallMessage::member() const
|
const char *CallMessage::member() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_member(_pvt->msg);
|
return dbus_message_get_member(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallMessage::member( const char* m )
|
bool CallMessage::member(const char *m)
|
||||||
{
|
{
|
||||||
return dbus_message_set_member(_pvt->msg, m);
|
return dbus_message_set_member(_pvt->msg, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CallMessage::path() const
|
const char *CallMessage::path() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_path(_pvt->msg);
|
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);
|
dbus_message_get_path_decomposed(_pvt->msg, &p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallMessage::path( const char* p )
|
bool CallMessage::path(const char *p)
|
||||||
{
|
{
|
||||||
return dbus_message_set_path(_pvt->msg, p);
|
return dbus_message_set_path(_pvt->msg, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CallMessage::signature() const
|
const char *CallMessage::signature() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_signature(_pvt->msg);
|
return dbus_message_get_signature(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
@ -631,12 +631,12 @@ const char* CallMessage::signature() const
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ReturnMessage::ReturnMessage( const CallMessage& callee )
|
ReturnMessage::ReturnMessage(const CallMessage &callee)
|
||||||
{
|
{
|
||||||
_pvt = new Private(dbus_message_new_method_return(callee._pvt->msg));
|
_pvt = new Private(dbus_message_new_method_return(callee._pvt->msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ReturnMessage::signature() const
|
const char *ReturnMessage::signature() const
|
||||||
{
|
{
|
||||||
return dbus_message_get_signature(_pvt->msg);
|
return dbus_message_get_signature(_pvt->msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,12 @@ namespace DBus {
|
||||||
|
|
||||||
struct DXXAPILOCAL Message::Private
|
struct DXXAPILOCAL Message::Private
|
||||||
{
|
{
|
||||||
DBusMessage* msg;
|
DBusMessage *msg;
|
||||||
|
|
||||||
Private() : msg(0)
|
Private() : msg(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Private( DBusMessage* m ) : msg(m)
|
Private(DBusMessage *m) : msg(m)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
102
src/object.cpp
102
src/object.cpp
|
@ -40,8 +40,8 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
Object::Object( Connection& conn, const Path& path, const char* service )
|
Object::Object(Connection &conn, const Path &path, const char *service)
|
||||||
: _conn(conn), _path(path), _service(service ? service : "")
|
: _conn(conn), _path(path), _service(service ? service : "")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ Object::~Object()
|
||||||
|
|
||||||
struct ObjectAdaptor::Private
|
struct ObjectAdaptor::Private
|
||||||
{
|
{
|
||||||
static void unregister_function_stub( DBusConnection*, void* );
|
static void unregister_function_stub(DBusConnection *, void *);
|
||||||
static DBusHandlerResult message_function_stub( DBusConnection*, DBusMessage*, void* );
|
static DBusHandlerResult message_function_stub(DBusConnection *, DBusMessage *, void *);
|
||||||
};
|
};
|
||||||
|
|
||||||
static DBusObjectPathVTable _vtable =
|
static DBusObjectPathVTable _vtable =
|
||||||
|
@ -62,16 +62,16 @@ static DBusObjectPathVTable _vtable =
|
||||||
NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
void ObjectAdaptor::Private::unregister_function_stub( DBusConnection* conn, void* data )
|
void ObjectAdaptor::Private::unregister_function_stub(DBusConnection *conn, void *data)
|
||||||
{
|
{
|
||||||
//TODO: what do we have to do here ?
|
//TODO: what do we have to do here ?
|
||||||
}
|
}
|
||||||
|
|
||||||
DBusHandlerResult ObjectAdaptor::Private::message_function_stub( DBusConnection*, DBusMessage* dmsg, void* data )
|
DBusHandlerResult ObjectAdaptor::Private::message_function_stub(DBusConnection *, DBusMessage *dmsg, void *data)
|
||||||
{
|
{
|
||||||
ObjectAdaptor* o = static_cast<ObjectAdaptor*>(data);
|
ObjectAdaptor *o = static_cast<ObjectAdaptor *>(data);
|
||||||
|
|
||||||
if( o )
|
if (o)
|
||||||
{
|
{
|
||||||
Message msg(new Message::Private(dmsg));
|
Message msg(new Message::Private(dmsg));
|
||||||
|
|
||||||
|
@ -92,20 +92,20 @@ DBusHandlerResult ObjectAdaptor::Private::message_function_stub( DBusConnection*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::map<Path, ObjectAdaptor*> ObjectAdaptorTable;
|
typedef std::map<Path, ObjectAdaptor *> ObjectAdaptorTable;
|
||||||
static ObjectAdaptorTable _adaptor_table;
|
static ObjectAdaptorTable _adaptor_table;
|
||||||
|
|
||||||
ObjectAdaptor* ObjectAdaptor::from_path( const Path& path )
|
ObjectAdaptor *ObjectAdaptor::from_path(const Path &path)
|
||||||
{
|
{
|
||||||
ObjectAdaptorTable::iterator ati = _adaptor_table.find(path);
|
ObjectAdaptorTable::iterator ati = _adaptor_table.find(path);
|
||||||
|
|
||||||
if(ati != _adaptor_table.end())
|
if (ati != _adaptor_table.end())
|
||||||
return ati->second;
|
return ati->second;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectAdaptorPList ObjectAdaptor::from_path_prefix( const std::string& prefix )
|
ObjectAdaptorPList ObjectAdaptor::from_path_prefix(const std::string &prefix)
|
||||||
{
|
{
|
||||||
ObjectAdaptorPList ali;
|
ObjectAdaptorPList ali;
|
||||||
|
|
||||||
|
@ -113,9 +113,9 @@ ObjectAdaptorPList ObjectAdaptor::from_path_prefix( const std::string& prefix )
|
||||||
|
|
||||||
size_t plen = prefix.length();
|
size_t plen = prefix.length();
|
||||||
|
|
||||||
while(ati != _adaptor_table.end())
|
while (ati != _adaptor_table.end())
|
||||||
{
|
{
|
||||||
if(!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
|
if (!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
|
||||||
ali.push_back(ati->second);
|
ali.push_back(ati->second);
|
||||||
|
|
||||||
++ati;
|
++ati;
|
||||||
|
@ -124,7 +124,7 @@ ObjectAdaptorPList ObjectAdaptor::from_path_prefix( const std::string& prefix )
|
||||||
return ali;
|
return ali;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectPathList ObjectAdaptor::child_nodes_from_prefix( const std::string& prefix )
|
ObjectPathList ObjectAdaptor::child_nodes_from_prefix(const std::string &prefix)
|
||||||
{
|
{
|
||||||
ObjectPathList ali;
|
ObjectPathList ali;
|
||||||
|
|
||||||
|
@ -132,9 +132,9 @@ ObjectPathList ObjectAdaptor::child_nodes_from_prefix( const std::string& prefix
|
||||||
|
|
||||||
size_t plen = prefix.length();
|
size_t plen = prefix.length();
|
||||||
|
|
||||||
while(ati != _adaptor_table.end())
|
while (ati != _adaptor_table.end())
|
||||||
{
|
{
|
||||||
if(!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
|
if (!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
|
||||||
{
|
{
|
||||||
std::string p = ati->second->path().substr(plen);
|
std::string p = ati->second->path().substr(plen);
|
||||||
p = p.substr(0,p.find('/'));
|
p = p.substr(0,p.find('/'));
|
||||||
|
@ -149,8 +149,8 @@ ObjectPathList ObjectAdaptor::child_nodes_from_prefix( const std::string& prefix
|
||||||
return ali;
|
return ali;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectAdaptor::ObjectAdaptor( Connection& conn, const Path& path )
|
ObjectAdaptor::ObjectAdaptor(Connection &conn, const Path &path)
|
||||||
: Object(conn, path, conn.unique_name())
|
: Object(conn, path, conn.unique_name())
|
||||||
{
|
{
|
||||||
register_obj();
|
register_obj();
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ void ObjectAdaptor::register_obj()
|
||||||
{
|
{
|
||||||
debug_log("registering local object %s", path().c_str());
|
debug_log("registering local object %s", path().c_str());
|
||||||
|
|
||||||
if(!dbus_connection_register_object_path(conn()._pvt->conn, path().c_str(), &_vtable, this))
|
if (!dbus_connection_register_object_path(conn()._pvt->conn, path().c_str(), &_vtable, this))
|
||||||
{
|
{
|
||||||
throw ErrorNoMemory("unable to register object path");
|
throw ErrorNoMemory("unable to register object path");
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ void ObjectAdaptor::unregister_obj()
|
||||||
dbus_connection_unregister_object_path(conn()._pvt->conn, path().c_str());
|
dbus_connection_unregister_object_path(conn()._pvt->conn, path().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectAdaptor::_emit_signal( SignalMessage& sig )
|
void ObjectAdaptor::_emit_signal(SignalMessage &sig)
|
||||||
{
|
{
|
||||||
sig.path(path().c_str());
|
sig.path(path().c_str());
|
||||||
|
|
||||||
|
@ -190,35 +190,35 @@ void ObjectAdaptor::_emit_signal( SignalMessage& sig )
|
||||||
|
|
||||||
struct ReturnLaterError
|
struct ReturnLaterError
|
||||||
{
|
{
|
||||||
const Tag* tag;
|
const Tag *tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ObjectAdaptor::handle_message( const Message& msg )
|
bool ObjectAdaptor::handle_message(const Message &msg)
|
||||||
{
|
{
|
||||||
switch( msg.type() )
|
switch (msg.type())
|
||||||
{
|
{
|
||||||
case DBUS_MESSAGE_TYPE_METHOD_CALL:
|
case DBUS_MESSAGE_TYPE_METHOD_CALL:
|
||||||
{
|
{
|
||||||
const CallMessage& cmsg = reinterpret_cast<const CallMessage&>(msg);
|
const CallMessage &cmsg = reinterpret_cast<const CallMessage &>(msg);
|
||||||
const char* member = cmsg.member();
|
const char *member = cmsg.member();
|
||||||
const char* interface = cmsg.interface();
|
const char *interface = cmsg.interface();
|
||||||
|
|
||||||
debug_log(" invoking method %s.%s", interface, member);
|
debug_log(" invoking method %s.%s", interface, member);
|
||||||
|
|
||||||
InterfaceAdaptor* ii = find_interface(interface);
|
InterfaceAdaptor *ii = find_interface(interface);
|
||||||
if( ii )
|
if (ii)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Message ret = ii->dispatch_method(cmsg);
|
Message ret = ii->dispatch_method(cmsg);
|
||||||
conn().send(ret);
|
conn().send(ret);
|
||||||
}
|
}
|
||||||
catch(Error& e)
|
catch(Error &e)
|
||||||
{
|
{
|
||||||
ErrorMessage em(cmsg, e.name(), e.message());
|
ErrorMessage em(cmsg, e.name(), e.message());
|
||||||
conn().send(em);
|
conn().send(em);
|
||||||
}
|
}
|
||||||
catch(ReturnLaterError& rle)
|
catch(ReturnLaterError &rle)
|
||||||
{
|
{
|
||||||
_continuations[rle.tag] = new Continuation(conn(), cmsg, rle.tag);
|
_continuations[rle.tag] = new Continuation(conn(), cmsg, rle.tag);
|
||||||
}
|
}
|
||||||
|
@ -236,13 +236,13 @@ bool ObjectAdaptor::handle_message( const Message& msg )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectAdaptor::return_later( const Tag* tag )
|
void ObjectAdaptor::return_later(const Tag *tag)
|
||||||
{
|
{
|
||||||
ReturnLaterError rle = { tag };
|
ReturnLaterError rle = { tag };
|
||||||
throw rle;
|
throw rle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectAdaptor::return_now( Continuation* ret )
|
void ObjectAdaptor::return_now(Continuation *ret)
|
||||||
{
|
{
|
||||||
ret->_conn.send(ret->_return);
|
ret->_conn.send(ret->_return);
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ void ObjectAdaptor::return_now( Continuation* ret )
|
||||||
_continuations.erase(di);
|
_continuations.erase(di);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectAdaptor::return_error( Continuation* ret, const Error error )
|
void ObjectAdaptor::return_error(Continuation *ret, const Error error)
|
||||||
{
|
{
|
||||||
ret->_conn.send(ErrorMessage(ret->_call, error.name(), error.message()));
|
ret->_conn.send(ErrorMessage(ret->_call, error.name(), error.message()));
|
||||||
|
|
||||||
|
@ -264,14 +264,14 @@ void ObjectAdaptor::return_error( Continuation* ret, const Error error )
|
||||||
_continuations.erase(di);
|
_continuations.erase(di);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectAdaptor::Continuation* ObjectAdaptor::find_continuation( const Tag* tag )
|
ObjectAdaptor::Continuation *ObjectAdaptor::find_continuation(const Tag *tag)
|
||||||
{
|
{
|
||||||
ContinuationMap::iterator di = _continuations.find(tag);
|
ContinuationMap::iterator di = _continuations.find(tag);
|
||||||
|
|
||||||
return di != _continuations.end() ? di->second : NULL;
|
return di != _continuations.end() ? di->second : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectAdaptor::Continuation::Continuation( Connection& conn, const CallMessage& call, 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
|
_writer = _return.writer(); //todo: verify
|
||||||
|
@ -280,8 +280,8 @@ ObjectAdaptor::Continuation::Continuation( Connection& conn, const CallMessage&
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ObjectProxy::ObjectProxy( Connection& conn, const Path& path, const char* service )
|
ObjectProxy::ObjectProxy(Connection &conn, const Path &path, const char *service)
|
||||||
: Object(conn, path, service)
|
: Object(conn, path, service)
|
||||||
{
|
{
|
||||||
register_obj();
|
register_obj();
|
||||||
}
|
}
|
||||||
|
@ -295,12 +295,12 @@ void ObjectProxy::register_obj()
|
||||||
{
|
{
|
||||||
debug_log("registering remote object %s", path().c_str());
|
debug_log("registering remote object %s", path().c_str());
|
||||||
|
|
||||||
_filtered = new Callback<ObjectProxy, bool, const Message&>(this, &ObjectProxy::handle_message);
|
_filtered = new Callback<ObjectProxy, bool, const Message &>(this, &ObjectProxy::handle_message);
|
||||||
|
|
||||||
conn().add_filter(_filtered);
|
conn().add_filter(_filtered);
|
||||||
|
|
||||||
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
|
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
|
||||||
while( ii != _interfaces.end() )
|
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());
|
conn().add_match(im.c_str());
|
||||||
|
@ -313,7 +313,7 @@ void ObjectProxy::unregister_obj()
|
||||||
debug_log("unregistering remote object %s", path().c_str());
|
debug_log("unregistering remote object %s", path().c_str());
|
||||||
|
|
||||||
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
|
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
|
||||||
while( ii != _interfaces.end() )
|
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());
|
conn().remove_match(im.c_str());
|
||||||
|
@ -322,7 +322,7 @@ void ObjectProxy::unregister_obj()
|
||||||
conn().remove_filter(_filtered);
|
conn().remove_filter(_filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
Message ObjectProxy::_invoke_method( CallMessage& call )
|
Message ObjectProxy::_invoke_method(CallMessage &call)
|
||||||
{
|
{
|
||||||
call.path(path().c_str());
|
call.path(path().c_str());
|
||||||
call.destination(service().c_str());
|
call.destination(service().c_str());
|
||||||
|
@ -330,24 +330,24 @@ Message ObjectProxy::_invoke_method( CallMessage& call )
|
||||||
return conn().send_blocking(call);
|
return conn().send_blocking(call);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectProxy::handle_message( const Message& msg )
|
bool ObjectProxy::handle_message(const Message &msg)
|
||||||
{
|
{
|
||||||
switch( msg.type() )
|
switch (msg.type())
|
||||||
{
|
{
|
||||||
case DBUS_MESSAGE_TYPE_SIGNAL:
|
case DBUS_MESSAGE_TYPE_SIGNAL:
|
||||||
{
|
{
|
||||||
const SignalMessage& smsg = reinterpret_cast<const SignalMessage&>(msg);
|
const SignalMessage &smsg = reinterpret_cast<const SignalMessage &>(msg);
|
||||||
const char* interface = smsg.interface();
|
const char *interface = smsg.interface();
|
||||||
const char* member = smsg.member();
|
const char *member = smsg.member();
|
||||||
const char* objpath = smsg.path();
|
const char *objpath = smsg.path();
|
||||||
|
|
||||||
if( objpath != path() ) return false;
|
if (objpath != path()) return false;
|
||||||
|
|
||||||
debug_log("filtered signal %s(in %s) from %s to object %s",
|
debug_log("filtered signal %s(in %s) from %s to object %s",
|
||||||
member, interface, msg.sender(), objpath);
|
member, interface, msg.sender(), objpath);
|
||||||
|
|
||||||
InterfaceProxy* ii = find_interface(interface);
|
InterfaceProxy *ii = find_interface(interface);
|
||||||
if( ii )
|
if (ii)
|
||||||
{
|
{
|
||||||
return ii->dispatch_signal(smsg);
|
return ii->dispatch_signal(smsg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
PendingCall::Private::Private( DBusPendingCall* dpc )
|
PendingCall::Private::Private(DBusPendingCall *dpc)
|
||||||
: call(dpc), dataslot(-1)
|
: call(dpc), dataslot(-1)
|
||||||
{
|
{
|
||||||
if(!dbus_pending_call_allocate_data_slot(&dataslot))
|
if (!dbus_pending_call_allocate_data_slot(&dataslot))
|
||||||
{
|
{
|
||||||
throw ErrorNoMemory("Unable to allocate data slot");
|
throw ErrorNoMemory("Unable to allocate data slot");
|
||||||
}
|
}
|
||||||
|
@ -47,30 +47,30 @@ PendingCall::Private::Private( DBusPendingCall* dpc )
|
||||||
|
|
||||||
PendingCall::Private::~Private()
|
PendingCall::Private::~Private()
|
||||||
{
|
{
|
||||||
if(dataslot != -1)
|
if (dataslot != -1)
|
||||||
{
|
{
|
||||||
dbus_pending_call_allocate_data_slot(&dataslot);
|
dbus_pending_call_allocate_data_slot(&dataslot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingCall::Private::notify_stub( DBusPendingCall* dpc, void* data )
|
void PendingCall::Private::notify_stub(DBusPendingCall *dpc, void *data)
|
||||||
{
|
{
|
||||||
PendingCall::Private* pvt = static_cast<PendingCall::Private*>(data);
|
PendingCall::Private *pvt = static_cast<PendingCall::Private *>(data);
|
||||||
|
|
||||||
PendingCall pc(pvt);
|
PendingCall pc(pvt);
|
||||||
pvt->slot(pc);
|
pvt->slot(pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCall::PendingCall( PendingCall::Private* p )
|
PendingCall::PendingCall(PendingCall::Private *p)
|
||||||
: _pvt(p)
|
: _pvt(p)
|
||||||
{
|
{
|
||||||
if(!dbus_pending_call_set_notify(_pvt->call, Private::notify_stub, p, NULL))
|
if (!dbus_pending_call_set_notify(_pvt->call, Private::notify_stub, p, NULL))
|
||||||
{
|
{
|
||||||
throw ErrorNoMemory("Unable to initialize pending call");
|
throw ErrorNoMemory("Unable to initialize pending call");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCall::PendingCall( const PendingCall& c )
|
PendingCall::PendingCall(const PendingCall &c)
|
||||||
: _pvt(c._pvt)
|
: _pvt(c._pvt)
|
||||||
{
|
{
|
||||||
dbus_pending_call_ref(_pvt->call);
|
dbus_pending_call_ref(_pvt->call);
|
||||||
|
@ -81,9 +81,9 @@ PendingCall::~PendingCall()
|
||||||
dbus_pending_call_unref(_pvt->call);
|
dbus_pending_call_unref(_pvt->call);
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCall& PendingCall::operator = ( const PendingCall& c )
|
PendingCall &PendingCall::operator = (const PendingCall &c)
|
||||||
{
|
{
|
||||||
if(&c != this)
|
if (&c != this)
|
||||||
{
|
{
|
||||||
dbus_pending_call_unref(_pvt->call);
|
dbus_pending_call_unref(_pvt->call);
|
||||||
_pvt = c._pvt;
|
_pvt = c._pvt;
|
||||||
|
@ -107,37 +107,37 @@ void PendingCall::block()
|
||||||
dbus_pending_call_block(_pvt->call);
|
dbus_pending_call_block(_pvt->call);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingCall::data( void* p )
|
void PendingCall::data(void *p)
|
||||||
{
|
{
|
||||||
if(!dbus_pending_call_set_data(_pvt->call, _pvt->dataslot, p, NULL))
|
if (!dbus_pending_call_set_data(_pvt->call, _pvt->dataslot, p, NULL))
|
||||||
{
|
{
|
||||||
throw ErrorNoMemory("Unable to initialize data slot");
|
throw ErrorNoMemory("Unable to initialize data slot");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* PendingCall::data()
|
void *PendingCall::data()
|
||||||
{
|
{
|
||||||
return dbus_pending_call_get_data(_pvt->call, _pvt->dataslot);
|
return dbus_pending_call_get_data(_pvt->call, _pvt->dataslot);
|
||||||
}
|
}
|
||||||
|
|
||||||
Slot<void, PendingCall&>& PendingCall::slot()
|
Slot<void, PendingCall &>& PendingCall::slot()
|
||||||
{
|
{
|
||||||
return _pvt->slot;
|
return _pvt->slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message PendingCall::steal_reply()
|
Message PendingCall::steal_reply()
|
||||||
{
|
{
|
||||||
DBusMessage* dmsg = dbus_pending_call_steal_reply(_pvt->call);
|
DBusMessage *dmsg = dbus_pending_call_steal_reply(_pvt->call);
|
||||||
if(!dmsg)
|
if (!dmsg)
|
||||||
{
|
{
|
||||||
dbus_bool_t callComplete = dbus_pending_call_get_completed(_pvt->call);
|
dbus_bool_t callComplete = dbus_pending_call_get_completed(_pvt->call);
|
||||||
|
|
||||||
if(callComplete)
|
if (callComplete)
|
||||||
throw ErrorNoReply("No reply available");
|
throw ErrorNoReply("No reply available");
|
||||||
else
|
else
|
||||||
throw ErrorNoReply("Call not complete");
|
throw ErrorNoReply("Call not complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Message( new Message::Private(dmsg) );
|
return Message(new Message::Private(dmsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,15 +39,15 @@ namespace DBus {
|
||||||
|
|
||||||
struct DXXAPILOCAL PendingCall::Private
|
struct DXXAPILOCAL PendingCall::Private
|
||||||
{
|
{
|
||||||
DBusPendingCall* call;
|
DBusPendingCall *call;
|
||||||
int dataslot;
|
int dataslot;
|
||||||
Slot<void, PendingCall&> slot;
|
Slot<void, PendingCall &> slot;
|
||||||
|
|
||||||
Private( DBusPendingCall* );
|
Private(DBusPendingCall *);
|
||||||
|
|
||||||
~Private();
|
~Private();
|
||||||
|
|
||||||
static void notify_stub( DBusPendingCall* dpc, void* data );
|
static void notify_stub(DBusPendingCall *dpc, void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
static const char* properties_name = "org.freedesktop.DBus.Properties";
|
static const char *properties_name = "org.freedesktop.DBus.Properties";
|
||||||
|
|
||||||
PropertiesAdaptor::PropertiesAdaptor()
|
PropertiesAdaptor::PropertiesAdaptor()
|
||||||
: InterfaceAdaptor(properties_name)
|
: InterfaceAdaptor(properties_name)
|
||||||
|
@ -42,25 +42,25 @@ PropertiesAdaptor::PropertiesAdaptor()
|
||||||
register_method(PropertiesAdaptor, Set, Set);
|
register_method(PropertiesAdaptor, Set, Set);
|
||||||
}
|
}
|
||||||
|
|
||||||
Message PropertiesAdaptor::Get( const CallMessage& call )
|
Message PropertiesAdaptor::Get(const CallMessage &call)
|
||||||
{
|
{
|
||||||
MessageIter ri = call.reader();
|
MessageIter ri = call.reader();
|
||||||
|
|
||||||
String iface_name;
|
std::string iface_name;
|
||||||
String property_name;
|
std::string property_name;
|
||||||
|
|
||||||
ri >> iface_name >> property_name;
|
ri >> iface_name >> property_name;
|
||||||
|
|
||||||
debug_log("requesting property %s on interface %s", property_name.c_str(), iface_name.c_str());
|
debug_log("requesting property %s on interface %s", property_name.c_str(), iface_name.c_str());
|
||||||
|
|
||||||
InterfaceAdaptor* interface = (InterfaceAdaptor*) find_interface(iface_name);
|
InterfaceAdaptor *interface = (InterfaceAdaptor *) find_interface(iface_name);
|
||||||
|
|
||||||
if(!interface)
|
if (!interface)
|
||||||
throw ErrorFailed("requested interface not found");
|
throw ErrorFailed("requested interface not found");
|
||||||
|
|
||||||
Variant* value = interface->get_property(property_name);
|
Variant *value = interface->get_property(property_name);
|
||||||
|
|
||||||
if(!value)
|
if (!value)
|
||||||
throw ErrorFailed("requested property not found");
|
throw ErrorFailed("requested property not found");
|
||||||
|
|
||||||
on_get_property(*interface, property_name, *value);
|
on_get_property(*interface, property_name, *value);
|
||||||
|
@ -73,19 +73,19 @@ Message PropertiesAdaptor::Get( const CallMessage& call )
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message PropertiesAdaptor::Set( const CallMessage& call )
|
Message PropertiesAdaptor::Set(const CallMessage &call)
|
||||||
{
|
{
|
||||||
MessageIter ri = call.reader();
|
MessageIter ri = call.reader();
|
||||||
|
|
||||||
String iface_name;
|
std::string iface_name;
|
||||||
String property_name;
|
std::string property_name;
|
||||||
Variant value;
|
Variant value;
|
||||||
|
|
||||||
ri >> iface_name >> property_name >> value;
|
ri >> iface_name >> property_name >> value;
|
||||||
|
|
||||||
InterfaceAdaptor* interface = (InterfaceAdaptor*) find_interface(iface_name);
|
InterfaceAdaptor *interface = (InterfaceAdaptor *) find_interface(iface_name);
|
||||||
|
|
||||||
if(!interface)
|
if (!interface)
|
||||||
throw ErrorFailed("requested interface not found");
|
throw ErrorFailed("requested interface not found");
|
||||||
|
|
||||||
on_set_property(*interface, property_name, value);
|
on_set_property(*interface, property_name, value);
|
||||||
|
@ -97,7 +97,7 @@ Message PropertiesAdaptor::Set( const CallMessage& call )
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrospectedInterface* const PropertiesAdaptor::introspect() const
|
IntrospectedInterface *const PropertiesAdaptor::introspect() const
|
||||||
{
|
{
|
||||||
static IntrospectedArgument Get_args[] =
|
static IntrospectedArgument Get_args[] =
|
||||||
{
|
{
|
||||||
|
@ -142,14 +142,14 @@ PropertiesProxy::PropertiesProxy()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant PropertiesProxy::Get( const String& iface, const String& property )
|
Variant PropertiesProxy::Get(const std::string &iface, const std::string &property)
|
||||||
{
|
{
|
||||||
//todo
|
//todo
|
||||||
Variant v;
|
Variant v;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesProxy::Set( const String& iface, const String& property, const Variant& value )
|
void PropertiesProxy::Set(const std::string &iface, const std::string &property, const Variant &value)
|
||||||
{
|
{
|
||||||
//todo
|
//todo
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
Server::Private::Private( DBusServer* s )
|
Server::Private::Private(DBusServer *s)
|
||||||
: server(s)
|
: server(s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ Server::Private::~Private()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::Private::on_new_conn_cb( DBusServer* server, DBusConnection* conn, void* data )
|
void Server::Private::on_new_conn_cb(DBusServer *server, DBusConnection *conn, void *data)
|
||||||
{
|
{
|
||||||
Server* s = static_cast<Server*>(data);
|
Server *s = static_cast<Server *>(data);
|
||||||
|
|
||||||
Connection nc (new Connection::Private(conn, s->_pvt.get()));
|
Connection nc (new Connection::Private(conn, s->_pvt.get()));
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ void Server::Private::on_new_conn_cb( DBusServer* server, DBusConnection* conn,
|
||||||
debug_log("incoming connection 0x%08x", conn);
|
debug_log("incoming connection 0x%08x", conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::Server( const char* address )
|
Server::Server(const char *address)
|
||||||
{
|
{
|
||||||
InternalError e;
|
InternalError e;
|
||||||
DBusServer* server = dbus_server_listen(address, e);
|
DBusServer *server = dbus_server_listen(address, e);
|
||||||
|
|
||||||
if(e) throw Error(e);
|
if (e) throw Error(e);
|
||||||
|
|
||||||
debug_log("server 0x%08x listening on %s", server, address);
|
debug_log("server 0x%08x listening on %s", server, address);
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ Server::Server( const char* address )
|
||||||
setup(default_dispatcher);
|
setup(default_dispatcher);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Server::Server( const Server& s )
|
Server::Server(const Server &s)
|
||||||
: _pvt(s._pvt)
|
: _pvt(s._pvt)
|
||||||
{
|
{
|
||||||
dbus_server_ref(_pvt->server);
|
dbus_server_ref(_pvt->server);
|
||||||
|
@ -85,11 +85,11 @@ Server::~Server()
|
||||||
dbus_server_unref(_pvt->server);
|
dbus_server_unref(_pvt->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dispatcher* Server::setup( Dispatcher* dispatcher )
|
Dispatcher *Server::setup(Dispatcher *dispatcher)
|
||||||
{
|
{
|
||||||
debug_log("registering stubs for server %p", _pvt->server);
|
debug_log("registering stubs for server %p", _pvt->server);
|
||||||
|
|
||||||
Dispatcher* prev = _pvt->dispatcher;
|
Dispatcher *prev = _pvt->dispatcher;
|
||||||
|
|
||||||
dbus_server_set_watch_functions(
|
dbus_server_set_watch_functions(
|
||||||
_pvt->server,
|
_pvt->server,
|
||||||
|
@ -114,7 +114,7 @@ Dispatcher* Server::setup( Dispatcher* dispatcher )
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::operator == ( const Server& s ) const
|
bool Server::operator == (const Server &s) const
|
||||||
{
|
{
|
||||||
return _pvt->server == s._pvt->server;
|
return _pvt->server == s._pvt->server;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,17 +40,17 @@ namespace DBus {
|
||||||
|
|
||||||
struct DXXAPILOCAL Server::Private
|
struct DXXAPILOCAL Server::Private
|
||||||
{
|
{
|
||||||
DBusServer* server;
|
DBusServer *server;
|
||||||
|
|
||||||
Dispatcher* dispatcher;
|
Dispatcher *dispatcher;
|
||||||
|
|
||||||
ConnectionList connections;
|
ConnectionList connections;
|
||||||
|
|
||||||
Private( DBusServer* );
|
Private(DBusServer *);
|
||||||
|
|
||||||
~Private();
|
~Private();
|
||||||
|
|
||||||
static void on_new_conn_cb( DBusServer* server, DBusConnection* conn, void* data );
|
static void on_new_conn_cb(DBusServer *server, DBusConnection *conn, void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
|
@ -42,7 +42,7 @@ Variant::Variant()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Variant( MessageIter& it )
|
Variant::Variant(MessageIter &it)
|
||||||
: _msg(CallMessage())
|
: _msg(CallMessage())
|
||||||
{
|
{
|
||||||
MessageIter vi = it.recurse();
|
MessageIter vi = it.recurse();
|
||||||
|
@ -50,9 +50,9 @@ Variant::Variant( MessageIter& it )
|
||||||
vi.copy_data(mi);
|
vi.copy_data(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant& Variant::operator = ( const Variant& v )
|
Variant &Variant::operator = (const Variant &v)
|
||||||
{
|
{
|
||||||
if(&v != this)
|
if (&v != this)
|
||||||
{
|
{
|
||||||
_msg = v._msg;
|
_msg = v._msg;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ void Variant::clear()
|
||||||
|
|
||||||
const Signature Variant::signature() const
|
const Signature Variant::signature() const
|
||||||
{
|
{
|
||||||
char* sigbuf = reader().signature();
|
char *sigbuf = reader().signature();
|
||||||
|
|
||||||
Signature signature = sigbuf;
|
Signature signature = sigbuf;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ const Signature Variant::signature() const
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIter& operator << ( MessageIter& iter, const Variant& val )
|
MessageIter &operator << (MessageIter &iter, const Variant &val)
|
||||||
{
|
{
|
||||||
const Signature sig = val.signature();
|
const Signature sig = val.signature();
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ MessageIter& operator << ( MessageIter& iter, const Variant& val )
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIter& operator >> ( MessageIter& iter, Variant& val )
|
MessageIter &operator >> (MessageIter &iter, Variant &val)
|
||||||
{
|
{
|
||||||
if(iter.type() != DBUS_TYPE_VARIANT)
|
if (iter.type() != DBUS_TYPE_VARIANT)
|
||||||
throw ErrorInvalidArgs("variant type expected");
|
throw ErrorInvalidArgs("variant type expected");
|
||||||
|
|
||||||
val.clear();
|
val.clear();
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
|
|
||||||
DBus::BusDispatcher dispatcher;
|
DBus::BusDispatcher dispatcher;
|
||||||
static bool systembus;
|
static bool systembus;
|
||||||
static char* path;
|
static char *path;
|
||||||
static char* service;
|
static char *service;
|
||||||
|
|
||||||
void niam( int sig )
|
void niam(int sig)
|
||||||
{
|
{
|
||||||
DBus::Connection conn = systembus ? DBus::Connection::SystemBus() : DBus::Connection::SessionBus();
|
DBus::Connection conn = systembus ? DBus::Connection::SystemBus() : DBus::Connection::SessionBus();
|
||||||
|
|
||||||
|
@ -43,19 +43,19 @@ void niam( int sig )
|
||||||
dispatcher.leave();
|
dispatcher.leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
signal(SIGTERM, niam);
|
signal(SIGTERM, niam);
|
||||||
signal(SIGINT, niam);
|
signal(SIGINT, niam);
|
||||||
signal(SIGALRM, niam);
|
signal(SIGALRM, niam);
|
||||||
|
|
||||||
if(argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
std::cerr << std::endl << "Usage: " << argv[0] << " [--system] <object_path> [<destination>]" << std::endl << std::endl;
|
std::cerr << std::endl << "Usage: " << argv[0] << " [--system] <object_path> [<destination>]" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(strcmp(argv[1], "--system"))
|
if (strcmp(argv[1], "--system"))
|
||||||
{
|
{
|
||||||
systembus = false;
|
systembus = false;
|
||||||
path = argv[1];
|
path = argv[1];
|
||||||
|
|
|
@ -36,7 +36,7 @@ class IntrospectedObject : public DBus::IntrospectableProxy, public DBus::Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
IntrospectedObject( DBus::Connection& conn, const char* path, const char* service )
|
IntrospectedObject(DBus::Connection &conn, const char *path, const char *service)
|
||||||
: DBus::ObjectProxy(conn, path, service)
|
: DBus::ObjectProxy(conn, path, service)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
102
tools/xml.cpp
102
tools/xml.cpp
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include <expat.h>
|
#include <expat.h>
|
||||||
|
|
||||||
std::istream& operator >> ( std::istream& in, DBus::Xml::Document& doc )
|
std::istream &operator >> (std::istream &in, DBus::Xml::Document &doc)
|
||||||
{
|
{
|
||||||
std::stringbuf xmlbuf;
|
std::stringbuf xmlbuf;
|
||||||
in.get(xmlbuf, '\0');
|
in.get(xmlbuf, '\0');
|
||||||
|
@ -37,7 +37,7 @@ std::istream& operator >> ( std::istream& in, DBus::Xml::Document& doc )
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator << ( std::ostream& out, const DBus::Xml::Document& doc )
|
std::ostream &operator << (std::ostream &out, const DBus::Xml::Document &doc)
|
||||||
{
|
{
|
||||||
return out << doc.to_xml();
|
return out << doc.to_xml();
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ std::ostream& operator << ( std::ostream& out, const DBus::Xml::Document& doc )
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
using namespace DBus::Xml;
|
using namespace DBus::Xml;
|
||||||
|
|
||||||
Error::Error( const char* error, int line, int column )
|
Error::Error(const char *error, int line, int column)
|
||||||
{
|
{
|
||||||
std::ostringstream estream;
|
std::ostringstream estream;
|
||||||
|
|
||||||
|
@ -54,11 +54,11 @@ Error::Error( const char* error, int line, int column )
|
||||||
_error = estream.str();
|
_error = estream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::Node( const char* n, const char** a )
|
Node::Node(const char *n, const char ** a)
|
||||||
: name(n)
|
: name(n)
|
||||||
{
|
{
|
||||||
if(a)
|
if (a)
|
||||||
for(int i = 0; a[i]; i += 2)
|
for (int i = 0; a[i]; i += 2)
|
||||||
{
|
{
|
||||||
_attrs[a[i]] = a[i+1];
|
_attrs[a[i]] = a[i+1];
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ Node::Node( const char* n, const char** a )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Nodes Nodes::operator[]( const std::string& key )
|
Nodes Nodes::operator[](const std::string &key)
|
||||||
{
|
{
|
||||||
Nodes result;
|
Nodes result;
|
||||||
|
|
||||||
for(iterator i = begin(); i != end(); ++i)
|
for (iterator i = begin(); i != end(); ++i)
|
||||||
{
|
{
|
||||||
Nodes part = (**i)[key];
|
Nodes part = (**i)[key];
|
||||||
|
|
||||||
|
@ -79,43 +79,43 @@ Nodes Nodes::operator[]( const std::string& key )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Nodes Nodes::select( const std::string& attr, const std::string& value )
|
Nodes Nodes::select(const std::string &attr, const std::string &value)
|
||||||
{
|
{
|
||||||
Nodes result;
|
Nodes result;
|
||||||
|
|
||||||
for(iterator i = begin(); i != end(); ++i)
|
for (iterator i = begin(); i != end(); ++i)
|
||||||
{
|
{
|
||||||
if((*i)->get(attr) == value)
|
if ((*i)->get(attr) == value)
|
||||||
result.insert(result.end(), *i);
|
result.insert(result.end(), *i);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Nodes Node::operator[]( const std::string& key )
|
Nodes Node::operator[](const std::string &key)
|
||||||
{
|
{
|
||||||
Nodes result;
|
Nodes result;
|
||||||
|
|
||||||
if(key.length() == 0) return result;
|
if (key.length() == 0) return result;
|
||||||
|
|
||||||
for(Children::iterator i = children.begin(); i != children.end(); ++i)
|
for (Children::iterator i = children.begin(); i != children.end(); ++i)
|
||||||
{
|
{
|
||||||
if(i->name == key)
|
if (i->name == key)
|
||||||
result.push_back(&(*i));
|
result.push_back(&(*i));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Node::get( const std::string& attribute )
|
std::string Node::get(const std::string &attribute)
|
||||||
{
|
{
|
||||||
if(_attrs.find(attribute) != _attrs.end())
|
if (_attrs.find(attribute) != _attrs.end())
|
||||||
return _attrs[attribute];
|
return _attrs[attribute];
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::set( const std::string& attribute, std::string value )
|
void Node::set(const std::string &attribute, std::string value)
|
||||||
{
|
{
|
||||||
if(value.length())
|
if (value.length())
|
||||||
_attrs[attribute] = value;
|
_attrs[attribute] = value;
|
||||||
else
|
else
|
||||||
_attrs.erase(value);
|
_attrs.erase(value);
|
||||||
|
@ -131,17 +131,17 @@ std::string Node::to_xml() const
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::_raw_xml( std::string& xml, int& depth ) const
|
void Node::_raw_xml(std::string &xml, int &depth) const
|
||||||
{
|
{
|
||||||
xml.append(depth*2, ' ');
|
xml.append(depth *2, ' ');
|
||||||
xml.append("<"+name);
|
xml.append("<"+name);
|
||||||
|
|
||||||
for(Attributes::const_iterator i = _attrs.begin(); i != _attrs.end(); ++i)
|
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)
|
if (cdata.length() == 0 && children.size() == 0)
|
||||||
{
|
{
|
||||||
xml.append("/>\n");
|
xml.append("/>\n");
|
||||||
}
|
}
|
||||||
|
@ -149,23 +149,23 @@ void Node::_raw_xml( std::string& xml, int& depth ) const
|
||||||
{
|
{
|
||||||
xml.append(">");
|
xml.append(">");
|
||||||
|
|
||||||
if(cdata.length())
|
if (cdata.length())
|
||||||
{
|
{
|
||||||
xml.append(cdata);
|
xml.append(cdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(children.size())
|
if (children.size())
|
||||||
{
|
{
|
||||||
xml.append("\n");
|
xml.append("\n");
|
||||||
depth++;
|
depth++;
|
||||||
|
|
||||||
for(Children::const_iterator i = children.begin(); i != children.end(); ++i)
|
for (Children::const_iterator i = children.begin(); i != children.end(); ++i)
|
||||||
{
|
{
|
||||||
i->_raw_xml(xml, depth);
|
i->_raw_xml(xml, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
depth--;
|
depth--;
|
||||||
xml.append(depth*2, ' ');
|
xml.append(depth *2, ' ');
|
||||||
}
|
}
|
||||||
xml.append("</"+name+">\n");
|
xml.append("</"+name+">\n");
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ Document::Document()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Document::Document( const std::string& xml )
|
Document::Document(const std::string &xml)
|
||||||
: root(0), _depth(0)
|
: root(0), _depth(0)
|
||||||
{
|
{
|
||||||
from_xml(xml);
|
from_xml(xml);
|
||||||
|
@ -190,15 +190,15 @@ Document::~Document()
|
||||||
struct Document::Expat
|
struct Document::Expat
|
||||||
{
|
{
|
||||||
static void start_doctype_decl_handler(
|
static void start_doctype_decl_handler(
|
||||||
void* data, const XML_Char* name, const XML_Char* sysid, const XML_Char* pubid, int has_internal_subset
|
void *data, const XML_Char *name, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset
|
||||||
);
|
);
|
||||||
static void end_doctype_decl_handler( void* data );
|
static void end_doctype_decl_handler(void *data);
|
||||||
static void start_element_handler( void *data, const XML_Char *name, const XML_Char **atts );
|
static void start_element_handler(void *data, const XML_Char *name, const XML_Char **atts);
|
||||||
static void character_data_handler( void *data, const XML_Char* chars, int len );
|
static void character_data_handler(void *data, const XML_Char *chars, int len);
|
||||||
static void end_element_handler( void *data, const XML_Char *name );
|
static void end_element_handler(void *data, const XML_Char *name);
|
||||||
};
|
};
|
||||||
|
|
||||||
void Document::from_xml( const std::string& xml )
|
void Document::from_xml(const std::string &xml)
|
||||||
{
|
{
|
||||||
_depth = 0;
|
_depth = 0;
|
||||||
delete root;
|
delete root;
|
||||||
|
@ -227,9 +227,9 @@ void Document::from_xml( const std::string& xml )
|
||||||
|
|
||||||
XML_Status status = XML_Parse(parser, xml.c_str(), xml.length(), true);
|
XML_Status status = XML_Parse(parser, xml.c_str(), xml.length(), true);
|
||||||
|
|
||||||
if(status == XML_STATUS_ERROR)
|
if (status == XML_STATUS_ERROR)
|
||||||
{
|
{
|
||||||
const char* error = XML_ErrorString(XML_GetErrorCode(parser));
|
const char *error = XML_ErrorString(XML_GetErrorCode(parser));
|
||||||
int line = XML_GetCurrentLineNumber(parser);
|
int line = XML_GetCurrentLineNumber(parser);
|
||||||
int column = XML_GetCurrentColumnNumber(parser);
|
int column = XML_GetCurrentColumnNumber(parser);
|
||||||
|
|
||||||
|
@ -249,30 +249,30 @@ std::string Document::to_xml() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::Expat::start_doctype_decl_handler(
|
void Document::Expat::start_doctype_decl_handler(
|
||||||
void* data, const XML_Char* name, const XML_Char* sysid, const XML_Char* pubid, int has_internal_subset
|
void *data, const XML_Char *name, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::Expat::end_doctype_decl_handler( void* data )
|
void Document::Expat::end_doctype_decl_handler(void *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::Expat::start_element_handler( void *data, const XML_Char *name, const XML_Char **atts )
|
void Document::Expat::start_element_handler(void *data, const XML_Char *name, const XML_Char **atts)
|
||||||
{
|
{
|
||||||
Document* doc = (Document*)data;
|
Document *doc = (Document *)data;
|
||||||
|
|
||||||
//debug_log("xml:%d -> %s", doc->_depth, name);
|
//debug_log("xml:%d -> %s", doc->_depth, name);
|
||||||
|
|
||||||
if(!doc->root)
|
if (!doc->root)
|
||||||
{
|
{
|
||||||
doc->root = new Node(name, atts);
|
doc->root = new Node(name, atts);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Node::Children* cld = &(doc->root->children);
|
Node::Children *cld = &(doc->root->children);
|
||||||
|
|
||||||
for(int i = 1; i < doc->_depth; ++i)
|
for (int i = 1; i < doc->_depth; ++i)
|
||||||
{
|
{
|
||||||
cld = &(cld->back().children);
|
cld = &(cld->back().children);
|
||||||
}
|
}
|
||||||
|
@ -283,13 +283,13 @@ void Document::Expat::start_element_handler( void *data, const XML_Char *name, c
|
||||||
doc->_depth++;
|
doc->_depth++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::Expat::character_data_handler( void *data, const XML_Char* chars, int len )
|
void Document::Expat::character_data_handler(void *data, const XML_Char *chars, int len)
|
||||||
{
|
{
|
||||||
Document* doc = (Document*)data;
|
Document *doc = (Document *)data;
|
||||||
|
|
||||||
Node* nod = doc->root;
|
Node *nod = doc->root;
|
||||||
|
|
||||||
for(int i = 1; i < doc->_depth; ++i)
|
for (int i = 1; i < doc->_depth; ++i)
|
||||||
{
|
{
|
||||||
nod = &(nod->children.back());
|
nod = &(nod->children.back());
|
||||||
}
|
}
|
||||||
|
@ -298,15 +298,15 @@ void Document::Expat::character_data_handler( void *data, const XML_Char* chars,
|
||||||
x = 0;
|
x = 0;
|
||||||
y = len-1;
|
y = len-1;
|
||||||
|
|
||||||
while(isspace(chars[y]) && y > 0) --y;
|
while (isspace(chars[y]) && y > 0) --y;
|
||||||
while(isspace(chars[x]) && x < y) ++x;
|
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 )
|
void Document::Expat::end_element_handler(void *data, const XML_Char *name)
|
||||||
{
|
{
|
||||||
Document* doc = (Document*)data;
|
Document *doc = (Document *)data;
|
||||||
|
|
||||||
//debug_log("xml:%d <- %s", doc->_depth, name);
|
//debug_log("xml:%d <- %s", doc->_depth, name);
|
||||||
|
|
||||||
|
|
34
tools/xml.h
34
tools/xml.h
|
@ -44,12 +44,12 @@ class Error : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Error( const char* error, int line, int column );
|
Error(const char *error, int line, int column);
|
||||||
|
|
||||||
~Error() throw()
|
~Error() throw()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const char* what() const throw()
|
const char *what() const throw()
|
||||||
{
|
{
|
||||||
return _error.c_str();
|
return _error.c_str();
|
||||||
}
|
}
|
||||||
|
@ -61,13 +61,13 @@ private:
|
||||||
|
|
||||||
class Node;
|
class Node;
|
||||||
|
|
||||||
class Nodes : public std::vector<Node*>
|
class Nodes : public std::vector<Node *>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Nodes operator[]( const std::string& key );
|
Nodes operator[](const std::string &key);
|
||||||
|
|
||||||
Nodes select( const std::string& attr, const std::string& value );
|
Nodes select(const std::string &attr, const std::string &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Node
|
class Node
|
||||||
|
@ -82,21 +82,21 @@ public:
|
||||||
std::string cdata;
|
std::string cdata;
|
||||||
Children children;
|
Children children;
|
||||||
|
|
||||||
Node( std::string& n, Attributes& a )
|
Node(std::string &n, Attributes &a)
|
||||||
: name(n), _attrs(a)
|
: 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 );
|
Nodes operator[](const std::string &key);
|
||||||
|
|
||||||
std::string get( const std::string& attribute );
|
std::string get(const std::string &attribute);
|
||||||
|
|
||||||
void set( const std::string& attribute, std::string value );
|
void set(const std::string &attribute, std::string value);
|
||||||
|
|
||||||
std::string to_xml() const;
|
std::string to_xml() const;
|
||||||
|
|
||||||
Node& add( Node child )
|
Node &add(Node child)
|
||||||
{
|
{
|
||||||
children.push_back(child);
|
children.push_back(child);
|
||||||
return children.back();
|
return children.back();
|
||||||
|
@ -104,7 +104,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void _raw_xml( std::string& xml, int& depth ) const;
|
void _raw_xml(std::string &xml, int &depth) const;
|
||||||
|
|
||||||
Attributes _attrs;
|
Attributes _attrs;
|
||||||
};
|
};
|
||||||
|
@ -115,15 +115,15 @@ public:
|
||||||
|
|
||||||
struct Expat;
|
struct Expat;
|
||||||
|
|
||||||
Node* root;
|
Node *root;
|
||||||
|
|
||||||
Document();
|
Document();
|
||||||
|
|
||||||
Document( const std::string& xml );
|
Document(const std::string &xml);
|
||||||
|
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
void from_xml( const std::string& xml );
|
void from_xml(const std::string &xml);
|
||||||
|
|
||||||
std::string to_xml() const;
|
std::string to_xml() const;
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ private:
|
||||||
|
|
||||||
} /* namespace DBus */
|
} /* namespace DBus */
|
||||||
|
|
||||||
std::istream& operator >> ( std::istream&, DBus::Xml::Document& );
|
std::istream &operator >> (std::istream &, DBus::Xml::Document &);
|
||||||
std::ostream& operator << ( std::ostream&, DBus::Xml::Document& );
|
std::ostream &operator << (std::ostream &, DBus::Xml::Document &);
|
||||||
|
|
||||||
#endif//__DBUSXX_XML_H
|
#endif//__DBUSXX_XML_H
|
||||||
|
|
|
@ -37,66 +37,66 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace DBus;
|
using namespace DBus;
|
||||||
|
|
||||||
static const char* tab = " ";
|
static const char *tab = " ";
|
||||||
|
|
||||||
static const char* header = "\n\
|
static const char *header = "\n\
|
||||||
/*\n\
|
/*\n\
|
||||||
* This file was automatically generated by dbusxx-xml2cpp; DO NOT EDIT!\n\
|
* This file was automatically generated by dbusxx-xml2cpp; DO NOT EDIT!\n\
|
||||||
*/\n\
|
*/\n\
|
||||||
\n\
|
\n\
|
||||||
";
|
";
|
||||||
|
|
||||||
static const char* dbus_includes = "\n\
|
static const char *dbus_includes = "\n\
|
||||||
#include <dbus-c++/dbus.h>\n\
|
#include <dbus-c++/dbus.h>\n\
|
||||||
\n\
|
\n\
|
||||||
";
|
";
|
||||||
|
|
||||||
typedef map<string,string> TypeCache;
|
typedef map<string,string> TypeCache;
|
||||||
|
|
||||||
void usage( const char* argv0 )
|
void usage(const char *argv0)
|
||||||
{
|
{
|
||||||
cerr << endl << "Usage: " << argv0 << " <xmlfile> [ --proxy=<outfile.h> ] [ --adaptor=<outfile.h> ]"
|
cerr << endl << "Usage: " << argv0 << " <xmlfile> [ --proxy=<outfile.h> ] [ --adaptor=<outfile.h> ]"
|
||||||
<< endl << endl;
|
<< endl << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void underscorize( string& str )
|
void underscorize(string &str)
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < str.length(); ++i)
|
for (unsigned int i = 0; i < str.length(); ++i)
|
||||||
{
|
{
|
||||||
if(!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_';
|
if (!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string stub_name( string name )
|
string stub_name(string name)
|
||||||
{
|
{
|
||||||
underscorize(name);
|
underscorize(name);
|
||||||
|
|
||||||
return "_" + name + "_stub";
|
return "_" + name + "_stub";
|
||||||
}
|
}
|
||||||
|
|
||||||
int char_to_atomic_type( char t )
|
int char_to_atomic_type(char t)
|
||||||
{
|
{
|
||||||
if(strchr("ybnqiuxtdsgavre", t))
|
if (strchr("ybnqiuxtdsgavre", t))
|
||||||
return t;
|
return t;
|
||||||
|
|
||||||
return DBUS_TYPE_INVALID;
|
return DBUS_TYPE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* atomic_type_to_string( char t )
|
const char *atomic_type_to_string(char t)
|
||||||
{
|
{
|
||||||
static struct { char type; const char* name; } atos[] =
|
static struct { char type; const char *name; } atos[] =
|
||||||
{
|
{
|
||||||
{ 'y', "::DBus::Byte" },
|
{ 'y', "uint8_t" },
|
||||||
{ 'b', "::DBus::Bool" },
|
{ 'b', "bool" },
|
||||||
{ 'n', "::DBus::Int16" },
|
{ 'n', "int16_t" },
|
||||||
{ 'q', "::DBus::UInt16" },
|
{ 'q', "uint16_t" },
|
||||||
{ 'i', "::DBus::Int32" },
|
{ 'i', "int32_t" },
|
||||||
{ 'u', "::DBus::UInt32" },
|
{ 'u', "uint32_t" },
|
||||||
{ 'x', "::DBus::Int64" },
|
{ 'x', "int64_t" },
|
||||||
{ 't', "::DBus::UInt64" },
|
{ 't', "uint64_t" },
|
||||||
{ 'd', "::DBus::Double" },
|
{ 'd', "double" },
|
||||||
{ 's', "::DBus::String" },
|
{ 's', "std::string" },
|
||||||
{ 'o', "::DBus::Path" },
|
{ 'o', "::DBus::Path" },
|
||||||
{ 'g', "::DBus::Signature" },
|
{ 'g', "::DBus::Signature" },
|
||||||
{ 'v', "::DBus::Variant" },
|
{ 'v', "::DBus::Variant" },
|
||||||
|
@ -104,34 +104,34 @@ const char* atomic_type_to_string( char t )
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; atos[i].type; ++i)
|
for (i = 0; atos[i].type; ++i)
|
||||||
{
|
{
|
||||||
if(atos[i].type == t) break;
|
if (atos[i].type == t) break;
|
||||||
}
|
}
|
||||||
return atos[i].name;
|
return atos[i].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_atomic_type( const string& type )
|
bool is_atomic_type(const string &type)
|
||||||
{
|
{
|
||||||
return type.length() == 1 && char_to_atomic_type(type[0]) != DBUS_TYPE_INVALID;
|
return type.length() == 1 && char_to_atomic_type(type[0]) != DBUS_TYPE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _parse_signature( const string& signature, string& type, unsigned int& i )
|
void _parse_signature(const string &signature, string &type, unsigned int &i)
|
||||||
{
|
{
|
||||||
for(; i < signature.length(); ++i)
|
for (; i < signature.length(); ++i)
|
||||||
{
|
{
|
||||||
switch(signature[i])
|
switch (signature[i])
|
||||||
{
|
{
|
||||||
case 'a':
|
case 'a':
|
||||||
{
|
{
|
||||||
switch(signature[++i])
|
switch (signature[++i])
|
||||||
{
|
{
|
||||||
case '{':
|
case '{':
|
||||||
{
|
{
|
||||||
type += "std::map< ";
|
type += "std::map< ";
|
||||||
|
|
||||||
const char* atom = atomic_type_to_string(signature[++i]);
|
const char *atom = atomic_type_to_string(signature[++i]);
|
||||||
if(!atom)
|
if (!atom)
|
||||||
{
|
{
|
||||||
cerr << "invalid signature" << endl;
|
cerr << "invalid signature" << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -157,7 +157,7 @@ void _parse_signature( const string& signature, string& type, unsigned int& i )
|
||||||
++i;
|
++i;
|
||||||
_parse_signature(signature, type, i);
|
_parse_signature(signature, type, i);
|
||||||
type += " >";
|
type += " >";
|
||||||
if(signature[i+1])
|
if (signature[i+1])
|
||||||
{
|
{
|
||||||
type += ", ";
|
type += ", ";
|
||||||
}
|
}
|
||||||
|
@ -170,15 +170,15 @@ void _parse_signature( const string& signature, string& type, unsigned int& i )
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
const char* atom = atomic_type_to_string(signature[i]);
|
const char *atom = atomic_type_to_string(signature[i]);
|
||||||
if(!atom)
|
if (!atom)
|
||||||
{
|
{
|
||||||
cerr << "invalid signature" << endl;
|
cerr << "invalid signature" << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
type += atom;
|
type += atom;
|
||||||
|
|
||||||
if(signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length())
|
if (signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length())
|
||||||
{
|
{
|
||||||
type += ", ";
|
type += ", ";
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ void _parse_signature( const string& signature, string& type, unsigned int& i )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string signature_to_type( const string& signature )
|
string signature_to_type(const string &signature)
|
||||||
{
|
{
|
||||||
string type;
|
string type;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
|
@ -196,12 +196,12 @@ string signature_to_type( const string& signature )
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_proxy( Xml::Document& doc, const char* filename )
|
void generate_proxy(Xml::Document &doc, const char *filename)
|
||||||
{
|
{
|
||||||
cerr << "writing " << filename << endl;
|
cerr << "writing " << filename << endl;
|
||||||
|
|
||||||
ofstream file(filename);
|
ofstream file(filename);
|
||||||
if(file.bad())
|
if (file.bad())
|
||||||
{
|
{
|
||||||
cerr << "unable to write file " << filename << endl;
|
cerr << "unable to write file " << filename << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -218,12 +218,12 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
|
|
||||||
file << dbus_includes;
|
file << dbus_includes;
|
||||||
|
|
||||||
Xml::Node& root = *(doc.root);
|
Xml::Node &root = *(doc.root);
|
||||||
Xml::Nodes interfaces = root["interface"];
|
Xml::Nodes interfaces = root["interface"];
|
||||||
|
|
||||||
for(Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
|
for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& iface = **i;
|
Xml::Node &iface = **i;
|
||||||
Xml::Nodes methods = iface["method"];
|
Xml::Nodes methods = iface["method"];
|
||||||
Xml::Nodes signals = iface["signal"];
|
Xml::Nodes signals = iface["signal"];
|
||||||
Xml::Nodes properties = iface["property"];
|
Xml::Nodes properties = iface["property"];
|
||||||
|
@ -232,7 +232,7 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
ms.insert(ms.end(), signals.begin(), signals.end());
|
ms.insert(ms.end(), signals.begin(), signals.end());
|
||||||
|
|
||||||
string ifacename = iface.get("name");
|
string ifacename = iface.get("name");
|
||||||
if(ifacename == "org.freedesktop.DBus.Introspectable"
|
if (ifacename == "org.freedesktop.DBus.Introspectable"
|
||||||
||ifacename == "org.freedesktop.DBus.Properties")
|
||ifacename == "org.freedesktop.DBus.Properties")
|
||||||
{
|
{
|
||||||
cerr << "skipping interface " << ifacename << endl;
|
cerr << "skipping interface " << ifacename << endl;
|
||||||
|
@ -243,7 +243,7 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
string nspace;
|
string nspace;
|
||||||
unsigned int nspaces = 0;
|
unsigned int nspaces = 0;
|
||||||
|
|
||||||
while(ss.str().find('.', ss.tellg()) != string::npos)
|
while (ss.str().find('.', ss.tellg()) != string::npos)
|
||||||
{
|
{
|
||||||
getline(ss, nspace, '.');
|
getline(ss, nspace, '.');
|
||||||
|
|
||||||
|
@ -268,9 +268,9 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
<< tab << ": ::DBus::InterfaceProxy(\"" << ifacename << "\")" << endl
|
<< tab << ": ::DBus::InterfaceProxy(\"" << ifacename << "\")" << endl
|
||||||
<< tab << "{" << endl;
|
<< tab << "{" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||||
{
|
{
|
||||||
Xml::Node& signal = **si;
|
Xml::Node &signal = **si;
|
||||||
|
|
||||||
string marshname = "_" + signal.get("name") + "_stub";
|
string marshname = "_" + signal.get("name") + "_stub";
|
||||||
|
|
||||||
|
@ -288,75 +288,75 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
<< tab << " * this functions will invoke the corresponding methods on the remote objects" << endl
|
<< tab << " * this functions will invoke the corresponding methods on the remote objects" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||||
{
|
{
|
||||||
Xml::Node& method = **mi;
|
Xml::Node &method = **mi;
|
||||||
Xml::Nodes args = method["arg"];
|
Xml::Nodes args = method["arg"];
|
||||||
Xml::Nodes args_in = args.select("direction","in");
|
Xml::Nodes args_in = args.select("direction","in");
|
||||||
Xml::Nodes args_out = args.select("direction","out");
|
Xml::Nodes args_out = args.select("direction","out");
|
||||||
|
|
||||||
if(args_out.size() == 0 || args_out.size() > 1 )
|
if (args_out.size() == 0 || args_out.size() > 1)
|
||||||
{
|
{
|
||||||
file << tab << "void ";
|
file << tab << "void ";
|
||||||
}
|
}
|
||||||
else if(args_out.size() == 1)
|
else if (args_out.size() == 1)
|
||||||
{
|
{
|
||||||
file << tab << signature_to_type(args_out.front()->get("type")) << " ";
|
file << tab << signature_to_type(args_out.front()->get("type")) << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
file << method.get("name") << "( ";
|
file << method.get("name") << "(";
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ai;
|
Xml::Node &arg = **ai;
|
||||||
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
||||||
|
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << arg_name;
|
file << arg_name;
|
||||||
else
|
else
|
||||||
file << "argin" << i;
|
file << "argin" << i;
|
||||||
|
|
||||||
if((i+1 != args_in.size() || args_out.size() > 1))
|
if ((i+1 != args_in.size() || args_out.size() > 1))
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args_out.size() > 1)
|
if (args_out.size() > 1)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ao;
|
Xml::Node &arg = **ao;
|
||||||
file << signature_to_type(arg.get("type")) << "&";
|
file << signature_to_type(arg.get("type")) << "&";
|
||||||
|
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << " " << arg_name;
|
file << " " << arg_name;
|
||||||
else
|
else
|
||||||
file << " argout" << i;
|
file << " argout" << i;
|
||||||
|
|
||||||
if(i+1 != args_out.size())
|
if (i+1 != args_out.size())
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file << " )" << endl;
|
file << ")" << endl;
|
||||||
|
|
||||||
file << tab << "{" << endl
|
file << tab << "{" << endl
|
||||||
<< tab << tab << "::DBus::CallMessage call;" << endl;
|
<< tab << tab << "::DBus::CallMessage call;" << endl;
|
||||||
|
|
||||||
if(args_in.size() > 0)
|
if (args_in.size() > 0)
|
||||||
{
|
{
|
||||||
file << tab << tab << "::DBus::MessageIter wi = call.writer();" << endl
|
file << tab << tab << "::DBus::MessageIter wi = call.writer();" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int j = 0;
|
unsigned int j = 0;
|
||||||
for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++j)
|
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++j)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ai;
|
Xml::Node &arg = **ai;
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << tab << tab << "wi << " << arg_name << ";" << endl;
|
file << tab << tab << "wi << " << arg_name << ";" << endl;
|
||||||
else
|
else
|
||||||
file << tab << tab << "wi << argin" << j << ";" << endl;
|
file << tab << tab << "wi << argin" << j << ";" << endl;
|
||||||
|
@ -366,27 +366,27 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
<< tab << tab << "::DBus::Message ret = invoke_method(call);" << endl;
|
<< tab << tab << "::DBus::Message ret = invoke_method(call);" << endl;
|
||||||
|
|
||||||
|
|
||||||
if(args_out.size() > 0)
|
if (args_out.size() > 0)
|
||||||
{
|
{
|
||||||
file << tab << tab << "::DBus::MessageIter ri = ret.reader();" << endl
|
file << tab << tab << "::DBus::MessageIter ri = ret.reader();" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args_out.size() == 1)
|
if (args_out.size() == 1)
|
||||||
{
|
{
|
||||||
file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout;" << endl;
|
file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout;" << endl;
|
||||||
file << tab << tab << "ri >> argout;" << endl;
|
file << tab << tab << "ri >> argout;" << endl;
|
||||||
file << tab << tab << "return argout;" << endl;
|
file << tab << tab << "return argout;" << endl;
|
||||||
}
|
}
|
||||||
else if(args_out.size() > 1)
|
else if (args_out.size() > 1)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ao;
|
Xml::Node &arg = **ao;
|
||||||
|
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << tab << tab << "ri >> " << arg.get("name") << ";" << endl;
|
file << tab << tab << "ri >> " << arg.get("name") << ";" << endl;
|
||||||
else
|
else
|
||||||
file << tab << tab << "ri >> argout" << i << ";" << endl;
|
file << tab << tab << "ri >> argout" << i << ";" << endl;
|
||||||
|
@ -403,29 +403,29 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
<< tab << "/* signal handlers for this interface" << endl
|
<< tab << "/* signal handlers for this interface" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||||
{
|
{
|
||||||
Xml::Node& signal = **si;
|
Xml::Node &signal = **si;
|
||||||
Xml::Nodes args = signal["arg"];
|
Xml::Nodes args = signal["arg"];
|
||||||
|
|
||||||
file << tab << "virtual void " << signal.get("name") << "( ";
|
file << tab << "virtual void " << signal.get("name") << "(";
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
|
for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ai;
|
Xml::Node &arg = **ai;
|
||||||
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
||||||
|
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << arg_name;
|
file << arg_name;
|
||||||
else
|
else
|
||||||
file << "argin" << i;
|
file << "argin" << i;
|
||||||
|
|
||||||
if((ai+1 != args.end()))
|
if ((ai+1 != args.end()))
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
file << " ) = 0;" << endl;
|
file << ") = 0;" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
file << endl
|
file << endl
|
||||||
|
@ -434,28 +434,28 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
<< tab << "/* unmarshalers (to unpack the DBus message before calling the actual signal handler)" << endl
|
<< tab << "/* unmarshalers (to unpack the DBus message before calling the actual signal handler)" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||||
{
|
{
|
||||||
Xml::Node& signal = **si;
|
Xml::Node &signal = **si;
|
||||||
Xml::Nodes args = signal["arg"];
|
Xml::Nodes args = signal["arg"];
|
||||||
|
|
||||||
file << tab << "void " << stub_name(signal.get("name")) << "( const ::DBus::SignalMessage& sig )" << endl
|
file << tab << "void " << stub_name(signal.get("name")) << "(const ::DBus::SignalMessage &sig)" << endl
|
||||||
<< tab << "{" << endl;
|
<< tab << "{" << endl;
|
||||||
|
|
||||||
if(args.size() > 0)
|
if (args.size() > 0)
|
||||||
{
|
{
|
||||||
file << tab << tab << "::DBus::MessageIter ri = sig.reader();" << endl
|
file << tab << tab << "::DBus::MessageIter ri = sig.reader();" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
|
for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ai;
|
Xml::Node &arg = **ai;
|
||||||
file << tab << tab << signature_to_type(arg.get("type")) << " " ;
|
file << tab << tab << signature_to_type(arg.get("type")) << " " ;
|
||||||
|
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << arg_name << ";" << " ri >> " << arg_name << ";" << endl;
|
file << arg_name << ";" << " ri >> " << arg_name << ";" << endl;
|
||||||
else
|
else
|
||||||
file << "arg" << i << ";" << " ri >> " << "arg" << i << ";" << endl;
|
file << "arg" << i << ";" << " ri >> " << "arg" << i << ";" << endl;
|
||||||
|
@ -464,17 +464,17 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
file << tab << tab << signal.get("name") << "(";
|
file << tab << tab << signal.get("name") << "(";
|
||||||
|
|
||||||
unsigned int j = 0;
|
unsigned int j = 0;
|
||||||
for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++j)
|
for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++j)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ai;
|
Xml::Node &arg = **ai;
|
||||||
|
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << arg_name;
|
file << arg_name;
|
||||||
else
|
else
|
||||||
file << "arg" << j;
|
file << "arg" << j;
|
||||||
|
|
||||||
if(ai+1 != args.end())
|
if (ai+1 != args.end())
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
file << "};" << endl
|
file << "};" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < nspaces; ++i)
|
for (unsigned int i = 0; i < nspaces; ++i)
|
||||||
{
|
{
|
||||||
file << "} ";
|
file << "} ";
|
||||||
}
|
}
|
||||||
|
@ -499,12 +499,12 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_adaptor( Xml::Document& doc, const char* filename )
|
void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
{
|
{
|
||||||
cerr << "writing " << filename << endl;
|
cerr << "writing " << filename << endl;
|
||||||
|
|
||||||
ofstream file(filename);
|
ofstream file(filename);
|
||||||
if(file.bad())
|
if (file.bad())
|
||||||
{
|
{
|
||||||
cerr << "unable to write file " << filename << endl;
|
cerr << "unable to write file " << filename << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -521,12 +521,12 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
|
|
||||||
file << dbus_includes;
|
file << dbus_includes;
|
||||||
|
|
||||||
Xml::Node& root = *(doc.root);
|
Xml::Node &root = *(doc.root);
|
||||||
Xml::Nodes interfaces = root["interface"];
|
Xml::Nodes interfaces = root["interface"];
|
||||||
|
|
||||||
for(Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
|
for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& iface = **i;
|
Xml::Node &iface = **i;
|
||||||
Xml::Nodes methods = iface["method"];
|
Xml::Nodes methods = iface["method"];
|
||||||
Xml::Nodes signals = iface["signal"];
|
Xml::Nodes signals = iface["signal"];
|
||||||
Xml::Nodes properties = iface["property"];
|
Xml::Nodes properties = iface["property"];
|
||||||
|
@ -535,7 +535,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
ms.insert(ms.end(), signals.begin(), signals.end());
|
ms.insert(ms.end(), signals.begin(), signals.end());
|
||||||
|
|
||||||
string ifacename = iface.get("name");
|
string ifacename = iface.get("name");
|
||||||
if(ifacename == "org.freedesktop.DBus.Introspectable"
|
if (ifacename == "org.freedesktop.DBus.Introspectable"
|
||||||
||ifacename == "org.freedesktop.DBus.Properties")
|
||ifacename == "org.freedesktop.DBus.Properties")
|
||||||
{
|
{
|
||||||
cerr << "skipping interface " << ifacename << endl;
|
cerr << "skipping interface " << ifacename << endl;
|
||||||
|
@ -546,7 +546,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
string nspace;
|
string nspace;
|
||||||
unsigned int nspaces = 0;
|
unsigned int nspaces = 0;
|
||||||
|
|
||||||
while(ss.str().find('.', ss.tellg()) != string::npos)
|
while (ss.str().find('.', ss.tellg()) != string::npos)
|
||||||
{
|
{
|
||||||
getline(ss, nspace, '.');
|
getline(ss, nspace, '.');
|
||||||
|
|
||||||
|
@ -571,26 +571,26 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
<< tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl
|
<< tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl
|
||||||
<< tab << "{" << endl;
|
<< tab << "{" << endl;
|
||||||
|
|
||||||
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;
|
Xml::Node &property = **pi;
|
||||||
|
|
||||||
file << tab << tab << "bind_property("
|
file << tab << tab << "bind_property("
|
||||||
<< property.get("name") << ", "
|
<< property.get("name") << ", "
|
||||||
<< "\"" << property.get("type") << "\", "
|
<< "\"" << property.get("type") << "\", "
|
||||||
<< ( property.get("access").find("read") != string::npos
|
<< (property.get("access").find("read") != string::npos
|
||||||
? "true"
|
? "true"
|
||||||
: "false" )
|
: "false")
|
||||||
<< ", "
|
<< ", "
|
||||||
<< ( property.get("access").find("write") != string::npos
|
<< (property.get("access").find("write") != string::npos
|
||||||
? "true"
|
? "true"
|
||||||
: "false" )
|
: "false")
|
||||||
<< ");" << endl;
|
<< ");" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||||
{
|
{
|
||||||
Xml::Node& method = **mi;
|
Xml::Node &method = **mi;
|
||||||
|
|
||||||
file << tab << tab << "register_method("
|
file << tab << tab << "register_method("
|
||||||
<< ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name"))
|
<< ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name"))
|
||||||
|
@ -600,24 +600,24 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
file << tab << "}" << endl
|
file << tab << "}" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
file << tab << "::DBus::IntrospectedInterface* const introspect() const " << endl
|
file << tab << "::DBus::IntrospectedInterface *const introspect() const " << endl
|
||||||
<< tab << "{" << endl;
|
<< tab << "{" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi)
|
for (Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi)
|
||||||
{
|
{
|
||||||
Xml::Node& method = **mi;
|
Xml::Node &method = **mi;
|
||||||
Xml::Nodes args = method["arg"];
|
Xml::Nodes args = method["arg"];
|
||||||
|
|
||||||
file << tab << tab << "static ::DBus::IntrospectedArgument " << method.get("name") << "_args[] = " << endl
|
file << tab << tab << "static ::DBus::IntrospectedArgument " << method.get("name") << "_args[] = " << endl
|
||||||
<< tab << tab << "{" << endl;
|
<< tab << tab << "{" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai)
|
for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ai;
|
Xml::Node &arg = **ai;
|
||||||
|
|
||||||
file << tab << tab << tab << "{ ";
|
file << tab << tab << tab << "{ ";
|
||||||
|
|
||||||
if(arg.get("name").length())
|
if (arg.get("name").length())
|
||||||
{
|
{
|
||||||
file << "\"" << arg.get("name") << "\", ";
|
file << "\"" << arg.get("name") << "\", ";
|
||||||
}
|
}
|
||||||
|
@ -626,7 +626,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
file << "0, ";
|
file << "0, ";
|
||||||
}
|
}
|
||||||
file << "\"" << arg.get("type") << "\", "
|
file << "\"" << arg.get("type") << "\", "
|
||||||
<< ( arg.get("direction") == "in" ? "true" : "false" )
|
<< (arg.get("direction") == "in" ? "true" : "false")
|
||||||
<< " }," << endl;
|
<< " }," << endl;
|
||||||
}
|
}
|
||||||
file << tab << tab << tab << "{ 0, 0, 0 }" << endl
|
file << tab << tab << tab << "{ 0, 0, 0 }" << endl
|
||||||
|
@ -636,9 +636,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl
|
file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl
|
||||||
<< tab << tab << "{" << endl;
|
<< tab << tab << "{" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||||
{
|
{
|
||||||
Xml::Node& method = **mi;
|
Xml::Node &method = **mi;
|
||||||
|
|
||||||
file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl;
|
file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl;
|
||||||
}
|
}
|
||||||
|
@ -649,9 +649,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_signals[] = " << endl
|
file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_signals[] = " << endl
|
||||||
<< tab << tab << "{" << endl;
|
<< tab << tab << "{" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||||
{
|
{
|
||||||
Xml::Node& method = **si;
|
Xml::Node &method = **si;
|
||||||
|
|
||||||
file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl;
|
file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl;
|
||||||
}
|
}
|
||||||
|
@ -662,20 +662,20 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
file << tab << tab << "static ::DBus::IntrospectedProperty " << ifaceclass << "_properties[] = " << endl
|
file << tab << tab << "static ::DBus::IntrospectedProperty " << ifaceclass << "_properties[] = " << endl
|
||||||
<< tab << tab << "{" << endl;
|
<< tab << tab << "{" << endl;
|
||||||
|
|
||||||
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;
|
Xml::Node &property = **pi;
|
||||||
|
|
||||||
file << tab << tab << tab << "{ "
|
file << tab << tab << tab << "{ "
|
||||||
<< "\"" << property.get("name") << "\", "
|
<< "\"" << property.get("name") << "\", "
|
||||||
<< "\"" << property.get("type") << "\", "
|
<< "\"" << property.get("type") << "\", "
|
||||||
<< ( property.get("access").find("read") != string::npos
|
<< (property.get("access").find("read") != string::npos
|
||||||
? "true"
|
? "true"
|
||||||
: "false" )
|
: "false")
|
||||||
<< ", "
|
<< ", "
|
||||||
<< ( property.get("access").find("write") != string::npos
|
<< (property.get("access").find("write") != string::npos
|
||||||
? "true"
|
? "true"
|
||||||
: "false" )
|
: "false")
|
||||||
<< " }," << endl;
|
<< " }," << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,9 +700,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
<< tab << " * property() and property(value) to get and set a particular property" << endl
|
<< tab << " * property() and property(value) to get and set a particular property" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
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;
|
Xml::Node &property = **pi;
|
||||||
string name = property.get("name");
|
string name = property.get("name");
|
||||||
string type = property.get("type");
|
string type = property.get("type");
|
||||||
string type_name = signature_to_type(type);
|
string type_name = signature_to_type(type);
|
||||||
|
@ -718,57 +718,57 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
<< tab << " * you will have to implement them in your ObjectAdaptor" << endl
|
<< tab << " * you will have to implement them in your ObjectAdaptor" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||||
{
|
{
|
||||||
Xml::Node& method = **mi;
|
Xml::Node &method = **mi;
|
||||||
Xml::Nodes args = method["arg"];
|
Xml::Nodes args = method["arg"];
|
||||||
Xml::Nodes args_in = args.select("direction","in");
|
Xml::Nodes args_in = args.select("direction","in");
|
||||||
Xml::Nodes args_out = args.select("direction","out");
|
Xml::Nodes args_out = args.select("direction","out");
|
||||||
|
|
||||||
file << tab << "virtual ";
|
file << tab << "virtual ";
|
||||||
|
|
||||||
if(args_out.size() == 0 || args_out.size() > 1 )
|
if (args_out.size() == 0 || args_out.size() > 1)
|
||||||
{
|
{
|
||||||
file << "void ";
|
file << "void ";
|
||||||
}
|
}
|
||||||
else if(args_out.size() == 1)
|
else if (args_out.size() == 1)
|
||||||
{
|
{
|
||||||
file << signature_to_type(args_out.front()->get("type")) << " ";
|
file << signature_to_type(args_out.front()->get("type")) << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
file << method.get("name") << "( ";
|
file << method.get("name") << "(";
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ai;
|
Xml::Node &arg = **ai;
|
||||||
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
||||||
|
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << arg_name;
|
file << arg_name;
|
||||||
|
|
||||||
if((i+1 != args_in.size() || args_out.size() > 1))
|
if ((i+1 != args_in.size() || args_out.size() > 1))
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args_out.size() > 1)
|
if (args_out.size() > 1)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ao;
|
Xml::Node &arg = **ao;
|
||||||
file << signature_to_type(arg.get("type")) << "&";
|
file << signature_to_type(arg.get("type")) << "&";
|
||||||
|
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
if(arg_name.length())
|
if (arg_name.length())
|
||||||
file << " " << arg_name;
|
file << " " << arg_name;
|
||||||
|
|
||||||
if(i+1 != args_out.size())
|
if (i+1 != args_out.size())
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file << " ) = 0;" << endl;
|
file << ") = 0;" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
file << endl
|
file << endl
|
||||||
|
@ -777,34 +777,34 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
<< tab << "/* signal emitters for this interface" << endl
|
<< tab << "/* signal emitters for this interface" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||||
{
|
{
|
||||||
Xml::Node& signal = **si;
|
Xml::Node &signal = **si;
|
||||||
Xml::Nodes args = signal["arg"];
|
Xml::Nodes args = signal["arg"];
|
||||||
|
|
||||||
file << tab << "void " << signal.get("name") << "( ";
|
file << tab << "void " << signal.get("name") << "(";
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i)
|
for (Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **a;
|
Xml::Node &arg = **a;
|
||||||
|
|
||||||
file << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1;
|
file << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1;
|
||||||
|
|
||||||
if(i+1 != args.size())
|
if (i+1 != args.size())
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
file << " )" << endl
|
file << ")" << endl
|
||||||
<< tab << "{" << endl
|
<< tab << "{" << endl
|
||||||
<< tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl;;
|
<< tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl;;
|
||||||
|
|
||||||
|
|
||||||
if(args.size() > 0)
|
if (args.size() > 0)
|
||||||
{
|
{
|
||||||
file << tab << tab << "::DBus::MessageIter wi = sig.writer();" << endl;
|
file << tab << tab << "::DBus::MessageIter wi = sig.writer();" << endl;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < args.size(); ++i)
|
for (unsigned int i = 0; i < args.size(); ++i)
|
||||||
{
|
{
|
||||||
file << tab << tab << "wi << arg" << i+1 << ";" << endl;
|
file << tab << tab << "wi << arg" << i+1 << ";" << endl;
|
||||||
}
|
}
|
||||||
|
@ -820,40 +820,40 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
<< tab << "/* unmarshalers (to unpack the DBus message before calling the actual interface method)" << endl
|
<< tab << "/* unmarshalers (to unpack the DBus message before calling the actual interface method)" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||||
{
|
{
|
||||||
Xml::Node& method = **mi;
|
Xml::Node &method = **mi;
|
||||||
Xml::Nodes args = method["arg"];
|
Xml::Nodes args = method["arg"];
|
||||||
Xml::Nodes args_in = args.select("direction","in");
|
Xml::Nodes args_in = args.select("direction","in");
|
||||||
Xml::Nodes args_out = args.select("direction","out");
|
Xml::Nodes args_out = args.select("direction","out");
|
||||||
|
|
||||||
file << tab << "::DBus::Message " << stub_name(method.get("name")) << "( const ::DBus::CallMessage& call )" << endl
|
file << tab << "::DBus::Message " << stub_name(method.get("name")) << "(const ::DBus::CallMessage &call)" << endl
|
||||||
<< tab << "{" << endl
|
<< tab << "{" << endl
|
||||||
<< tab << tab << "::DBus::MessageIter ri = call.reader();" << endl
|
<< tab << tab << "::DBus::MessageIter ri = call.reader();" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
unsigned int i = 1;
|
unsigned int i = 1;
|
||||||
for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ai;
|
Xml::Node &arg = **ai;
|
||||||
file << tab << tab << signature_to_type(arg.get("type")) << " argin" << i << ";"
|
file << tab << tab << signature_to_type(arg.get("type")) << " argin" << i << ";"
|
||||||
<< " ri >> argin" << i << ";" << endl;
|
<< " ri >> argin" << i << ";" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args_out.size() == 0)
|
if (args_out.size() == 0)
|
||||||
{
|
{
|
||||||
file << tab << tab;
|
file << tab << tab;
|
||||||
}
|
}
|
||||||
else if(args_out.size() == 1)
|
else if (args_out.size() == 1)
|
||||||
{
|
{
|
||||||
file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout1 = ";
|
file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout1 = ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int i = 1;
|
unsigned int i = 1;
|
||||||
for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||||
{
|
{
|
||||||
Xml::Node& arg = **ao;
|
Xml::Node &arg = **ao;
|
||||||
file << tab << tab << signature_to_type(arg.get("type")) << " argout" << i << ";" << endl;
|
file << tab << tab << signature_to_type(arg.get("type")) << " argout" << i << ";" << endl;
|
||||||
}
|
}
|
||||||
file << tab << tab;
|
file << tab << tab;
|
||||||
|
@ -861,20 +861,20 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
|
|
||||||
file << method.get("name") << "(";
|
file << method.get("name") << "(";
|
||||||
|
|
||||||
for(unsigned int i = 0; i < args_in.size(); ++i)
|
for (unsigned int i = 0; i < args_in.size(); ++i)
|
||||||
{
|
{
|
||||||
file << "argin" << i+1;
|
file << "argin" << i+1;
|
||||||
|
|
||||||
if((i+1 != args_in.size() || args_out.size() > 1))
|
if ((i+1 != args_in.size() || args_out.size() > 1))
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args_out.size() > 1)
|
if (args_out.size() > 1)
|
||||||
for(unsigned int i = 0; i < args_out.size(); ++i)
|
for (unsigned int i = 0; i < args_out.size(); ++i)
|
||||||
{
|
{
|
||||||
file << "argout" << i+1;
|
file << "argout" << i+1;
|
||||||
|
|
||||||
if(i+1 != args_out.size())
|
if (i+1 != args_out.size())
|
||||||
file << ", ";
|
file << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,11 +882,11 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
|
|
||||||
file << tab << tab << "::DBus::ReturnMessage reply(call);" << endl;
|
file << tab << tab << "::DBus::ReturnMessage reply(call);" << endl;
|
||||||
|
|
||||||
if(args_out.size() > 0)
|
if (args_out.size() > 0)
|
||||||
{
|
{
|
||||||
file << tab << tab << "::DBus::MessageIter wi = reply.writer();" << endl;
|
file << tab << tab << "::DBus::MessageIter wi = reply.writer();" << endl;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < args_out.size(); ++i)
|
for (unsigned int i = 0; i < args_out.size(); ++i)
|
||||||
{
|
{
|
||||||
file << tab << tab << "wi << argout" << i+1 << ";" << endl;
|
file << tab << tab << "wi << argout" << i+1 << ";" << endl;
|
||||||
}
|
}
|
||||||
|
@ -900,7 +900,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
file << "};" << endl
|
file << "};" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < nspaces; ++i)
|
for (unsigned int i = 0; i < nspaces; ++i)
|
||||||
{
|
{
|
||||||
file << "} ";
|
file << "} ";
|
||||||
}
|
}
|
||||||
|
@ -912,9 +912,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
if(argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
@ -928,26 +928,26 @@ int main( int argc, char** argv )
|
||||||
adaptor_mode = false;
|
adaptor_mode = false;
|
||||||
adaptor = 0;
|
adaptor = 0;
|
||||||
|
|
||||||
for(int a = 1; a < argc; ++a)
|
for (int a = 1; a < argc; ++a)
|
||||||
{
|
{
|
||||||
if(!strncmp(argv[a], "--proxy=", 8))
|
if (!strncmp(argv[a], "--proxy=", 8))
|
||||||
{
|
{
|
||||||
proxy_mode = true;
|
proxy_mode = true;
|
||||||
proxy = argv[a] +8;
|
proxy = argv[a] +8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if(!strncmp(argv[a], "--adaptor=", 10))
|
if (!strncmp(argv[a], "--adaptor=", 10))
|
||||||
{
|
{
|
||||||
adaptor_mode = true;
|
adaptor_mode = true;
|
||||||
adaptor = argv[a] +10;
|
adaptor = argv[a] +10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!proxy_mode && !adaptor_mode) usage(argv[0]);
|
if (!proxy_mode && !adaptor_mode) usage(argv[0]);
|
||||||
|
|
||||||
ifstream xmlfile(argv[1]);
|
ifstream xmlfile(argv[1]);
|
||||||
|
|
||||||
if(xmlfile.bad())
|
if (xmlfile.bad())
|
||||||
{
|
{
|
||||||
cerr << "unable to open file " << argv[1] << endl;
|
cerr << "unable to open file " << argv[1] << endl;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -960,20 +960,20 @@ int main( int argc, char** argv )
|
||||||
xmlfile >> doc;
|
xmlfile >> doc;
|
||||||
//cout << doc.to_xml();
|
//cout << doc.to_xml();
|
||||||
}
|
}
|
||||||
catch(Xml::Error& e)
|
catch(Xml::Error &e)
|
||||||
{
|
{
|
||||||
cerr << "error parsing " << argv[1] << ": " << e.what() << endl;
|
cerr << "error parsing " << argv[1] << ": " << e.what() << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!doc.root)
|
if (!doc.root)
|
||||||
{
|
{
|
||||||
cerr << "empty document" << endl;
|
cerr << "empty document" << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(proxy_mode) generate_proxy(doc, proxy);
|
if (proxy_mode) generate_proxy(doc, proxy);
|
||||||
if(adaptor_mode) generate_adaptor(doc, adaptor);
|
if (adaptor_mode) generate_adaptor(doc, adaptor);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue