Original DBUS bindings for TQt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.4KB

  1. /* -*- mode: C; c-file-style: "gnu" -*- */
  2. /*
  3. * dbus-qt.h TQt integration
  4. *
  5. * Copyright (C) 2002 DBus Developers
  6. *
  7. * Licensed under the Academic Free License version 2.1
  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_TQT_H
  26. #define DBUS_TQT_H
  27. #include <dbus/dbus.h>
  28. /*
  29. * Two approaches - one presented below a DBusQtConnection
  30. * object which is a TQt wrapper around DBusConnection
  31. class DBusQtConnection : public TQObject {
  32. Q_OBJECT
  33. public:
  34. DBusQtConnection( const char *address=0, TQObject *parent=0,
  35. const char *name=0 );
  36. bool open( const char *address );
  37. bool isConnected() const;
  38. int numMessages() const;
  39. public slots:
  40. void disconnect();
  41. void flush();
  42. void sendMessage( DBusMessage *message );
  43. signals:
  44. void message( DBusMessage* message );
  45. void error( const char* error );
  46. private:
  47. DBusConnection *mConnection;
  48. TQSocketNotifier *mReadNotifier;
  49. TQSocketNotifier *mWriteNotifier;
  50. };
  51. *
  52. * Second approach is to have a static TQt dispatcher like:
  53. class DBusQtNotifier : public TQObject {
  54. Q_OBJECT
  55. public:
  56. static DBusQtNotifier* dbus_qt_notifier();
  57. void addConnection(DBusConnection* connection);
  58. signals:
  59. void message (DBusConnection* connection, DBusMessage* message);
  60. private:
  61. DBusQtNotifier(TQObject *parent);
  62. private slots:
  63. void processNotifiers( int socket );
  64. private:
  65. //implemented in terms of TQSocketNotifiers
  66. TQAsciiDict<DBusConnection> mReadNotifiers;
  67. TQAsciiDict<DBusConnection> mWriteNotifiers;
  68. };
  69. *
  70. * First one gives us a full wrapper for DBusConnection (the TQt way),
  71. * the other exposes DBusConnection, so would be easier to maintain
  72. * and keep up while DBus evolves.
  73. *
  74. */
  75. #endif /* DBUS_TQT_H */