71bfb5829c7b1b7b192f104d1a6a8850fd3d5e27
[platform/upstream/dbus.git] / qt / qdbusabstractadaptor_p.h
1 /* -*- mode: C++; set-fill-width: 100 -*-
2  *
3  * Copyright (C) 2006 Trolltech AS. All rights reserved.
4  *    Author: Thiago Macieira <thiago.macieira@trolltech.com>
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 Foundation
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  */
23
24 //
25 //  W A R N I N G
26 //  -------------
27 //
28 // This file is not part of the public API.  This header file may
29 // change from version to version without notice, or even be
30 // removed.
31 //
32 // We mean it.
33 //
34 //
35
36 #ifndef QDBUSABSTRACTADAPTORPRIVATE_H
37 #define QDBUSABSTRACTADAPTORPRIVATE_H
38
39 #include <QtCore/qobject.h>
40 #include <QtCore/qmap.h>
41 #include <QtCore/qhash.h>
42 #include <QtCore/qreadwritelock.h>
43 #include <QtCore/qvariant.h>
44 #include <QtCore/qvector.h>
45
46 #define QCLASSINFO_DBUS_INTERFACE       "D-Bus Interface"
47 #define QCLASSINFO_DBUS_INTROSPECTION   "D-Bus Introspection"
48
49 class QDBusAbstractAdaptor;
50 class QDBusAdaptorConnector;
51 class QDBusAdaptorManager;
52 class QDBusConnectionPrivate;
53
54 #if QT_VERSION < 0x040200
55 /* mirrored in qobject_p.h, DON'T CHANGE without prior warning */
56 struct QSignalSpyCallbackSet
57 {
58     typedef void (*BeginCallback)(QObject *caller, int method_index, void **argv);
59     typedef void (*EndCallback)(QObject *caller, int method_index);
60     BeginCallback signal_begin_callback,
61                     slot_begin_callback;
62     EndCallback signal_end_callback,
63                 slot_end_callback;
64 };
65 #else
66 # error Qt 4.2.0 is supposed to have a better solution!
67   CHOKE!
68 #endif  // Qt 4.2.0
69
70 class QDBusAbstractAdaptorPrivate
71 {
72 public:
73     QString xml;
74
75     static QString retrieveIntrospectionXml(QDBusAbstractAdaptor *adaptor);
76     static void saveIntrospectionXml(QDBusAbstractAdaptor *adaptor, const QString &xml);
77 };
78
79 class QDBusAdaptorConnector: public QObject
80 {
81     Q_OBJECT
82 public: // typedefs
83     struct AdaptorData
84     {
85         QString interface;
86         QDBusAbstractAdaptor *adaptor;
87         const QMetaObject *metaObject;
88
89         inline bool operator<(const AdaptorData &other) const
90         { return interface < other.interface; }
91         inline bool operator<(const QString &other) const
92         { return interface < other; }
93     };
94     typedef QVector<AdaptorData> AdaptorMap;
95
96 public: // methods
97     explicit QDBusAdaptorConnector(QObject *parent);
98     ~QDBusAdaptorConnector();
99
100     void addAdaptor(QDBusAbstractAdaptor *adaptor);
101     void relay(QObject *sender);
102
103 public slots:
104     void relaySlot();
105     void polish();
106
107 signals:
108     void relaySignal(QObject *obj, const char *interface, const char *name, const QVariantList &args);
109
110 public: // member variables
111     AdaptorMap adaptors;
112     bool waitingForPolish : 1;
113
114     int lastSignalIdx;
115     void **argv;
116     const QMetaObject *senderMetaObject;
117
118 public: // static members
119     static void signalBeginCallback(QObject *caller, int method_index, void **argv);
120     static void signalEndCallback(QObject *caller, int method_index);
121     //static int id;
122 };
123
124 extern QDBusAdaptorConnector *qDBusFindAdaptorConnector(QObject *object);
125 extern QDBusAdaptorConnector *qDBusCreateAdaptorConnector(QObject *object);
126
127 #endif // QDBUSABSTRACTADAPTORPRIVATE_H