DBus-1-TQt  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tqdbusconnection_p.h
Go to the documentation of this file.
1 /* qdbusconnection_p.h TQT_DBusConnection private object
2  *
3  * Copyright (C) 2005 Harald Fernengel <harry@kdevelop.org>
4  * Copyright (C) 2005 Kevin Krammer <kevin.krammer@gmx.at>
5  *
6  * Licensed under the Academic Free License version 2.1
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21  * USA.
22  *
23  */
24 
25 //
26 // W A R N I N G
27 // -------------
28 //
29 // This file is not part of the public API. This header file may
30 // change from version to version without notice, or even be
31 // removed.
32 //
33 // We mean it.
34 //
35 //
36 
37 #ifndef TQDBUSCONNECTION_P_H
38 #define TQDBUSCONNECTION_P_H
39 
40 #include <tqguardedptr.h>
41 #include <tqmap.h>
42 #include <tqobject.h>
43 #include <tqvaluelist.h>
44 
45 #include <dbus/dbus.h>
46 
47 #include "tqdbusatomic.h"
48 #include "tqdbuserror.h"
49 #include "tqdbusobject.h"
50 #include "tqdbusmessage.h"
51 
52 class TQT_DBusMessage;
53 class TQSocketNotifier;
54 class TQTimer;
55 class TQTimerEvent;
56 
57 struct DBusConnection;
58 struct DBusServer;
59 
61 {
62  public:
64  TQObject* receiver;
65  TQCString method;
66 };
68 
69 class TQT_DBusConnectionPrivate: public TQObject
70 {
71  Q_OBJECT
72 
73 
74 public:
75  TQT_DBusConnectionPrivate(TQObject *parent = 0);
77 
78  void bindToApplication();
79 
80  void setConnection(DBusConnection *connection);
81  void setServer(DBusServer *server);
82  void closeConnection();
83  void timerEvent(TQTimerEvent *e);
84 
85  bool handleSignal(DBusMessage *msg);
86  bool handleObjectCall(DBusMessage *message);
87  bool handleError();
88 
89  void emitPendingCallReply(const TQT_DBusMessage& message);
90 
91 signals:
92  void dbusSignal(const TQT_DBusMessage& message);
93 
94  void dbusPendingCallReply(const TQT_DBusMessage& message);
95 
96 public slots:
97  void socketRead(int);
98  void socketWrite(int);
99 
100  void objectDestroyed(TQObject* object);
101 
102  void purgeRemovedWatches();
103 
104  void scheduleDispatch();
105  void dispatch();
106 
107 public:
108  DBusError error;
110 
112 
113  // FIXME TQAtomic ref;
116  DBusConnection *connection;
117  DBusServer *server;
118 
119  TQTimer* dispatcher;
120 
121  static int messageMetaType;
122  static int registerMessageMetaType();
123  int sendWithReplyAsync(const TQT_DBusMessage &message, TQObject *receiver,
124  const char *method);
125  void flush();
126 
127  struct Watcher
128  {
129  Watcher(): watch(0), read(0), write(0) {}
130  DBusWatch *watch;
131  TQSocketNotifier *read;
132  TQSocketNotifier *write;
133  };
134  // FIXME typedef TQMultiHash<int, Watcher> WatcherHash;
136  WatcherList removedWatches;
137  typedef TQMap<int, WatcherList> WatcherHash;
138  WatcherHash watchers;
139 
140  // FIXME typedef TQHash<int, DBusTimeout *> TimeoutHash;
141  typedef TQMap<int, DBusTimeout*> TimeoutHash;
142  TimeoutHash timeouts;
143 
144  typedef TQMap<TQString, TQT_DBusObjectBase*> ObjectMap;
145  ObjectMap registeredObjects;
146 
148 
150  {
151  TQGuardedPtr<TQObject> receiver;
152  TQCString method;
153  DBusPendingCall *pending;
154  };
155  typedef TQMap<DBusPendingCall*, TQT_DBusPendingCall*> PendingCallMap;
156  PendingCallMap pendingCalls;
157 
159  PendingMessagesForEmit pendingMessages;
160 
162 
164 
165 public:
167 
168 private slots:
171 
172 private:
175 };
176 
177 #endif
bool handleSignal(DBusMessage *msg)
void setConnection(DBusConnection *connection)
void dbusPendingCallReply(const TQT_DBusMessage &message)
PendingMessagesForEmit pendingMessages
TQValueList< DBusTimeout * > pendingTimeouts
bool handleObjectCall(DBusMessage *message)
TQMap< int, DBusTimeout * > TimeoutHash
TQMap< int, WatcherList > WatcherHash
void emitPendingCallReply(const TQT_DBusMessage &message)
Class for transporting D-Bus errors.
Definition: tqdbuserror.h:40
TQValueList< TQT_DBusResultInfo > TQT_DBusResultInfoList
TQT_DBusMessage message
TQValueList< Watcher > WatcherList
int sendWithReplyAsync(const TQT_DBusMessage &message, TQObject *receiver, const char *method)
TQMap< DBusPendingCall *, TQT_DBusPendingCall * > PendingCallMap
void dbusSignal(const TQT_DBusMessage &message)
A message converts and transports data over D-Bus.
TQT_DBusResultInfoList m_resultEmissionQueue
void objectDestroyed(TQObject *object)
TQT_DBusConnectionPrivate(TQObject *parent=0)
void timerEvent(TQTimerEvent *e)
void setServer(DBusServer *server)
TQMap< TQString, TQT_DBusObjectBase * > ObjectMap
TQValueList< TQT_DBusMessage > PendingMessagesForEmit