From b0fbf9dae591dc839e14a087c1d69189e3fe9461 Mon Sep 17 00:00:00 2001 From: "Jarkko T. Toivonen" Date: Thu, 15 Sep 2011 15:40:51 +0300 Subject: Fix the incorrect sizeHint given by QLabel on Symbian Using the S60 clientRect width in the QLabel size hint calculation (instead of assuming that 80 characters will fit on one line). Task-number: QTBUG-14318 Reviewed-by: Murray Read --- src/gui/widgets/qlabel.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp index ab88f38..c0be3e1 100644 --- a/src/gui/widgets/qlabel.cpp +++ b/src/gui/widgets/qlabel.cpp @@ -59,6 +59,10 @@ #include #endif +#ifdef Q_OS_SYMBIAN +#include "qt_s60_p.h" +#endif + QT_BEGIN_NAMESPACE /*! @@ -698,7 +702,11 @@ QSize QLabelPrivate::sizeForWidth(int w) const bool tryWidth = (w < 0) && (align & Qt::TextWordWrap); if (tryWidth) +#ifdef Q_OS_SYMBIAN + w = qMin(S60->clientRect().Width(), q->maximumSize().width()); +#else w = qMin(fm.averageCharWidth() * 80, q->maximumSize().width()); +#endif else if (w < 0) w = 2000; w -= (hextra + contentsMargin.width()); -- cgit v0.12 From a0ad54acd33873316908080f432768fdf3e3bfc2 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 19 Sep 2011 14:34:04 +0100 Subject: symbian bearer: fix tst_qnetworksession test failures Symbian is not reporting the expected KLinkLayerClosed event on the last RConnection handle. Instead, it reports the event KConfigDaemonFinishedDeregistrationStop, which indicates the nif plugin is being destroyed (this is followed by unload events) To fix, this event is treated the same as a link down event, and results in the state change to disconnected. Either there has been a behaviour change in the platform, or the test was previously run with another user of the API running in the background (e.g. WLAN wizard, connection monitor) which prevented the unload. Task-Number: QTBUG-21382 Reviewed-By: mread --- src/plugins/bearer/symbian/qnetworksession_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index fc65b86..a7dad2b 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -1377,6 +1377,9 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne newState(QNetworkSession::Closing,accessPointId); break; + // Connection stopped + case KConfigDaemonFinishedDeregistrationStop: //this comes if this is the last session, instead of KLinkLayerClosed + case KConfigDaemonFinishedDeregistrationPreserve: // Connection closed case KConnectionClosed: case KLinkLayerClosed: -- cgit v0.12 From 3dd9e66baaa0848bcc2eb7daecf2b63724624358 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Mon, 19 Sep 2011 10:43:14 -0300 Subject: dos2unix on a webkit source file (fix support for Visual Studio) webkit/Source/WebCore/bindings/js/JSExceptionBase.h had CRLF terminations, which Visual Studio didn't like for some reason. Reported by Simo Falt. Patch is also being submited to upstream (webkit.org) --- .../Source/WebCore/bindings/js/JSExceptionBase.h | 86 +++++++++++----------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/3rdparty/webkit/Source/WebCore/bindings/js/JSExceptionBase.h b/src/3rdparty/webkit/Source/WebCore/bindings/js/JSExceptionBase.h index 01c6ac2..a9366ed 100644 --- a/src/3rdparty/webkit/Source/WebCore/bindings/js/JSExceptionBase.h +++ b/src/3rdparty/webkit/Source/WebCore/bindings/js/JSExceptionBase.h @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSExceptionBase_h -#define JSExceptionBase_h - -namespace JSC { - -class JSValue; - -} // namespace JSC - -namespace WebCore { - -class ExceptionBase; - -ExceptionBase* toExceptionBase(JSC::JSValue); - -} // namespace WebCore - -#endif // JSExceptionBase_h +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSExceptionBase_h +#define JSExceptionBase_h + +namespace JSC { + +class JSValue; + +} // namespace JSC + +namespace WebCore { + +class ExceptionBase; + +ExceptionBase* toExceptionBase(JSC::JSValue); + +} // namespace WebCore + +#endif // JSExceptionBase_h -- cgit v0.12 From 3489808c1dcd157ac09dd6da16bc057b56696d59 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Tue, 20 Sep 2011 11:12:04 -0300 Subject: Workaround MSVC2010 problems when linking QtWebKit Include MSVC2010 in the list of compilers where incremental build is disabled (INCREMENTAL:NO). Change suggested by Simo Falt --- src/3rdparty/webkit/Source/WebCore/WebCore.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/Source/WebCore/WebCore.pri b/src/3rdparty/webkit/Source/WebCore/WebCore.pri index 82311d2..00357a1 100644 --- a/src/3rdparty/webkit/Source/WebCore/WebCore.pri +++ b/src/3rdparty/webkit/Source/WebCore/WebCore.pri @@ -303,7 +303,7 @@ win32-* { } # Remove whole program optimizations due to miscompilations -win32-msvc2005|win32-msvc2008|wince*:{ +win32-msvc2005|win32-msvc2008|win32-msvc2010|wince*:{ QMAKE_CFLAGS_RELEASE -= -GL QMAKE_CXXFLAGS_RELEASE -= -GL -- cgit v0.12 From 94a18b734a67ee59bc3ac48012c48d06d1362e8b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 20 Sep 2011 15:53:38 +0100 Subject: symbian: Implement QNetworkConfiguration::purpose() QNetworkConfiguration::purpose() will now return translated values for the system SNAPs rather than always UnknownPurpose. e.g. the "Internet" SNAP returns PublicPurpose, and the WAP/MMS SNAPs return ServiceSpecificPurpose. IAPs inherit the purpose of the service network that contains them, unless the same IAP is present in more than one with conflicting purposes, in which case UnknownPurpose is returned. Task-Number: QTBUG-19166 Reviewed-By: mread --- src/plugins/bearer/symbian/symbianengine.cpp | 52 +++++++++++++++++++++++++++- src/plugins/bearer/symbian/symbianengine.h | 1 + 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index fdfe94a..ee80297 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -329,7 +329,27 @@ void SymbianEngine::updateConfigurationsL() cpPriv->connectionId = 0; cpPriv->state = QNetworkConfiguration::Defined; cpPriv->type = QNetworkConfiguration::ServiceNetwork; - cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + + // determine purpose of this SNAP + TUint32 purpose = CMManager::ESnapPurposeUnknown; + TRAP_IGNORE(purpose = destination.MetadataL(CMManager::ESnapMetadataPurpose)); + switch (purpose) { + case CMManager::ESnapPurposeInternet: + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + break; + case CMManager::ESnapPurposeIntranet: + cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; + break; + case CMManager::ESnapPurposeMMS: + case CMManager::ESnapPurposeOperator: + cpPriv->purpose = QNetworkConfiguration::ServiceSpecificPurpose; + break; + case CMManager::ESnapPurposeUnknown: + default: + cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + break; + } + cpPriv->roamingSupported = false; QNetworkConfigurationPrivatePointer ptr(cpPriv); @@ -482,9 +502,39 @@ void SymbianEngine::updateConfigurationsL() #ifdef SNAP_FUNCTIONALITY_AVAILABLE updateStatesToSnaps(); + updatePurposeToIaps(); #endif } +//copy purpose from SNAP to child IAPs, unless child is contained in more than one SNAP with conflicting purposes. +void SymbianEngine::updatePurposeToIaps() +{ + QMutexLocker lock(&mutex); + QHash purposes; + foreach (QNetworkConfigurationPrivatePointer snap, snapConfigurations.values()) { + QMutexLocker snaplock(&snap->mutex); + foreach (QNetworkConfigurationPrivatePointer iap, snap->serviceNetworkMembers.values()) { + QMutexLocker iaplock(&iap->mutex); + QString id = iap->id; + if (purposes.contains(id) && purposes.value(id) != snap->purpose) + purposes[id] = -1; //conflict detected + else + purposes[id] = snap->purpose; + } + } + + for (QHash::const_iterator it = purposes.constBegin(); it != purposes.constEnd(); ++it) { + if (accessPointConfigurations.contains(it.key())) { + QNetworkConfigurationPrivatePointer iap = accessPointConfigurations.value(it.key()); + QMutexLocker iaplock(&iap->mutex); + int purpose = it.value(); + if (purpose == -1) //resolve conflicts as unknown + purpose = QNetworkConfiguration::UnknownPurpose; + iap->purpose = (QNetworkConfiguration::Purpose)purpose; + } + } +} + #ifdef SNAP_FUNCTIONALITY_AVAILABLE SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( RCmConnectionMethod& connectionMethod) diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index a205c97..b75f27e 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -155,6 +155,7 @@ public Q_SLOTS: private: void updateStatesToSnaps(); + void updatePurposeToIaps(); bool changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState); bool changeConfigurationStateAtMinTo(QNetworkConfigurationPrivatePointer ptr, -- cgit v0.12 From 7cd29ef169b94b0182b4207b37715f7427e4e4d6 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 20 Sep 2011 14:36:24 +0300 Subject: Symbian: Added copy-paste functionality to FEP input context The support for copy-paste functionality in FEP was initially submitted as merge request #1151, though that only provided support for basic Qt edit widgets. I modified the code so that QML edit elements are also supported, as well as any other editor that provides the required "copy", "cut", and "paste" slots, and "canPaste" property. A number of other minor fixes were also done to the original merge request, as well as the removal of S60 version plugin elements. Task-number: QTBUG-20921 Reviewed-by: Sami Merila --- src/gui/inputmethod/qcoefepinputcontext_p.h | 50 ++- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 567 +++++++++++++++++++++++- 2 files changed, 597 insertions(+), 20 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index 8c30838..8ef9726 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -63,13 +63,36 @@ #include #include +#include QT_BEGIN_NAMESPACE +class QCoeFepInputMaskHandler +{ +public: + QCoeFepInputMaskHandler(const QString &mask); + ~QCoeFepInputMaskHandler(); + bool canPasteClipboard(const QString &text); +private: + bool isValidInput(QChar key, QChar mask) const; +private: + struct MaskInputData { + enum Casemode { NoCaseMode, Upper, Lower }; + QChar maskChar; + bool separator; + Casemode caseMode; + }; + int m_maxLength; + QChar m_blank; + MaskInputData *m_maskData; +}; + class Q_AUTOTEST_EXPORT QCoeFepInputContext : public QInputContext, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1, - public MObjectProvider + public MObjectProvider, + public MEikCcpuEditor + { Q_OBJECT @@ -135,6 +158,25 @@ private: void DoCommitFepInlineEditL(); MCoeFepAwareTextEditor_Extension1* Extension1(TBool& aSetToTrue); void ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateEvent aEventType); + void enableSymbianCcpuSupport(); + void changeCBA(bool showCopyAndOrPaste); + void copyOrCutTextToClipboard(const char *operation); + + //From MEikCcpuEditor interface +public: + TBool CcpuIsFocused() const; + TBool CcpuCanCut() const; + void CcpuCutL(); + TBool CcpuCanCopy() const; + void CcpuCopyL(); + TBool CcpuCanPaste() const; + void CcpuPasteL(); + TBool CcpuCanUndo() const; + void CcpuUndoL(); + +private slots: + void copy(); + void paste(); // From MCoeFepAwareTextEditor_Extension1 public: @@ -167,6 +209,12 @@ private: Qt::WindowStates m_splitViewPreviousWindowStates; QRectF m_transformation; + CAknCcpuSupport *m_ccpu; + QAction *m_copyAction; + QAction *m_pasteAction; + QPointer m_lastFocusedEditor; + QPointer m_lastFocusedObject; + friend class tst_QInputContext; }; diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 56338b2..9025221 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -57,6 +57,21 @@ #include #include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + // You only find these enumerations on SDK 5 onwards, so we need to provide our own // to remain compatible with older releases. They won't be called by pre-5.0 SDKs. @@ -79,8 +94,253 @@ #define QT_EPSUidAknFep 0x100056de #define QT_EAknFepTouchInputActive 0x00000004 +_LIT(KAvkonResourceFile, "z:\\resource\\avkon.rsc" ); + QT_BEGIN_NAMESPACE +static QWidget* getFocusedChild(const QList& objectList) +{ + for (int j = 0; j < objectList.count(); j++) { + if (QWidget* ow = qobject_cast(objectList[j])) { + if (ow->hasFocus()) { + return ow; + } else { + if (QWidget* rw = getFocusedChild(ow->children())) + return rw; + } + } + } + return 0; +} + +// A generic method for invoking "cut", "copy", and "paste" slots on editor +// All supported editors are expected to have these. +static bool ccpuInvokeSlot(QObject *obj, QObject *focusObject, const char *member) +{ + QObject *invokeTarget = obj; + if (focusObject) + invokeTarget = focusObject; + + return QMetaObject::invokeMethod(invokeTarget, member, Qt::DirectConnection); +} + +// focusObject is used to return a pointer to focused graphics object, if any +static QWidget *getQWidgetFromQGraphicsView(QWidget *widget, QObject **focusObject = 0) +{ + if (focusObject) + *focusObject = 0; + + if (!widget) + return 0; + + if (QGraphicsView* qgv = qobject_cast(widget)) { + QGraphicsItem *focusItem = 0; + if (qgv->scene()) + focusItem = qgv->scene()->focusItem(); + if (focusItem) { + if (focusObject) + *focusObject = focusItem->toGraphicsObject(); + if (QGraphicsProxyWidget* const qgpw = qgraphicsitem_cast(focusItem)) { + if (QWidget* w = qgpw->widget()) { + if (w->layout()) { + if (QWidget* rw = getFocusedChild(w->children())) + return rw; + } else { + return w; + } + } + } + } + } + return widget; +} + +QCoeFepInputMaskHandler::QCoeFepInputMaskHandler(const QString &mask) +{ + QString inputMask; + int delimiter = mask.indexOf(QLatin1Char(';')); + if (mask.isEmpty() || delimiter == 0) + return; + + if (delimiter == -1) { + m_blank = QLatin1Char(' '); + inputMask = mask; + } else { + inputMask = mask.left(delimiter); + m_blank = (delimiter + 1 < mask.length()) ? mask[delimiter + 1] : QLatin1Char(' '); + } + + // Calculate m_maxLength / m_maskData length + m_maxLength = 0; + QChar c = 0; + for (int i = 0; i < inputMask.length(); i++) { + c = inputMask.at(i); + if (i > 0 && inputMask.at(i - 1) == QLatin1Char('\\')) { + m_maxLength++; + continue; + } + if (c != QLatin1Char('\\') && c != QLatin1Char('!') + && c != QLatin1Char('<') && c != QLatin1Char('>') + && c != QLatin1Char('{') && c != QLatin1Char('}') + && c != QLatin1Char('[') && c != QLatin1Char(']')) { + m_maxLength++; + } + } + + m_maskData = new MaskInputData[m_maxLength]; + + MaskInputData::Casemode m = MaskInputData::NoCaseMode; + c = 0; + bool s = false; + bool escape = false; + int index = 0; + for (int i = 0; i < inputMask.length(); i++) { + c = inputMask.at(i); + if (escape) { + s = true; + m_maskData[index].maskChar = c; + m_maskData[index].separator = s; + m_maskData[index].caseMode = m; + index++; + escape = false; + } else if (c == QLatin1Char('<')) { + m = MaskInputData::Lower; + } else if (c == QLatin1Char('>')) { + m = MaskInputData::Upper; + } else if (c == QLatin1Char('!')) { + m = MaskInputData::NoCaseMode; + } else if (c != QLatin1Char('{') && c != QLatin1Char('}') && c != QLatin1Char('[') && c != QLatin1Char(']')) { + switch (c.unicode()) { + case 'A': + case 'a': + case 'N': + case 'n': + case 'X': + case 'x': + case '9': + case '0': + case 'D': + case 'd': + case '#': + case 'H': + case 'h': + case 'B': + case 'b': + s = false; + break; + case '\\': + escape = true; + break; + default: + s = true; + break; + } + + if (!escape) { + m_maskData[index].maskChar = c; + m_maskData[index].separator = s; + m_maskData[index].caseMode = m; + index++; + } + } + } +} + +QCoeFepInputMaskHandler::~QCoeFepInputMaskHandler() +{ + if (m_maskData) + delete[] m_maskData; +} + +bool QCoeFepInputMaskHandler::canPasteClipboard(const QString &text) +{ + if (!m_maskData) + return true; + + if (text.length() > m_maxLength) + return false; + int limit = qMin(m_maxLength, text.length()); + for (int i = 0; i < limit; ++i) { + if (m_maskData[i].separator) { + if (text.at(i) != m_maskData[i].maskChar) + return false; + } else { + if (!isValidInput(text.at(i), m_maskData[i].maskChar)) + return false; + } + } + return true; +} + +bool QCoeFepInputMaskHandler::isValidInput(QChar key, QChar mask) const +{ + switch (mask.unicode()) { + case 'A': + if (key.isLetter()) + return true; + break; + case 'a': + if (key.isLetter() || key == m_blank) + return true; + break; + case 'N': + if (key.isLetterOrNumber()) + return true; + break; + case 'n': + if (key.isLetterOrNumber() || key == m_blank) + return true; + break; + case 'X': + if (key.isPrint()) + return true; + break; + case 'x': + if (key.isPrint() || key == m_blank) + return true; + break; + case '9': + if (key.isNumber()) + return true; + break; + case '0': + if (key.isNumber() || key == m_blank) + return true; + break; + case 'D': + if (key.isNumber() && key.digitValue() > 0) + return true; + break; + case 'd': + if ((key.isNumber() && key.digitValue() > 0) || key == m_blank) + return true; + break; + case '#': + if (key.isNumber() || key == QLatin1Char('+') || key == QLatin1Char('-') || key == m_blank) + return true; + break; + case 'B': + if (key == QLatin1Char('0') || key == QLatin1Char('1')) + return true; + break; + case 'b': + if (key == QLatin1Char('0') || key == QLatin1Char('1') || key == m_blank) + return true; + break; + case 'H': + if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F'))) + return true; + break; + case 'h': + if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F')) || key == m_blank) + return true; + break; + default: + break; + } + return false; +} + Q_GUI_EXPORT void qt_s60_setPartialScreenInputMode(bool enable) { S60->partial_keyboard = enable; @@ -116,7 +376,8 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_pointerHandler(0), m_hasTempPreeditString(false), m_splitViewResizeBy(0), - m_splitViewPreviousWindowStates(Qt::WindowNoState) + m_splitViewPreviousWindowStates(Qt::WindowNoState), + m_ccpu(0) { m_fepState->SetObjectProvider(this); int defaultFlags = EAknEditorFlagDefault; @@ -133,6 +394,29 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_fepState->SetPermittedCases( EAknEditorAllCaseModes ); m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); m_fepState->SetNumericKeymap(EAknEditorAlphanumericNumberModeKeymap); + enableSymbianCcpuSupport(); + + //adding softkeys + QString copyLabel = QLatin1String("Copy"); + QString pasteLabel = QLatin1String("Paste"); + TRAP_IGNORE( + CEikonEnv* coe = CEikonEnv::Static(); + if (coe) { + HBufC* copyBuf = coe->AllocReadResourceLC(R_TEXT_SOFTKEY_COPY); + copyLabel = qt_TDesC2QString(*copyBuf); + CleanupStack::PopAndDestroy(copyBuf); + HBufC* pasteBuf = coe->AllocReadResourceLC(R_TEXT_SOFTKEY_PASTE); + pasteLabel = qt_TDesC2QString(*pasteBuf); + CleanupStack::PopAndDestroy(pasteBuf); + } + ) + + m_copyAction = new QAction(copyLabel, QApplication::desktop()); + m_pasteAction = new QAction(pasteLabel, QApplication::desktop()); + m_copyAction->setSoftKeyRole(QAction::PositiveSoftKey); + m_pasteAction->setSoftKeyRole(QAction::NegativeSoftKey); + connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copy())); + connect(m_pasteAction, SIGNAL(triggered()), this, SLOT(paste())); } QCoeFepInputContext::~QCoeFepInputContext() @@ -145,8 +429,8 @@ QCoeFepInputContext::~QCoeFepInputContext() // but is synchronous, rather than asynchronous. CCoeEnv::Static()->SyncNotifyFocusObserversOfChangeInFocus(); - if (m_fepState) - delete m_fepState; + delete m_fepState; + delete m_ccpu; } void QCoeFepInputContext::reset() @@ -347,6 +631,12 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) sControl = focusWidget()->effectiveWinId()->MopGetObject(sControl); Q_ASSERT(sControl); + // Store last focused widget and object in case of fullscreen VKB + QObject *focusObject = 0; + m_lastFocusedEditor = getQWidgetFromQGraphicsView(focusWidget(), &focusObject); + m_lastFocusedObject = focusObject; // Can be null + Q_ASSERT(m_lastFocusedEditor); + // The FEP UI temporarily steals focus when it shows up the first time, causing // all sorts of weird effects on the focused widgets. Since it will immediately give // back focus to us, we temporarily disable focus handling until the job's done. @@ -369,28 +659,66 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) bool QCoeFepInputContext::symbianFilterEvent(QWidget *keyWidget, const QSymbianEvent *event) { Q_UNUSED(keyWidget); + if (event->type() == QSymbianEvent::WindowServerEvent) { + const TWsEvent* wsEvent = event->windowServerEvent(); + TInt eventType = 0; + if (wsEvent) + eventType = wsEvent->Type(); + + if (eventType == EEventKey) { + TKeyEvent* keyEvent = wsEvent->Key(); + if (keyEvent) { + switch (keyEvent->iScanCode) { + case EEikCmdEditCopy: + CcpuCopyL(); + break; + case EEikCmdEditCut: + CcpuCutL(); + break; + case EEikCmdEditPaste: + CcpuPasteL(); + break; + case EStdKeyF21: + changeCBA(true); + break; + default: + break; + } + switch (keyEvent->iCode) { + case EKeyLeftArrow: + case EKeyRightArrow: + case EKeyUpArrow: + case EKeyDownArrow: + if (CcpuCanCopy() && ((keyEvent->iModifiers & EModifierShift) == EModifierShift)) + changeCBA(true); + break; + default: + break; + } + } + } else if (eventType == EEventKeyUp) { + if (wsEvent->Key() && wsEvent->Key()->iScanCode == EStdKeyLeftShift) + changeCBA(false); + } else if (eventType == EEventWindowVisibilityChanged && S60->splitViewLastWidget) { + QGraphicsView *gv = qobject_cast(S60->splitViewLastWidget); + const bool alwaysResize = (gv && gv->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff); + + if (alwaysResize) { + TUint visibleFlags = event->windowServerEvent()->VisibilityChanged()->iFlags; + if (visibleFlags & TWsVisibilityChangedEvent::EPartiallyVisible) + ensureFocusWidgetVisible(S60->splitViewLastWidget); + if (visibleFlags & TWsVisibilityChangedEvent::ENotVisible) + resetSplitViewWidget(true); + } + } + } + if (event->type() == QSymbianEvent::CommandEvent) // A command basically means the same as a button being pushed. With Qt buttons // that would normally result in a reset of the input method due to the focus change. // This should also happen for commands. reset(); - if (event->type() == QSymbianEvent::WindowServerEvent - && event->windowServerEvent() - && event->windowServerEvent()->Type() == EEventWindowVisibilityChanged - && S60->splitViewLastWidget) { - - QGraphicsView *gv = qobject_cast(S60->splitViewLastWidget); - const bool alwaysResize = (gv && gv->verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff); - - if (alwaysResize) { - TUint visibleFlags = event->windowServerEvent()->VisibilityChanged()->iFlags; - if (visibleFlags & TWsVisibilityChangedEvent::EPartiallyVisible) - ensureFocusWidgetVisible(S60->splitViewLastWidget); - if (visibleFlags & TWsVisibilityChangedEvent::ENotVisible) - resetSplitViewWidget(true); - } - } if (event->type() == QSymbianEvent::ResourceChangeEvent && (event->resourceChangeType() == KEikMessageFadeAllWindows @@ -1231,6 +1559,71 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin aAscent = metrics.ascent(); } +void QCoeFepInputContext::enableSymbianCcpuSupport() +{ + if (!m_ccpu) { + QT_TRAP_THROWING( + m_ccpu = new (ELeave) CAknCcpuSupport(this); + m_ccpu->SetMopParent(this); + CleanupStack::PushL(m_ccpu); + m_ccpu->ConstructL(); + CleanupStack::Pop(m_ccpu); + ); + Q_ASSERT(m_fepState); + if (m_fepState) + m_fepState->SetCcpuState(this); + } +} + +void QCoeFepInputContext::changeCBA(bool showCopyAndOrPaste) +{ + QWidget *w = focusWidget(); + if (!w) + w = m_lastFocusedEditor; + + if (w) { + if (showCopyAndOrPaste) { + if (CcpuCanCopy()) + w->addAction(m_copyAction); + if (CcpuCanPaste()) + w->addAction(m_pasteAction); + } else { + w->removeAction(m_copyAction); + w->removeAction(m_pasteAction); + } + } +} + +void QCoeFepInputContext::copyOrCutTextToClipboard(const char *operation) +{ + bool hasText = false; + + QWidget *w = focusWidget(); + QObject *focusObject = 0; + if (!w) { + w = m_lastFocusedEditor; + focusObject = m_lastFocusedObject; + } else { + w = getQWidgetFromQGraphicsView(w, &focusObject); + } + + if (w) { + int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); + int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); + + if (cursor != anchor) { + if (ccpuInvokeSlot(w, focusObject, operation)) { + TRAP_IGNORE( + CAknDiscreetPopup::ShowGlobalPopupL( + R_AVKON_DISCREET_POPUP_TEXT_COPIED, + KAvkonResourceFile); + ) + } + } + } +} + + void QCoeFepInputContext::DoCommitFepInlineEditL() { commitCurrentString(false); @@ -1295,6 +1688,142 @@ MCoeFepAwareTextEditor_Extension1::CState* QCoeFepInputContext::State(TUid /*aTy return m_fepState; } +TBool QCoeFepInputContext::CcpuIsFocused() const +{ + return focusWidget() != 0; +} + +TBool QCoeFepInputContext::CcpuCanCut() const +{ + bool retval = false; + QWidget *w = focusWidget(); + if (!w) + w = m_lastFocusedEditor; + else + w = getQWidgetFromQGraphicsView(w); + if (w) { + int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); + int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); + retval = cursor != anchor; + } + return retval; +} + +void QCoeFepInputContext::CcpuCutL() +{ + copyOrCutTextToClipboard("cut"); +} + +TBool QCoeFepInputContext::CcpuCanCopy() const +{ + return CcpuCanCut(); +} + +void QCoeFepInputContext::CcpuCopyL() +{ + copyOrCutTextToClipboard("copy"); +} + +TBool QCoeFepInputContext::CcpuCanPaste() const +{ + bool canPaste = false; + QString textToPaste = QApplication::clipboard()->text(); + if (!textToPaste.isEmpty()) { + QWidget *w = focusWidget(); + QObject *focusObject = 0; + if (!w) { + w = m_lastFocusedEditor; + focusObject = m_lastFocusedObject; + } else { + w = getQWidgetFromQGraphicsView(w, &focusObject); + } + if (w) { + // First, check if we are dealing with standard Qt editors (QLineEdit, QTextEdit, or QPlainTextEdit), + // as they do not have queryable property. + if (QTextEdit* tedit = qobject_cast(w)) { + canPaste = tedit->canPaste(); + } else if (QPlainTextEdit* ptedit = qobject_cast(w)) { + canPaste = ptedit->canPaste(); + } else if (QLineEdit* ledit = qobject_cast(w)) { + QString fullText = ledit->text(); + if (ledit->hasSelectedText()) { + fullText.remove(ledit->selectionStart(), ledit->selectedText().length()); + fullText.insert(ledit->selectionStart(), textToPaste); + } else { + fullText.insert(ledit->cursorPosition(), textToPaste); + } + + if (fullText.length() > ledit->maxLength()) { + canPaste = false; + } else { + const QValidator* validator = ledit->validator(); + if (validator) { + int pos = 0; + if (validator->validate(fullText, pos) == QValidator::Invalid) + canPaste = false; + else + canPaste = true; + } else { + QString mask(ledit->inputMask()); + if (!mask.isEmpty()) { + QCoeFepInputMaskHandler maskhandler(mask); + if (maskhandler.canPasteClipboard(fullText)) + canPaste = true; + else + canPaste = false; + } else { + canPaste = true; + } + } + } + } else { + // Unknown editor (probably a QML one); Request the "canPaste" property. + QObject *invokeTarget = w; + if (focusObject) + invokeTarget = focusObject; + + canPaste = invokeTarget->property("canPaste").toBool(); + } + } + } + return canPaste; +} + +void QCoeFepInputContext::CcpuPasteL() +{ + QWidget *w = focusWidget(); + QObject *focusObject = 0; + if (!w) { + w = m_lastFocusedEditor; + focusObject = m_lastFocusedObject; + } else { + w = getQWidgetFromQGraphicsView(w, &focusObject); + } + if (w) + ccpuInvokeSlot(w, focusObject, "paste"); +} + +TBool QCoeFepInputContext::CcpuCanUndo() const +{ + //not supported + return EFalse; +} + +void QCoeFepInputContext::CcpuUndoL() +{ + //not supported +} + +void QCoeFepInputContext::copy() +{ + QT_TRAP_THROWING(CcpuCopyL()); +} + +void QCoeFepInputContext::paste() +{ + QT_TRAP_THROWING(CcpuPasteL()); +} + TTypeUid::Ptr QCoeFepInputContext::MopSupplyObject(TTypeUid /*id*/) { return TTypeUid::Null(); -- cgit v0.12 From 8e2368bce81180c12a607afd101964ef1e8a1f1b Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Wed, 21 Sep 2011 11:53:30 +0300 Subject: Fix memory leaks in schema validation Bug fix for QTBUG-12550. QExplicitlySharedDataPointer is excessively used in XmlPatterns code. This forumate cyclic loops in some situation. This fix replace the shared data pointer with normal C++ pointer to break the loop. Task-number: QTBUG-12550 Reviewed-by: Tomi Vihria --- src/xmlpatterns/schema/qnamespacesupport.cpp | 4 +- src/xmlpatterns/schema/qnamespacesupport_p.h | 4 +- src/xmlpatterns/schema/qxsdcomplextype.cpp | 4 +- src/xmlpatterns/schema/qxsdcomplextype_p.h | 2 +- src/xmlpatterns/schema/qxsdelement.cpp | 4 +- src/xmlpatterns/schema/qxsdelement_p.h | 2 +- src/xmlpatterns/schema/qxsdschemaparser.cpp | 252 ++++++++++----------- src/xmlpatterns/schema/qxsdschemaparser_p.h | 10 +- src/xmlpatterns/schema/qxsdschemaparser_setup.cpp | 144 ++++++------ .../xmlpatternsschemats/TESTSUITE/updateSuite.sh | 5 +- 10 files changed, 218 insertions(+), 213 deletions(-) diff --git a/src/xmlpatterns/schema/qnamespacesupport.cpp b/src/xmlpatterns/schema/qnamespacesupport.cpp index cb0cbf7..5e0aea6 100644 --- a/src/xmlpatterns/schema/qnamespacesupport.cpp +++ b/src/xmlpatterns/schema/qnamespacesupport.cpp @@ -59,8 +59,8 @@ NamespaceSupport::NamespaceSupport() { } -NamespaceSupport::NamespaceSupport(const NamePool::Ptr &namePool) - : m_namePool(namePool) +NamespaceSupport::NamespaceSupport(NamePool &namePool) + : m_namePool(&namePool) { // the XML namespace m_ns.insert(StandardPrefixes::xml, StandardNamespaces::xml); diff --git a/src/xmlpatterns/schema/qnamespacesupport_p.h b/src/xmlpatterns/schema/qnamespacesupport_p.h index 656026e..b61bf19 100644 --- a/src/xmlpatterns/schema/qnamespacesupport_p.h +++ b/src/xmlpatterns/schema/qnamespacesupport_p.h @@ -97,7 +97,7 @@ namespace QPatternist * * @param namePool The name pool where all processed names are stored in. */ - NamespaceSupport(const NamePool::Ptr &namePool); + NamespaceSupport(NamePool &namePool); /** * Adds a new prefix-to-namespace binding. @@ -160,7 +160,7 @@ namespace QPatternist private: typedef QHash NamespaceHash; - NamePool::Ptr m_namePool; + NamePool *m_namePool; QStack m_nsStack; NamespaceHash m_ns; }; diff --git a/src/xmlpatterns/schema/qxsdcomplextype.cpp b/src/xmlpatterns/schema/qxsdcomplextype.cpp index 32e420a..fe97f04 100644 --- a/src/xmlpatterns/schema/qxsdcomplextype.cpp +++ b/src/xmlpatterns/schema/qxsdcomplextype.cpp @@ -130,12 +130,12 @@ QString XsdComplexType::displayName(const NamePool::Ptr &np) const void XsdComplexType::setWxsSuperType(const SchemaType::Ptr &type) { - m_superType = type; + m_superType = type.data(); } SchemaType::Ptr XsdComplexType::wxsSuperType() const { - return m_superType; + return SchemaType::Ptr(m_superType); } void XsdComplexType::setContext(const NamedSchemaComponent::Ptr &component) diff --git a/src/xmlpatterns/schema/qxsdcomplextype_p.h b/src/xmlpatterns/schema/qxsdcomplextype_p.h index 1b90e5d..f6c512e 100644 --- a/src/xmlpatterns/schema/qxsdcomplextype_p.h +++ b/src/xmlpatterns/schema/qxsdcomplextype_p.h @@ -385,7 +385,7 @@ namespace QPatternist virtual bool isDefinedBySchema() const; private: - SchemaType::Ptr m_superType; + SchemaType *m_superType; NamedSchemaComponent *m_context; DerivationMethod m_derivationMethod; bool m_isAbstract; diff --git a/src/xmlpatterns/schema/qxsdelement.cpp b/src/xmlpatterns/schema/qxsdelement.cpp index dda0f54..ab2b873 100644 --- a/src/xmlpatterns/schema/qxsdelement.cpp +++ b/src/xmlpatterns/schema/qxsdelement.cpp @@ -128,12 +128,12 @@ bool XsdElement::isElement() const void XsdElement::setType(const SchemaType::Ptr &type) { - m_type = type; + m_type = type.data(); } SchemaType::Ptr XsdElement::type() const { - return m_type; + return SchemaType::Ptr(m_type); } void XsdElement::setScope(const Scope::Ptr &scope) diff --git a/src/xmlpatterns/schema/qxsdelement_p.h b/src/xmlpatterns/schema/qxsdelement_p.h index 3b9dd88..69fa769 100644 --- a/src/xmlpatterns/schema/qxsdelement_p.h +++ b/src/xmlpatterns/schema/qxsdelement_p.h @@ -382,7 +382,7 @@ namespace QPatternist XsdElement::WeakList substitutionGroups() const; private: - SchemaType::Ptr m_type; + SchemaType *m_type; Scope::Ptr m_scope; ValueConstraint::Ptr m_valueConstraint; TypeTable::Ptr m_typeTable; diff --git a/src/xmlpatterns/schema/qxsdschemaparser.cpp b/src/xmlpatterns/schema/qxsdschemaparser.cpp index 4281a41..0cb0153 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser.cpp +++ b/src/xmlpatterns/schema/qxsdschemaparser.cpp @@ -251,13 +251,13 @@ inline static bool isValidUri(const QString &string) XsdSchemaParser::XsdSchemaParser(const XsdSchemaContext::Ptr &context, const XsdSchemaParserContext::Ptr &parserContext, QIODevice *device) : MaintainingReader(parserContext->elementDescriptions(), QSet(), context, device) - , m_context(context) - , m_parserContext(parserContext) - , m_namePool(m_parserContext->namePool()) - , m_namespaceSupport(m_namePool) + , m_context(context.data()) + , m_parserContext(parserContext.data()) + , m_namePool(m_parserContext->namePool().data()) + , m_namespaceSupport(*m_namePool) { - m_schema = m_parserContext->schema(); - m_schemaResolver = m_parserContext->resolver(); + m_schema = m_parserContext->schema().data(); + m_schemaResolver = m_parserContext->resolver().data(); m_idCache = XsdIdCache::Ptr(new XsdIdCache()); setupStateMachines(); @@ -365,7 +365,7 @@ void XsdSchemaParser::attributeContentError(const char *attributeName, const cha .arg(formatAttribute(attributeName)) .arg(formatElement(elementName)) .arg(formatData(value)) - .arg(formatType(m_namePool, type))); + .arg(formatType(NamePool::Ptr(m_namePool), type))); } else { error(QtXmlPatterns::tr("%1 attribute of %2 element contains invalid content: {%3}.") .arg(formatAttribute(attributeName)) @@ -520,7 +520,7 @@ void XsdSchemaParser::parseSchema(ParserType parserType) validateIdAttribute("schema"); - TagValidationHandler tagValidator(XsdTagScope::Schema, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Schema, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -601,10 +601,10 @@ void XsdSchemaParser::parseInclude() m_includedSchemas.insert(url); const AutoPtr reply(AccelTreeResourceLoader::load(url, m_context->networkAccessManager(), - m_context, AccelTreeResourceLoader::ContinueOnError)); + XsdSchemaContext::Ptr(m_context), AccelTreeResourceLoader::ContinueOnError)); if (reply) { // parse the included schema by a different parser but with the same context - XsdSchemaParser parser(m_context, m_parserContext, reply.data()); + XsdSchemaParser parser(XsdSchemaContext::Ptr(m_context), XsdSchemaParserContext::Ptr(m_parserContext), reply.data()); parser.setDocumentURI(url); parser.setTargetNamespaceExtended(m_targetNamespace); parser.setIncludedSchemas(m_includedSchemas); @@ -623,7 +623,7 @@ void XsdSchemaParser::parseInclude() validateIdAttribute("include"); - TagValidationHandler tagValidator(XsdTagScope::Include, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Include, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -697,10 +697,10 @@ void XsdSchemaParser::parseImport() m_importedSchemas.insert(importNamespace); AutoPtr reply(AccelTreeResourceLoader::load(url, m_context->networkAccessManager(), - m_context, AccelTreeResourceLoader::ContinueOnError)); + XsdSchemaContext::Ptr(m_context), AccelTreeResourceLoader::ContinueOnError)); if (reply) { // parse the included schema by a different parser but with the same context - XsdSchemaParser parser(m_context, m_parserContext, reply.data()); + XsdSchemaParser parser(XsdSchemaContext::Ptr(m_context), XsdSchemaParserContext::Ptr(m_parserContext), reply.data()); parser.setDocumentURI(url); parser.setTargetNamespace(importNamespace); parser.setIncludedSchemas(m_includedSchemas); @@ -724,7 +724,7 @@ void XsdSchemaParser::parseImport() QFile file(QString::fromLatin1(":") + importNamespace); if (file.open(QIODevice::ReadOnly)) { - XsdSchemaParser parser(m_context, m_parserContext, &file); + XsdSchemaParser parser(XsdSchemaContext::Ptr(m_context), XsdSchemaParserContext::Ptr(m_parserContext), &file); parser.setDocumentURI(importNamespace); parser.setTargetNamespace(importNamespace); parser.setIncludedSchemas(m_includedSchemas); @@ -747,7 +747,7 @@ void XsdSchemaParser::parseImport() validateIdAttribute("import"); - TagValidationHandler tagValidator(XsdTagScope::Import, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Import, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -785,7 +785,7 @@ void XsdSchemaParser::parseRedefine() const QString schemaLocation = readAttribute(QString::fromLatin1("schemaLocation")); - TagValidationHandler tagValidator(XsdTagScope::Redefine, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Redefine, this, NamePool::Ptr(m_namePool)); XsdSimpleType::List redefinedSimpleTypes; XsdComplexType::List redefinedComplexTypes; @@ -812,8 +812,8 @@ void XsdSchemaParser::parseRedefine() redefinedSimpleTypes.append(type); const QXmlName baseTypeName = m_parserContext->resolver()->baseTypeNameOfType(type); - if (baseTypeName != type->name(m_namePool)) { - error(QString::fromLatin1("redefined simple type %1 must have itself as base type").arg(formatType(m_namePool, type))); + if (baseTypeName != type->name(NamePool::Ptr(m_namePool))) { + error(QString::fromLatin1("redefined simple type %1 must have itself as base type").arg(formatType(NamePool::Ptr(m_namePool), type))); return; } } else if (isSchemaTag(XsdSchemaToken::ComplexType, token, namespaceToken)) { @@ -824,8 +824,8 @@ void XsdSchemaParser::parseRedefine() // 5 const QXmlName baseTypeName = m_parserContext->resolver()->baseTypeNameOfType(type); - if (baseTypeName != type->name(m_namePool)) { - error(QString::fromLatin1("redefined complex type %1 must have itself as base type").arg(formatType(m_namePool, type))); + if (baseTypeName != type->name(NamePool::Ptr(m_namePool))) { + error(QString::fromLatin1("redefined complex type %1 must have itself as base type").arg(formatType(NamePool::Ptr(m_namePool), type))); return; } } else if (isSchemaTag(XsdSchemaToken::Group, token, namespaceToken)) { @@ -855,7 +855,7 @@ void XsdSchemaParser::parseRedefine() } // we parse the schema given in the redefine tag into its own context - const XsdSchemaParserContext::Ptr redefinedContext(new XsdSchemaParserContext(m_namePool, m_context)); + const XsdSchemaParserContext::Ptr redefinedContext(new XsdSchemaParserContext(NamePool::Ptr(m_namePool), XsdSchemaContext::Ptr(m_context))); if (m_redefinedSchemas.contains(url)) { // we have redefined that file already, according to the schema spec we are @@ -863,11 +863,11 @@ void XsdSchemaParser::parseRedefine() } else { m_redefinedSchemas.insert(url); QNetworkReply *reply = AccelTreeResourceLoader::load(url, m_context->networkAccessManager(), - m_context, + XsdSchemaContext::Ptr(m_context), (locationMustResolve ? AccelTreeResourceLoader::FailOnError : AccelTreeResourceLoader::ContinueOnError)); if (reply) { // parse the included schema by a different parser but with the same context - XsdSchemaParser parser(m_context, redefinedContext, reply); + XsdSchemaParser parser(XsdSchemaContext::Ptr(m_context), redefinedContext, reply); parser.setDocumentURI(url); parser.setTargetNamespaceExtended(m_targetNamespace); parser.setIncludedSchemas(m_includedSchemas); @@ -904,7 +904,7 @@ void XsdSchemaParser::parseRedefine() for (int j = 0; j < contextSimpleTypes.count(); ++j) { XsdSimpleType::Ptr contextType = contextSimpleTypes.at(j); - if (redefinedType->name(m_namePool) == contextType->name(m_namePool)) { // we found the right type + if (redefinedType->name(NamePool::Ptr(m_namePool)) == contextType->name(NamePool::Ptr(m_namePool))) { // we found the right type found = true; // 1) set name of context type to empty name @@ -932,7 +932,7 @@ void XsdSchemaParser::parseRedefine() } if (!found) { - error(QString::fromLatin1("no matching type found to redefine simple type %1").arg(formatType(m_namePool, redefinedType))); + error(QString::fromLatin1("no matching type found to redefine simple type %1").arg(formatType(NamePool::Ptr(m_namePool), redefinedType))); return; } } @@ -953,7 +953,7 @@ void XsdSchemaParser::parseRedefine() for (int j = 0; j < contextComplexTypes.count(); ++j) { XsdComplexType::Ptr contextType = contextComplexTypes.at(j); - if (redefinedType->name(m_namePool) == contextType->name(m_namePool)) { // we found the right type + if (redefinedType->name(NamePool::Ptr(m_namePool)) == contextType->name(NamePool::Ptr(m_namePool))) { // we found the right type found = true; // 1) set name of context type to empty name @@ -981,7 +981,7 @@ void XsdSchemaParser::parseRedefine() } if (!found) { - error(QString::fromLatin1("no matching type found to redefine complex type %1").arg(formatType(m_namePool, redefinedType))); + error(QString::fromLatin1("no matching type found to redefine complex type %1").arg(formatType(NamePool::Ptr(m_namePool), redefinedType))); return; } } @@ -998,11 +998,11 @@ void XsdSchemaParser::parseRedefine() int sameNameCounter = 0; for (int i = 0; i < particles.count(); ++i) { const XsdReference::Ptr ref(particles.at(i)->term()); - if (ref->referenceName() == group->name(m_namePool)) { + if (ref->referenceName() == group->name(NamePool::Ptr(m_namePool))) { referencedParticle = particles.at(i); if (referencedParticle->minimumOccurs() != 1 || referencedParticle->maximumOccurs() != 1 || referencedParticle->maximumOccursUnbounded()) { // 6.1.2 - error(QString::fromLatin1("redefined group %1 can not contain reference to itself with minOccurs or maxOccurs != 1").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined group %1 can not contain reference to itself with minOccurs or maxOccurs != 1").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } sameNameCounter++; @@ -1011,21 +1011,21 @@ void XsdSchemaParser::parseRedefine() // 6.1.1 if (sameNameCounter > 1) { - error(QString::fromLatin1("redefined group %1 can not contain multiple references to itself").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined group %1 can not contain multiple references to itself").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } // search the group definition in the included schema (S2) XsdModelGroup::Ptr contextGroup; for (int j = 0; j < contextGroups.count(); ++j) { - if (group->name(m_namePool) == contextGroups.at(j)->name(m_namePool)) { + if (group->name(NamePool::Ptr(m_namePool)) == contextGroups.at(j)->name(NamePool::Ptr(m_namePool))) { contextGroup = contextGroups.at(j); break; } } if (!contextGroup) { // 6.2.1 - error(QString::fromLatin1("redefined group %1 has no occurrence in included schema").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined group %1 has no occurrence in included schema").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } @@ -1034,7 +1034,7 @@ void XsdSchemaParser::parseRedefine() // group from the included schema // set a anonymous name to the group of the included schema - contextGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(contextGroup->name(m_namePool).namespaceURI()))); + contextGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(contextGroup->name(NamePool::Ptr(m_namePool)).namespaceURI()))); // replace the self-reference with the group from the included schema referencedParticle->setTerm(contextGroup); @@ -1050,7 +1050,7 @@ void XsdSchemaParser::parseRedefine() addElementGroup(group); // we have to add them, otherwise it is not resolved and we can't validate it later - contextGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(contextGroup->name(m_namePool).namespaceURI()))); + contextGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(contextGroup->name(NamePool::Ptr(m_namePool)).namespaceURI()))); addElementGroup(contextGroup); m_schemaResolver->addRedefinedGroups(group, contextGroup); @@ -1075,13 +1075,13 @@ void XsdSchemaParser::parseRedefine() if (attributeUse->isReference()) { const XsdAttributeReference::Ptr reference(attributeUse); if (reference->type() == XsdAttributeReference::AttributeGroup) { - if (group->name(m_namePool) == reference->referenceName()) + if (group->name(NamePool::Ptr(m_namePool)) == reference->referenceName()) sameNameCounter++; } } } if (sameNameCounter > 1) { - error(QString::fromLatin1("redefined attribute group %1 can not contain multiple references to itself").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined attribute group %1 can not contain multiple references to itself").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } @@ -1089,14 +1089,14 @@ void XsdSchemaParser::parseRedefine() XsdAttributeGroup::Ptr baseGroup; for (int j = 0; j < contextAttributeGroups.count(); ++j) { const XsdAttributeGroup::Ptr contextGroup(contextAttributeGroups.at(j)); - if (group->name(m_namePool) == contextGroup->name(m_namePool)) { + if (group->name(NamePool::Ptr(m_namePool)) == contextGroup->name(NamePool::Ptr(m_namePool))) { baseGroup = contextGroup; break; } } if (!baseGroup) { // 7.2.1 - error(QString::fromLatin1("redefined attribute group %1 has no occurrence in included schema").arg(formatKeyword(group->displayName(m_namePool)))); + error(QString::fromLatin1("redefined attribute group %1 has no occurrence in included schema").arg(formatKeyword(group->displayName(NamePool::Ptr(m_namePool))))); return; } @@ -1104,7 +1104,7 @@ void XsdSchemaParser::parseRedefine() // first set an anonymous name to the attribute group from the included // schema - baseGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(baseGroup->name(m_namePool).namespaceURI()))); + baseGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(baseGroup->name(NamePool::Ptr(m_namePool)).namespaceURI()))); // iterate over the attribute uses of the redefined attribute group // and replace the self-reference with the attribute group from the @@ -1114,8 +1114,8 @@ void XsdSchemaParser::parseRedefine() if (attributeUse->isReference()) { const XsdAttributeReference::Ptr reference(attributeUse); if (reference->type() == XsdAttributeReference::AttributeGroup) { - if (group->name(m_namePool) == reference->referenceName()) { - reference->setReferenceName(baseGroup->name(m_namePool)); + if (group->name(NamePool::Ptr(m_namePool)) == reference->referenceName()) { + reference->setReferenceName(baseGroup->name(NamePool::Ptr(m_namePool))); break; } } @@ -1132,7 +1132,7 @@ void XsdSchemaParser::parseRedefine() if (sameNameCounter == 0) { // 7.2 // we have to add them, otherwise it is not resolved and we can't validate it later - baseGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(baseGroup->name(m_namePool).namespaceURI()))); + baseGroup->setName(m_parserContext->createAnonymousName(m_namePool->stringForNamespace(baseGroup->name(NamePool::Ptr(m_namePool)).namespaceURI()))); addAttributeGroup(baseGroup); m_schemaResolver->addRedefinedAttributeGroups(group, baseGroup); @@ -1191,7 +1191,7 @@ XsdAnnotation::Ptr XsdSchemaParser::parseAnnotation() // parse attributes validateIdAttribute("annotation"); - TagValidationHandler tagValidator(XsdTagScope::Annotation, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Annotation, this, NamePool::Ptr(m_namePool)); const XsdAnnotation::Ptr annotation(new XsdAnnotation()); @@ -1344,7 +1344,7 @@ void XsdSchemaParser::parseDefaultOpenContent() validateIdAttribute("defaultOpenContent"); - TagValidationHandler tagValidator(XsdTagScope::DefaultOpenContent, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::DefaultOpenContent, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1392,7 +1392,7 @@ XsdSimpleType::Ptr XsdSchemaParser::parseGlobalSimpleType() validateIdAttribute("simpleType"); - TagValidationHandler tagValidator(XsdTagScope::GlobalSimpleType, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::GlobalSimpleType, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1438,7 +1438,7 @@ XsdSimpleType::Ptr XsdSchemaParser::parseLocalSimpleType() validateIdAttribute("simpleType"); - TagValidationHandler tagValidator(XsdTagScope::LocalSimpleType, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalSimpleType, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1501,7 +1501,7 @@ void XsdSchemaParser::parseSimpleRestriction(const XsdSimpleType::Ptr &ptr) QList enumerationFacets; QList assertionFacets; - TagValidationHandler tagValidator(XsdTagScope::SimpleRestriction, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::SimpleRestriction, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1659,7 +1659,7 @@ void XsdSchemaParser::parseList(const XsdSimpleType::Ptr &ptr) validateIdAttribute("list"); - TagValidationHandler tagValidator(XsdTagScope::List, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::List, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1713,7 +1713,7 @@ void XsdSchemaParser::parseList(const XsdSimpleType::Ptr &ptr) const XsdFacet::Ptr defaultFacet(new XsdFacet()); defaultFacet->setType(XsdFacet::WhiteSpace); defaultFacet->setFixed(true); - defaultFacet->setValue(DerivedString::fromLexical(m_namePool, XsdSchemaToken::toString(XsdSchemaToken::Collapse))); + defaultFacet->setValue(DerivedString::fromLexical(NamePool::Ptr(m_namePool), XsdSchemaToken::toString(XsdSchemaToken::Collapse))); XsdFacet::Hash facets; facets.insert(defaultFacet->type(), defaultFacet); ptr->setFacets(facets); @@ -1756,7 +1756,7 @@ void XsdSchemaParser::parseUnion(const XsdSimpleType::Ptr &ptr) AnySimpleType::List memberTypes; - TagValidationHandler tagValidator(XsdTagScope::Union, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Union, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1828,7 +1828,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinExclusiveFacet() // as minExclusive can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString::Ptr string = DerivedString::fromLexical(m_namePool, value); + DerivedString::Ptr string = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "minExclusive", value, BuiltinTypes::xsAnySimpleType); return facet; @@ -1838,7 +1838,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinExclusiveFacet() validateIdAttribute("minExclusive"); - TagValidationHandler tagValidator(XsdTagScope::MinExclusiveFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MinExclusiveFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1892,7 +1892,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinInclusiveFacet() // as minInclusive can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString::Ptr string = DerivedString::fromLexical(m_namePool, value); + DerivedString::Ptr string = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "minInclusive", value, BuiltinTypes::xsAnySimpleType); return facet; @@ -1902,7 +1902,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinInclusiveFacet() validateIdAttribute("minInclusive"); - TagValidationHandler tagValidator(XsdTagScope::MinInclusiveFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MinInclusiveFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -1956,7 +1956,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxExclusiveFacet() // as maxExclusive can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString::Ptr string = DerivedString::fromLexical(m_namePool, value); + DerivedString::Ptr string = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "maxExclusive", value, BuiltinTypes::xsAnySimpleType); return facet; @@ -1966,7 +1966,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxExclusiveFacet() validateIdAttribute("maxExclusive"); - TagValidationHandler tagValidator(XsdTagScope::MaxExclusiveFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MaxExclusiveFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2020,7 +2020,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxInclusiveFacet() // as maxInclusive can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString::Ptr string = DerivedString::fromLexical(m_namePool, value); + DerivedString::Ptr string = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "maxInclusive", value, BuiltinTypes::xsAnySimpleType); return facet; @@ -2030,7 +2030,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxInclusiveFacet() validateIdAttribute("maxInclusive"); - TagValidationHandler tagValidator(XsdTagScope::MaxInclusiveFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MaxInclusiveFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2082,7 +2082,7 @@ XsdFacet::Ptr XsdSchemaParser::parseTotalDigitsFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger::Ptr integer = DerivedInteger::fromLexical(m_namePool, value); + DerivedInteger::Ptr integer = DerivedInteger::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "totalDigits", value, BuiltinTypes::xsPositiveInteger); return facet; @@ -2092,7 +2092,7 @@ XsdFacet::Ptr XsdSchemaParser::parseTotalDigitsFacet() validateIdAttribute("totalDigits"); - TagValidationHandler tagValidator(XsdTagScope::TotalDigitsFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::TotalDigitsFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2144,7 +2144,7 @@ XsdFacet::Ptr XsdSchemaParser::parseFractionDigitsFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger::Ptr integer = DerivedInteger::fromLexical(m_namePool, value); + DerivedInteger::Ptr integer = DerivedInteger::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "fractionDigits", value, BuiltinTypes::xsNonNegativeInteger); return facet; @@ -2154,7 +2154,7 @@ XsdFacet::Ptr XsdSchemaParser::parseFractionDigitsFacet() validateIdAttribute("fractionDigits"); - TagValidationHandler tagValidator(XsdTagScope::FractionDigitsFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::FractionDigitsFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2206,7 +2206,7 @@ XsdFacet::Ptr XsdSchemaParser::parseLengthFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger::Ptr integer = DerivedInteger::fromLexical(m_namePool, value); + DerivedInteger::Ptr integer = DerivedInteger::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "length", value, BuiltinTypes::xsNonNegativeInteger); return facet; @@ -2216,7 +2216,7 @@ XsdFacet::Ptr XsdSchemaParser::parseLengthFacet() validateIdAttribute("length"); - TagValidationHandler tagValidator(XsdTagScope::LengthFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LengthFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2268,7 +2268,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinLengthFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger::Ptr integer = DerivedInteger::fromLexical(m_namePool, value); + DerivedInteger::Ptr integer = DerivedInteger::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "minLength", value, BuiltinTypes::xsNonNegativeInteger); return facet; @@ -2278,7 +2278,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMinLengthFacet() validateIdAttribute("minLength"); - TagValidationHandler tagValidator(XsdTagScope::MinLengthFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MinLengthFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2330,7 +2330,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxLengthFacet() } const QString value = readAttribute(QString::fromLatin1("value")); - DerivedInteger::Ptr integer = DerivedInteger::fromLexical(m_namePool, value); + DerivedInteger::Ptr integer = DerivedInteger::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("value", "maxLength", value, BuiltinTypes::xsNonNegativeInteger); return facet; @@ -2340,7 +2340,7 @@ XsdFacet::Ptr XsdSchemaParser::parseMaxLengthFacet() validateIdAttribute("maxLength"); - TagValidationHandler tagValidator(XsdTagScope::MaxLengthFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::MaxLengthFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2384,7 +2384,7 @@ XsdFacet::Ptr XsdSchemaParser::parseEnumerationFacet() // as enumeration can have a value of type anySimpleType, we just read // the string here and store it for later intepretation - DerivedString::Ptr string = DerivedString::fromLexical(m_namePool, value); + DerivedString::Ptr string = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "enumeration", value); return facet; @@ -2397,7 +2397,7 @@ XsdFacet::Ptr XsdSchemaParser::parseEnumerationFacet() validateIdAttribute("enumeration"); - TagValidationHandler tagValidator(XsdTagScope::EnumerationFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::EnumerationFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2455,7 +2455,7 @@ XsdFacet::Ptr XsdSchemaParser::parseWhiteSpaceFacet() attributeContentError("value", "whiteSpace", value); return facet; } else { - DerivedString::Ptr string = DerivedString::fromLexical(m_namePool, value); + DerivedString::Ptr string = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "whiteSpace", value); return facet; @@ -2466,7 +2466,7 @@ XsdFacet::Ptr XsdSchemaParser::parseWhiteSpaceFacet() validateIdAttribute("whiteSpace"); - TagValidationHandler tagValidator(XsdTagScope::WhiteSpaceFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::WhiteSpaceFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2508,7 +2508,7 @@ XsdFacet::Ptr XsdSchemaParser::parsePatternFacet() // as pattern can have a value of type anySimpleType, we just read // the string here and store it for later intepretation const QString value = readAttribute(QString::fromLatin1("value")); - DerivedString::Ptr string = DerivedString::fromLexical(m_namePool, value); + DerivedString::Ptr string = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (string->hasError()) { attributeContentError("value", "pattern", value); return facet; @@ -2520,7 +2520,7 @@ XsdFacet::Ptr XsdSchemaParser::parsePatternFacet() validateIdAttribute("pattern"); - TagValidationHandler tagValidator(XsdTagScope::PatternFacet, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::PatternFacet, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2608,7 +2608,7 @@ XsdComplexType::Ptr XsdSchemaParser::parseGlobalComplexType() validateIdAttribute("complexType"); - TagValidationHandler tagValidator(XsdTagScope::GlobalComplexType, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::GlobalComplexType, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2763,7 +2763,7 @@ XsdComplexType::Ptr XsdSchemaParser::parseLocalComplexType() validateIdAttribute("complexType"); - TagValidationHandler tagValidator(XsdTagScope::LocalComplexType, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalComplexType, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2926,7 +2926,7 @@ void XsdSchemaParser::parseSimpleContent(const XsdComplexType::Ptr &complexType) // parse attributes validateIdAttribute("simpleContent"); - TagValidationHandler tagValidator(XsdTagScope::SimpleContent, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::SimpleContent, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -2976,7 +2976,7 @@ void XsdSchemaParser::parseSimpleContentRestriction(const XsdComplexType::Ptr &c QList enumerationFacets; QList assertionFacets; - TagValidationHandler tagValidator(XsdTagScope::SimpleContentRestriction, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::SimpleContentRestriction, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3117,7 +3117,7 @@ void XsdSchemaParser::parseSimpleContentExtension(const XsdComplexType::Ptr &com validateIdAttribute("extension"); - TagValidationHandler tagValidator(XsdTagScope::SimpleContentExtension, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::SimpleContentExtension, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3180,7 +3180,7 @@ void XsdSchemaParser::parseComplexContent(const XsdComplexType::Ptr &complexType validateIdAttribute("complexContent"); - TagValidationHandler tagValidator(XsdTagScope::ComplexContent, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ComplexContent, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3226,7 +3226,7 @@ void XsdSchemaParser::parseComplexContentRestriction(const XsdComplexType::Ptr & validateIdAttribute("restriction"); - TagValidationHandler tagValidator(XsdTagScope::ComplexContentRestriction, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ComplexContentRestriction, this, NamePool::Ptr(m_namePool)); bool hasContent = false; while (!atEnd()) { @@ -3312,7 +3312,7 @@ void XsdSchemaParser::parseComplexContentExtension(const XsdComplexType::Ptr &co validateIdAttribute("extension"); - TagValidationHandler tagValidator(XsdTagScope::ComplexContentExtension, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ComplexContentExtension, this, NamePool::Ptr(m_namePool)); bool hasContent = false; while (!atEnd()) { @@ -3401,7 +3401,7 @@ XsdAssertion::Ptr XsdSchemaParser::parseAssertion(const XsdSchemaToken::NodeName validateIdAttribute("assertion"); - TagValidationHandler tagValidator(tag, this, m_namePool); + TagValidationHandler tagValidator(tag, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3456,7 +3456,7 @@ XsdComplexType::OpenContent::Ptr XsdSchemaParser::parseOpenContent() validateIdAttribute("openContent"); - TagValidationHandler tagValidator(XsdTagScope::OpenContent, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::OpenContent, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3504,7 +3504,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseNamedGroup() validateIdAttribute("group"); - TagValidationHandler tagValidator(XsdTagScope::NamedGroup, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::NamedGroup, this, NamePool::Ptr(m_namePool)); XsdAnnotation::Ptr annotation; @@ -3566,7 +3566,7 @@ XsdTerm::Ptr XsdSchemaParser::parseReferredGroup(const XsdParticle::Ptr &particl validateIdAttribute("group"); - TagValidationHandler tagValidator(XsdTagScope::ReferredGroup, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ReferredGroup, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3605,7 +3605,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseAll(const NamedSchemaComponent::Ptr &pa validateIdAttribute("all"); - TagValidationHandler tagValidator(XsdTagScope::All, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::All, this, NamePool::Ptr(m_namePool)); XsdParticle::List particles; while (!atEnd()) { @@ -3682,7 +3682,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseLocalAll(const XsdParticle::Ptr &partic validateIdAttribute("all"); - TagValidationHandler tagValidator(XsdTagScope::LocalAll, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalAll, this, NamePool::Ptr(m_namePool)); XsdParticle::List particles; while (!atEnd()) { @@ -3741,7 +3741,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseChoice(const NamedSchemaComponent::Ptr XsdParticle::List particles; - TagValidationHandler tagValidator(XsdTagScope::Choice, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Choice, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3815,7 +3815,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseLocalChoice(const XsdParticle::Ptr &par XsdParticle::List particles; - TagValidationHandler tagValidator(XsdTagScope::LocalChoice, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalChoice, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3884,7 +3884,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseSequence(const NamedSchemaComponent::Pt XsdParticle::List particles; - TagValidationHandler tagValidator(XsdTagScope::Sequence, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Sequence, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -3958,7 +3958,7 @@ XsdModelGroup::Ptr XsdSchemaParser::parseLocalSequence(const XsdParticle::Ptr &p XsdParticle::List particles; - TagValidationHandler tagValidator(XsdTagScope::LocalSequence, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalSequence, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4082,7 +4082,7 @@ XsdAttribute::Ptr XsdSchemaParser::parseGlobalAttribute() validateIdAttribute("attribute"); - TagValidationHandler tagValidator(XsdTagScope::GlobalAttribute, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::GlobalAttribute, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4314,7 +4314,7 @@ XsdAttributeUse::Ptr XsdSchemaParser::parseLocalAttribute(const NamedSchemaCompo validateIdAttribute("attribute"); - TagValidationHandler tagValidator(XsdTagScope::LocalAttribute, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalAttribute, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4383,7 +4383,7 @@ XsdAttributeGroup::Ptr XsdSchemaParser::parseNamedAttributeGroup() validateIdAttribute("attributeGroup"); - TagValidationHandler tagValidator(XsdTagScope::NamedAttributeGroup, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::NamedAttributeGroup, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4443,7 +4443,7 @@ XsdAttributeUse::Ptr XsdSchemaParser::parseReferredAttributeGroup() validateIdAttribute("attributeGroup"); - TagValidationHandler tagValidator(XsdTagScope::ReferredAttributeGroup, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::ReferredAttributeGroup, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4581,7 +4581,7 @@ XsdElement::Ptr XsdSchemaParser::parseGlobalElement() XsdAlternative::List alternatives; - TagValidationHandler tagValidator(XsdTagScope::GlobalElement, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::GlobalElement, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -4856,7 +4856,7 @@ XsdTerm::Ptr XsdSchemaParser::parseLocalElement(const XsdParticle::Ptr &particle XsdAlternative::List alternatives; - TagValidationHandler tagValidator(XsdTagScope::LocalElement, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::LocalElement, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5015,7 +5015,7 @@ XsdIdentityConstraint::Ptr XsdSchemaParser::parseUnique() validateIdAttribute("unique"); - TagValidationHandler tagValidator(XsdTagScope::Unique, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Unique, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5065,7 +5065,7 @@ XsdIdentityConstraint::Ptr XsdSchemaParser::parseKey() validateIdAttribute("key"); - TagValidationHandler tagValidator(XsdTagScope::Key, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Key, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5120,7 +5120,7 @@ XsdIdentityConstraint::Ptr XsdSchemaParser::parseKeyRef(const XsdElement::Ptr &e validateIdAttribute("keyref"); - TagValidationHandler tagValidator(XsdTagScope::KeyRef, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::KeyRef, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5171,7 +5171,7 @@ void XsdSchemaParser::parseSelector(const XsdIdentityConstraint::Ptr &ptr) validateIdAttribute("selector"); - TagValidationHandler tagValidator(XsdTagScope::Selector, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Selector, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5213,7 +5213,7 @@ void XsdSchemaParser::parseField(const XsdIdentityConstraint::Ptr &ptr) validateIdAttribute("field"); - TagValidationHandler tagValidator(XsdTagScope::Field, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Field, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5269,7 +5269,7 @@ XsdAlternative::Ptr XsdSchemaParser::parseAlternative() validateIdAttribute("alternative"); - TagValidationHandler tagValidator(XsdTagScope::Alternative, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Alternative, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5339,7 +5339,7 @@ XsdNotation::Ptr XsdSchemaParser::parseNotation() if (hasAttribute(QString::fromLatin1("public"))) { const QString value = readAttribute(QString::fromLatin1("public")); if (!value.isEmpty()) { - const DerivedString::Ptr publicId = DerivedString::fromLexical(m_namePool, value); + const DerivedString::Ptr publicId = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (publicId->hasError()) { attributeContentError("public", "notation", value, BuiltinTypes::xsToken); return notation; @@ -5375,7 +5375,7 @@ XsdNotation::Ptr XsdSchemaParser::parseNotation() validateIdAttribute("notation"); - TagValidationHandler tagValidator(XsdTagScope::Notation, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Notation, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5498,7 +5498,7 @@ XsdWildcard::Ptr XsdSchemaParser::parseAny(const XsdParticle::Ptr &particle) validateIdAttribute("any"); - TagValidationHandler tagValidator(XsdTagScope::Any, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::Any, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5610,7 +5610,7 @@ XsdWildcard::Ptr XsdSchemaParser::parseAnyAttribute() validateIdAttribute("anyAttribute"); - TagValidationHandler tagValidator(XsdTagScope::AnyAttribute, this, m_namePool); + TagValidationHandler tagValidator(XsdTagScope::AnyAttribute, this, NamePool::Ptr(m_namePool)); while (!atEnd()) { readNext(); @@ -5684,7 +5684,7 @@ bool XsdSchemaParser::parseMinMaxConstraint(const XsdParticle::Ptr &particle, co if (hasAttribute(QString::fromLatin1("minOccurs"))) { const QString value = readAttribute(QString::fromLatin1("minOccurs")); - DerivedInteger::Ptr integer = DerivedInteger::fromLexical(m_namePool, value); + DerivedInteger::Ptr integer = DerivedInteger::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("minOccurs", elementName, value, BuiltinTypes::xsNonNegativeInteger); return false; @@ -5702,7 +5702,7 @@ bool XsdSchemaParser::parseMinMaxConstraint(const XsdParticle::Ptr &particle, co particle->setMaximumOccursUnbounded(true); } else { particle->setMaximumOccursUnbounded(false); - DerivedInteger::Ptr integer = DerivedInteger::fromLexical(m_namePool, value); + DerivedInteger::Ptr integer = DerivedInteger::fromLexical(NamePool::Ptr(m_namePool), value); if (integer->hasError()) { attributeContentError("maxOccurs", elementName, value, BuiltinTypes::xsNonNegativeInteger); return false; @@ -5963,7 +5963,7 @@ QString XsdSchemaParser::readXPathAttribute(const QString &attributeName, XPathT return QString(); } - QXmlNamePool namePool(m_namePool.data()); + QXmlNamePool namePool(NamePool::Ptr(m_namePool).data()); QXmlQuery::QueryLanguage language = QXmlQuery::XPath20; switch (type) { @@ -5994,7 +5994,7 @@ void XsdSchemaParser::validateIdAttribute(const char *elementName) { if (hasAttribute(QString::fromLatin1("id"))) { const QString value = readAttribute(QString::fromLatin1("id")); - DerivedString::Ptr id = DerivedString::fromLexical(m_namePool, value); + DerivedString::Ptr id = DerivedString::fromLexical(NamePool::Ptr(m_namePool), value); if (id->hasError()) { attributeContentError("id", elementName, value, BuiltinTypes::xsID); } else { @@ -6014,7 +6014,7 @@ bool XsdSchemaParser::isSchemaTag(XsdSchemaToken::NodeName tag, XsdSchemaToken:: void XsdSchemaParser::addElement(const XsdElement::Ptr &element) { - const QXmlName objectName = element->name(m_namePool); + const QXmlName objectName = element->name(NamePool::Ptr(m_namePool)); if (m_schema->element(objectName)) { error(QtXmlPatterns::tr("Element %1 already defined.").arg(formatElement(m_namePool->displayName(objectName)))); } else { @@ -6025,7 +6025,7 @@ void XsdSchemaParser::addElement(const XsdElement::Ptr &element) void XsdSchemaParser::addAttribute(const XsdAttribute::Ptr &attribute) { - const QXmlName objectName = attribute->name(m_namePool); + const QXmlName objectName = attribute->name(NamePool::Ptr(m_namePool)); if (m_schema->attribute(objectName)) { error(QtXmlPatterns::tr("Attribute %1 already defined.").arg(formatAttribute(m_namePool->displayName(objectName)))); } else { @@ -6037,12 +6037,12 @@ void XsdSchemaParser::addAttribute(const XsdAttribute::Ptr &attribute) void XsdSchemaParser::addType(const SchemaType::Ptr &type) { // we don't import redefinitions of builtin types, that just causes problems - if (m_builtinTypeNames.contains(type->name(m_namePool))) + if (m_builtinTypeNames.contains(type->name(NamePool::Ptr(m_namePool)))) return; - const QXmlName objectName = type->name(m_namePool); + const QXmlName objectName = type->name(NamePool::Ptr(m_namePool)); if (m_schema->type(objectName)) { - error(QtXmlPatterns::tr("Type %1 already defined.").arg(formatType(m_namePool, objectName))); + error(QtXmlPatterns::tr("Type %1 already defined.").arg(formatType(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addType(type); if (type->isSimpleType()) @@ -6063,9 +6063,9 @@ void XsdSchemaParser::addAnonymousType(const SchemaType::Ptr &type) void XsdSchemaParser::addAttributeGroup(const XsdAttributeGroup::Ptr &group) { - const QXmlName objectName = group->name(m_namePool); + const QXmlName objectName = group->name(NamePool::Ptr(m_namePool)); if (m_schema->attributeGroup(objectName)) { - error(QtXmlPatterns::tr("Attribute group %1 already defined.").arg(formatKeyword(m_namePool, objectName))); + error(QtXmlPatterns::tr("Attribute group %1 already defined.").arg(formatKeyword(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addAttributeGroup(group); m_componentLocationHash.insert(group, currentSourceLocation()); @@ -6074,9 +6074,9 @@ void XsdSchemaParser::addAttributeGroup(const XsdAttributeGroup::Ptr &group) void XsdSchemaParser::addElementGroup(const XsdModelGroup::Ptr &group) { - const QXmlName objectName = group->name(m_namePool); + const QXmlName objectName = group->name(NamePool::Ptr(m_namePool)); if (m_schema->elementGroup(objectName)) { - error(QtXmlPatterns::tr("Element group %1 already defined.").arg(formatKeyword(m_namePool, objectName))); + error(QtXmlPatterns::tr("Element group %1 already defined.").arg(formatKeyword(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addElementGroup(group); m_componentLocationHash.insert(group, currentSourceLocation()); @@ -6085,9 +6085,9 @@ void XsdSchemaParser::addElementGroup(const XsdModelGroup::Ptr &group) void XsdSchemaParser::addNotation(const XsdNotation::Ptr ¬ation) { - const QXmlName objectName = notation->name(m_namePool); + const QXmlName objectName = notation->name(NamePool::Ptr(m_namePool)); if (m_schema->notation(objectName)) { - error(QtXmlPatterns::tr("Notation %1 already defined.").arg(formatKeyword(m_namePool, objectName))); + error(QtXmlPatterns::tr("Notation %1 already defined.").arg(formatKeyword(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addNotation(notation); m_componentLocationHash.insert(notation, currentSourceLocation()); @@ -6096,9 +6096,9 @@ void XsdSchemaParser::addNotation(const XsdNotation::Ptr ¬ation) void XsdSchemaParser::addIdentityConstraint(const XsdIdentityConstraint::Ptr &constraint) { - const QXmlName objectName = constraint->name(m_namePool); + const QXmlName objectName = constraint->name(NamePool::Ptr(m_namePool)); if (m_schema->identityConstraint(objectName)) { - error(QtXmlPatterns::tr("Identity constraint %1 already defined.").arg(formatKeyword(m_namePool, objectName))); + error(QtXmlPatterns::tr("Identity constraint %1 already defined.").arg(formatKeyword(NamePool::Ptr(m_namePool), objectName))); } else { m_schema->addIdentityConstraint(constraint); m_componentLocationHash.insert(constraint, currentSourceLocation()); @@ -6109,7 +6109,7 @@ void XsdSchemaParser::addFacet(const XsdFacet::Ptr &facet, XsdFacet::Hash &facet { // @see http://www.w3.org/TR/xmlschema-2/#src-single-facet-value if (facets.contains(facet->type())) { - error(QtXmlPatterns::tr("Duplicated facets in simple type %1.").arg(formatType(m_namePool, type))); + error(QtXmlPatterns::tr("Duplicated facets in simple type %1.").arg(formatType(NamePool::Ptr(m_namePool), type))); return; } diff --git a/src/xmlpatterns/schema/qxsdschemaparser_p.h b/src/xmlpatterns/schema/qxsdschemaparser_p.h index 7054b87..93163de 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser_p.h +++ b/src/xmlpatterns/schema/qxsdschemaparser_p.h @@ -704,12 +704,12 @@ namespace QPatternist */ inline bool isSchemaTag(XsdSchemaToken::NodeName tag, XsdSchemaToken::NodeName token, XsdSchemaToken::NodeName namespaceToken) const; - XsdSchemaContext::Ptr m_context; - XsdSchemaParserContext::Ptr m_parserContext; - NamePool::Ptr m_namePool; + XsdSchemaContext *m_context; + XsdSchemaParserContext *m_parserContext; + NamePool *m_namePool; NamespaceSupport m_namespaceSupport; - XsdSchemaResolver::Ptr m_schemaResolver; - XsdSchema::Ptr m_schema; + XsdSchemaResolver *m_schemaResolver; + XsdSchema *m_schema; QString m_targetNamespace; QString m_attributeFormDefault; diff --git a/src/xmlpatterns/schema/qxsdschemaparser_setup.cpp b/src/xmlpatterns/schema/qxsdschemaparser_setup.cpp index 35ededd..1757d25 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser_setup.cpp +++ b/src/xmlpatterns/schema/qxsdschemaparser_setup.cpp @@ -260,8 +260,9 @@ using namespace QPatternist; void XsdSchemaParser::setupStateMachines() { + NamePool::Ptr namePool(m_namePool); { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, simpleType?) : attribute const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -277,7 +278,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, ((simpleType | complexType)?, alternative*, (unique | key | keyref)*)) : element const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -320,7 +321,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (simpleContent | complexContent | (openContent?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), assert*))) : complexType const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -385,7 +386,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (restriction | extension)) : simpleContent/complexContent const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartState); @@ -404,7 +405,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern | assertion)*)?, ((attribute | attributeGroup)*, anyAttribute?), assert*) : simpleContent restriction const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -503,7 +504,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, ((attribute | attributeGroup)*, anyAttribute?), assert*) : simple content extension const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -536,7 +537,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, openContent?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), assert*)) : complex content restriction/complex content extension const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -596,7 +597,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) : named attribute group const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -621,7 +622,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (all | choice | sequence)?) : group const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -642,7 +643,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (element | any)*) : all const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -664,7 +665,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (element | group | choice | sequence | any)*) : choice sequence const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -697,7 +698,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?) : any/selector/field/notation/include/import/referred attribute group/anyAttribute/all facets/assert const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -730,7 +731,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (selector, field+)) : unique/key/keyref const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartState); @@ -751,7 +752,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (simpleType | complexType)?) : alternative const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -769,7 +770,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (appinfo | documentation)* : annotation const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -785,7 +786,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (restriction | list | union)) : simpleType const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartState); @@ -806,7 +807,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern | assertion)*)) : simple type restriction const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -877,7 +878,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, simpleType?) : list const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -893,7 +894,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, simpleType*) : union const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -910,7 +911,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for ((include | import | redefine |i override | annotation)*, (defaultOpenContent, annotation*)?, (((simpleType | complexType | group | attributeGroup) | element | attribute | notation), annotation*)*) : schema const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -987,7 +988,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation?, any) : defaultOpenContent const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -1003,7 +1004,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation | (simpleType | complexType | group | attributeGroup))* : redefine const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -1025,7 +1026,7 @@ void XsdSchemaParser::setupStateMachines() } { - XsdStateMachine machine(m_namePool); + XsdStateMachine machine(namePool); // setup state machine for (annotation | (simpleType | complexType | group | attributeGroup | element | attribute | notation))* : override const XsdStateMachine::StateId startState = machine.addState(XsdStateMachine::StartEndState); @@ -1055,56 +1056,57 @@ void XsdSchemaParser::setupStateMachines() void XsdSchemaParser::setupBuiltinTypeNames() { + NamePool::Ptr namePool(m_namePool); m_builtinTypeNames.reserve(48); - m_builtinTypeNames.insert(BuiltinTypes::xsAnyType->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsAnySimpleType->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUntyped->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsAnyAtomicType->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUntypedAtomic->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDateTime->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDate->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsTime->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDuration->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsYearMonthDuration->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDayTimeDuration->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsFloat->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDouble->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsDecimal->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNonPositiveInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNegativeInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsLong->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsInt->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsShort->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsByte->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNonNegativeInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedLong->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedInt->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedShort->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedByte->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsPositiveInteger->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGYearMonth->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGYear->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGMonthDay->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGDay->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsGMonth->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsBoolean->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsBase64Binary->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsHexBinary->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsAnyURI->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsQName->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsString->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNormalizedString->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsToken->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsLanguage->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNMTOKEN->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsName->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNCName->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsID->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsIDREF->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsENTITY->name(m_namePool)); - m_builtinTypeNames.insert(BuiltinTypes::xsNOTATION->name(m_namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsAnyType->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsAnySimpleType->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUntyped->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsAnyAtomicType->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUntypedAtomic->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDateTime->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDate->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsTime->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDuration->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsYearMonthDuration->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDayTimeDuration->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsFloat->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDouble->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsDecimal->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNonPositiveInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNegativeInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsLong->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsInt->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsShort->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsByte->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNonNegativeInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedLong->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedInt->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedShort->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsUnsignedByte->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsPositiveInteger->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGYearMonth->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGYear->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGMonthDay->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGDay->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsGMonth->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsBoolean->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsBase64Binary->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsHexBinary->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsAnyURI->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsQName->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsString->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNormalizedString->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsToken->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsLanguage->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNMTOKEN->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsName->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNCName->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsID->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsIDREF->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsENTITY->name(namePool)); + m_builtinTypeNames.insert(BuiltinTypes::xsNOTATION->name(namePool)); } QT_END_NAMESPACE diff --git a/tests/auto/xmlpatternsschemats/TESTSUITE/updateSuite.sh b/tests/auto/xmlpatternsschemats/TESTSUITE/updateSuite.sh index a61f0a1..894fa5a 100755 --- a/tests/auto/xmlpatternsschemats/TESTSUITE/updateSuite.sh +++ b/tests/auto/xmlpatternsschemats/TESTSUITE/updateSuite.sh @@ -47,6 +47,8 @@ # # To run the script, Saxon package version 9 and above shall be installed # +# Installation instruction +# http://johnbokma.com/mexit/2011/07/04/installing-saxon-he-ubuntu.html DIRECTORY_NAME="xmlschema2006-11-06" ARCHIVE_NAME="xsts-2007-06-20.tar.gz" @@ -62,5 +64,6 @@ rm $ARCHIVE_NAME #CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs checkout -d xmlschema2006-11-06-new XML/xml-schema-test-suite/2004-01-14/xmlschema2006-11-06 #Saxon need to be installed before the following command works. -java -jar /usr/share/java/saxon.jar -xsl:unifyCatalog.xsl -s:$DIRECTORY_NAME/suite.xml > testSuites.xml +#java -jar /usr/share/java/saxonb.jar -xsl:unifyCatalog.xsl -s:$DIRECTORY_NAME/suite.xml > testSuites.xml +saxon9he-xslt -xsl:unifyCatalog.xsl -s:$DIRECTORY_NAME/suite.xml > testSuites.xml -- cgit v0.12 From 265430f71ac7c3bf79d7fbf7f02e9a911489c475 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 21 Sep 2011 13:16:34 +0300 Subject: Symbian: Fix qmdiarea autotest regressions Some cases in qmdiarea test passed on 4.7 but failed on 4.8. A closer examination reveals that the cases are in any case invalid in Symbian and should be skipped like in WinCE and Mac. Task-number: QT-5254 Reviewed-by: Sami Merila --- tests/auto/qmdiarea/tst_qmdiarea.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/auto/qmdiarea/tst_qmdiarea.cpp b/tests/auto/qmdiarea/tst_qmdiarea.cpp index c752362..f782bf8 100644 --- a/tests/auto/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/qmdiarea/tst_qmdiarea.cpp @@ -661,7 +661,7 @@ void tst_QMdiArea::changeWindowTitle() #else widget->setWindowState(Qt::WindowMaximized); #endif -#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) ); #endif @@ -671,7 +671,7 @@ void tst_QMdiArea::changeWindowTitle() qApp->processEvents(); QTest::qWaitForWindowShown(mw); -#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) ); #endif @@ -689,7 +689,7 @@ void tst_QMdiArea::changeWindowTitle() widget->setWindowState(Qt::WindowMaximized); #endif qApp->processEvents(); -#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) ); widget->setWindowTitle( wc2 ); QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc2) ); @@ -707,7 +707,7 @@ void tst_QMdiArea::changeWindowTitle() #endif qApp->processEvents(); -#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc2).arg(wc2) ); #endif #ifdef USE_SHOW @@ -716,7 +716,7 @@ void tst_QMdiArea::changeWindowTitle() widget->setWindowState(Qt::WindowNoState); #endif qApp->processEvents(); -#if defined(Q_WS_MAC) || defined(Q_OS_WINCE) +#if defined(Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QCOMPARE(mw->windowTitle(), mwc); #else QCOMPARE( mw->windowTitle(), mwc2 ); @@ -728,7 +728,7 @@ void tst_QMdiArea::changeWindowTitle() widget->setWindowState(Qt::WindowMaximized); #endif qApp->processEvents(); -#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc2).arg(wc2) ); #endif @@ -777,7 +777,7 @@ void tst_QMdiArea::changeModified() QCOMPARE( mw->isWindowModified(), false); QCOMPARE( widget->isWindowModified(), true); widget->setWindowState(Qt::WindowMaximized); -#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QCOMPARE( mw->isWindowModified(), true); #endif QCOMPARE( widget->isWindowModified(), true); @@ -787,7 +787,7 @@ void tst_QMdiArea::changeModified() QCOMPARE( widget->isWindowModified(), true); widget->setWindowState(Qt::WindowMaximized); -#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QCOMPARE( mw->isWindowModified(), true); #endif QCOMPARE( widget->isWindowModified(), true); @@ -797,7 +797,7 @@ void tst_QMdiArea::changeModified() QCOMPARE( widget->isWindowModified(), false); widget->setWindowModified(true); -#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QCOMPARE( mw->isWindowModified(), true); #endif QCOMPARE( widget->isWindowModified(), true); @@ -2046,7 +2046,7 @@ void tst_QMdiArea::delayedPlacement() void tst_QMdiArea::iconGeometryInMenuBar() { -#if !defined (Q_WS_MAC) && !defined(Q_OS_WINCE) +#if !defined (Q_WS_MAC) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QMainWindow mainWindow; QMenuBar *menuBar = mainWindow.menuBar(); QMdiArea *mdiArea = new QMdiArea; -- cgit v0.12 From 3107ec55be7053b451a37221b1fb6ab278eb7c1f Mon Sep 17 00:00:00 2001 From: Timo Kauppinen Date: Wed, 13 Apr 2011 10:18:15 +0300 Subject: Added SQL driver plugin implementation for Symbian. The Symbian SQL driver enables the usage of native Symbian SQL server from Qt code. Symbian SQL driver also supports the usage of Symbian platform security capabilities. Task-number: QT-4860 Reviewed-by: Honglei Zhang --- src/plugins/sqldrivers/symsql/main.cpp | 81 ++ src/plugins/sqldrivers/symsql/symsql.pro | 13 + src/sql/drivers/symsql/qsql_symsql.cpp | 1236 ++++++++++++++++++++++++++++++ src/sql/drivers/symsql/qsql_symsql.h | 132 ++++ src/sql/drivers/symsql/qsql_symsql.pri | 5 + 5 files changed, 1467 insertions(+) create mode 100644 src/plugins/sqldrivers/symsql/main.cpp create mode 100644 src/plugins/sqldrivers/symsql/symsql.pro create mode 100644 src/sql/drivers/symsql/qsql_symsql.cpp create mode 100644 src/sql/drivers/symsql/qsql_symsql.h create mode 100644 src/sql/drivers/symsql/qsql_symsql.pri diff --git a/src/plugins/sqldrivers/symsql/main.cpp b/src/plugins/sqldrivers/symsql/main.cpp new file mode 100644 index 0000000..0fd8756 --- /dev/null +++ b/src/plugins/sqldrivers/symsql/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "../../../sql/drivers/symsql/qsql_symsql.h" + +QT_BEGIN_NAMESPACE + +class QSymSQLDriverPlugin : public QSqlDriverPlugin +{ +public: + QSymSQLDriverPlugin(); + + QSqlDriver* create(const QString &); + QStringList keys() const; +}; + +QSymSQLDriverPlugin::QSymSQLDriverPlugin() + : QSqlDriverPlugin() +{ +} + +QSqlDriver* QSymSQLDriverPlugin::create(const QString &name) +{ + if (name == QLatin1String("QSYMSQL")) { + QSymSQLDriver* driver = new QSymSQLDriver(); + return driver; + } + return 0; +} + +QStringList QSymSQLDriverPlugin::keys() const +{ + QStringList l; + l.append(QLatin1String("QSYMSQL")); + return l; +} + +Q_EXPORT_STATIC_PLUGIN(QSymSQLDriverPlugin) +Q_EXPORT_PLUGIN2(qsymsql, QSymSQLDriverPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/sqldrivers/symsql/symsql.pro b/src/plugins/sqldrivers/symsql/symsql.pro new file mode 100644 index 0000000..8b8434c --- /dev/null +++ b/src/plugins/sqldrivers/symsql/symsql.pro @@ -0,0 +1,13 @@ +TARGET = qsymsql +PLUGIN_TYPE = sqldrivers +SOURCES = main.cpp + +include(../../../sql/drivers/symsql/qsql_symsql.pri) +include(../qsqldriverbase.pri) + +symbian: { +pluginDep.sources = $${TARGET}.dll +pluginDep.path = $${QT_PLUGINS_BASE_DIR}/$${PLUGIN_TYPE} +DEPLOYMENT += pluginDep +} + diff --git a/src/sql/drivers/symsql/qsql_symsql.cpp b/src/sql/drivers/symsql/qsql_symsql.cpp new file mode 100644 index 0000000..a015400 --- /dev/null +++ b/src/sql/drivers/symsql/qsql_symsql.cpp @@ -0,0 +1,1236 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsql_symsql.h" + + +#define SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../../corelib/kernel/qcore_symbian_p.h" + +#if defined Q_OS_WIN +# include +#else +# include +#endif + +#include +#include + +const char* qCapabilityNames[ECapability_Limit] = +{ + "TCB", + "CommDD", + "PowerMgmt", + "MultimediaDD", + "ReadDeviceData", + "WriteDeviceData", + "DRM", + "TrustedUI", + "ProtServ", + "DiskAdmin", + "NetworkControl", + "AllFiles", + "SwEvent", + "NetworkServices", + "LocalServices", + "ReadUserData", + "WriteUserData", + "Location", + "SurroundingsDD", + "UserEnvironment" +}; + +const char qCapabilityNone[] = "None"; + + +Q_DECLARE_METATYPE(RSqlDatabase) +Q_DECLARE_METATYPE(RSqlStatement) + +QT_BEGIN_NAMESPACE + +const QString valueSeparator(QLatin1String("=")); +const QString fieldSeparator(QLatin1String(",")); + +static QString _q_escapeIdentifier(const QString &identifier) +{ + QString res = identifier; + if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('"')) && identifier.right(1) != QString(QLatin1Char('"')) ) { + res.replace(QLatin1Char('"'), QLatin1String("\"\"")); + res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); + res.replace(QLatin1Char('.'), QLatin1String("\".\"")); + } + return res; +} + +static QVariant::Type qGetColumnType(const TSqlColumnType coltype) +{ + //ToDo Check Implmentation + switch(coltype){ + case ESqlInt: + case ESqlInt64: + return QVariant::Int; + case ESqlReal: + return QVariant::Double; + case ESqlBinary: + return QVariant::ByteArray; + case ESqlText: + case ESqlNull: + default: + return QVariant::String; + } +} + +static QVariant::Type qGetColumnType(const QString &tpName) + { + const QString typeName = tpName.toLower(); + + if (typeName == QLatin1String("integer") + || typeName == QLatin1String("int")) + return QVariant::Int; + if (typeName == QLatin1String("double") + || typeName == QLatin1String("float") + || typeName == QLatin1String("real") + || typeName.startsWith(QLatin1String("numeric"))) + return QVariant::Double; + if (typeName == QLatin1String("blob")) + return QVariant::ByteArray; + return QVariant::String; +} + +static QSqlError qMakeError(RSqlDatabase& access, const QString &descr, QSqlError::ErrorType type, + int errorCode = -1) +{ + return QSqlError(descr, + QString::fromUtf16(static_cast(access.LastErrorMessage().Ptr())), + type, errorCode); +} + + +static QSqlError gMakeErrorOpen(const QString &descr, QSqlError::ErrorType type, + TInt errorCode) +{ + return QSqlError(descr, QLatin1String(""), type, errorCode); +} + +class QSymSQLDriverPrivate +{ +public: + inline QSymSQLDriverPrivate() {} + RSqlDatabase access; +}; + +class QSymSQLResultPrivate +{ +public: + QSymSQLResultPrivate(QSymSQLResult *res); + void cleanup(); + bool fetchNext(bool initialFetch); + // initializes the recordInfo + void initColumns(QSqlRecord& rec); + void finalize(); + + QSymSQLResult* q; + RSqlDatabase access; + RSqlStatement stmt; + bool skipRow; // skip the next fetchNext()? + bool skippedStatus; // the status of the fetchNext() that's skipped + bool prepareCalled; +}; + +QSymSQLResultPrivate::QSymSQLResultPrivate(QSymSQLResult* res) : q(res), +skipRow(false), skippedStatus(false), prepareCalled(false) +{ +} + +void QSymSQLResultPrivate::cleanup() +{ + finalize(); + skippedStatus = false; + skipRow = false; + q->setAt(QSql::BeforeFirstRow); + q->setActive(false); +} + +void QSymSQLResultPrivate::finalize() +{ + prepareCalled = false; + stmt.Close(); +} + +void QSymSQLResultPrivate::initColumns(QSqlRecord& rec) +{ + int nCols = stmt.ColumnCount(); + if (nCols <= 0) { + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Error retreving column count"), QSqlError::UnknownError, nCols)); + return; + } + + for (int i = 0; i < nCols; ++i) { + TPtrC cName; + TInt err = stmt.ColumnName(i, cName); + + if (err != KErrNone) { + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Error retreving column name"), QSqlError::UnknownError, err)); + return; + } + + QString colName = qt_TDesC2QString(cName); + + // must use typeName for resolving the type to match QSymSQLDriver::record + TPtrC tName; + TSqlColumnType decColType; + err = stmt.DeclaredColumnType(i, decColType); + + if (err != KErrNone) { + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Error retreving column type"), QSqlError::UnknownError, err)); + return; + } + + int dotIdx = colName.lastIndexOf(QLatin1Char('.')); + QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(decColType)); + + //int stp = stmt.ColumnType(i); Useless lines of code, comment modified according to review + //fld.setSqlType(stp); Useless lines of code, comment modified according to review + rec.append(fld); + } +} + +bool QSymSQLResultPrivate::fetchNext(bool initialFetch) +{ + int res; + + if (skipRow) { + // already fetched + Q_ASSERT(!initialFetch); + skipRow = false; + return skippedStatus; + } + + skipRow = initialFetch; + res = stmt.Next(); + + switch(res) { + case KSqlAtRow: + return true; + case KSqlAtEnd: + stmt.Reset(); + //Removed debug qDebug()<<"query Reset(1)"<setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Unable to fetch row"), QSqlError::ConnectionError, res)); + q->setAt(QSql::AfterLastRow); + return false; + case KSqlErrMisuse: + case KSqlErrBusy: + default: + // something wrong, don't get col info, but still return false + q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", + "Unable to fetch row"), QSqlError::ConnectionError, res)); + stmt.Reset(); + //Removed debug qDebug()<<"query Reset(3)"<setAt(QSql::AfterLastRow); + return false; + } + return false; +} + +////////////////////////////////// QSymSQLResult ///////////////////////////////////////////////// + +QSymSQLResult::QSymSQLResult(const QSymSQLDriver* db) + : QSqlResult(db) +{ + d = new QSymSQLResultPrivate(this); + d->access = db->d->access; +} + + +QSymSQLResult::~QSymSQLResult() +{ + d->cleanup(); + delete d; +} + +bool QSymSQLResult::reset(const QString &query) +{ + if (!prepare(query)) + return false; + + return exec(); +} + +bool QSymSQLResult::prepare(const QString &query) +{ + if (!driver() || !driver()->isOpen() || driver()->isOpenError()) + return false; + + d->cleanup(); + setSelect(false); + + TInt res = d->stmt.Prepare(d->access, qt_QString2TPtrC(query)); + //Removed debug qDebug()<<"query:"<access, QCoreApplication::translate("QSymSQLResult", + "Unable to execute statement"), QSqlError::StatementError, res)); + d->finalize(); + return false; + } + + d->prepareCalled = true; + + return true; +} + +bool QSymSQLResult::exec() +{ + if(d->prepareCalled == false) { + setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", + "Statement is not prepared"), QSqlError::StatementError, KErrGeneral)); + return false; + } + + const QVector values = boundValues(); + + d->skippedStatus = false; + d->skipRow = false; + setAt(QSql::BeforeFirstRow); + setLastError(QSqlError()); + int res = d->stmt.Reset(); + + //Removed debug qDebug()<<"query Reset(4)"<access, QCoreApplication::translate("QSymSQLResult", + "Unable to reset statement"), QSqlError::StatementError, res)); + d->finalize(); + return false; + } + TPtrC tmp; + TInt paramCount = 0; + while(d->stmt.ParamName(paramCount, tmp) == KErrNone) + { + paramCount++; + } + + if (paramCount == values.count()) { + for (int i = 0; i < paramCount; ++i) { + res = KErrNone; + const QVariant value = values.at(i); + + if (value.isNull()) { + res = d->stmt.BindNull(i); //replaced i + 1 with i + } else { + switch (value.type()) { + case QVariant::ByteArray: { + //ToDo check how to handle SQLITE_STATIC + const QByteArray *ba = static_cast(value.constData()); + TPtrC8 data(reinterpret_cast(ba->constData()), ba->length()); + res = d->stmt.BindBinary(i, data); //replaced i + 1 with i + //res = sqlite3_bind_blob(d->stmt, i + 1, ba->constData(), + // ba->size(), SQLITE_STATIC); + break; } + case QVariant::Int: + res = d->stmt.BindInt(i, value.toInt()); //replaced i + 1 with i + break; + case QVariant::Double: + res = d->stmt.BindReal(i, value.toDouble()); //replaced i + 1 with i + + break; + case QVariant::UInt: + case QVariant::LongLong: + res = d->stmt.BindReal(i, value.toLongLong()); //replaced i + 1 with i + break; + + case QVariant::String: { + // lifetime of string == lifetime of its qvariant + //ToDo check how to handle SQLITE_STATIC + const QString *str = static_cast(value.constData()); + res = d->stmt.BindText(i, qt_QString2TPtrC(*str)); // replaced i + 1 with i + //res = sqlite3_bind_text16(d->stmt, i + 1, str->utf16(), + // (str->size()) * sizeof(QChar), SQLITE_STATIC); + break; } + default: { + //ToDo check how to handle SQLITE_TRANSIENT + QString str = value.toString(); + res = d->stmt.BindText(i, qt_QString2TPtrC(str)); //replaced i + 1 with i + // SQLITE_TRANSIENT makes sure that sqlite buffers the data + //res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(), + // (str.size()) * sizeof(QChar), SQLITE_TRANSIENT); + break; } + } + } + if (res != KErrNone) { + setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", + "Unable to bind parameters"), QSqlError::StatementError, res)); + d->finalize(); + return false; + } + } + } else { + setLastError(QSqlError(QCoreApplication::translate("QSymSQLResult", + "Parameter count mismatch"), QString(), QSqlError::StatementError)); + return false; + } + + d->skippedStatus = d->fetchNext(true); + + if (lastError().isValid()) { + setSelect(false); + setActive(false); + return false; + } + + if(d->stmt.ColumnCount() > 0) { + //If there is something, it has to be select + setSelect(true); + } else { + //If there isn't it might be just bad query, let's check manually whether we can find SELECT + QString query = this->lastQuery(); + query = query.trimmed(); + query = query.toLower(); + + //Just check whether there is one in the beginning, don't know if this is enough + //Comments should be at the end of line if those are passed + //For some reason, case insensitive indexOf didn't work for me + if(query.indexOf(QLatin1String("select")) == 0) { + setSelect(true); + } else { + setSelect(false); + } + } + + setActive(true); + return true; +} + + +int QSymSQLResult::size() +{ + return -1; +} + +int QSymSQLResult::numRowsAffected() +{ + return -1; +} + +QVariant QSymSQLResult::lastInsertId() const +{ + if (isActive()) { + qint64 id = static_cast(d->access.LastInsertedRowId()); + if (id){ + return id; + } + } + + return QVariant(); +} + +QSqlRecord QSymSQLResult::record() const +{ + if (!isActive() || !isSelect()) + return QSqlRecord(); + + QSqlRecord res; + d->initColumns(res); + + return res; +} + +QVariant QSymSQLResult::handle() const +{ + return qVariantFromValue(d->stmt); +} + + +// ToDo is a virtual_hook needed? +void QSymSQLResult::virtual_hook(int id, void *data) +{ + switch (id) + { + case QSqlResult::DetachFromResultSet: + d->stmt.Reset(); + //Removed debug qDebug()<<"query Reset(5)"<stmt.ColumnType(idx)) { + case ESqlBinary: + { + TPtrC8 data; + d->stmt.ColumnBinary(idx, data); + return QByteArray(reinterpret_cast(data.Ptr()), data.Length()); + + //ToDo - check if this is correct + // values[i + idx] = QByteArray(static_cast( + // sqlite3_column_blob(stmt, i)), + // stmt.ColumnSize(i)); + break; + } + case ESqlInt: + r = QVariant(d->stmt.ColumnInt(idx)); + break; + case ESqlInt64: + r = QVariant(d->stmt.ColumnInt64(idx)); + break; + case ESqlReal: + switch(numericalPrecisionPolicy()) { + case QSql::LowPrecisionInt32: + r = QVariant(d->stmt.ColumnInt(idx)); + break; + case QSql::LowPrecisionInt64: + r = QVariant(d->stmt.ColumnInt64(idx)); + break; + case QSql::LowPrecisionDouble: + r = QVariant(d->stmt.ColumnReal(idx)); + break; + case QSql::HighPrecision: + default: + TPtrC res; + d->stmt.ColumnText(idx, res); + r = QVariant(qt_TDesC2QString(res)); + //values[i + idx] = QString::fromUtf16(res.Ptr(), res.Length()); + + //ToDo - Check if the implementation is correct + //values[i + idx] = QString::fromUtf16(static_cast( + // sqlite3_column_text16(stmt, i)), + // sqlite3_column_bytes16(stmt, i) / sizeof(ushort)); + break; + }; + break; + case ESqlNull: + r = QVariant(QVariant::String); + break; + default: + TPtrC res; + d->stmt.ColumnText(idx, res); + r = QVariant(qt_TDesC2QString(res)); + //values[i + idx] = QString::fromUtf16(res.Ptr(), res.Length()); + + //ToDo - Check if the implementation is correct + //values[i + idx] = QString::fromUtf16(static_cast( + // sqlite3_column_text16(stmt, i)), + // sqlite3_column_bytes16(stmt, i) / sizeof(ushort)); + break; + } + //Removed debug qDebug()<<"SymSql, Data:"<stmt.IsNull(i); +} + +bool QSymSQLResult::fetch(int i) +{ + //Single return point modified according to review + bool retVal = true; + + if(i < 0 || !isActive()) { + retVal = false; + } else { + //Removed for benchmark, comment modified according to review qDebug()<<"fetch i="<stmt.Reset(); + setAt(-1); + d->skipRow = false; + } + + while(at() < i){ + if(!d->fetchNext(false)) { + retVal = false; + break; + } + + setAt(at() + 1); + } + } + + return retVal; +} + +bool QSymSQLResult::fetchNext() +{ + bool res = d->fetchNext(false); + if(res){ + setAt(at()+1); + } + + return res; +} + +bool QSymSQLResult::fetchPrevious() +{ + return QSqlResult::fetchPrevious(); +} + +bool QSymSQLResult::fetchFirst() +{ + return fetch(0); +} + +bool QSymSQLResult::fetchLast() +{ + if(!isActive()){ + return false; + } + + if(at() <= -1){ + if(!fetchFirst()){ + return false; + } + } + + TInt res; + qDebug() << at(); + + do + { + res = d->stmt.Next(); + setAt(at()+1); + } + while(res == KSqlAtRow); + + if(res != KSqlAtEnd){ + return false; + } + + d->skippedStatus = false; + d->skipRow = false; + + return fetchPrevious(); +} +////////////////////////////////// QSymSQLDriver ////////////////////////////////////////// + +QSymSQLDriver::QSymSQLDriver(QObject * parent) + : QSqlDriver(parent) +{ + d = new QSymSQLDriverPrivate(); +} + +QSymSQLDriver::QSymSQLDriver(RSqlDatabase& connection, QObject *parent) + : QSqlDriver(parent) +{ + d = new QSymSQLDriverPrivate(); + d->access = connection; + setOpen(true); + setOpenError(false); +} + + +QSymSQLDriver::~QSymSQLDriver() +{ + d->access.Close(); + delete d; +} + +bool QSymSQLDriver::hasFeature(DriverFeature f) const +{ + switch (f) { + case BLOB: + case Transactions: + case Unicode: + case PreparedQueries: + case PositionalPlaceholders: + case SimpleLocking: + case FinishQuery: + case LowPrecisionNumbers: + case LastInsertId: + case NamedPlaceholders: + return true; + case QuerySize: + case BatchOperations: + case EventNotifications: + case MultipleResultSets: + return false; + } + return false; +} + +/*! + Converts capability string to TCapability +*/ +TCapability qMatchCapStr(QString& str) +{ + TCapability cap = ECapability_HardLimit; + + for(int i = 0; i < static_cast(ECapability_Limit); i++) { + if(str.compare(QLatin1String(qCapabilityNames[i]), Qt::CaseInsensitive) == 0){ + cap = static_cast(i); + break; + } + } + + //Special case, we allow ECapability_None to be defined + if(cap == ECapability_HardLimit && + str.compare(QLatin1String(qCapabilityNone), Qt::CaseInsensitive) == 0) { + cap = ECapability_None; + } + + return cap; +} + +bool qExtractSecurityPolicyFromString(const QString &string, TSecurityPolicy &policy) +{ + int startPos = string.indexOf(QLatin1Char('=')); + QStringList values; + bool ret = false; + + if(startPos == -1) { + values = string.split(QLatin1Char(','), QString::SkipEmptyParts); + } else { + values = string.mid(startPos + 1).split(QLatin1Char(','), QString::SkipEmptyParts); + } + + if(values.count() > 0) { + const QString findVid(QLatin1String("vid[")); + const QString findSid(QLatin1String("sid[")); + const int MaxCapCount = 7; + const int VidMaxCount = 3; + const int SidMaxCount = 3; + + TCapability capList[MaxCapCount] = { ECapability_None,ECapability_None,ECapability_None, + ECapability_None,ECapability_None,ECapability_None,ECapability_None }; + + bool isVID = false; + bool isSID = false; + + QString idString(QLatin1String("")); + int maxAllowed = MaxCapCount; + + if(values[0].contains(findVid, Qt::CaseInsensitive)) { + idString = values[0].remove(findVid, Qt::CaseInsensitive); + idString = idString.remove(QLatin1Char(']')); + values.removeAt(0); + isVID = true; + maxAllowed = VidMaxCount; + + } else if(values[0].contains(findSid, Qt::CaseInsensitive)) { + idString = values[0].remove(findSid, Qt::CaseInsensitive); + idString = idString.remove(QLatin1Char(']')); + values.removeAt(0); + isSID = true; + maxAllowed = SidMaxCount; + } + + if(values.count() <= maxAllowed) { + bool wasSuccesful = true; + + for(int i = 0; i < values.count(); i++) { + capList[i] = qMatchCapStr(values[i]); + + if(capList[i] == ECapability_HardLimit) { + wasSuccesful = false; + break; + } + } + + if(wasSuccesful) { + if(isVID || isSID){ + bool ok = true; + quint32 id = idString.toUInt(&ok, 16); + + if(ok) { + if(isVID) { + TVendorId vid(id); + policy = TSecurityPolicy(vid, capList[0], capList[1], capList[2]); + } else { + TSecureId sid(id); + policy = TSecurityPolicy(sid, capList[0], capList[1], capList[2]); + } + + ret = true; //Everything is fine + } + } else { + policy = TSecurityPolicy(capList[0], capList[1], capList[2], capList[3], + capList[4], capList[5], capList[6]); + + ret = true; //Everything is fine + } + } + } + } + + return ret; +} + +/*! + Opens the database connection using the given connection options. Returns true on success; otherwise returns false. + Error information can be retrieved using the lastError() function. Symbian SQL dbs have no \a user, \a password, \a host + or \a port just file names. + + \a connOpts Connection options hold definition for security policies and all parameters that does not contain "POLICY_" will be + passed to RSqlDatabase. Policy will be filled according to parsed values. + + Value in database wide parameters starts by definition which can be vendorId or secureId. These come directly from TSecurityPolicy class in Symbian. + + POLICY_DB_DEFAULT + Default security policy which will be used for the database and all database objects. POLICY_DB_DEFAULT must be + defined before any other policy definitions can be used. + POLICY_DB_READ + Read database security policy. An application with read database security policy can read from database. + POLICY_DB_WRITE: + Write database security policy. An application with write database security policy can write to database. + POLICY_DB_SCHEMA: + Schema database security policy. An application with schema database security policy can modify + the database schema, write to database, read from database. + + Format: + POLICY_DB_DEFAULT=cap1,cap2,cap3,cap4,cap5,cap6,cap7 (Up to 7 capabilities) + POLICY_DB_READ=cap1,cap2,cap3,cap4,cap5,cap6,cap7 (Up to 7 capabilities) + POLICY_DB_WRITE=vendorid,cap1,cap2,cap3 (Vendor ID and up to 3 capabilities) + POLICY_DB_SCHEMA=secureid,cap1,cap2,cap3 (Secure ID and up to 3 capabilities) + + Table policies does not support schema policy as database level does. + + Table specific parameters would be as: + POLICY_TABLE_WRITE=tablename,cap1,cap2,cap3,cap4,cap5,cap6,cap7 + POLICY_TABLE_READ=tablename,cap1,cap2,cap3,cap4,cap5,cap6,cap7 + + Vendor Id and Secure id format: + vid[0x12345678] (Hex) + sid[0x12345678] (Hex) + + Example: + \code + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setConnectOptions("POLICY_DB_DEFAULT=ReadDeviceData"); + database.setDatabaseName("[12345678]myDatabase"); + bool ok = database.open(); + \encode + + \code + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setConnectOptions("POLICY_DB_DEFAULT=None; POLICY_DB_WRITE=sid[0x12345678], WriteDeviceData"); + database.setDatabaseName("[12345678]myDatabase"); + bool ok = database.open(); + \encode + + FOREIGN KEY: + Enabling foreign key support from underlying SQLite + add: "foreign_keys = ON" to your connection options string. This will be passes to SQLite. + + Foreign key Example: + \code + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setDatabaseName("[12345678]myDatabase"); + database.setConnectOptions("foreign_keys = ON"); + bool ok = database.open(); + \encode + + More information about Symbian Security Policy can be found from Symbian documentation. + +*/ +bool QSymSQLDriver::open(const QString & db, const QString &, const QString &, const QString &, int, const QString &conOpts) +{ + if (isOpen()) + close(); + if (db.isEmpty()) + return false; + + //Separating our parameters from Symbian ones and construct new connection options + const QString itemSeparator(QLatin1String(";")); + QRegExp isOurOption(QLatin1String("POLICY_*"), Qt::CaseInsensitive, QRegExp::Wildcard); + + QStringList optionList = conOpts.split(itemSeparator, QString::SkipEmptyParts); + QStringList symbianList; + + for( int i = optionList.count() - 1; i >= 0; i--) { + if(!optionList[i].contains(isOurOption)) { + symbianList.append(optionList[i]); + optionList.removeAt(i); + } else { + //Removing whitespace + QString formatted = optionList[i]; + formatted = formatted.remove(QLatin1Char(' ')); + formatted = formatted.remove(QLatin1Char('\t')); + formatted = formatted.remove(QLatin1Char('\n')); + formatted = formatted.remove(QLatin1Char('\r')); + optionList[i] = formatted; + } + } + + QString symbianOpt; + + for( int i = 0; i < symbianList.count(); i++) { + symbianOpt += symbianList[i]; + symbianOpt += itemSeparator; + } + + TPtrC dbName(qt_QString2TPtrC(db)); + QByteArray conOpts8 = symbianOpt.toUtf8(); + const TPtrC8 config(reinterpret_cast(conOpts8.constData()), (conOpts8.length())); + + TInt res = d->access.Open(dbName, &config); + + if(res == KErrNotFound) { + + QRegExp findDefault(QLatin1String("POLICY_DB_DEFAULT=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findRead(QLatin1String("POLICY_DB_READ=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findWrite(QLatin1String("POLICY_DB_WRITE=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findSchema(QLatin1String("POLICY_DB_SCHEMA=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findTableRead(QLatin1String("POLICY_TABLE_READ=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + QRegExp findTableWrite(QLatin1String("POLICY_TABLE_WRITE=*"), Qt::CaseInsensitive, QRegExp::Wildcard); + + int policyIndex = optionList.indexOf(findDefault); + + if(policyIndex != -1) { + QString defaultPolicyString = optionList[policyIndex]; + optionList.removeAt(policyIndex); + + TSecurityPolicy policyItem; + + if(qExtractSecurityPolicyFromString(defaultPolicyString, policyItem)) { + RSqlSecurityPolicy policy; + res = policy.Create(policyItem); + + if(res == KErrNone) { + for(int i = 0; i < optionList.count(); i++) { + QString option = optionList[i]; + + if(option.contains(findRead)) { + if(qExtractSecurityPolicyFromString(option, policyItem)) { + res = policy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, policyItem); + } else { + res = KErrArgument; + } + } else if(option.contains(findWrite)) { + if(qExtractSecurityPolicyFromString(option, policyItem)) { + res = policy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, policyItem); + } else { + res = KErrArgument; + } + } else if(option.contains(findSchema)) { + if(qExtractSecurityPolicyFromString(option, policyItem)) { + res = policy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, policyItem); + } else { + res = KErrArgument; + } + } else if(option.contains(findTableWrite)) { + QString tableOption = option.mid(option.indexOf(QLatin1Char('=')) + 1); + int firstComma = tableOption.indexOf(QLatin1Char(',')); + + if(firstComma != -1) { + QString tableName = tableOption.left(firstComma); + tableOption = tableOption.mid(firstComma + 1); + + if(qExtractSecurityPolicyFromString(tableOption, policyItem)) { + TPtrC symTableName(qt_QString2TPtrC(tableName)); + + res = policy.SetPolicy(RSqlSecurityPolicy::ETable, symTableName, + RSqlSecurityPolicy::EWritePolicy, policyItem); + } else { + res = KErrArgument; + } + } else { + res = KErrArgument; + } + } else if(option.contains(findTableRead)) { + QString tableOption = option.mid(option.indexOf(QLatin1Char('=')) + 1); + int firstComma = tableOption.indexOf(QLatin1Char(',')); + + if(firstComma != -1) { + QString tableName = tableOption.left(firstComma); + tableOption = tableOption.mid(firstComma + 1); + + if(qExtractSecurityPolicyFromString(tableOption, policyItem)) { + TPtrC symTableName(qt_QString2TPtrC(tableName)); + + res = policy.SetPolicy(RSqlSecurityPolicy::ETable, symTableName, + RSqlSecurityPolicy::EReadPolicy, policyItem); + } else { + res = KErrArgument; + } + } else { + res = KErrArgument; + } + } else { + res = KErrArgument; + } + + if(res != KErrNone) { + setLastError(gMakeErrorOpen(tr("Invalid option: ") + option, QSqlError::ConnectionError, res)); + break; + } + } + + if(res == KErrNone) { + res = d->access.Create(dbName, policy, &config); + policy.Close(); + + if(res != KErrNone) { + setLastError(gMakeErrorOpen(tr("Error opening database"), QSqlError::ConnectionError, res)); + } + } + } + + } else { + res = KErrArgument; + setLastError(gMakeErrorOpen(tr("Invalid option: ") + defaultPolicyString, QSqlError::ConnectionError, res)); + } + + } else { + //Check whether there is some of our options, fail if so. + policyIndex = optionList.indexOf(isOurOption); + + if(policyIndex == -1) { + res = d->access.Create(dbName, &config); + + if(res != KErrNone) { + setLastError(gMakeErrorOpen(tr("Error opening database"), QSqlError::ConnectionError, res)); + } + } else { + res = KErrArgument; + setLastError(gMakeErrorOpen(tr("POLICY_DB_DEFAULT must be defined before any other POLICY definitions can be used"), QSqlError::ConnectionError, res)); + } + } + } + + if (res == KErrNone) { + setOpen(true); + setOpenError(false); + return true; + } else { + setOpenError(true); + return false; + } +} + +void QSymSQLDriver::close() +{ + if (isOpen()) { + d->access.Close(); + setOpen(false); + setOpenError(false); + } +} + +QSqlResult *QSymSQLDriver::createResult() const +{ + return new QSymSQLResult(this); +} + +bool QSymSQLDriver::beginTransaction() +{ + if (!isOpen() || isOpenError()) + return false; + + TInt err = d->access.Exec(_L("BEGIN")); + if(err < KErrNone) { + setLastError(QSqlError(tr("Unable to begin transaction"), + qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); + return false; + } + + return true; +} + +bool QSymSQLDriver::commitTransaction() +{ + if (!isOpen() || isOpenError()) + return false; + + TInt err = d->access.Exec(_L("COMMIT")); + if(err < KErrNone) { + setLastError(QSqlError(tr("Unable to commit transaction"), + qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); + return false; + } + + return true; +} + +bool QSymSQLDriver::rollbackTransaction() +{ + if (!isOpen() || isOpenError()) + return false; + + TInt err = d->access.Exec(_L("ROLLBACK")); + if(err < KErrNone) { + setLastError(QSqlError(tr("Unable to rollback transaction"), + qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); + return false; + } + + return true; +} + +QStringList QSymSQLDriver::tables(QSql::TableType type) const +{ + QStringList res; + if (!isOpen()) + return res; + + QSqlQuery q(createResult()); + q.setForwardOnly(true); + + QString sql = QLatin1String("SELECT name FROM sqlite_master WHERE %1 " + "UNION ALL SELECT name FROM sqlite_temp_master WHERE %1"); + if ((type & QSql::Tables) && (type & QSql::Views)) + sql = sql.arg(QLatin1String("type='table' OR type='view'")); + else if (type & QSql::Tables) + sql = sql.arg(QLatin1String("type='table'")); + else if (type & QSql::Views) + sql = sql.arg(QLatin1String("type='view'")); + else + sql.clear(); + + if (!sql.isEmpty() && q.exec(sql)) { + while(q.next()) + res.append(q.value(0).toString()); + } + + if (type & QSql::SystemTables) { + // there are no internal tables beside this one: + res.append(QLatin1String("sqlite_master")); + } + + return res; +} + +static QSqlIndex qGetTableInfo(QSqlQuery &q, QString &tableName, bool onlyPIndex = false) +{ + QString dbName; + QString table(tableName); + int indexOfSeparator = tableName.indexOf(QLatin1Char('.')); + if (indexOfSeparator > -1) { + dbName = tableName.left(indexOfSeparator +1 ); + table = tableName.mid(indexOfSeparator + 1); + } + q.exec(QLatin1String("PRAGMA ") + dbName + QLatin1String("table_info (") + _q_escapeIdentifier(table) + QLatin1String(")")); + + const int NAME_IDX = 1; + const int TYPE_IDX = 2; + const int NOTNULL_IDX = 3; + const int DFLT_VALUE_IDX = 4; + const int PK_IDX = 5; + + QSqlIndex ind; + while (q.next()) { + bool isPk = q.value(PK_IDX).toInt(); + if (onlyPIndex && !isPk) + continue; + QString typeName = q.value(TYPE_IDX).toString().toLower(); + QSqlField fld(q.value(NAME_IDX).toString(), qGetColumnType(typeName)); + if (isPk && (typeName == QLatin1String("integer"))) + // INTEGER PRIMARY KEY fields are auto-generated in sqlite + // INT PRIMARY KEY is not the same as INTEGER PRIMARY KEY! + fld.setAutoValue(true); + fld.setRequired(q.value(NOTNULL_IDX).toInt() != 0); + fld.setDefaultValue(q.value(DFLT_VALUE_IDX)); + ind.append(fld); + } + /*Removed debug + for (int i = 0; i< ind.count(); i++) + { + qDebug() << "QSqlIndex" << ind.field(i).name() << endl; + } + */ + return ind; +} + +QSqlIndex QSymSQLDriver::primaryIndex(const QString &tblname) const +{ + if (!isOpen()) + return QSqlIndex(); + + QString table = tblname; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + + QSqlQuery q(createResult()); + q.setForwardOnly(true); + return qGetTableInfo(q, table, true); +} + +QSqlRecord QSymSQLDriver::record(const QString &tbl) const +{ + if (!isOpen()) + return QSqlRecord(); + + QString table = tbl; + if (isIdentifierEscaped(table, QSqlDriver::TableName)) + table = stripDelimiters(table, QSqlDriver::TableName); + + QSqlQuery q(createResult()); + q.setForwardOnly(true); + return qGetTableInfo(q, table); +} + +QVariant QSymSQLDriver::handle() const +{ + return qVariantFromValue(d->access); +} + +QString QSymSQLDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const +{ + Q_UNUSED(type); + return _q_escapeIdentifier(identifier); +} + +QT_END_NAMESPACE diff --git a/src/sql/drivers/symsql/qsql_symsql.h b/src/sql/drivers/symsql/qsql_symsql.h new file mode 100644 index 0000000..a53bc4f --- /dev/null +++ b/src/sql/drivers/symsql/qsql_symsql.h @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSQL_SYMSQL_H +#define QSQL_SYMSQL_H + +#include +#include +#include + + + +#ifdef QT_PLUGIN +#define Q_EXPORT_SQLDRIVER_SYMSQL +#else +#define Q_EXPORT_SQLDRIVER_SYMSQL Q_SQL_EXPORT +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE +class QSymSQLDriverPrivate; +class QSymSQLResultPrivate; +class QSymSQLDriver; +class RSqlDatabase; + +class QSymSQLResult : public QSqlResult +{ + friend class QSymSQLDriver; + friend class QSymSQLResultPrivate; +public: + explicit QSymSQLResult(const QSymSQLDriver* db); + ~QSymSQLResult(); + QVariant handle() const; + +protected: + QVariant data(int field); + bool isNull(int i); + bool fetch(int i); + bool fetchNext(); + bool fetchPrevious(); + bool fetchFirst(); + bool fetchLast(); + + bool reset(const QString &query); + bool prepare(const QString &query); + bool exec(); + int size(); + int numRowsAffected(); + QSqlRecord record() const; + void virtual_hook(int id, void *data); + + QVariant lastInsertId() const; + +private: + QSymSQLResultPrivate* d; +}; + +class Q_EXPORT_SQLDRIVER_SYMSQL QSymSQLDriver : public QSqlDriver +{ + Q_OBJECT + friend class QSymSQLResult; +public: + explicit QSymSQLDriver(QObject *parent = 0); + explicit QSymSQLDriver(RSqlDatabase& connection, QObject *parent = 0); + ~QSymSQLDriver(); + bool hasFeature(DriverFeature f) const; + bool open(const QString & db, + const QString & user, + const QString & password, + const QString & host, + int port, + const QString & connOpts); + void close(); + QSqlResult *createResult() const; + bool beginTransaction(); + bool commitTransaction(); + bool rollbackTransaction(); + QStringList tables(QSql::TableType)const; + + QSqlRecord record(const QString& tablename) const; + QSqlIndex primaryIndex(const QString &table) const; + QVariant handle() const; + QString escapeIdentifier(const QString &identifier, IdentifierType) const; + +private: + QSymSQLDriverPrivate* d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSQL_SYMSQL_H diff --git a/src/sql/drivers/symsql/qsql_symsql.pri b/src/sql/drivers/symsql/qsql_symsql.pri new file mode 100644 index 0000000..e18cce9 --- /dev/null +++ b/src/sql/drivers/symsql/qsql_symsql.pri @@ -0,0 +1,5 @@ +HEADERS += $$PWD/qsql_symsql.h +SOURCES += $$PWD/qsql_symsql.cpp + +symbian::LIBS += -lsqldb + -- cgit v0.12 From 0f2f2cd33967502a2d04ec551ecdefba1220b843 Mon Sep 17 00:00:00 2001 From: Timo Kauppinen Date: Mon, 23 May 2011 15:32:27 +0300 Subject: Fixed a typo found by static checker Task-number: QT-4860 Reviewd-by: Honglei Zhang --- src/sql/drivers/symsql/qsql_symsql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/drivers/symsql/qsql_symsql.cpp b/src/sql/drivers/symsql/qsql_symsql.cpp index a015400..7425cfe 100644 --- a/src/sql/drivers/symsql/qsql_symsql.cpp +++ b/src/sql/drivers/symsql/qsql_symsql.cpp @@ -112,7 +112,7 @@ static QString _q_escapeIdentifier(const QString &identifier) static QVariant::Type qGetColumnType(const TSqlColumnType coltype) { - //ToDo Check Implmentation + //ToDo Check Implementation switch(coltype){ case ESqlInt: case ESqlInt64: -- cgit v0.12 From b8c427eb220000d369a6ad6df0a8525daded6b36 Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Mon, 4 Jul 2011 13:17:35 +0300 Subject: Release Symbian SQL driver Symbian SQL driver provides service of secure databases. SQL databases are stored in Symbian SQL server's private data cage. The API ensures only authorised clients can access the database. The Symbian SQL driver enables Qt application to use Symbian secure databases. Task-number: QT-4860 Reviewed-by: Trust Me --- src/sql/drivers/symsql/qsql_symsql.cpp | 299 ++++++++++++++------------------- 1 file changed, 124 insertions(+), 175 deletions(-) diff --git a/src/sql/drivers/symsql/qsql_symsql.cpp b/src/sql/drivers/symsql/qsql_symsql.cpp index 7425cfe..a67caa8 100644 --- a/src/sql/drivers/symsql/qsql_symsql.cpp +++ b/src/sql/drivers/symsql/qsql_symsql.cpp @@ -102,7 +102,9 @@ const QString fieldSeparator(QLatin1String(",")); static QString _q_escapeIdentifier(const QString &identifier) { QString res = identifier; - if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('"')) && identifier.right(1) != QString(QLatin1Char('"')) ) { + if (!identifier.isEmpty() + && identifier.left(1) != QString(QLatin1Char('"')) + && identifier.right(1) != QString(QLatin1Char('"'))) { res.replace(QLatin1Char('"'), QLatin1String("\"\"")); res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); res.replace(QLatin1Char('.'), QLatin1String("\".\"")); @@ -112,24 +114,23 @@ static QString _q_escapeIdentifier(const QString &identifier) static QVariant::Type qGetColumnType(const TSqlColumnType coltype) { - //ToDo Check Implementation switch(coltype){ - case ESqlInt: - case ESqlInt64: - return QVariant::Int; - case ESqlReal: - return QVariant::Double; - case ESqlBinary: - return QVariant::ByteArray; - case ESqlText: - case ESqlNull: - default: - return QVariant::String; + case ESqlInt: + case ESqlInt64: + return QVariant::Int; + case ESqlReal: + return QVariant::Double; + case ESqlBinary: + return QVariant::ByteArray; + case ESqlText: + case ESqlNull: + default: + return QVariant::String; } } static QVariant::Type qGetColumnType(const QString &tpName) - { +{ const QString typeName = tpName.toLower(); if (typeName == QLatin1String("integer") @@ -145,17 +146,21 @@ static QVariant::Type qGetColumnType(const QString &tpName) return QVariant::String; } -static QSqlError qMakeError(RSqlDatabase& access, const QString &descr, QSqlError::ErrorType type, - int errorCode = -1) +static QSqlError qMakeError(RSqlDatabase& access, + const QString &descr, + QSqlError::ErrorType type, + int errorCode = -1) { return QSqlError(descr, QString::fromUtf16(static_cast(access.LastErrorMessage().Ptr())), - type, errorCode); + type, + errorCode); } -static QSqlError gMakeErrorOpen(const QString &descr, QSqlError::ErrorType type, - TInt errorCode) +static QSqlError gMakeErrorOpen(const QString &descr, + QSqlError::ErrorType type, + TInt errorCode) { return QSqlError(descr, QLatin1String(""), type, errorCode); } @@ -186,7 +191,9 @@ public: }; QSymSQLResultPrivate::QSymSQLResultPrivate(QSymSQLResult* res) : q(res), -skipRow(false), skippedStatus(false), prepareCalled(false) + skipRow(false), + skippedStatus(false), + prepareCalled(false) { } @@ -240,8 +247,6 @@ void QSymSQLResultPrivate::initColumns(QSqlRecord& rec) int dotIdx = colName.lastIndexOf(QLatin1Char('.')); QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(decColType)); - //int stp = stmt.ColumnType(i); Useless lines of code, comment modified according to review - //fld.setSqlType(stp); Useless lines of code, comment modified according to review rec.append(fld); } } @@ -265,13 +270,11 @@ bool QSymSQLResultPrivate::fetchNext(bool initialFetch) return true; case KSqlAtEnd: stmt.Reset(); - //Removed debug qDebug()<<"query Reset(1)"<setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", "Unable to fetch row"), QSqlError::ConnectionError, res)); q->setAt(QSql::AfterLastRow); @@ -283,7 +286,6 @@ bool QSymSQLResultPrivate::fetchNext(bool initialFetch) q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", "Unable to fetch row"), QSqlError::ConnectionError, res)); stmt.Reset(); - //Removed debug qDebug()<<"query Reset(3)"<setAt(QSql::AfterLastRow); return false; } @@ -323,7 +325,6 @@ bool QSymSQLResult::prepare(const QString &query) setSelect(false); TInt res = d->stmt.Prepare(d->access, qt_QString2TPtrC(query)); - //Removed debug qDebug()<<"query:"<access, QCoreApplication::translate("QSymSQLResult", @@ -339,7 +340,7 @@ bool QSymSQLResult::prepare(const QString &query) bool QSymSQLResult::exec() { - if(d->prepareCalled == false) { + if (d->prepareCalled == false) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", "Statement is not prepared"), QSqlError::StatementError, KErrGeneral)); return false; @@ -353,8 +354,6 @@ bool QSymSQLResult::exec() setLastError(QSqlError()); int res = d->stmt.Reset(); - //Removed debug qDebug()<<"query Reset(4)"<access, QCoreApplication::translate("QSymSQLResult", "Unable to reset statement"), QSqlError::StatementError, res)); @@ -363,10 +362,8 @@ bool QSymSQLResult::exec() } TPtrC tmp; TInt paramCount = 0; - while(d->stmt.ParamName(paramCount, tmp) == KErrNone) - { + while (d->stmt.ParamName(paramCount, tmp) == KErrNone) paramCount++; - } if (paramCount == values.count()) { for (int i = 0; i < paramCount; ++i) { @@ -378,12 +375,9 @@ bool QSymSQLResult::exec() } else { switch (value.type()) { case QVariant::ByteArray: { - //ToDo check how to handle SQLITE_STATIC const QByteArray *ba = static_cast(value.constData()); TPtrC8 data(reinterpret_cast(ba->constData()), ba->length()); res = d->stmt.BindBinary(i, data); //replaced i + 1 with i - //res = sqlite3_bind_blob(d->stmt, i + 1, ba->constData(), - // ba->size(), SQLITE_STATIC); break; } case QVariant::Int: res = d->stmt.BindInt(i, value.toInt()); //replaced i + 1 with i @@ -399,19 +393,12 @@ bool QSymSQLResult::exec() case QVariant::String: { // lifetime of string == lifetime of its qvariant - //ToDo check how to handle SQLITE_STATIC const QString *str = static_cast(value.constData()); res = d->stmt.BindText(i, qt_QString2TPtrC(*str)); // replaced i + 1 with i - //res = sqlite3_bind_text16(d->stmt, i + 1, str->utf16(), - // (str->size()) * sizeof(QChar), SQLITE_STATIC); break; } default: { - //ToDo check how to handle SQLITE_TRANSIENT QString str = value.toString(); res = d->stmt.BindText(i, qt_QString2TPtrC(str)); //replaced i + 1 with i - // SQLITE_TRANSIENT makes sure that sqlite buffers the data - //res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(), - // (str.size()) * sizeof(QChar), SQLITE_TRANSIENT); break; } } } @@ -436,7 +423,7 @@ bool QSymSQLResult::exec() return false; } - if(d->stmt.ColumnCount() > 0) { + if (d->stmt.ColumnCount() > 0) { //If there is something, it has to be select setSelect(true); } else { @@ -448,7 +435,7 @@ bool QSymSQLResult::exec() //Just check whether there is one in the beginning, don't know if this is enough //Comments should be at the end of line if those are passed //For some reason, case insensitive indexOf didn't work for me - if(query.indexOf(QLatin1String("select")) == 0) { + if (query.indexOf(QLatin1String("select")) == 0) { setSelect(true); } else { setSelect(false); @@ -474,9 +461,8 @@ QVariant QSymSQLResult::lastInsertId() const { if (isActive()) { qint64 id = static_cast(d->access.LastInsertedRowId()); - if (id){ + if (id) return id; - } } return QVariant(); @@ -499,14 +485,12 @@ QVariant QSymSQLResult::handle() const } -// ToDo is a virtual_hook needed? void QSymSQLResult::virtual_hook(int id, void *data) { switch (id) { case QSqlResult::DetachFromResultSet: d->stmt.Reset(); - //Removed debug qDebug()<<"query Reset(5)"<stmt.ColumnType(idx)) { - case ESqlBinary: + case ESqlBinary: { TPtrC8 data; d->stmt.ColumnBinary(idx, data); - return QByteArray(reinterpret_cast(data.Ptr()), data.Length()); - - //ToDo - check if this is correct - // values[i + idx] = QByteArray(static_cast( - // sqlite3_column_blob(stmt, i)), - // stmt.ColumnSize(i)); - break; + return QByteArray(reinterpret_cast(data.Ptr()), data.Length()); + break; } - case ESqlInt: - r = QVariant(d->stmt.ColumnInt(idx)); - break; - case ESqlInt64: - r = QVariant(d->stmt.ColumnInt64(idx)); - break; - case ESqlReal: - switch(numericalPrecisionPolicy()) { - case QSql::LowPrecisionInt32: - r = QVariant(d->stmt.ColumnInt(idx)); - break; - case QSql::LowPrecisionInt64: - r = QVariant(d->stmt.ColumnInt64(idx)); - break; - case QSql::LowPrecisionDouble: - r = QVariant(d->stmt.ColumnReal(idx)); - break; - case QSql::HighPrecision: - default: - TPtrC res; - d->stmt.ColumnText(idx, res); - r = QVariant(qt_TDesC2QString(res)); - //values[i + idx] = QString::fromUtf16(res.Ptr(), res.Length()); - - //ToDo - Check if the implementation is correct - //values[i + idx] = QString::fromUtf16(static_cast( - // sqlite3_column_text16(stmt, i)), - // sqlite3_column_bytes16(stmt, i) / sizeof(ushort)); - break; - }; - break; - case ESqlNull: - r = QVariant(QVariant::String); - break; - default: - TPtrC res; - d->stmt.ColumnText(idx, res); - r = QVariant(qt_TDesC2QString(res)); - //values[i + idx] = QString::fromUtf16(res.Ptr(), res.Length()); - - //ToDo - Check if the implementation is correct - //values[i + idx] = QString::fromUtf16(static_cast( - // sqlite3_column_text16(stmt, i)), - // sqlite3_column_bytes16(stmt, i) / sizeof(ushort)); - break; + case ESqlInt: + r = QVariant(d->stmt.ColumnInt(idx)); + break; + case ESqlInt64: + r = QVariant(d->stmt.ColumnInt64(idx)); + break; + case ESqlReal: + switch(numericalPrecisionPolicy()) { + case QSql::LowPrecisionInt32: + r = QVariant(d->stmt.ColumnInt(idx)); + break; + case QSql::LowPrecisionInt64: + r = QVariant(d->stmt.ColumnInt64(idx)); + break; + case QSql::LowPrecisionDouble: + r = QVariant(d->stmt.ColumnReal(idx)); + break; + case QSql::HighPrecision: + default: + TPtrC res; + d->stmt.ColumnText(idx, res); + r = QVariant(qt_TDesC2QString(res)); + break; + }; + break; + case ESqlNull: + r = QVariant(QVariant::String); + break; + default: + TPtrC res; + d->stmt.ColumnText(idx, res); + r = QVariant(qt_TDesC2QString(res)); + break; } - //Removed debug qDebug()<<"SymSql, Data:"<= 0; i--) { - if(!optionList[i].contains(isOurOption)) { + for (int i = optionList.count() - 1; i >= 0; i--) { + if (!optionList[i].contains(isOurOption)) { symbianList.append(optionList[i]); optionList.removeAt(i); } else { @@ -917,7 +875,7 @@ bool QSymSQLDriver::open(const QString & db, const QString &, const QString &, c QString symbianOpt; - for( int i = 0; i < symbianList.count(); i++) { + for (int i = 0; i < symbianList.count(); i++) { symbianOpt += symbianList[i]; symbianOpt += itemSeparator; } @@ -928,7 +886,7 @@ bool QSymSQLDriver::open(const QString & db, const QString &, const QString &, c TInt res = d->access.Open(dbName, &config); - if(res == KErrNotFound) { + if (res == KErrNotFound) { QRegExp findDefault(QLatin1String("POLICY_DB_DEFAULT=*"), Qt::CaseInsensitive, QRegExp::Wildcard); QRegExp findRead(QLatin1String("POLICY_DB_READ=*"), Qt::CaseInsensitive, QRegExp::Wildcard); @@ -939,47 +897,47 @@ bool QSymSQLDriver::open(const QString & db, const QString &, const QString &, c int policyIndex = optionList.indexOf(findDefault); - if(policyIndex != -1) { + if (policyIndex != -1) { QString defaultPolicyString = optionList[policyIndex]; optionList.removeAt(policyIndex); TSecurityPolicy policyItem; - if(qExtractSecurityPolicyFromString(defaultPolicyString, policyItem)) { + if (qExtractSecurityPolicyFromString(defaultPolicyString, policyItem)) { RSqlSecurityPolicy policy; res = policy.Create(policyItem); - if(res == KErrNone) { - for(int i = 0; i < optionList.count(); i++) { + if (res == KErrNone) { + for (int i = 0; i < optionList.count(); i++) { QString option = optionList[i]; - if(option.contains(findRead)) { - if(qExtractSecurityPolicyFromString(option, policyItem)) { + if (option.contains(findRead)) { + if (qExtractSecurityPolicyFromString(option, policyItem)) { res = policy.SetDbPolicy(RSqlSecurityPolicy::EReadPolicy, policyItem); } else { res = KErrArgument; } - } else if(option.contains(findWrite)) { - if(qExtractSecurityPolicyFromString(option, policyItem)) { + } else if (option.contains(findWrite)) { + if (qExtractSecurityPolicyFromString(option, policyItem)) { res = policy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, policyItem); } else { res = KErrArgument; } - } else if(option.contains(findSchema)) { - if(qExtractSecurityPolicyFromString(option, policyItem)) { + } else if (option.contains(findSchema)) { + if (qExtractSecurityPolicyFromString(option, policyItem)) { res = policy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, policyItem); } else { res = KErrArgument; } - } else if(option.contains(findTableWrite)) { + } else if (option.contains(findTableWrite)) { QString tableOption = option.mid(option.indexOf(QLatin1Char('=')) + 1); int firstComma = tableOption.indexOf(QLatin1Char(',')); - if(firstComma != -1) { + if (firstComma != -1) { QString tableName = tableOption.left(firstComma); tableOption = tableOption.mid(firstComma + 1); - if(qExtractSecurityPolicyFromString(tableOption, policyItem)) { + if (qExtractSecurityPolicyFromString(tableOption, policyItem)) { TPtrC symTableName(qt_QString2TPtrC(tableName)); res = policy.SetPolicy(RSqlSecurityPolicy::ETable, symTableName, @@ -990,15 +948,15 @@ bool QSymSQLDriver::open(const QString & db, const QString &, const QString &, c } else { res = KErrArgument; } - } else if(option.contains(findTableRead)) { + } else if (option.contains(findTableRead)) { QString tableOption = option.mid(option.indexOf(QLatin1Char('=')) + 1); int firstComma = tableOption.indexOf(QLatin1Char(',')); - if(firstComma != -1) { + if (firstComma != -1) { QString tableName = tableOption.left(firstComma); tableOption = tableOption.mid(firstComma + 1); - if(qExtractSecurityPolicyFromString(tableOption, policyItem)) { + if (qExtractSecurityPolicyFromString(tableOption, policyItem)) { TPtrC symTableName(qt_QString2TPtrC(tableName)); res = policy.SetPolicy(RSqlSecurityPolicy::ETable, symTableName, @@ -1013,19 +971,18 @@ bool QSymSQLDriver::open(const QString & db, const QString &, const QString &, c res = KErrArgument; } - if(res != KErrNone) { + if (res != KErrNone) { setLastError(gMakeErrorOpen(tr("Invalid option: ") + option, QSqlError::ConnectionError, res)); break; } } - if(res == KErrNone) { + if (res == KErrNone) { res = d->access.Create(dbName, policy, &config); policy.Close(); - if(res != KErrNone) { + if (res != KErrNone) setLastError(gMakeErrorOpen(tr("Error opening database"), QSqlError::ConnectionError, res)); - } } } @@ -1038,12 +995,11 @@ bool QSymSQLDriver::open(const QString & db, const QString &, const QString &, c //Check whether there is some of our options, fail if so. policyIndex = optionList.indexOf(isOurOption); - if(policyIndex == -1) { + if (policyIndex == -1) { res = d->access.Create(dbName, &config); - if(res != KErrNone) { + if (res != KErrNone) setLastError(gMakeErrorOpen(tr("Error opening database"), QSqlError::ConnectionError, res)); - } } else { res = KErrArgument; setLastError(gMakeErrorOpen(tr("POLICY_DB_DEFAULT must be defined before any other POLICY definitions can be used"), QSqlError::ConnectionError, res)); @@ -1081,7 +1037,7 @@ bool QSymSQLDriver::beginTransaction() return false; TInt err = d->access.Exec(_L("BEGIN")); - if(err < KErrNone) { + if (err < KErrNone) { setLastError(QSqlError(tr("Unable to begin transaction"), qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); return false; @@ -1096,7 +1052,7 @@ bool QSymSQLDriver::commitTransaction() return false; TInt err = d->access.Exec(_L("COMMIT")); - if(err < KErrNone) { + if (err < KErrNone) { setLastError(QSqlError(tr("Unable to commit transaction"), qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); return false; @@ -1111,7 +1067,7 @@ bool QSymSQLDriver::rollbackTransaction() return false; TInt err = d->access.Exec(_L("ROLLBACK")); - if(err < KErrNone) { + if (err < KErrNone) { setLastError(QSqlError(tr("Unable to rollback transaction"), qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); return false; @@ -1141,14 +1097,13 @@ QStringList QSymSQLDriver::tables(QSql::TableType type) const sql.clear(); if (!sql.isEmpty() && q.exec(sql)) { - while(q.next()) + while (q.next()) res.append(q.value(0).toString()); } - if (type & QSql::SystemTables) { + if (type & QSql::SystemTables) // there are no internal tables beside this one: res.append(QLatin1String("sqlite_master")); - } return res; } @@ -1185,12 +1140,6 @@ static QSqlIndex qGetTableInfo(QSqlQuery &q, QString &tableName, bool onlyPIndex fld.setDefaultValue(q.value(DFLT_VALUE_IDX)); ind.append(fld); } - /*Removed debug - for (int i = 0; i< ind.count(); i++) - { - qDebug() << "QSqlIndex" << ind.field(i).name() << endl; - } - */ return ind; } -- cgit v0.12 From bf02a3e9bcad5faf01135df02472ebdfba39c51f Mon Sep 17 00:00:00 2001 From: Timo Kauppinen Date: Fri, 19 Aug 2011 09:51:45 +0300 Subject: Documentation modifications for SymbianSQL added into sql-driver.qdoc Task-number: QT-4860 Reviewed-by: Honglei Zhang --- doc/src/sql-programming/sql-driver.qdoc | 48 ++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/doc/src/sql-programming/sql-driver.qdoc b/doc/src/sql-programming/sql-driver.qdoc index 40c7c6a..45138fb 100644 --- a/doc/src/sql-programming/sql-driver.qdoc +++ b/doc/src/sql-programming/sql-driver.qdoc @@ -60,6 +60,7 @@ \row \o \link #QPSQL QPSQL\endlink \o PostgreSQL (versions 7.3 and above) \row \o \link #QSQLITE2 QSQLITE2\endlink \o SQLite version 2 \row \o \link #QSQLITE QSQLITE\endlink \o SQLite version 3 + \row \o \link #QSYMSQL QSYMSQL\endlink \o SQLite version 3 for Symbian SQL Database \row \o \link #QTDS QTDS\endlink \o Sybase Adaptive Server \note obsolete from Qt 4.7 \endtable @@ -665,7 +666,52 @@ ship your own database plugin with your own SQLite library as illustrated above. Some versions of SQLite can be forced to write a specific file format by setting the \c{SQLITE_DEFAULT_FILE_FORMAT} define when building SQLite. - + + \target QSYMSQL + \section2 QSYMSQL for SQLite (Version 3 and Above) with Symbian SQL Database + + \section3 General Information about QSYMSQL + + QtSQL is the Qt module which allows clients to access SQL database services. + Database vendors can create QtSQL drivers for their database engines. +  + QSYMSQL driver enables to access the native Symbian database engine (“Symbian SQL”) + through the QtSQL API. + + The main difference to QSQLITE is that, with Symbian SQL database client can specify a + set of access control policies when creating a new database with Symbian SQL security policies + within open() method call (security policy is defined with in the connection options). + + See QSymSQLDriver::open(const QString & db, const QString &, const QString &, const QString &, int, const QString &conOpts) + description for detail information of policy settings. + + Symbian RSqlSecurityPolicy class is a container for the security policies for a shared SQL database. + + The container can contain: + security policies that apply to the database. + security policies that apply to individual database objects, i.e. database tables. + + For the database, you use RSqlSecurityPolicy::SetDbPolicy() to apply a separate security policy to: + the database schema. + read activity on the database. + write activity on the database. + + For database tables, you use RSqlSecurityPolicy::SetPolicy() to apply a separate security policy to: + write activity on each named database table. + read activity on each named database table. + + More information about Symbian SQL and RSqlSecurityPolicy class reference about policy definitions, + can be found from Forum Nokia Library: http://library.developer.nokia.com/. + + \section3 How to Build the QSYMSQL Plugin + + Building QSYMSQL requires symbian platform, since it is using Symbian SQL database. + + QSYMSQL is a dynamic plugin, which appears to available drivers list, when the binaries are build in. + + The build sequence is similar to the QSQLITE plugin with installing the plugin in the standard location. + + \target QIBASE \section2 QIBASE for Borland InterBase -- cgit v0.12 From 2103202b200023fa295e726728e4d8aefe071210 Mon Sep 17 00:00:00 2001 From: Timo Kauppinen Date: Fri, 2 Sep 2011 15:51:32 +0300 Subject: Added correct licence headers to symsql source files Task-number: QT-4860 Reviewed-by: Honglei Zhang --- src/plugins/sqldrivers/symsql/main.cpp | 36 +++++++++++++++++----------------- src/sql/drivers/symsql/qsql_symsql.cpp | 36 +++++++++++++++++----------------- src/sql/drivers/symsql/qsql_symsql.h | 36 +++++++++++++++++----------------- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/plugins/sqldrivers/symsql/main.cpp b/src/plugins/sqldrivers/symsql/main.cpp index 0fd8756..5dfa9f4 100644 --- a/src/plugins/sqldrivers/symsql/main.cpp +++ b/src/plugins/sqldrivers/symsql/main.cpp @@ -4,32 +4,32 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the plugins of the Qt Toolkit. +** This file is part of the QtSql module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. ** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. ** ** ** diff --git a/src/sql/drivers/symsql/qsql_symsql.cpp b/src/sql/drivers/symsql/qsql_symsql.cpp index a67caa8..4ceac9b 100644 --- a/src/sql/drivers/symsql/qsql_symsql.cpp +++ b/src/sql/drivers/symsql/qsql_symsql.cpp @@ -4,32 +4,32 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the plugins of the Qt Toolkit. +** This file is part of the QtSql module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. ** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. ** ** ** diff --git a/src/sql/drivers/symsql/qsql_symsql.h b/src/sql/drivers/symsql/qsql_symsql.h index a53bc4f..7fdc10f 100644 --- a/src/sql/drivers/symsql/qsql_symsql.h +++ b/src/sql/drivers/symsql/qsql_symsql.h @@ -4,32 +4,32 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the plugins of the Qt Toolkit. +** This file is part of the QtSql module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. ** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. ** ** ** -- cgit v0.12 From 6aa506e1d863e5bb7642d4947be0d8c8c9b24d33 Mon Sep 17 00:00:00 2001 From: Timo Kauppinen Date: Mon, 5 Sep 2011 15:13:16 +0300 Subject: Modified SymSQL documentation in sql-driver.qdoc according review comments Task-number: QT-4860 Reviewed-by: Honglei Zhang --- doc/src/sql-programming/sql-driver.qdoc | 129 +++++++++++++++++++++++--------- 1 file changed, 92 insertions(+), 37 deletions(-) diff --git a/doc/src/sql-programming/sql-driver.qdoc b/doc/src/sql-programming/sql-driver.qdoc index 45138fb..ed60e7f 100644 --- a/doc/src/sql-programming/sql-driver.qdoc +++ b/doc/src/sql-programming/sql-driver.qdoc @@ -671,47 +671,102 @@ \section2 QSYMSQL for SQLite (Version 3 and Above) with Symbian SQL Database \section3 General Information about QSYMSQL - - QtSQL is the Qt module which allows clients to access SQL database services. - Database vendors can create QtSQL drivers for their database engines. -  - QSYMSQL driver enables to access the native Symbian database engine (“Symbian SQL”) - through the QtSQL API. - - The main difference to QSQLITE is that, with Symbian SQL database client can specify a - set of access control policies when creating a new database with Symbian SQL security policies - within open() method call (security policy is defined with in the connection options). - - See QSymSQLDriver::open(const QString & db, const QString &, const QString &, const QString &, int, const QString &conOpts) - description for detail information of policy settings. - - Symbian RSqlSecurityPolicy class is a container for the security policies for a shared SQL database. - - The container can contain: - security policies that apply to the database. - security policies that apply to individual database objects, i.e. database tables. - - For the database, you use RSqlSecurityPolicy::SetDbPolicy() to apply a separate security policy to: - the database schema. - read activity on the database. - write activity on the database. - - For database tables, you use RSqlSecurityPolicy::SetPolicy() to apply a separate security policy to: - write activity on each named database table. - read activity on each named database table. - + + QSYMSQL driver enables clients to access the native Symbian database engine (“Symbian SQL”) + through the QtSQL API. + + The main difference to QSQLITE is that, with Symbian SQL database client can specify a + set of access control policies when creating a new database. It uses Symbian SQL security policy + definitions within open() call (security policy is defined with in the connection options parameters). + + Symbian RSqlSecurityPolicy class is a container for the security policies for a shared SQL database. + + The container can contain: + security policies that apply to the database. + security policies that apply to individual database objects, i.e. database tables. + + For the database, you use RSqlSecurityPolicy::SetDbPolicy() to apply a separate security policy to: + the database schema. + read activity on the database. + write activity on the database. + + For database tables, you use RSqlSecurityPolicy::SetPolicy() to apply a separate security policy to: + write activity on each named database table. + read activity on each named database table. + More information about Symbian SQL and RSqlSecurityPolicy class reference about policy definitions, can be found from Forum Nokia Library: http://library.developer.nokia.com/. - + + +Example of setting Security Policy: + + Connection options hold definition for security policies and all parameters that does not contain "POLICY_" will be + passed to RSqlDatabase. Policy will be filled according to parsed values. + + Value in database wide parameters starts by definition which can be vendorId or secureId. These come directly from TSecurityPolicy class in Symbian. + + POLICY_DB_DEFAULT + Default security policy which will be used for the database and all database objects. POLICY_DB_DEFAULT must be + defined before any other policy definitions can be used. + POLICY_DB_READ + Read database security policy. An application with read database security policy can read from database. + POLICY_DB_WRITE: + Write database security policy. An application with write database security policy can write to database. + POLICY_DB_SCHEMA: + Schema database security policy. An application with schema database security policy can modify + the database schema, write to database, read from database. + + Format: + POLICY_DB_DEFAULT=cap1,cap2,cap3,cap4,cap5,cap6,cap7 (Up to 7 capabilities) + POLICY_DB_READ=cap1,cap2,cap3,cap4,cap5,cap6,cap7 (Up to 7 capabilities) + POLICY_DB_WRITE=vendorid,cap1,cap2,cap3 (Vendor ID and up to 3 capabilities) + POLICY_DB_SCHEMA=secureid,cap1,cap2,cap3 (Secure ID and up to 3 capabilities) + + Table policies does not support schema policy as database level does. + + Table specific parameters would be as: + POLICY_TABLE_WRITE=tablename,cap1,cap2,cap3,cap4,cap5,cap6,cap7 + POLICY_TABLE_READ=tablename,cap1,cap2,cap3,cap4,cap5,cap6,cap7 + + Vendor Id and Secure id format: + vid[0x12345678] (Hex) + sid[0x12345678] (Hex) + + Examples: + Setting default policy: + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setConnectOptions("POLICY_DB_DEFAULT=ReadDeviceData"); + database.setDatabaseName("[12345678]myDatabase"); + bool ok = database.open(); + + Setting POLICY_DB_WRITE: + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setConnectOptions("POLICY_DB_DEFAULT=None; POLICY_DB_WRITE=sid[0x12345678], WriteDeviceData"); + database.setDatabaseName("[12345678]myDatabase"); + bool ok = database.open(); + + FOREIGN KEY: + Enabling foreign key support from underlying SQLite + add: "foreign_keys = ON" to your connection options string. This will be passes to SQLite. + + Foreign key Example: + QSqlDatabase database = QSqlDatabase::addDatabase("QSYMSQL", "MyConnection"); + database.setDatabaseName("[12345678]myDatabase"); + database.setConnectOptions("foreign_keys = ON"); + bool ok = database.open(); + \section3 How to Build the QSYMSQL Plugin - - Building QSYMSQL requires symbian platform, since it is using Symbian SQL database. - - QSYMSQL is a dynamic plugin, which appears to available drivers list, when the binaries are build in. - + + Building QSYMSQL requires Symbian SDK. + The build sequence is similar to the QSQLITE plugin with installing the plugin in the standard location. - - + + Build sequence: + + >cd sf\mw\qt\src\plugins\sqldrivers\symsql\ + >qmake + >sbs -c winscw_udeb|armv5_urel + \target QIBASE \section2 QIBASE for Borland InterBase -- cgit v0.12 From a14033620fab5edca44293ec6dfcc904e2e0eb20 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 22 Sep 2011 14:48:44 +0200 Subject: Sentences should end with a period! (Poor man's rebuild trigger.) --- src/3rdparty/webkit/Source/WebCore/WebCore.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/Source/WebCore/WebCore.pri b/src/3rdparty/webkit/Source/WebCore/WebCore.pri index 00357a1..d8ba8a6 100644 --- a/src/3rdparty/webkit/Source/WebCore/WebCore.pri +++ b/src/3rdparty/webkit/Source/WebCore/WebCore.pri @@ -153,7 +153,7 @@ symbian { CONFIG += do_not_build_as_thumb CONFIG(release, debug|release): QMAKE_CXXFLAGS.ARMCC += -OTime -O3 - # Symbian plugin support + # Symbian plugin support. LIBS += -lefsrv !CONFIG(QTDIR_build) { -- cgit v0.12 From c6eac82ad48c3956a16cfa89105374003fc854d6 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 22 Sep 2011 16:21:58 +0300 Subject: Improve sbsv2 whatlog support. All builds will now add anything generated via QMAKE_EXTRA_COMPILERS to whatlog. In addition, platform builds will now add to whatlog the exported mkspecs and qmake_clean.flm that were missing. Task-number: QTBUG-21591 Reviewed-by: Sami Merila --- config.profiles/symbian/bld.inf | 1 + config.profiles/symbian/qtconfig.flm | 12 ++++++++++-- mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config.profiles/symbian/bld.inf b/config.profiles/symbian/bld.inf index 6ccb11c..21b3614 100644 --- a/config.profiles/symbian/bld.inf +++ b/config.profiles/symbian/bld.inf @@ -19,6 +19,7 @@ qtconfig.flm /epoc32/tools/makefile_templates/qt/qtconfig.flm ../../mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm /epoc32/tools/makefile_templates/qt/ ../../mkspecs/symbian-sbsv2/flm/qt/qmake_post_link.flm /epoc32/tools/makefile_templates/qt/ ../../mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm /epoc32/tools/makefile_templates/qt/ +../../mkspecs/symbian-sbsv2/flm/qt/qmake_clean.flm /epoc32/tools/makefile_templates/qt/ ../../mkspecs/symbian-sbsv2/flm/qt/qt.xml /epoc32/tools/makefile_templates/qt/ qt.conf /epoc32/tools/qt.conf diff --git a/config.profiles/symbian/qtconfig.flm b/config.profiles/symbian/qtconfig.flm index 56c3d6b..94f732a 100644 --- a/config.profiles/symbian/qtconfig.flm +++ b/config.profiles/symbian/qtconfig.flm @@ -66,9 +66,10 @@ $(SOURCEDIR)/qmake$(DOTEXE): $(EXTENSION_ROOT)/$(QT_ROOT)/$(CONFIGURE_APP) $(GNUCP) -R $(EXTENSION_ROOT)/$(QT_ROOT)/mkspecs $(MKSPECDIR) $(call endrule,mkspecexport) -WHAT:: +FINAL WHAT:: $(SOURCEDIR)/qmake$(DOTEXE) $(call startrawoutput) \ echo "$(call whatLogOpen)"; \ + cd $(EXTENSION_ROOT)/$(QT_ROOT)/config.profiles/symbian && \ perl headerexport -base-dir $(EXTENSION_ROOT)/$(QT_ROOT) -outdir $(EPOCROOT)/epoc32/include/ -what | \ (read -r LINE; \ while [ $$$$? -eq 0 ]; do \ @@ -76,7 +77,14 @@ WHAT:: read -r LINE; \ done; \ ); \ - echo "$(call whatLogClose)" \ + $(GNUFIND) $(EXTENSION_ROOT)/$(QT_ROOT)/mkspecs -type f | \ + (read -r LINE; \ + while [ $$$$? -eq 0 ]; do \ + echo "$(call whatLogItem,,$$$$LINE)" | $(GNUSED) 's#$(EXTENSION_ROOT)/$(QT_ROOT)#$(MKSPECDIR)#'; \ + read -r LINE; \ + done; \ + ); \ + echo "$(call whatLogClose)"; \ $(call endrawoutput) endef diff --git a/mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm b/mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm index dce7f20..26afff6 100644 --- a/mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm +++ b/mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm @@ -31,6 +31,7 @@ endef ifeq ($($(SINGLETON)),) $(eval $(qmake_extra_pre_targetdep)) $(eval $(call GenerateStandardCleanTarget,$(PREDEP_TARGET),'')) +$(eval $(call whatmacro,$(PREDEP_TARGET))) endif -- cgit v0.12 From 48f64fc7ae9f0e9e8ab07ab60ccd55d3b053dfab Mon Sep 17 00:00:00 2001 From: Iikka Eklund Date: Thu, 22 Sep 2011 15:11:42 +0200 Subject: Fix broken Solaris build (getpwnam_r usage) Added ifdef inside qt_tildeExpansion function to use correct version of getpwnam_r depending on _C_POSIX_SOURCE version on Solaris platform. Task-number: QTBUG-21451 Merge-request: 1380 Reviewed-by: ossi --- src/gui/dialogs/qfiledialog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 5e8533e..817cd38 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -880,7 +880,12 @@ Q_AUTOTEST_EXPORT QString qt_tildeExpansion(const QString &path, bool *expanded passwd *tmpPw; char buf[200]; const int bufSize = sizeof(buf); - int err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw); + int err = 0; +#if defined(Q_OS_SOLARIS) && (_POSIX_C_SOURCE - 0 < 199506L) + tmpPw = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize); +#else + err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw); +#endif if (err || !tmpPw) return ret; const QString homePath = QString::fromLocal8Bit(pw.pw_dir); -- cgit v0.12 From 3cd5e01f359d47975c27627ff4866e35258a9d0b Mon Sep 17 00:00:00 2001 From: Sinan Tanilkan Date: Fri, 23 Sep 2011 10:18:34 +0200 Subject: Update changelog for Qt 4.8 Change recieved from James Perrett --- dist/changes-4.8.0 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index 84e58f9..4299c1a 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -219,6 +219,7 @@ Qt for Embedded Linux - Improved support for INTEGRITY RTOS - Allow hard-coding the temp path in mkspecs (QT_UNIX_TEMP_PATH_OVERRIDE define) - Added support for opening LinuxInput devices exclusively (via ioctl EVIOCGRAB) + - Added eglnullws QScreen driver for use with OpenGL ES EGL null window system (NullWS). Qt for Symbian -------------- @@ -357,6 +358,9 @@ Qt for Windows CE * New tool to generate text descriptions of the QML components defined in plugins loaded by a QML module. +- syncqt + * Fix to allow $QTDIR to contain any valid pathname characters. + **************************************************************************** * Plugins * **************************************************************************** -- cgit v0.12 From bafaaa85f77259e256581e4cba5d7afcda56a377 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Thu, 22 Sep 2011 14:35:31 -0300 Subject: Update changelog for Qt-4.8.0: add QtWebKit notes --- dist/changes-4.8.0 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index 4299c1a..9b118d5 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -163,6 +163,11 @@ QtDBus ------ - Added a method that returns the local machine ID +QtWebKit +-------- + - Update QtWebKit to 2.2.0 + http://trac.webkit.org/wiki/QtWebKitRelease22 + QtSql ----- - Update sqlite to 3.7.7.1 -- cgit v0.12 From a6f87c60ed135c8f92a0de846dba5734fa7cf6c6 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 23 Sep 2011 12:19:02 +0200 Subject: Don't store the alignment attribute for spacers And for QLayoutWidget as it is not allowed and will create a code which doesn't compile Reviewed-by: con Task-number: QTBUG-21575 --- tools/designer/src/lib/uilib/abstractformbuilder.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 81f1a3b..665badb 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -1452,6 +1452,8 @@ struct FormBuilderSaveLayoutEntry { explicit FormBuilderSaveLayoutEntry(QLayoutItem *li = 0) : item(li), row(-1), column(-1), rowSpan(0), columnSpan(0), alignment(0) {} + void setAlignment(Qt::Alignment al); + QLayoutItem *item; int row; int column; @@ -1460,6 +1462,20 @@ struct FormBuilderSaveLayoutEntry { Qt::Alignment alignment; }; +// filter out the case of "Spacer" and "QLayoutWidget" widgets +void FormBuilderSaveLayoutEntry::setAlignment(Qt::Alignment al) +{ + if (!item->widget()) + return; + + const QString className = item->widget()->metaObject()->className(); + if (className == QLatin1String("Spacer") + || className == QLatin1String("QLayoutWidget")) + return; + + alignment = al; +} + // Create list from standard box layout static QList saveLayoutEntries(const QLayout *layout) { @@ -1469,7 +1485,7 @@ static QList saveLayoutEntries(const QLayout *layout for (int idx = 0; idx < count; ++idx) { QLayoutItem *item = layout->itemAt(idx); FormBuilderSaveLayoutEntry entry(item); - entry.alignment = item->alignment(); + entry.setAlignment(item->alignment()); rc.append(entry); } } @@ -1486,7 +1502,7 @@ static QList saveGridLayoutEntries(QGridLayout *grid QLayoutItem *item = gridLayout->itemAt(idx); FormBuilderSaveLayoutEntry entry(item); gridLayout->getItemPosition(idx, &entry.row, &entry.column, &entry.rowSpan,&entry.columnSpan); - entry.alignment = item->alignment(); + entry.setAlignment(item->alignment()); rc.append(entry); } } -- cgit v0.12 From 140e68ae50411631aa5c1649face4c7d9d1b651d Mon Sep 17 00:00:00 2001 From: Iikka Eklund Date: Fri, 23 Sep 2011 17:13:39 +0200 Subject: Fix broken qglthreads autotest build on Solaris. qglthreads autotest can not find usleep() function when compiling on Solaris platform. Added qplatformdefs.h include to fix compilation. Task-number: QTBUG-21594 Merge-request: 1394 Reviewed-by: Oswald Buddenhagen --- tests/auto/qglthreads/tst_qglthreads.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qglthreads/tst_qglthreads.cpp b/tests/auto/qglthreads/tst_qglthreads.cpp index 859f47f..60fb10c 100644 --- a/tests/auto/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/qglthreads/tst_qglthreads.cpp @@ -49,6 +49,7 @@ #include // for usleep #define RUNNING_TIME 2000 // save GPU mem by running shorter time. #else +#include "qplatformdefs.h" // for usleep #define RUNNING_TIME 5000 #endif -- cgit v0.12 From 3df9ac2f0719718ceb7385e46445447d95fd7857 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 23 Sep 2011 14:23:52 +0200 Subject: Fix accessible menu not returning child name. When accessible name is set, QAccessibleMenu would always return the menu's name, not that of the child action. Task-Number: QTBUG-21578 Reviewed-by: Jan-Arve --- src/plugins/accessible/widgets/qaccessiblemenu.cpp | 2 +- tests/auto/qaccessibility/tst_qaccessibility.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp index 4ae1d15..e9e5ca8 100644 --- a/src/plugins/accessible/widgets/qaccessiblemenu.cpp +++ b/src/plugins/accessible/widgets/qaccessiblemenu.cpp @@ -93,7 +93,7 @@ int QAccessibleMenu::childAt(int x, int y) const QString QAccessibleMenu::text(Text t, int child) const { QString tx = QAccessibleWidgetEx::text(t, child); - if (tx.size()) + if (!child && tx.size()) return tx; switch (t) { diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index d452820..d24f52f 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -2531,6 +2531,12 @@ void tst_QAccessibility::menuTest() QCOMPARE(interface->actionText(QAccessible::DefaultAction, QAccessible::Name, 4), QString()); QCOMPARE(interface->actionText(QAccessible::DefaultAction, QAccessible::Name, 5), QString("Execute")); + // QTBUG-21578 - after setting accessible name on a menu it would no longer + // return the right names for it's children. + QCOMPARE(interface->text(QAccessible::Name, 1), QString("New...")); + file->setAccessibleName("File"); + QCOMPARE(interface->text(QAccessible::Name, 1), QString("New...")); + QAccessibleInterface *iface = 0; QAccessibleInterface *iface2 = 0; -- cgit v0.12