1 /* -*- mode: C; c-file-style: "gnu" -*- */
3 * dbus-qt.h Qt integration
5 * Copyright (C) 2002 DBus Developers
7 * Licensed under the Academic Free License version 1.2
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 #include <dbus/dbus.h>
30 * Two approaches - one presented below a DBusQtConnection
31 * object which is a Qt wrapper around DBusConnection
32 class DBusQtConnection : public QObject {
35 DBusQtConnection( const char *address=0, QObject *parent=0,
38 bool open( const char *address );
39 bool isConnected() const;
40 int numMessages() const;
45 void sendMessage( DBusMessage *message );
48 void message( DBusMessage* message );
49 void error( const char* error );
51 DBusConnection *mConnection;
52 QSocketNotifier *mReadNotifier;
53 QSocketNotifier *mWriteNotifier;
56 * Second approach is to have a static Qt dispatcher like:
57 class DBusQtNotifier : public QObject {
60 static DBusQtNotifier* dbus_qt_notifier();
61 void addConnection(DBusConnection* connection);
63 void message (DBusConnection* connection, DBusMessage* message);
66 DBusQtNotifier(QObject *parent);
68 void processNotifiers( int socket );
70 //implemented in terms of QSocketNotifiers
71 QAsciiDict<DBusConnection> mReadNotifiers;
72 QAsciiDict<DBusConnection> mWriteNotifiers;
75 * First one gives us a full wrapper for DBusConnection (the Qt way),
76 * the other exposes DBusConnection, so would be easier to maintain
77 * and keep up while DBus evolves.
81 #endif /* DBUS_QT_H */