imported D-Bus C++ library
git-svn-id: http://dev.openwengo.org/svn/openwengo/wengophone-ng/branches/wengophone-dbus-api/libs/dbus@7382 30a43799-04e7-0310-8b2b-ea0d24f86d0e
This commit is contained in:
commit
acfeb85b87
89 changed files with 92818 additions and 0 deletions
115
src/server.cpp
Normal file
115
src/server.cpp
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
*
|
||||
* D-Bus++ - C++ bindings for DBus
|
||||
*
|
||||
* Copyright (C) 2005-2006 Paolo Durante <shackan@gmail.com>
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <dbus-c++/debug.h>
|
||||
#include <dbus-c++/server.h>
|
||||
|
||||
#include "internalerror.h"
|
||||
#include "server_p.h"
|
||||
#include "connection_p.h"
|
||||
#include "dispatcher_p.h"
|
||||
|
||||
using namespace DBus;
|
||||
|
||||
Server::Private::Private( DBusServer* s )
|
||||
: server(s)
|
||||
{
|
||||
dbus_server_set_new_connection_function(server, on_new_conn_cb, this, NULL);
|
||||
}
|
||||
|
||||
void Server::Private::on_new_conn_cb( DBusServer* server, DBusConnection* conn, void* data )
|
||||
{
|
||||
//Private* p = static_cast<Private*>(data);
|
||||
|
||||
//m->on_new_connection(nc); //TODO
|
||||
|
||||
Connection nc(new Connection::Private(conn));
|
||||
|
||||
debug_log("incoming connection");
|
||||
}
|
||||
|
||||
Server::Server( const char* address )
|
||||
{
|
||||
InternalError e;
|
||||
DBusServer* server = dbus_server_listen(address, e);
|
||||
|
||||
if(e) throw Error(e);
|
||||
|
||||
_pvt = new Private(server);
|
||||
}
|
||||
|
||||
Server::Server( const Server& s )
|
||||
: _pvt(s._pvt)
|
||||
{
|
||||
dbus_server_ref(_pvt->server);
|
||||
}
|
||||
|
||||
Server::~Server()
|
||||
{
|
||||
dbus_server_unref(_pvt->server);
|
||||
}
|
||||
|
||||
Dispatcher* Server::setup( Dispatcher* dispatcher )
|
||||
{
|
||||
debug_log("registering stubs for server %p", _pvt->server);
|
||||
|
||||
Dispatcher* prev = _pvt->dispatcher;
|
||||
|
||||
dbus_server_set_watch_functions(
|
||||
_pvt->server,
|
||||
Dispatcher::Private::on_add_watch,
|
||||
Dispatcher::Private::on_rem_watch,
|
||||
Dispatcher::Private::on_toggle_watch,
|
||||
dispatcher,
|
||||
0
|
||||
);
|
||||
|
||||
dbus_server_set_timeout_functions(
|
||||
_pvt->server,
|
||||
Dispatcher::Private::on_add_timeout,
|
||||
Dispatcher::Private::on_rem_timeout,
|
||||
Dispatcher::Private::on_toggle_timeout,
|
||||
dispatcher,
|
||||
0
|
||||
);
|
||||
|
||||
_pvt->dispatcher = dispatcher;
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
bool Server::operator == ( const Server& s ) const
|
||||
{
|
||||
return _pvt->server == s._pvt->server;
|
||||
}
|
||||
|
||||
bool Server::listening() const
|
||||
{
|
||||
return dbus_server_get_is_connected(_pvt->server);
|
||||
}
|
||||
void Server::disconnect()
|
||||
{
|
||||
dbus_server_disconnect(_pvt->server);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue