Main Page | Modules | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Namespace Members | Data Fields | Related Pages

dbus-qt.h

00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /*
00003  * dbus-qt.h Qt integration
00004  *
00005  * Copyright (C)  2002  DBus Developers
00006  *
00007  * Licensed under the Academic Free License version 2.1
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00022  * 02111-1307  USA
00023  *
00024  */
00025 #ifndef DBUS_QT_H
00026 #define DBUS_QT_H
00027 
00028 #include <dbus/dbus.h>
00029 /*
00030  * Two approaches - one presented below a DBusQtConnection
00031  * object which is a Qt wrapper around DBusConnection
00032 class DBusQtConnection : public QObject {
00033   Q_OBJECT
00034 public:
00035   DBusQtConnection( const char *address=0, QObject *parent=0,
00036                     const char *name=0 );
00037 
00038   bool         open( const char *address );
00039   bool         isConnected() const;
00040   int          numMessages() const;
00041 
00042 public slots:
00043   void disconnect();
00044   void flush();
00045   void sendMessage( DBusMessage *message );
00046 
00047 signals:
00048   void message( DBusMessage* message );
00049   void error( const char* error );
00050 private:
00051   DBusConnection  *mConnection;
00052   QSocketNotifier *mReadNotifier;
00053   QSocketNotifier *mWriteNotifier;
00054 };
00055  *
00056  * Second approach is to have a static Qt dispatcher like:
00057 class DBusQtNotifier : public QObject {
00058   Q_OBJECT
00059 public:
00060   static DBusQtNotifier* dbus_qt_notifier();
00061   void addConnection(DBusConnection* connection);
00062 signals:
00063   void message (DBusConnection* connection, DBusMessage* message);
00064 
00065 private:
00066   DBusQtNotifier(QObject *parent);
00067 private slots:
00068   void processNotifiers( int socket );
00069 private:
00070   //implemented in terms of QSocketNotifiers
00071   QAsciiDict<DBusConnection> mReadNotifiers;
00072   QAsciiDict<DBusConnection> mWriteNotifiers;
00073 };
00074  *
00075  * First one gives us a full wrapper for DBusConnection (the Qt way),
00076  * the other exposes DBusConnection, so would be easier to maintain
00077  * and keep up while DBus evolves.
00078  *
00079  */
00080 
00081 #endif /* DBUS_QT_H */

Generated on Tue Sep 13 01:28:07 2005 for D-BUS by  doxygen 1.4.4