Debian Codegraph @

src/imports/serviceframework/qdeclarativeserviceold_p.h

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSystems module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ***************************************************************************/
39
40 #ifndef QDECLARATIVESERVICEOLD_P_H
41 #define QDECLARATIVESERVICEOLD_P_H
42
43 //
44 // W A R N I N G
45 // -------------
46 //
47 // This file is not part of the Qt API. It exists purely as an
48 // implementation detail. This header file may change from version to
49 // version without notice, or even be removed.
50 //
51 // We mean it.
52 //
53
54 #include <QtCore>
55 #include <qserviceinterfacedescriptor.h>
56 #include <qservicemanager.h>
57 #include <qqml.h>
58 #include <qqmllist.h>
59
60 QT_BEGIN_NAMESPACE
61
62 class QDeclarativeService : public QObject, public QQmlParserStatus {
63 Q_OBJECT
64 Q_INTERFACES(QQmlParserStatus)
65 Q_PROPERTY(QString interfaceName READ interfaceName WRITE setInterfaceName NOTIFY interfaceNameChanged)
66 Q_PROPERTY(QString serviceName READ serviceName WRITE setServiceName NOTIFY serviceNameChanged)
67 Q_PROPERTY(int majorVersion READ majorVersion WRITE setMajorVersion NOTIFY majorVersionChanged)
68 Q_PROPERTY(int minorVersion READ minorVersion WRITE setMinorVersion NOTIFY minorVersionChanged)
69 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
70 Q_PROPERTY(QObject* serviceObject READ serviceObject NOTIFY serviceObjectChanged)
71 Q_PROPERTY(QString error READ lastError NOTIFY error)
72
73 public:
74 QDeclarativeService();
75 ~QDeclarativeService();
76
77 void setInterfaceDesc(const QServiceInterfaceDescriptor& desc);
78 QServiceInterfaceDescriptor interfaceDesc() const;
79
80 void setInterfaceName(const QString& serviceInterface);
81 QString interfaceName() const;
82 QString serviceName() const;
83 void setServiceName(const QString &service);
84 int majorVersion() const;
85 void setMajorVersion(int version);
86 int minorVersion() const;
87 void setMinorVersion(int version);
88 QString lastError() const;
89
90 bool isValid() const;
91 QObject* serviceObject();
92
93 //Derived from QDeclarativeParserStatus
94 virtual void classBegin();
95 virtual void componentComplete();
96
97 bool operator== ( const QServiceInterfaceDescriptor& other ) const;
98
99 Q_SIGNALS:
100 void validChanged();
101 void serviceObjectChanged();
102 void interfaceNameChanged();
103 void serviceNameChanged();
104 void majorVersionChanged();
105 void minorVersionChanged();
106
107 void error(const QString &errorString);
108
109 private slots:
110 void IPCFault(QService::UnrecoverableIPCError);
111
112 private:
113 void updateDescriptor();
114 void setServiceObject(QObject *object);
115
116 QPointer<QObject> m_serviceInstance;
117 QServiceManager* m_serviceManager;
118
119 QServiceInterfaceDescriptor m_descriptor;
120
121 int m_minor;
122 int m_major;
123 QString m_service;
124 QString m_interface;
125
126 QString m_error;
127
128 bool m_componentComplete;
129 };
130
131
132 class QDeclarativeServiceList : public QObject, public QQmlParserStatus {
133 Q_OBJECT
134 Q_INTERFACES(QQmlParserStatus)
135 Q_PROPERTY(QString serviceName READ serviceName WRITE setServiceName NOTIFY serviceNameChanged)
136 Q_PROPERTY(QString interfaceName READ interfaceName WRITE setInterfaceName NOTIFY interfaceNameChanged)
137 Q_PROPERTY(int majorVersion READ majorVersion WRITE setMajorVersion NOTIFY majorVersionChanged)
138 Q_PROPERTY(int minorVersion READ minorVersion WRITE setMinorVersion NOTIFY minorVersionChanged)
139 Q_PROPERTY(bool monitorServiceRegistrations READ monitorServiceRegistrations WRITE setMonitorServiceRegistrations NOTIFY monitorServiceRegistrationsChanged)
140 Q_PROPERTY(QQmlListProperty<QDeclarativeService> services READ services NOTIFY resultsChanged)
141
142 Q_PROPERTY(MatchRule versionMatch READ versionMatch WRITE setVersionMatch NOTIFY versionMatchChanged)
143 Q_ENUMS(MatchRule)
144
145 public:
146 enum MatchRule {
147 Minimum = 0,
148 Exact
149 };
150
151 QDeclarativeServiceList();
152 ~QDeclarativeServiceList();
153
154 QQmlListProperty<QDeclarativeService> services();
155
156 void setServiceName(const QString& service);
157 QString serviceName() const;
158
159 void setInterfaceName(const QString& serviceInterface);
160 QString interfaceName() const;
161
162 void setMinorVersion(int minor);
163 int minorVersion() const;
164
165 void setMajorVersion(int major);
166 int majorVersion() const;
167
168 void setMonitorServiceRegistrations(bool updates);
169 bool monitorServiceRegistrations() const;
170
171 void setVersionMatch(QDeclarativeServiceList::MatchRule match);
172 QDeclarativeServiceList::MatchRule versionMatch() const;
173
174 void listUpdated();
175
176 //Derived from QDeclarativeParserStatus
177 virtual void classBegin();
178 virtual void componentComplete();
179
180 Q_SIGNALS:
181 void resultsChanged();
182 void servicesChanged(const QQmlListProperty<QDeclarativeService>&);
183 void serviceNameChanged();
184 void interfaceNameChanged();
185 void minorVersionChanged();
186 void majorVersionChanged();
187 void versionMatchChanged();
188 void monitorServiceRegistrationsChanged();
189
190 protected slots:
191 void servicesAddedRemoved();
192 void updateFilterResults();
193 void updateServiceList();
194
195 private:
196 QList<QDeclarativeService *> m_services;
197 QList<QServiceInterfaceDescriptor> m_currentList;
198 QServiceManager* serviceManager;
199 QString m_service;
200 QString m_interface;
201 int m_major;
202 int m_minor;
203 QDeclarativeServiceList::MatchRule m_match;
204 bool m_componentComplete;
205 bool m_dynamicUpdates;
206
207 static void s_append(QQmlListProperty<QDeclarativeService> *prop, QDeclarativeService *service);
208 static int s_count(QQmlListProperty<QDeclarativeService> *prop);
209 static QDeclarativeService* s_at(QQmlListProperty<QDeclarativeService> *prop, int index);
210 static void s_clear(QQmlListProperty<QDeclarativeService> *prop);
211 };
212
213 QT_END_NAMESPACE
214
215 QML_DECLARE_TYPE(QDeclarativeService);
216 QML_DECLARE_TYPE(QDeclarativeServiceList);
217
218 #endif //QDECLARATIVESERVICEOLD_P_H