| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
#ifndef QDECLARATIVESERVICEOLD_P_H |
| 41 |
#define QDECLARATIVESERVICEOLD_P_H |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 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 |
|
| 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 |
|
| 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 |