1 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 /* connection.cpp: Qt wrapper for DBusConnection
4 * Copyright (C) 2003 Zack Rusin <zack@kde.org>
6 * Licensed under the Academic Free License version 1.2
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "connection.h"
25 using namespace DBusQt;
27 #include "integrator.h"
28 using Internal::Integrator;
30 struct Connection::Private
32 DBusConnection *connection;
35 Integrator *integrator;
38 Connection::Connection( const QString& host )
41 d->integrator = new Integrator( this );
42 connect( d->integrator, SIGNAL(readReady()),
43 SLOT(dispatchRead()) );
47 if ( !host.isEmpty() )
51 void Connection::initDbus()
55 void Connection::init( const QString& host )
57 dbus_error_init( &d->error );
58 d->connection = dbus_connection_open( host.ascii(), &d->error );
59 //dbus_connection_allocate_data_slot( &d->connectionSlot );
60 //dbus_connection_set_data( d->connection, d->connectionSlot, 0, 0 );
64 bool Connection::isConnected() const
68 bool Connection::isAuthenticated() const
72 void Connection::open( const QString& host )
74 if ( host.isEmpty() ) return;
79 void Connection::close()
81 dbus_connection_disconnect( d->connection );
84 void Connection::flush()
86 dbus_connection_flush( d->connection );
89 void Connection::dispatchRead()
91 while ( dbus_connection_dispatch( d->connection ) == DBUS_DISPATCH_DATA_REMAINS )
95 DBusConnection* Connection::connection() const
100 /////////////////////////////////////////////////////////
102 #include "connection.moc"