index.html
Main Page
|
modules.html
Modules
|
namespaces.html
Namespace List
|
hierarchy.html
Class Hierarchy
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
namespacemembers.html
Namespace Members
|
functions.html
Data Fields
|
pages.html
Related Pages
dir_000003.html
qt
connection.cpp
00001
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002
/* connection.cpp: Qt wrapper for DBusConnection
00003
*
00004
* Copyright (C) 2003  Zack Rusin <zack@kde.org>
00005
*
00006
* Licensed under the Academic Free License version 2.0
00007
*
00008
* This program is free software; you can redistribute it and/or modify
00009
* it under the terms of the GNU General Public License as published by
00010
* the Free Software Foundation; either version 2 of the License, or
00011
* (at your option) any later version.
00012
*
00013
* This program is distributed in the hope that it will be useful,
00014
* but WITHOUT ANY WARRANTY; without even the implied warranty of
00015
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016
* GNU General Public License for more details.
00017
*
00018
* You should have received a copy of the GNU General Public License
00019
* along with this program; if not, write to the Free Software
00020
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021
*
00022
*/
00023
#include "connection.h"
00024
00025
using
namespace
DBusQt;
00026
00027
#include "integrator.h"
00028
using
classDBusQt_1_1Internal_1_1Integrator.html
Internal::Integrator
;
00029
structConnection_1_1Private.html
00030
struct
structConnection_1_1Private.html
Connection::Private
00031 {
00032
structConnection_1_1Private.html#a0
Private
(
classDBusQt_1_1Connection.html
Connection
*qq );
00033
void
structConnection_1_1Private.html#a1
setConnection
(
structDBusConnection.html
DBusConnection
*c );
structConnection_1_1Private.html#o0
00034
structDBusConnection.html
DBusConnection
*
structConnection_1_1Private.html#o0
connection
;
structConnection_1_1Private.html#o1
00035
int
structConnection_1_1Private.html#o1
connectionSlot
;
structConnection_1_1Private.html#o2
00036
structDBusError.html
DBusError
structConnection_1_1Private.html#o2
error
;
structConnection_1_1Private.html#o3
00037
classDBusQt_1_1Internal_1_1Integrator.html
Integrator
*
structConnection_1_1Private.html#o3
integrator
;
structConnection_1_1Private.html#o4
00038
int
structConnection_1_1Private.html#o4
timeout
;
structConnection_1_1Private.html#o5
00039
classDBusQt_1_1Connection.html
Connection
*
structConnection_1_1Private.html#o5
q
;
00040 };
00041
structConnection_1_1Private.html#a0
00042
structConnection_1_1Private.html#a0
Connection::Private::Private
(
classDBusQt_1_1Connection.html
Connection
*qq )
00043   : connection( 0 ), connectionSlot( 0 ), integrator( 0 ),
00044     timeout( -1 ), q( qq )
00045 {
00046
group__DBusErrors.html#ga0
dbus_error_init
( &
structConnection_1_1Private.html#o2
error
);
00047 }
00048
structConnection_1_1Private.html#a1
00049
void
structConnection_1_1Private.html#a1
Connection::Private::setConnection
(
structDBusConnection.html
DBusConnection
*c )
00050 {
00051
if
(!c) {
00052     qDebug(
"error: %s, %s"
,
structConnection_1_1Private.html#o2
error
.
structDBusError.html#o0
name
,
structConnection_1_1Private.html#o2
error
.
structDBusError.html#o1
message
);
00053
group__DBusErrors.html#ga1
dbus_error_free
( &
structConnection_1_1Private.html#o2
error
);
00054
return
;
00055   }
00056
structConnection_1_1Private.html#o0
connection
= c;
00057
structConnection_1_1Private.html#o3
integrator
=
new
classDBusQt_1_1Internal_1_1Integrator.html
Integrator
( c,
structConnection_1_1Private.html#o5
q
);
00058   connect(
structConnection_1_1Private.html#o3
integrator
, SIGNAL(readReady()),
structConnection_1_1Private.html#o5
q
, SLOT(dispatchRead()) );
00059 }
00060
00061 Connection::Connection( QObject *parent )
00062   : QObject( parent )
00063 {
00064   d =
new
structConnection_1_1Private.html#a0
Private
(
this
);
00065 }
00066
00067 Connection::Connection(
const
QString& host, QObject *parent )
00068   : QObject( parent )
00069 {
00070   d =
new
structConnection_1_1Private.html#a0
Private
(
this
);
00071
00072
if
( !host.isEmpty() )
00073     init( host );
00074 }
00075
00076 Connection::Connection( DBusBusType type, QObject* parent )
00077   : QObject( parent )
00078 {
00079   d =
new
structConnection_1_1Private.html#a0
Private
(
this
);
00080   d->setConnection(
group__DBusBus.html#ga0
dbus_bus_get
(type, &d->error) );
00081 }
00082
00083
void
Connection::init(
const
QString& host )
00084 {
00085   d->setConnection(
group__DBusConnection.html#ga1
dbus_connection_open
( host.ascii(), &d->error) );
00086
//dbus_connection_allocate_data_slot( &d->connectionSlot );
00087
//dbus_connection_set_data( d->connection, d->connectionSlot, 0, 0 );
00088 }
00089
00090
bool
Connection::isConnected()
const
00091
{
00092
return
group__DBusConnection.html#ga9
dbus_connection_get_is_connected
( d->connection );
00093 }
00094
00095
bool
Connection::isAuthenticated()
const
00096
{
00097
return
group__DBusConnection.html#ga10
dbus_connection_get_is_authenticated
( d->connection );
00098 }
00099
00100
void
Connection::open(
const
QString& host )
00101 {
00102
if
( host.isEmpty() )
return
;
00103
00104   init( host );
00105 }
00106
00107
void
Connection::close()
00108 {
00109
group__DBusConnection.html#ga7
dbus_connection_disconnect
( d->connection );
00110 }
00111
00112
void
Connection::flush()
00113 {
00114
group__DBusConnection.html#ga27
dbus_connection_flush
( d->connection );
00115 }
00116
00117
void
Connection::dispatchRead()
00118 {
00119
while
(
group__DBusConnection.html#ga40
dbus_connection_dispatch
( d->connection ) == DBUS_DISPATCH_DATA_REMAINS )
00120     ;
00121 }
00122
00123
structDBusConnection.html
DBusConnection
* Connection::connection()
const
00124
{
00125
return
d->connection;
00126 }
00127
00128 Connection::Connection(
structDBusConnection.html
DBusConnection
*connection, QObject *parent  )
00129   : QObject( parent )
00130 {
00131   d =
new
structConnection_1_1Private.html#a0
Private
(
this
);
00132   d->setConnection(connection);
00133 }
00134
00135
void
Connection::send(
const
classDBusQt_1_1Message.html
Message
&m )
00136 {
00137
group__DBusConnection.html#ga20
dbus_connection_send
(d->connection, m.
classDBusQt_1_1Message.html#b0
message
(), 0);
00138 }
00139
00140
void
Connection::sendWithReply(
const
classDBusQt_1_1Message.html
Message
& )
00141 {
00142 }
00143
00144
classDBusQt_1_1Message.html
Message
Connection::sendWithReplyAndBlock(
const
classDBusQt_1_1Message.html
Message
&m )
00145 {
00146
structDBusMessage.html
DBusMessage
*reply;
00147   reply =
group__DBusConnection.html#ga26
dbus_connection_send_with_reply_and_block
( d->connection, m.
classDBusQt_1_1Message.html#b0
message
(), d->timeout, &d->error );
00148
if
(
group__DBusErrors.html#ga5
dbus_error_is_set
(&d->error)) {
00149       qDebug(
"error: %s, %s"
, d->error.name, d->error.message);
00150
group__DBusErrors.html#ga1
dbus_error_free
(&d->error);
00151   }
00152
return
classDBusQt_1_1Message.html
Message
( reply );
00153 }
00154
00155
void
* Connection::virtual_hook(
int
,
void
*  )
00156 {
00157
return
(
void
*)
group__DBusMacros.html#ga4
NULL
;
00158 }
00159
00160
void
Connection::dbus_connection_setup_with_qt_main (
structDBusConnection.html
DBusConnection
*connection)
00161 {
00162   d->setConnection( connection );
00163 }
00164
00165
00166
00168
00169
#include "connection.moc"
Generated on Tue Sep 13 01:28:06 2005 for D-BUS by
http://www.doxygen.org/index.html
doxygen
1.4.4
