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