| 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 QSERVICEDATABASE_H_ |
| 41 |
#define QSERVICEDATABASE_H_ |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
#include "qserviceframeworkglobal.h" |
| 55 |
#include <QtSql> |
| 56 |
#include <QList> |
| 57 |
#include "servicemetadata_p.h" |
| 58 |
#include "qservicefilter.h" |
| 59 |
#include "dberror_p.h" |
| 60 |
|
| 61 |
QT_BEGIN_NAMESPACE |
| 62 |
|
| 63 |
class QServiceInterfaceDescriptor; |
| 64 |
|
| 65 |
class Q_AUTOTEST_EXPORT ServiceDatabase : public QObject |
| 66 |
{ |
| 67 |
Q_OBJECT |
| 68 |
|
| 69 |
public: |
| 70 |
ServiceDatabase(void); |
| 71 |
|
| 72 |
virtual ~ServiceDatabase(); |
| 73 |
|
| 74 |
bool open(); |
| 75 |
bool close(); |
| 76 |
|
| 77 |
bool isOpen() const; |
| 78 |
void setDatabasePath(const QString &databasePath); |
| 79 |
QString databasePath() const; |
| 80 |
|
| 81 |
bool registerService(const ServiceMetaDataResults &service, const QString &securityToken = QString()); |
| 82 |
bool unregisterService(const QString &serviceName, const QString &securityToken = QString()); |
| 83 |
bool serviceInitialized(const QString &serviceName, const QString &securityToken = QString()); |
| 84 |
|
| 85 |
QList<QServiceInterfaceDescriptor> getInterfaces(const QServiceFilter &filter); |
| 86 |
QServiceInterfaceDescriptor getInterface(const QString &interfaceID); |
| 87 |
QString getInterfaceID(const QServiceInterfaceDescriptor &serviceInterface); |
| 88 |
QStringList getServiceNames(const QString &interfaceName); |
| 89 |
|
| 90 |
QServiceInterfaceDescriptor interfaceDefault(const QString &interfaceName, |
| 91 |
QString *interfaceID = 0, bool inTransaction = false); |
| 92 |
bool setInterfaceDefault(const QServiceInterfaceDescriptor &serviceInterface, |
| 93 |
const QString &externalInterfaceID = QString()); |
| 94 |
QList<QPair<QString,QString> > externalDefaultsInfo(); |
| 95 |
bool removeExternalDefaultServiceInterface(const QString &interfaceID); |
| 96 |
|
| 97 |
DBError lastError() const { return m_lastError; } |
| 98 |
|
| 99 |
Q_SIGNALS: |
| 100 |
void serviceAdded(const QString& serviceName); |
| 101 |
void serviceRemoved(const QString& serviceName); |
| 102 |
|
| 103 |
#ifdef QT_BUILD_INTERNAL |
| 104 |
public: |
| 105 |
#else |
| 106 |
private: |
| 107 |
#endif |
| 108 |
enum TransactionType{Read, Write}; |
| 109 |
|
| 110 |
bool createTables(); |
| 111 |
bool dropTables(); |
| 112 |
bool checkTables(); |
| 113 |
|
| 114 |
bool checkConnection(); |
| 115 |
|
| 116 |
bool executeQuery(QSqlQuery *query, const QString &statement, const QList<QVariant> &bindValues = QList<QVariant>()); |
| 117 |
QString getInterfaceID(QSqlQuery *query, const QServiceInterfaceDescriptor &serviceInterface); |
| 118 |
bool insertInterfaceData(QSqlQuery *query, const QServiceInterfaceDescriptor &anInterface, const QString &serviceID); |
| 119 |
|
| 120 |
bool beginTransaction(QSqlQuery *query, TransactionType); |
| 121 |
bool commitTransaction(QSqlQuery *query); |
| 122 |
bool rollbackTransaction(QSqlQuery *query); |
| 123 |
|
| 124 |
bool populateInterfaceProperties(QServiceInterfaceDescriptor *descriptor, const QString &interfaceID); |
| 125 |
bool populateServiceProperties(QServiceInterfaceDescriptor *descriptor, const QString &serviceID); |
| 126 |
|
| 127 |
QString m_databasePath; |
| 128 |
QString m_connectionName; |
| 129 |
bool m_isDatabaseOpen; |
| 130 |
bool m_inTransaction; |
| 131 |
DBError m_lastError; |
| 132 |
}; |
| 133 |
|
| 134 |
QT_END_NAMESPACE |
| 135 |
|
| 136 |
#endif |