adjusted ctor and getter function to KDE/Qt conventions
[platform/upstream/dbus.git] / qt / dbus-qt.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /*
3  * dbus-qt.h Qt integration
4  *
5  * Copyright (C)  2002  DBus Developers
6  *
7  * Licensed under the Academic Free License version 1.2
8  *
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.
13  *
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.
18  *
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
22  * 02111-1307  USA
23  *
24  */
25 #ifndef DBUS_QT_H
26 #define DBUS_QT_H
27
28 #include <dbus/dbus.h>
29 /*
30  * Two approaches - one presented below a DBusQtConnection
31  * object which is a Qt wrapper around DBusConnection
32 class DBusQtConnection : public QObject {
33   Q_OBJECT
34 public:
35   DBusQtConnection( const char *address=0, QObject *parent=0,
36                     const char *name=0 );
37
38   bool         open( const char *address );
39   bool         isConnected() const;
40   int          numMessages() const;
41
42 public slots:
43   void disconnect();
44   void flush();
45   void sendMessage( DBusMessage *message );
46
47 signals:
48   void message( DBusMessage* message );
49   void error( const char* error );
50 private:
51   DBusConnection  *mConnection;
52   QSocketNotifier *mReadNotifier;
53   QSocketNotifier *mWriteNotifier;
54 };
55  *
56  * Second approach is to have a static Qt dispatcher like:
57 class DBusQtNotifier : public QObject {
58   Q_OBJECT
59 public:
60   static DBusQtNotifier* dbus_qt_notifier();
61   void addConnection(DBusConnection* connection);
62 signals:
63   void message (DBusConnection* connection, DBusMessage* message);
64
65 private:
66   DBusQtNotifier(QObject *parent);
67 private slots:
68   void processNotifiers( int socket );
69 private:
70   //implemented in terms of QSocketNotifiers
71   QAsciiDict<DBusConnection> mReadNotifiers;
72   QAsciiDict<DBusConnection> mWriteNotifiers;
73 };
74  *
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.
78  *
79  */
80
81 #endif /* DBUS_QT_H */