diff options
Diffstat (limited to 'src')
98 files changed, 3755 insertions, 552 deletions
diff --git a/src/3rdparty/phonon/phonon/mediasource.cpp b/src/3rdparty/phonon/phonon/mediasource.cpp index be22dc3..11d2428 100644 --- a/src/3rdparty/phonon/phonon/mediasource.cpp +++ b/src/3rdparty/phonon/phonon/mediasource.cpp @@ -50,7 +50,7 @@ MediaSource::MediaSource(const QString &filename) const QFileInfo fileInfo(filename); if (fileInfo.exists()) { bool localFs = QAbstractFileEngine::LocalDiskFlag & QFSFileEngine(filename).fileFlags(QAbstractFileEngine::LocalDiskFlag); - if (localFs) { + if (localFs && !filename.startsWith(QLatin1String(":/")) && !filename.startsWith(QLatin1String("qrc://"))) { d->url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); } else { #ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM diff --git a/src/3rdparty/sqlite.pri b/src/3rdparty/sqlite.pri new file mode 100644 index 0000000..575412d --- /dev/null +++ b/src/3rdparty/sqlite.pri @@ -0,0 +1,4 @@ +CONFIG(release, debug|release):DEFINES *= NDEBUG +DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE +INCLUDEPATH += $$PWD/sqlite +SOURCES += $$PWD/sqlite/sqlite3.c diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp index 0342c9f..9dcba60 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -612,7 +612,7 @@ QAction* QDeclarativeWebView::stopAction() const #endif // QT_NO_ACTION /*! - \qmlproperty real WebView::title + \qmlproperty string WebView::title This property holds the title of the web page currently viewed By default, this property contains an empty string. diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index ed2ae6e..5cd7f0e 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -470,6 +470,7 @@ \value TextIncludeTrailingSpaces Same as IncludeTrailingSpaces \value TextJustificationForced Ensures that text lines are justified. + \omitvalue TextBypassShaping \omitvalue BreakAnywhere \omitvalue DontClip \omitvalue DontPrint @@ -1730,7 +1731,7 @@ \value Key_MediaLast \value Key_unknown - \value Key_Call A key to answer or initiate a call (see \l Key_ToggleCallHangup for a key to toggle current call state) + \value Key_Call A key to answer or initiate a call (see Qt::Key_ToggleCallHangup for a key to toggle current call state) \value Key_Camera A key to activate the camera shutter \value Key_CameraFocus A key to focus the camera \value Key_Context1 @@ -1738,7 +1739,7 @@ \value Key_Context3 \value Key_Context4 \value Key_Flip - \value Key_Hangup A key to end an ongoing call (see \l Key_ToggleCallHangup for a key to toggle current call state) + \value Key_Hangup A key to end an ongoing call (see Qt::Key_ToggleCallHangup for a key to toggle current call state) \value Key_No \value Key_Select \value Key_Yes diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index 4a25562..1dd51ea 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -155,10 +155,10 @@ public: if ((first - buf) < size) { // underflow, the existing valid data needs to move to the end of the (potentially bigger) buffer makeSpace(len + size, freeSpaceAtStart); - memcpy(first - size, block, size); } first -= size; len += size; + memcpy(first, block, size); } private: diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 9bc4063..739ac4d 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1399,10 +1399,10 @@ QString QProcess::nativeArguments() const \since 4.7 \overload - Sets additional native command line arguments for the program. + Sets additional native command line \a arguments for the program. On operating systems where the system API for passing command line - arguments to a subprocess natively uses a single string, one can + \a arguments to a subprocess natively uses a single string, one can conceive command lines which cannot be passed via QProcess's portable list-based API. In such cases this function must be used to set a string which is \e appended to the string composed from the usual diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 8415259..e3fce18 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -1197,7 +1197,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \l{QAbstractItemModel::}{endInsertRows()} must be called. \sa {Model Classes}, {Model Subclassing Reference}, QModelIndex, - QAbstractItemView, {Using Drag and Drop with Item Views}, + QAbstractItemView, {Using drag & drop with item views}, {Simple DOM Model Example}, {Simple Tree Model Example}, {Editable Tree Model Example}, {Fetch More Example} */ @@ -1761,7 +1761,7 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const where to place the data. This can occur in a tree when data is dropped on a parent. Models will usually append the data to the parent in this case. - \sa supportedDropActions(), {Using Drag and Drop with Item Views} + \sa supportedDropActions(), {Using drag & drop with item views} */ bool QAbstractItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) @@ -1798,8 +1798,8 @@ bool QAbstractItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti reimplement the dropMimeData() function to handle the additional operations. - \sa dropMimeData(), Qt::DropActions, {Using Drag and Drop with Item - Views} + \sa dropMimeData(), Qt::DropActions, {Using drag & drop with item + views} */ Qt::DropActions QAbstractItemModel::supportedDropActions() const { @@ -1815,7 +1815,7 @@ Qt::DropActions QAbstractItemModel::supportedDropActions() const supportedDragActions() is used by QAbstractItemView::startDrag() as the default values when a drag occurs. - \sa Qt::DropActions, {Using Drag and Drop with Item Views} + \sa Qt::DropActions, {Using drag & drop with item views} */ Qt::DropActions QAbstractItemModel::supportedDragActions() const { @@ -1831,7 +1831,7 @@ Qt::DropActions QAbstractItemModel::supportedDragActions() const Sets the supported drag \a actions for the items in the model. - \sa supportedDragActions(), {Using Drag and Drop with Item Views} + \sa supportedDragActions(), {Using drag & drop with item views} */ void QAbstractItemModel::setSupportedDragActions(Qt::DropActions actions) { @@ -2547,7 +2547,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star For example, as shown in the diagram, we move three rows from row 2 to 4 in the source, so \a sourceFirst is 2 and \a sourceLast is 4. - We move those items to above row 2 in the destination, so \a destinationRow is 2. + We move those items to above row 2 in the destination, so \a destinationChild is 2. \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 6 @@ -2558,7 +2558,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star \o To append rows to another parent, move them to after the last row. For example, as shown in the diagram, we move three rows to a - collection of 6 existing rows (ending in row 5), so \a destinationStart is 6: + collection of 6 existing rows (ending in row 5), so \a destinationChild is 6: \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 7 diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index a51ee81..6b1de5e 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2096,6 +2096,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) \value Serbia \value SaintBarthelemy \value SaintMartin + \value LatinAmericaAndTheCaribbean \omitvalue LastCountry \sa country() diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 57f79a0..b2cf49b 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6954,7 +6954,7 @@ bool QString::isRightToLeft() const /*! \fn bool QString::isRightToLeft() const - \internal + Returns true if the string is read right to left. */ diff --git a/src/declarative/debugger/qdeclarativedebugtrace.cpp b/src/declarative/debugger/qdeclarativedebugtrace.cpp index 5e6d5e7..b2b0c8a 100644 --- a/src/declarative/debugger/qdeclarativedebugtrace.cpp +++ b/src/declarative/debugger/qdeclarativedebugtrace.cpp @@ -78,6 +78,9 @@ void QDeclarativeDebugTrace::endRange(RangeType t) void QDeclarativeDebugTrace::addEventImpl(EventType event) { + if (!isEnabled()) + return; + QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); ds << m_timer.elapsed() << (int)Event << (int)event; @@ -86,6 +89,9 @@ void QDeclarativeDebugTrace::addEventImpl(EventType event) void QDeclarativeDebugTrace::startRangeImpl(RangeType range) { + if (!isEnabled()) + return; + QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); ds << m_timer.elapsed() << (int)RangeStart << (int)range; @@ -94,6 +100,9 @@ void QDeclarativeDebugTrace::startRangeImpl(RangeType range) void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &u) { + if (!isEnabled()) + return; + QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); ds << m_timer.elapsed() << (int)RangeData << (int)range << (QString)u.toString(); @@ -102,6 +111,9 @@ void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &u) void QDeclarativeDebugTrace::endRangeImpl(RangeType range) { + if (!isEnabled()) + return; + QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); ds << m_timer.elapsed() << (int)RangeEnd << (int)range; diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 44c206b..4881248 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -149,6 +149,8 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() \endqml The URL may be absolute, or relative to the URL of the component. + + \sa QDeclarativeImageProvider */ void QDeclarativeBorderImage::setSource(const QUrl &url) { diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 190b22c..b9498f1 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1388,26 +1388,6 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec */ /*! - \property QDeclarativeItem::baseline - \internal -*/ - -/*! - \property QDeclarativeItem::focus - \internal -*/ - -/*! - \property QDeclarativeItem::wantsFocus - \internal -*/ - -/*! - \property QDeclarativeItem::transformOrigin - \internal -*/ - -/*! \fn void QDeclarativeItem::childrenRectChanged(const QRectF &) \internal */ @@ -1970,6 +1950,9 @@ QVariant QDeclarativeItem::inputMethodQuery(Qt::InputMethodQuery query) const return v; } +/*! + \internal + */ void QDeclarativeItem::keyPressPreHandler(QKeyEvent *event) { Q_D(QDeclarativeItem); @@ -1980,6 +1963,9 @@ void QDeclarativeItem::keyPressPreHandler(QKeyEvent *event) d->doneEventPreHandler = true; } +/*! + \internal + */ void QDeclarativeItem::keyReleasePreHandler(QKeyEvent *event) { Q_D(QDeclarativeItem); @@ -1990,6 +1976,9 @@ void QDeclarativeItem::keyReleasePreHandler(QKeyEvent *event) d->doneEventPreHandler = true; } +/*! + \internal + */ void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event) { Q_D(QDeclarativeItem); @@ -2000,7 +1989,6 @@ void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event) d->doneEventPreHandler = true; } - /*! \internal */ @@ -2503,7 +2491,7 @@ QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItemPrivate::transi \qmlproperty bool Item::clip This property holds whether clipping is enabled. - if clipping is enabled, an item will clip its own painting, as well + If clipping is enabled, an item will clip its own painting, as well as the painting of its children, to its bounding rectangle. Non-rectangular clipping regions are not supported for performance reasons. @@ -2543,11 +2531,6 @@ QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeItemPrivate::transi \sa {qmlstates}{States} */ -/*! - \property QDeclarativeItem::state - \internal -*/ - /*! \internal */ QString QDeclarativeItemPrivate::state() const { @@ -2570,11 +2553,6 @@ void QDeclarativeItemPrivate::setState(const QString &state) For more information see \l Transform. */ -/*! - \property QDeclarativeItem::transform - \internal -*/ - /*! \internal */ QDeclarativeListProperty<QGraphicsTransform> QDeclarativeItem::transform() { @@ -2863,6 +2841,26 @@ void QDeclarativeItem::setSmooth(bool smooth) } /*! + \property QDeclarativeItem::focus + \internal +*/ + +/*! + \property QDeclarativeItem::transform + \internal +*/ + +/*! + \property QDeclarativeItem::transformOrigin + \internal +*/ + +/*! + \property QDeclarativeItem::wantsFocus + \internal +*/ + +/*! \internal Return the width of the item */ diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 110c970..fa422fd 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1732,7 +1732,7 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight) highlight is not moved by the view, and any movement must be implemented by the highlight. - Here is a highlight with its motion defined by a \l {SpringAniamtion} item: + Here is a highlight with its motion defined by a \l {SpringAnimation} item: \snippet doc/src/snippets/declarative/listview/listview.qml highlightFollowsCurrentItem diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index e745ca6..cc7f8e5 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -118,9 +118,9 @@ void QDeclarativeLoaderPrivate::initResize() be instantiated may be specified directly by the \l sourceComponent property, or loaded from a URL via the \l source property. - Loader can be used to delay the creation of a component until it is required. - For example, this loads "Page1.qml" as a component into the Loader element - when the \l MouseArea is clicked: + Loader can be used to delay the creation of a component until it + is required. For example, this loads "Page1.qml" as a component + into the Loader element, when the \l MouseArea is clicked: \code import Qt 4.7 @@ -165,7 +165,6 @@ void QDeclarativeLoaderPrivate::initResize() /*! \internal \class QDeclarativeLoader - \qmlclass Loader */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 9a281e5..ba4fa21 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -1127,6 +1127,15 @@ int QDeclarativeText::resourcesLoading() const return d->doc ? d->doc->resourcesLoading() : 0; } +/*! + \qmlproperty bool Text::clip + This property holds whether the text is clipped. + + Note that if the text does not fit in the bounding rectangle it will be abruptly chopped. + + If you want to display potentially long text in a limited space, you probably want to use \c elide instead. +*/ + void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeText); @@ -1146,13 +1155,10 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid bool needClip = clip() && (d->imgCache.width() > width() || d->imgCache.height() > height()); - if (needClip) { - p->save(); - p->setClipRect(boundingRect(), Qt::IntersectClip); - } - p->drawPixmap(br.x(), br.y(), d->imgCache); if (needClip) - p->restore(); + p->drawPixmap(0, 0, width(), height(), d->imgCache, -br.x(), -br.y(), width(), height()); + else + p->drawPixmap(br.x(), br.y(), d->imgCache); if (d->smooth) { p->setRenderHint(QPainter::Antialiasing, oldAA); @@ -1166,7 +1172,7 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid if (needClip) { p->save(); - p->setClipRect(boundingRect(), Qt::IntersectClip); + p->setClipRect(0, 0, width(), height(), Qt::IntersectClip); } if (d->richText) { QAbstractTextDocumentLayout::PaintContext context; diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index f3eef23..d13e139 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -202,8 +202,9 @@ QString QDeclarativeTextEdit::text() const Sets the font size in pixels. - Using this function makes the font device dependent. - Use \l font.pointSize to set the size of the font in a device independent manner. + Using this function makes the font device dependent. Use + \l{TextEdit::font.pointSize} to set the size of the font in a + device independent manner. */ /*! diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 97ef99c..f2eb770 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -125,7 +125,7 @@ QT_BEGIN_NAMESPACE QObject. See the QObject documentation for further details. */ /*! - \qmlproperty string QtObject::objectName + \qmlproperty string QML:QtObject::objectName This property allows you to give a name to this specific object instance. See \l{scripting.html#accessing-child-qobjects}{Accessing Child QObjects} @@ -237,8 +237,8 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) } /*! -\qmlmethod url Qt::resolvedUrl(url) -Returns \c url resolved relative to the URL of the caller. + \qmlmethod url Qt::resolvedUrl(url) + Returns \c url resolved relative to the URL of the caller. */ QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url) { @@ -1090,8 +1090,6 @@ If you are certain the files will be local, you could simplify to: To create a QML object from an arbitrary string of QML (instead of a file), use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}. - -\sa {Dynamic Object Management} */ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QScriptEngine *engine) @@ -1139,8 +1137,6 @@ Each object in this array has the members \c lineNumber, \c columnNumber, \c fil Note that this function returns immediately, and therefore may not work if the \a qml string loads new components (that is, external QML files that have not yet been loaded). If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead. - -\sa {Dynamic Object Management} */ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine) diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 001da46..008d054 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -495,7 +495,7 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId, QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression); } else { QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); - QDeclarativeProperty property(object, propertyName); + QDeclarativeProperty property(object, propertyName, context); binding->setTarget(property); binding->setNotifyOnValueChanged(true); QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding); diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp index 7c89672..9598d98 100644 --- a/src/declarative/qml/qdeclarativelist.cpp +++ b/src/declarative/qml/qdeclarativelist.cpp @@ -306,7 +306,7 @@ int QDeclarativeListReference::count() const /*! \class QDeclarativeListProperty \since 4.7 -\brief The QDeclarativeListProperty class allows applications to explose list-like +\brief The QDeclarativeListProperty class allows applications to expose list-like properties to QML. QML has many list properties, where more than one object value can be assigned. diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index bdb9510..88ec5ba 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -634,13 +634,23 @@ QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation() \inherits PropertyAnimation \brief The ColorAnimation element allows you to animate color changes. - \code - ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 } - \endcode + ColorAnimation defines an animation to be applied when a color value + changes. + + Here is a ColorAnimation applied to the \c color property of a \l Rectangle + as a property value source: + + \snippet doc/src/snippets/declarative/coloranimation.qml 0 + + Like any other animation element, a NumberAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. When used in a transition, ColorAnimation will by default animate - all properties of type color that are changing. If a property or properties - are explicitly set for the animation, then those will be used instead. + all properties of type color that have changed. If a \l{PropertyAnimation::}{property} + or \l{PropertyAnimation::}{properties} are explicitly set for the animation, + then those are used instead. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -665,6 +675,17 @@ QDeclarativeColorAnimation::~QDeclarativeColorAnimation() /*! \qmlproperty color ColorAnimation::from This property holds the starting color. + + For example, the following animation is not applied until a color value + has reached "#c0c0c0": + + Item { + states: [ ... ] + + transition: Transition { + NumberAnimation { from: "#c0c0c0"; duration: 2000 } + } + } */ QColor QDeclarativeColorAnimation::from() const { @@ -1098,11 +1119,22 @@ void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions, \inherits PropertyAnimation \brief The NumberAnimation element allows you to animate changes in properties of type qreal. - For example, to animate a set of properties over 200ms, from their values in the start state to - their values in the end state of the transition: - \code - NumberAnimation { properties: "x,y,scale"; duration: 200 } - \endcode + NumberAnimation defines an animation to be applied when a numerical value + changes. + + Here is a NumberAnimation applied to the \c x property of a \l Rectangle + as a property value source: + + \snippet doc/src/snippets/declarative/numberanimation.qml 0 + + Like any other animation element, a NumberAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. + + Note that NumberAnimation may not animate smoothly if there are irregular + changes in the number value that it is tracking. If this is the case, use + SmoothedAnimation instead. \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -1137,9 +1169,23 @@ void QDeclarativeNumberAnimation::init() /*! \qmlproperty real NumberAnimation::from - This property holds the starting value. - If not set, then the value defined in the start state of the transition. + This property holds the starting number value. + + For example, the following animation is not applied until the \c x value + has reached 100: + + Item { + states: [ ... ] + + transition: Transition { + NumberAnimation { properties: "x"; from: 100; duration: 200 } + } + } + + If this value is not set, it defaults to the value defined in the start + state of the \l Transition. */ + qreal QDeclarativeNumberAnimation::from() const { Q_D(const QDeclarativePropertyAnimation); @@ -1153,8 +1199,10 @@ void QDeclarativeNumberAnimation::setFrom(qreal f) /*! \qmlproperty real NumberAnimation::to - This property holds the ending value. - If not set, then the value defined in the end state of the transition or Behavior. + This property holds the ending number value. + + If this value is not set, it defaults to the value defined in the end + state of the \l Transition or \l Behavior. */ qreal QDeclarativeNumberAnimation::to() const { @@ -1199,7 +1247,9 @@ QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation() /*! \qmlproperty real Vector3dAnimation::from This property holds the starting value. - If not set, then the value defined in the start state of the transition. + + If this value is not set, it defaults to the value defined in the start + state of the \l Transition. */ QVector3D QDeclarativeVector3dAnimation::from() const { @@ -1215,7 +1265,9 @@ void QDeclarativeVector3dAnimation::setFrom(QVector3D f) /*! \qmlproperty real Vector3dAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition or Behavior. + + If this value is not set, it defaults to the value defined in the end + state of the \l Transition or \l Behavior. */ QVector3D QDeclarativeVector3dAnimation::to() const { @@ -1320,8 +1372,21 @@ QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation() /*! \qmlproperty real RotationAnimation::from - This property holds the starting value. - If not set, then the value defined in the start state of the transition. + This property holds the starting number value. + + For example, the following animation is not applied until the \c angle value + has reached 100: + + Item { + states: [ ... ] + + transition: Transition { + RotationAnimation { properties: "angle"; from: 100; duration: 2000 } + } + } + + If this value is not set, it defaults to the value defined in the start + state of the \l Transition. */ qreal QDeclarativeRotationAnimation::from() const { @@ -1337,7 +1402,9 @@ void QDeclarativeRotationAnimation::setFrom(qreal f) /*! \qmlproperty real RotationAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition or Behavior. + + If this value is not set, it defaults to the value defined in the end + state of the \l Transition or \l Behavior. */ qreal QDeclarativeRotationAnimation::to() const { @@ -1620,57 +1687,58 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int \inherits Animation \brief The PropertyAnimation element allows you to animate property changes. - PropertyAnimation provides a way to animate changes to a property's value. It can - be used in many different situations: + PropertyAnimation provides a way to animate changes to a property's value. + + It can be used to define animations in a number of ways: + \list - \o In a Transition + \o In a \l Transition + + For example, to animate any objects that have changed their \c x or \c y properties + as a result of a state change, using an \c InOutQuad easing curve: + + \snippet doc/src/snippets/declarative/propertyanimation.qml transition + + + \o In a \l Behavior + + For example, to animate all changes to a rectangle's \c x property: + + \snippet doc/src/snippets/declarative/propertyanimation.qml behavior - Animate any objects that have changed their x or y properties in the target state using - an InOutQuad easing curve: - \qml - Transition { PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } } - \endqml - \o In a Behavior - Animate all changes to a rectangle's x property. - \qml - Rectangle { - Behavior on x { PropertyAnimation {} } - } - \endqml \o As a property value source - Repeatedly animate the rectangle's x property. - \qml - Rectangle { - SequentialAnimation on x { - loops: Animation.Infinite - PropertyAnimation { to: 50 } - PropertyAnimation { to: 0 } - } - } - \endqml + For example, to repeatedly animate the rectangle's \c x property: + + \snippet doc/src/snippets/declarative/propertyanimation.qml propertyvaluesource + + \o In a signal handler - Fade out \c theObject when clicked: + For example, to fade out \c theObject when clicked: \qml MouseArea { anchors.fill: theObject onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 } } \endqml + \o Standalone - Animate \c theObject's size property over 200ms, from its current size to 20-by-20: - \qml - PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 } - \endqml + For example, to animate \c rect's \c width property over 500ms, from its current width to 30: + + \snippet doc/src/snippets/declarative/propertyanimation.qml standalone + \endlist Depending on how the animation is used, the set of properties normally used will be different. For more information see the individual property documentation, as well as the \l{QML Animation} introduction. + Note that PropertyAnimation inherits the abstract \l Animation element. + This includes additional properties and methods for controlling the animation. + \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index 5d47c30..e0d1097 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -272,33 +272,8 @@ void QSmoothedAnimation::init() with both a velocity of 200 and a duration of 8000 set. The follow example shows one rectangle tracking the position of another. -\code -import Qt 4.7 - -Rectangle { - width: 800; height: 600; color: "blue" - - Rectangle { - color: "green" - width: 60; height: 60; - x: rect1.x - 5; y: rect1.y - 5; - Behavior on x { SmoothedAnimation { velocity: 200 } } - Behavior on y { SmoothedAnimation { velocity: 200 } } - } - - Rectangle { - id: rect1 - color: "red" - width: 50; height: 50; - } - focus: true - Keys.onRightPressed: rect1.x = rect1.x + 100 - Keys.onLeftPressed: rect1.x = rect1.x - 100 - Keys.onUpPressed: rect1.y = rect1.y - 100 - Keys.onDownPressed: rect1.y = rect1.y + 100 -} -\endcode + \snippet doc/src/snippets/declarative/smoothedanimation.qml 0 The default velocity of SmoothedAnimation is 200 units/second. Note that if the range of the value being animated is small, then the velocity will need to be adjusted @@ -307,6 +282,11 @@ Rectangle { set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity of 0.5 will take 2000 ms to complete. + Like any other animation element, a SmoothedAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. + \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} */ @@ -388,11 +368,13 @@ void QDeclarativeSmoothedAnimation::transition(QDeclarativeStateActions &actions Sets how the SmoothedAnimation behaves if an animation direction is reversed. - If reversing mode is \c SmoothedAnimation.Eased, the animation will smoothly decelerate, and - then reverse direction. If the reversing mode is \c SmoothedAnimation.Immediate, the - animation will immediately begin accelerating in the reverse direction, - begining with a velocity of 0. If the reversing mode is \c SmoothedAnimation.Sync, the - property is immediately set to the target value. + Possible values are: + + \list + \o SmoothedAnimation.Eased (default) - the animation will smoothly decelerate, and then reverse direction + \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, begining with a velocity of 0 + \o SmoothedAnimation.Sync - the property is immediately set to the target value + \endlist */ QDeclarativeSmoothedAnimation::ReversingMode QDeclarativeSmoothedAnimation::reversingMode() const { diff --git a/src/declarative/util/qdeclarativespringanimation.cpp b/src/declarative/util/qdeclarativespringanimation.cpp index 4cf2fc0..be0af6d 100644 --- a/src/declarative/util/qdeclarativespringanimation.cpp +++ b/src/declarative/util/qdeclarativespringanimation.cpp @@ -207,14 +207,24 @@ void QDeclarativeSpringAnimationPrivate::updateMode() \qmlclass SpringAnimation QDeclarativeSpringAnimation \since 4.7 - \brief The SpringAnimation element allows a property to track a value in a spring-like motion + \brief The SpringAnimation element allows a property to track a value in a spring-like motion. SpringAnimation mimics the oscillatory behavior of a spring, with the appropriate \l spring constant to control the acceleration and the \l damping to control how quickly the effect dies away. You can also limit the maximum \l velocity of the animation. + The following \l Rectangle moves to the position of the mouse using a + SpringAnimation when the mouse is clicked: + \snippet doc/src/snippets/declarative/springanimation.qml 0 + + Like any other animation element, a SpringAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l PropertyAnimation documentation shows a variety of methods + for creating animations. + + \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example} */ QDeclarativeSpringAnimation::QDeclarativeSpringAnimation(QObject *parent) @@ -244,6 +254,11 @@ qreal QDeclarativeSpringAnimation::to() const /*! \qmlproperty real SpringAnimation::to + + This property holds the value at which the animation will end. + + If not set, the animation will continue until it reaches the + value that is being tracked. */ void QDeclarativeSpringAnimation::setTo(qreal value) @@ -266,6 +281,11 @@ qreal QDeclarativeSpringAnimation::from() const /*! \qmlproperty real SpringAnimation::from + + This property holds the value from which the animation will begin. + + If not set, the animation will start regardless of the + value being tracked. */ void QDeclarativeSpringAnimation::setFrom(qreal value) @@ -325,10 +345,12 @@ void QDeclarativeSpringAnimation::setSpring(qreal spring) /*! \qmlproperty real SpringAnimation::damping - This property holds the spring damping constant + This property holds the spring damping value. + + This value describes how quickly a sprung follower comes to rest. - The damping constant describes how quickly a sprung follower comes to rest. - Useful range is 0 - 1.0 + The useful range is 0 - 1.0. The lower the value, the faster the + follower comes to rest. */ qreal QDeclarativeSpringAnimation::damping() const { @@ -348,7 +370,7 @@ void QDeclarativeSpringAnimation::setDamping(qreal damping) /*! \qmlproperty real SpringAnimation::epsilon - This property holds the spring epsilon + This property holds the spring epsilon. The epsilon is the rate and amount of change in the value which is close enough to 0 to be considered equal to zero. This will depend on the usage of the value. diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index ae19a9c..9f4cc39 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -144,7 +144,7 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje can, for example, be used to apply different sets of property values or execute different scripts. - The following example displays a single Rectangle. In the default state, the rectangle + The following example displays a single \l Rectangle. In the default state, the rectangle is colored black. In the "clicked" state, a PropertyChanges element changes the rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state between the default state and the "clicked" state, thus toggling the color of the @@ -157,7 +157,7 @@ QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObje States are commonly used together with \l {state-transitions}{Transitions} to provide animations when state changes occur. - \note setting the state of an object from within another state of the same object is + \note Setting the state of an object from within another state of the same object is not allowed. \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, QtDeclarative @@ -194,7 +194,7 @@ QDeclarativeState::~QDeclarativeState() \qmlproperty string State::name This property holds the name of the state. - Each state should have a unique name. + Each state should have a unique name within its item. */ QString QDeclarativeState::name() const { @@ -226,7 +226,23 @@ bool QDeclarativeState::isWhenKnown() const This property holds when the state should be applied. This should be set to an expression that evaluates to \c true when you want the state to - be applied. + be applied. For example, the following \l Rectangle changes in and out of the "hidden" + state when the \l MouseArea is pressed: + + \qml + Rectangle { + id: myRect + width: 100; height: 100 + color: "red" + + MouseArea { id: mouseArea; anchors.fill: parent } + + states: State { + name: "hidden"; when: mouseArea.pressed + PropertyChanges { target: myRect; opacity: 0 } + } + } + \endqml If multiple states in a group have \c when clauses that evaluate to \c true at the same time, the first matching state will be applied. For example, in the following snippet diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index 38ed97e..34e1e2b 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -56,6 +56,30 @@ QT_BEGIN_NAMESPACE \since 4.7 \brief The Transition element defines animated transitions that occur on state changes. + A Transition defines the animations to be applied when a \l State change occurs. + + For example, the following \l Rectangle has two states: the default state, and + an added "moved" state. In the "moved state, the rectangle's position changes + to (50, 50). The added \l Transition specifies that when the rectangle + changes between the default and the "moved" state, any changes + to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad. + + \snippet doc/src/snippets/declarative/transition.qml 0 + + Items can have multiple transitions, if + + To specify multiple transitions, specify \l Item::transitions as a list: + + \qml + Item { + ... + transitions: [ + Transition { ... } + Transition { ... } + ] + } + |endqml + \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative} */ @@ -171,18 +195,31 @@ void QDeclarativeTransition::prepare(QDeclarativeStateOperation::ActionList &act /*! \qmlproperty string Transition::from \qmlproperty string Transition::to - These properties are selectors indicating which state changes should trigger the transition. - from is used in conjunction with to to determine when a transition should - be applied. By default from and to are both "*" (any state). In the following example, - the transition is applied when changing from state1 to state2. - \code - Transition { - from: "state1" - to: "state2" - ... + These properties indicate the state changes that trigger the transition. + + The default values for these properties is "*" (that is, any state). + + For example, the following transition has not set the \c to and \c from + properties, so the animation is always applied when changing between + the two states (i.e. when the mouse is pressed and released). + + \snippet doc/src/snippets/declarative/transition-from-to.qml 0 + + If the transition was changed to this: + + \qml + transitions: Transition { + to: "brighter" + ColorAnimation { duration: 1000 } + } } - \endcode + \endqml + + The animation would only be applied when changing from the default state to + the "brighter" state (i.e. when the mouse is pressed, but not on release). + + \sa reversible */ QString QDeclarativeTransition::fromState() const { @@ -205,6 +242,24 @@ void QDeclarativeTransition::setFromState(const QString &f) This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed. The default value is false. + + By default, transitions run in parallel and are applied to all state + changes if the \l from and \l to states have not been set. In this + situation, the transition is automatically applied when a state change + is reversed, and it is not necessary to set this property to reverse + the transition. + + However, if a SequentialAnimation is used, or if the \l from or \l to + properties have been set, this property will need to be set to reverse + a transition when a state change is reverted. For example, the following + transition applies a sequential animation when the mouse is pressed, + and reverses the sequence of the animation when the mouse is released: + + \snippet doc/src/snippets/declarative/transition-reversible.qml 0 + + If the transition did not set the \c to and \c reversible values, then + on the mouse release, the transition would play the PropertyAnimation + before the ColorAnimation instead of reversing the sequence. */ bool QDeclarativeTransition::reversible() const { @@ -241,12 +296,27 @@ void QDeclarativeTransition::setToState(const QString &t) /*! \qmlproperty list<Animation> Transition::animations \default + This property holds a list of the animations to be run for this transition. + \qml + Transition { + PropertyAnimation { ... } + NumberAnimation { ... } + } + \endqml + The top-level animations are run in parallel. To run them sequentially, - you can create a single SequentialAnimation which contains all the animations, - and assign that to animations the animations property. - \default + define them within a SequentialAnimation: + + \qml + Transition { + SequentialAnimation { + PropertyAnimation { ... } + NumberAnimation { ... } + } + } + \endqml */ QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeTransition::animations() { diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 9895ff2..9f4df22 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -596,7 +596,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla with a combined value of all key roles that is not already present in the model. - \sa {demos/declarative/rssnews}{RSS News demo} + \sa {RSS News} */ QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent) diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp index e406cba..ad8801a 100644 --- a/src/gui/dialogs/qwizard_win.cpp +++ b/src/gui/dialogs/qwizard_win.cpp @@ -180,7 +180,8 @@ QVistaBackButton::QVistaBackButton(QWidget *widget) QSize QVistaBackButton::sizeHint() const { ensurePolished(); - int width = 32, height = 32; + int size = int(QStyleHelper::dpiScaled(32)); + int width = size, height = size; /* HANDLE theme = pOpenThemeData(0, L"Navigation"); SIZE size; @@ -213,8 +214,8 @@ void QVistaBackButton::paintEvent(QPaintEvent *) HANDLE theme = pOpenThemeData(0, L"Navigation"); //RECT rect; RECT clipRect; - int xoffset = QWidget::mapToParent(r.topLeft()).x(); - int yoffset = QWidget::mapToParent(r.topLeft()).y(); + int xoffset = QWidget::mapToParent(r.topLeft()).x() - 1; + int yoffset = QWidget::mapToParent(r.topLeft()).y() - 1; clipRect.top = r.top() + yoffset; clipRect.bottom = r.bottom() + yoffset; @@ -245,6 +246,11 @@ QVistaHelper::QVistaHelper(QWizard *wizard) is_vista = resolveSymbols(); if (is_vista) backButton_ = new QVistaBackButton(wizard); + + // Handle diff between Windows 7 and Vista + iconSpacing = QStyleHelper::dpiScaled(7); + textSpacing = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? + iconSpacing : QStyleHelper::dpiScaled(20); } QVistaHelper::~QVistaHelper() @@ -308,18 +314,15 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) void QVistaHelper::drawTitleBar(QPainter *painter) { - if (vistaState() == VistaAero) - drawBlackRect( - QRect(0, 0, wizard->width(), titleBarSize() + topOffset()), - painter->paintEngine()->getDC()); + HDC hdc = painter->paintEngine()->getDC(); + if (vistaState() == VistaAero) + drawBlackRect(QRect(0, 0, wizard->width(), + titleBarSize() + topOffset()), hdc); Q_ASSERT(backButton_); const int btnTop = backButton_->mapToParent(QPoint()).y(); const int btnHeight = backButton_->size().height(); - const int verticalCenter = (btnTop + btnHeight / 2); - - wizard->windowIcon().paint( - painter, QRect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize())); + const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); const QFont font = QApplication::font("QWorkspaceTitleBar"); @@ -327,14 +330,25 @@ void QVistaHelper::drawTitleBar(QPainter *painter) const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); int textWidth = brect.width(); + int glowOffset = 0; + if (vistaState() == VistaAero) { textHeight += 2 * glowSize(); textWidth += 2 * glowSize(); + glowOffset = glowSize(); } + drawTitleText( painter, text, - QRect(titleOffset(), verticalCenter - textHeight / 2, textWidth, textHeight), - painter->paintEngine()->getDC()); + QRect(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight), + hdc); + + if (!wizard->windowIcon().isNull()) { + QRect rect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize()); + HICON hIcon = wizard->windowIcon().pixmap(iconSize()).toWinHICON(); + DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT); + DestroyIcon(hIcon); + } } void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible) @@ -734,7 +748,7 @@ bool QVistaHelper::resolveSymbols() int QVistaHelper::titleOffset() { - int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + padding(); + int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing; return leftMargin() + iconOffset; } diff --git a/src/gui/dialogs/qwizard_win_p.h b/src/gui/dialogs/qwizard_win_p.h index 5f3b6c2..caf018d 100644 --- a/src/gui/dialogs/qwizard_win_p.h +++ b/src/gui/dialogs/qwizard_win_p.h @@ -61,6 +61,7 @@ #include <qwidget.h> #include <qabstractbutton.h> #include <QtGui/private/qwidget_p.h> +#include <QtGui/private/qstylehelper_p.h> QT_BEGIN_NAMESPACE @@ -100,9 +101,14 @@ public: enum VistaState { VistaAero, VistaBasic, Classic, Dirty }; static VistaState vistaState(); static int titleBarSize() { return frameSize() + captionSize(); } - static int topPadding() { return 8; } - static int topOffset() { return titleBarSize() + (vistaState() == VistaAero ? 13 : 3); } - + static int topPadding() { // padding under text + return int(QStyleHelper::dpiScaled( + QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? 4 : 6)); + } + static int topOffset() { + static int aeroOffset = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? + QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13); + return (titleBarSize() + (vistaState() == VistaAero ? aeroOffset : 3)); } private: static HFONT getCaptionFont(HANDLE hTheme); bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc); @@ -111,11 +117,10 @@ private: static int frameSize() { return GetSystemMetrics(SM_CYSIZEFRAME); } static int captionSize() { return GetSystemMetrics(SM_CYCAPTION); } - static int backButtonSize() { return 31; } // ### should be queried from back button itself + static int backButtonSize() { return int(QStyleHelper::dpiScaled(30)); } static int iconSize() { return 16; } // Standard Aero - static int padding() { return 7; } // Standard Aero - static int leftMargin() { return backButtonSize() + padding(); } static int glowSize() { return 10; } + int leftMargin() { return backButton_->isVisible() ? backButtonSize() + iconSpacing : 0; } int titleOffset(); bool resolveSymbols(); @@ -139,6 +144,10 @@ private: QRect rtTitle; QWizard *wizard; QVistaBackButton *backButton_; + + int titleBarOffset; // Extra spacing above the text + int iconSpacing; // Space between button and icon + int textSpacing; // Space between icon and text }; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index abe4e25..6249822 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -133,7 +133,8 @@ \img graphicsview-parentchild.png - \section1 Transformation + \target Transformations + \section1 Transformations QGraphicsItem supports projective transformations in addition to its base position, pos(). There are several ways to change an item's transformation. diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 4fb93fc..97499f3 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1363,7 +1363,7 @@ bool QAbstractItemView::dragEnabled() const Note that the model used needs to provide support for drag and drop operations. - \sa setDragDropMode() {Using Drag and Drop with Item Views} + \sa setDragDropMode() {Using drag & drop with item views} */ /*! diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp index 5dbd1f0..4748f89 100644 --- a/src/gui/itemviews/qfileiconprovider.cpp +++ b/src/gui/itemviews/qfileiconprovider.cpp @@ -100,69 +100,80 @@ public: QIcon getMacIcon(const QFileInfo &fi) const; #endif QFileIconProvider *q_ptr; - QString homePath; + const QString homePath; private: - QIcon file; - QIcon fileLink; - QIcon directory; - QIcon directoryLink; - QIcon harddisk; - QIcon floppy; - QIcon cdrom; - QIcon ram; - QIcon network; - QIcon computer; - QIcon desktop; - QIcon trashcan; - QIcon generic; - QIcon home; + mutable QIcon file; + mutable QIcon fileLink; + mutable QIcon directory; + mutable QIcon directoryLink; + mutable QIcon harddisk; + mutable QIcon floppy; + mutable QIcon cdrom; + mutable QIcon ram; + mutable QIcon network; + mutable QIcon computer; + mutable QIcon desktop; + mutable QIcon trashcan; + mutable QIcon generic; + mutable QIcon home; }; -QFileIconProviderPrivate::QFileIconProviderPrivate() +QFileIconProviderPrivate::QFileIconProviderPrivate() : + homePath(QDir::home().absolutePath()) { - QStyle *style = QApplication::style(); - file = style->standardIcon(QStyle::SP_FileIcon); - directory = style->standardIcon(QStyle::SP_DirIcon); - fileLink = style->standardIcon(QStyle::SP_FileLinkIcon); - directoryLink = style->standardIcon(QStyle::SP_DirLinkIcon); - harddisk = style->standardIcon(QStyle::SP_DriveHDIcon); - floppy = style->standardIcon(QStyle::SP_DriveFDIcon); - cdrom = style->standardIcon(QStyle::SP_DriveCDIcon); - network = style->standardIcon(QStyle::SP_DriveNetIcon); - computer = style->standardIcon(QStyle::SP_ComputerIcon); - desktop = style->standardIcon(QStyle::SP_DesktopIcon); - trashcan = style->standardIcon(QStyle::SP_TrashIcon); - home = style->standardIcon(QStyle::SP_DirHomeIcon); - homePath = QDir::home().absolutePath(); } QIcon QFileIconProviderPrivate::getIcon(QStyle::StandardPixmap name) const { switch (name) { case QStyle::SP_FileIcon: + if (file.isNull()) + file = QApplication::style()->standardIcon(name); return file; case QStyle::SP_FileLinkIcon: + if (fileLink.isNull()) + fileLink = QApplication::style()->standardIcon(name); return fileLink; case QStyle::SP_DirIcon: + if (directory.isNull()) + directory = QApplication::style()->standardIcon(name); return directory; case QStyle::SP_DirLinkIcon: + if (directoryLink.isNull()) + directoryLink = QApplication::style()->standardIcon(name); return directoryLink; case QStyle::SP_DriveHDIcon: + if (harddisk.isNull()) + harddisk = QApplication::style()->standardIcon(name); return harddisk; case QStyle::SP_DriveFDIcon: + if (floppy.isNull()) + floppy = QApplication::style()->standardIcon(name); return floppy; case QStyle::SP_DriveCDIcon: + if (cdrom.isNull()) + cdrom = QApplication::style()->standardIcon(name); return cdrom; case QStyle::SP_DriveNetIcon: + if (network.isNull()) + network = QApplication::style()->standardIcon(name); return network; case QStyle::SP_ComputerIcon: + if (computer.isNull()) + computer = QApplication::style()->standardIcon(name); return computer; case QStyle::SP_DesktopIcon: + if (desktop.isNull()) + desktop = QApplication::style()->standardIcon(name); return desktop; case QStyle::SP_TrashIcon: + if (trashcan.isNull()) + trashcan = QApplication::style()->standardIcon(name); return trashcan; case QStyle::SP_DirHomeIcon: + if (home.isNull()) + home = QApplication::style()->standardIcon(name); return home; default: return QIcon(); diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 94211fd..aaf479f 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5294,6 +5294,7 @@ bool QApplication::keypadNavigationEnabled() \sa QCoreApplication::instance() */ +#ifndef QT_NO_IM // ************************************************************************ // Input Method support // ************************************************************************ @@ -5359,6 +5360,7 @@ QInputContext *QApplication::inputContext() const #endif return d->inputContext; } +#endif // QT_NO_IM //Returns the current platform used by keyBindings uint QApplicationPrivate::currentPlatform(){ diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index d31d9e5..799d4c2 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -267,8 +267,11 @@ public: virtual void commitData(QSessionManager& sm); virtual void saveState(QSessionManager& sm); #endif + +#ifndef QT_NO_IM void setInputContext(QInputContext *); QInputContext *inputContext() const; +#endif static QLocale keyboardInputLocale(); static Qt::LayoutDirection keyboardInputDirection(); diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 9e8a128..ec26e81 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2485,7 +2485,7 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa if (OkCommand) QApplication::postEvent(widget, new QEvent(QEvent::OkRequest)); if (CancelCommand) - QApplication::postEvent(widget, new QEvent(QEvent::Close)); + widget->showMinimized(); else #ifndef QT_NO_MENUBAR QMenuBar::wceCommands(LOWORD(wParam)); diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 5dcf613..7a9dc70 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -196,7 +196,6 @@ static void cleanupCocoaApplicationDelegate() qAppInstance()->quit(); startedQuit = false; } - return NSTerminateNow; } if (qtPrivate->threadData->eventLoops.size() == 0) { diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 8652816..6795149 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -85,6 +85,8 @@ QT_END_NAMESPACE - (BOOL)canBecomeKeyWindow { QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; + if (!widget) + return NO; // This should happen only for qt_root_win bool isToolTip = (widget->windowType() == Qt::ToolTip); bool isPopup = (widget->windowType() == Qt::Popup); @@ -94,6 +96,8 @@ QT_END_NAMESPACE - (BOOL)canBecomeMainWindow { QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; + if (!widget) + return NO; // This should happen only for qt_root_win bool isToolTip = (widget->windowType() == Qt::ToolTip); bool isPopup = (widget->windowType() == Qt::Popup); diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 5c90e2e..1935531 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -269,6 +269,28 @@ static int qCocoaViewCount = 0; dropData = new QCocoaDropData(dropPasteboard); } +- (void)changeDraggingCursor:(NSDragOperation)newOperation +{ + static SEL action = nil; + static bool operationSupported = false; + if (action == nil) { + action = NSSelectorFromString(@"operationNotAllowedCursor"); + if ([NSCursor respondsToSelector:action]) { + operationSupported = true; + } + } + if (operationSupported) { + NSCursor *notAllowedCursor = [NSCursor performSelector:action]; + bool isNotAllowedCursor = ([NSCursor currentCursor] == notAllowedCursor); + if (newOperation == NSDragOperationNone && !isNotAllowedCursor) { + [notAllowedCursor push]; + } else if (newOperation != NSDragOperationNone && isNotAllowedCursor) { + [notAllowedCursor pop]; + } + + } +} + - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender { // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly @@ -300,6 +322,7 @@ static int qCocoaViewCount = 0; if (!qDEEvent.isAccepted()) { // widget is not interested in this drag, so ignore this drop data. [self removeDropData]; + [self changeDraggingCursor:NSDragOperationNone]; return NSDragOperationNone; } else { // save the mouse position, used by draggingExited handler. @@ -321,6 +344,7 @@ static int qCocoaViewCount = 0; nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction()); } QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent); + [self changeDraggingCursor:nsActions]; return nsActions; } } @@ -335,16 +359,21 @@ static int qCocoaViewCount = 0; if (dragEnterSequence != [sender draggingSequenceNumber]) [self draggingEntered:sender]; // drag enter event was rejected, so ignore the move event. - if (dropData == 0) + if (dropData == 0) { + [self changeDraggingCursor:NSDragOperationNone]; return NSDragOperationNone; + } // return last value, if we are still in the answerRect. NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint]; NSPoint localPoint = [self convertPoint:windowPoint fromView:nil]; NSDragOperation nsActions = [sender draggingSourceOperationMask]; QPoint posDrag(localPoint.x, localPoint.y); if (qt_mac_mouse_inside_answer_rect(posDrag) - && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) - return QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction)); + && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) { + NSDragOperation operation = QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction)); + [self changeDraggingCursor:operation]; + return operation; + } // send drag move event to the widget QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions; Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions); @@ -373,6 +402,7 @@ static int qCocoaViewCount = 0; qDMEvent.setDropAction(Qt::IgnoreAction); } qt_mac_copy_answer_rect(qDMEvent); + [self changeDraggingCursor:operation]; return operation; } @@ -388,6 +418,8 @@ static int qCocoaViewCount = 0; QApplication::sendEvent(qwidget, &de); [self removeDropData]; } + [self changeDraggingCursor:NSDragOperationEvery]; + } - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h index 33aaa24..b6b63ca 100644 --- a/src/gui/kernel/qcocoaview_mac_p.h +++ b/src/gui/kernel/qcocoaview_mac_p.h @@ -106,6 +106,7 @@ Q_GUI_EXPORT - (void) qt_clearQWidget; - (BOOL)qt_leftButtonIsRightButton; - (void)qt_setLeftButtonIsRightButton:(BOOL)isSwapped; +- (void)changeDraggingCursor:(NSDragOperation)newOperation; + (DnDParams*)currentMouseEvent; @end diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index f5688f4..6359ecf 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -41,6 +41,7 @@ #include "qgesture.h" #include "private/qgesture_p.h" +#include "private/qstandardgestures_p.h" #ifndef QT_NO_GESTURES @@ -726,6 +727,34 @@ void QTapAndHoldGesture::setPosition(const QPointF &value) d_func()->position = value; } +/*! + Set the timeout, in milliseconds, before the gesture triggers. + + The recognizer will detect a touch down and and if \a msecs + later the touch is still down, it will trigger the QTapAndHoldGesture. + The default value is 700 milliseconds. +*/ +// static +void QTapAndHoldGesture::setTimeout(int msecs) +{ + QTapAndHoldGesturePrivate::Timeout = msecs; +} + +/*! + Gets the timeout, in milliseconds, before the gesture triggers. + + The recognizer will detect a touch down and and if timeout() + later the touch is still down, it will trigger the QTapAndHoldGesture. + The default value is 700 milliseconds. +*/ +// static +int QTapAndHoldGesture::timeout() +{ + return QTapAndHoldGesturePrivate::Timeout; +} + +int QTapAndHoldGesturePrivate::Timeout = 700; // in ms + QT_END_NAMESPACE #endif // QT_NO_GESTURES diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 8c10895..8f410b1 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -252,6 +252,9 @@ public: QPointF position() const; void setPosition(const QPointF &pos); + static void setTimeout(int msecs); + static int timeout(); + friend class QTapAndHoldGestureRecognizer; }; diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index f5474c1..29b923e 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -177,6 +177,7 @@ public: QPointF position; int timerId; + static int Timeout; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index e43a560..fe9dd8a 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE QGestureManager::QGestureManager(QObject *parent) - : QObject(parent), state(NotGesture), m_lastCustomGestureId(0) + : QObject(parent), state(NotGesture), m_lastCustomGestureId(Qt::CustomGesture) { qRegisterMetaType<Qt::GestureState>(); @@ -119,7 +119,7 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r if (type == Qt::CustomGesture) { // generate a new custom gesture id ++m_lastCustomGestureId; - type = Qt::GestureType(Qt::CustomGesture + m_lastCustomGestureId); + type = Qt::GestureType(m_lastCustomGestureId); } m_recognizers.insertMulti(type, recognizer); delete dummy; diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp index f5004b0..377dfe3 100644 --- a/src/gui/kernel/qguifunctions_wince.cpp +++ b/src/gui/kernel/qguifunctions_wince.cpp @@ -76,6 +76,10 @@ struct AygSIPINFO #define SHIDIF_SIZEDLGFULLSCREEN 0x0004 #endif +#ifndef SHDB_HIDE +#define SHDB_HIDE 0x0002 +#endif + #ifndef SHFS_SHOWTASKBAR #define SHFS_SHOWTASKBAR 0x0001 #endif @@ -112,10 +116,12 @@ struct AygSIPINFO typedef BOOL (*AygInitDialog)(AygSHINITDLGINFO*); typedef BOOL (*AygFullScreen)(HWND, DWORD); typedef BOOL (*AygSHSipInfo)(UINT, UINT, PVOID, UINT); +typedef BOOL (*AygSHDoneButton)(HWND, DWORD); static AygInitDialog ptrAygInitDialog = 0; static AygFullScreen ptrAygFullScreen = 0; static AygSHSipInfo ptrAygSHSipInfo = 0; +static AygSHDoneButton ptrAygSHDoneButton = 0; static bool aygResolved = false; static void resolveAygLibs() @@ -128,18 +134,10 @@ static void resolveAygLibs() ptrAygInitDialog = (AygInitDialog) ayglib.resolve("SHInitDialog"); ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen"); ptrAygSHSipInfo = (AygSHSipInfo) ayglib.resolve("SHSipInfo"); + ptrAygSHDoneButton = (AygSHDoneButton) ayglib.resolve("SHDoneButton"); } } -struct DIBINFO : public BITMAPINFO -{ - RGBQUAD arColors[255]; - - operator LPBITMAPINFO() { return (LPBITMAPINFO) this; } - operator LPBITMAPINFOHEADER() { return &bmiHeader; } - RGBQUAD* ColorTable() { return bmiColors; } -}; - int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID lpvBits, LPBITMAPINFO, uint) { if (!lpvBits) { @@ -323,6 +321,8 @@ void qt_wince_maximize(QWidget *widget) shidi.dwFlags |= SHIDIF_CANCELBUTTON; if (widget->windowFlags() & Qt::WindowOkButtonHint) shidi.dwFlags |= SHIDIF_DONEBUTTON; + if (!(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint))) + shidi.dwFlags |= SHIDIF_CANCELBUTTON; resolveAygLibs(); if (ptrAygInitDialog) ptrAygInitDialog(&shidi); @@ -334,6 +334,16 @@ void qt_wince_maximize(QWidget *widget) } } +void qt_wince_unmaximize(QWidget *widget) +{ + if (ptrAygSHDoneButton && qt_wince_is_mobile() + && !(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint))) + { + // Hide the [X] button, we've added in qt_wince_maximize. + ptrAygSHDoneButton(widget->winId(), SHDB_HIDE); + } +} + void qt_wince_minimize(HWND hwnd) { #ifdef Q_OS_WINCE_WM diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 62d8a53..e05f8cc 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -517,7 +517,6 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, const QMouseEvent *me = static_cast<const QMouseEvent *>(event); const QGraphicsSceneMouseEvent *gsme = static_cast<const QGraphicsSceneMouseEvent *>(event); - enum { TimerInterval = 2000 }; enum { TapRadius = 40 }; switch (event->type()) { @@ -526,21 +525,21 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::MouseButtonPress: d->position = me->globalPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::TouchBegin: d->position = ev->touchPoints().at(0).startScreenPos(); q->setHotSpot(d->position); if (d->timerId) q->killTimer(d->timerId); - d->timerId = q->startTimer(TimerInterval); + d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout case QEvent::GraphicsSceneMouseRelease: case QEvent::MouseButtonRelease: diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 233df15..fed8d0a 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -338,8 +338,10 @@ QInputContext *QWidgetPrivate::inputContext() const #ifndef QT_NO_IM if (ic) return ic; -#endif return qApp->inputContext(); +#else + return 0; +#endif } /*! diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index e57ec77..c788711 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4389,6 +4389,13 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM data.window_state = data.window_state & ~Qt::WindowMaximized; const bool visible = q->isVisible(); + // Apply size restrictions, applicable for Windows & Widgets. + if (QWExtra *extra = extraData()) { + w = qMin(w, extra->maxw); + h = qMin(h, extra->maxh); + w = qMax(w, extra->minw); + h = qMax(h, extra->minh); + } data.crect = QRect(x, y, w, h); if (realWindow) { diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 0f05c6b..23f57da 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -70,6 +70,7 @@ #include "qguifunctions_wince.h" QT_USE_NAMESPACE extern void qt_wince_maximize(QWidget *widget); //defined in qguifunctions_wince.cpp +extern void qt_wince_unmaximize(QWidget *widget); //defined in qguifunctions_wince.cpp extern void qt_wince_minimize(HWND hwnd); //defined in qguifunctions_wince.cpp extern void qt_wince_full_screen(HWND hwnd, bool fullScreen, UINT swpf); //defined in qguifunctions_wince.cpp extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp diff --git a/src/gui/kernel/qwidget_wince.cpp b/src/gui/kernel/qwidget_wince.cpp index fc1e52c..76532ed 100644 --- a/src/gui/kernel/qwidget_wince.cpp +++ b/src/gui/kernel/qwidget_wince.cpp @@ -498,6 +498,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) int style = GetWindowLong(internalWinId(), GWL_STYLE) | WS_BORDER | WS_POPUP | WS_CAPTION; SetWindowLong(internalWinId(), GWL_STYLE, style); SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG); + qt_wince_unmaximize(this); } if (isVisible() && newstate & Qt::WindowMaximized) qt_wince_maximize(this); diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index daa40a1..769ab2f 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1283,7 +1283,7 @@ void QTextCursor::setVisualNavigation(bool b) /*! \since 4.7 - Sets the visual x position for vertical cursor movements. + Sets the visual x position for vertical cursor movements to \a x. The vertical movement x position is cleared automatically when the cursor moves horizontally, and kept unchanged when the cursor moves vertically. The mechanism allows the cursor to move up and down on a @@ -1335,8 +1335,8 @@ bool QTextCursor::keepPositionOnInsert() const Defines whether the cursor should keep its current position when text gets inserted at the current position of the cursor. - If \b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor. - If \b is false, the cursor moves along with the inserted text. + If \a b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor. + If \a b is false, the cursor moves along with the inserted text. The default is false. diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index d6535ea..674064e 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1935,7 +1935,7 @@ void QTextLine::layout_helper(int maxGlyphs) // We ignore the right bearing if the minimum negative bearing is too little to // expand the text beyond the edge. if (sb_or_ws|breakany) { - if (lbh.calculateNewWidth(line) + lbh.minimumRightBearing > line.width) + if (lbh.calculateNewWidth(line) - lbh.minimumRightBearing > line.width) lbh.adjustRightBearing(); if (lbh.checkFullOtherwiseExtend(line)) { if (!breakany) { diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index 8f31e46..9eeec0b 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -392,7 +392,12 @@ QList<QTextOption::Tab> QTextOption::tabs() const /*! \fn Tab::Tab(qreal pos, TabType tabType, QChar delim = QChar()) - Creates a tab with the given position, tab type, and (for DelimiterTab) delimiter + + Creates a tab with the given position, tab type, and delimiter + (\a pos, \a tabType, \a delim). + + \note \a delim is only used when \a tabType is DelimiterTab. + \since 4.7 */ diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index ada18c8..c291f25 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -754,19 +754,39 @@ void QTextTable::insertColumns(int pos, int num) QTextFormatCollection *c = p->formatCollection(); p->beginEditBlock(); + QList<int> extendedSpans; for (int i = 0; i < d->nRows; ++i) { int cell; if (i == d->nRows - 1 && pos == d->nCols) cell = d->fragment_end; else cell = d->grid[i*d->nCols + pos]; - QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); - QTextCharFormat fmt = c->charFormat(it->format); if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) { // cell spans the insertion place, extend it - fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); - p->setCharFormat(it.position(), 1, fmt); + if (!extendedSpans.contains(cell)) { + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); + fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num); + p->setCharFormat(it.position(), 1, fmt); + d->dirty = true; + extendedSpans << cell; + } } else { + /* If the next cell is spanned from the row above, we need to find the right position + to insert to */ + if (i > 0 && pos < d->nCols && cell == d->grid[(i-1) * d->nCols + pos]) { + int gridIndex = i*d->nCols + pos; + const int gridEnd = d->nRows * d->nCols - 1; + while (gridIndex < gridEnd && cell == d->grid[gridIndex]) { + ++gridIndex; + } + if (gridIndex == gridEnd) + cell = d->fragment_end; + else + cell = d->grid[gridIndex]; + } + QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell); + QTextCharFormat fmt = c->charFormat(it->format); fmt.setTableCellRowSpan(1); fmt.setTableCellColumnSpan(1); Q_ASSERT(fmt.objectIndex() == objectIndex()); diff --git a/src/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/video/qabstractvideobuffer.cpp index e9d30d0..db05ee5 100644 --- a/src/multimedia/video/qabstractvideobuffer.cpp +++ b/src/multimedia/video/qabstractvideobuffer.cpp @@ -73,6 +73,7 @@ QT_BEGIN_NAMESPACE \value GLTextureHandle The handle of the buffer is an OpenGL texture ID. \value XvShmImageHandle The handle contains pointer to shared memory XVideo image. \value CoreImageHandle The handle contains pointer to Mac OS X CIImage. + \value QPixmapHandle The handle of the buffer is a QPixmap. \value UserHandle Start value for user defined handle types. \sa handleType() diff --git a/src/multimedia/video/qabstractvideobuffer.h b/src/multimedia/video/qabstractvideobuffer.h index a8389db..98e12da 100644 --- a/src/multimedia/video/qabstractvideobuffer.h +++ b/src/multimedia/video/qabstractvideobuffer.h @@ -63,6 +63,7 @@ public: GLTextureHandle, XvShmImageHandle, CoreImageHandle, + QPixmapHandle, UserHandle = 1000 }; diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 1afabec..9e2b85e 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -286,13 +286,8 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket resend = false; //create the response header to be used with QAuthenticatorPrivate. - QHttpResponseHeader responseHeader; QList<QPair<QByteArray, QByteArray> > fields = reply->header(); - QList<QPair<QByteArray, QByteArray> >::const_iterator it = fields.constBegin(); - while (it != fields.constEnd()) { - responseHeader.addValue(QString::fromLatin1(it->first), QString::fromUtf8(it->second)); - it++; - } + //find out the type of authentication protocol requested. QAuthenticatorPrivate::Method authMethod = reply->d_func()->authenticationMethod(isProxy); if (authMethod != QAuthenticatorPrivate::None) { @@ -310,7 +305,7 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket if (auth->isNull()) auth->detach(); QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*auth); - priv->parseHttpResponse(responseHeader, isProxy); + priv->parseHttpResponse(fields, isProxy); if (priv->phase == QAuthenticatorPrivate::Done) { if ((isProxy && pendingProxyAuthSignal) ||(!isProxy && pendingAuthSignal)) { diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index a6c5c02..f617244 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -944,10 +944,10 @@ bool QNetworkAccessHttpBackend::sendCacheContents(const QNetworkCacheMetaData &m checkForRedirect(status); - emit metaDataChanged(); - - // invoke this asynchronously, else Arora/QtDemoBrowser don't like cached downloads - // see task 250221 / 251801 + // This needs to be emitted in the event loop because it can be reached at + // the direct code path of qnam.get(...) before the user has a chance + // to connect any signals. + QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection); qRegisterMetaType<QIODevice*>("QIODevice*"); QMetaObject::invokeMethod(this, "writeDownstreamData", Qt::QueuedConnection, Q_ARG(QIODevice*, contents)); diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index bccfec1..fa592c2 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -230,6 +230,14 @@ QT_BEGIN_NAMESPACE \since 4.7 + \omitvalue MaximumDownloadBufferSizeAttribute + \since 4.7 + \internal + + \omitvalue DownloadBufferAttribute + \since 4.7 + \internal + \value User Special type. Additional information can be passed in QVariants with types ranging from User to UserMax. The default diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index d2945c4..cdadf0f 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -82,6 +82,8 @@ public: CookieLoadControlAttribute, AuthenticationReuseAttribute, CookieSaveControlAttribute, + MaximumDownloadBufferSizeAttribute, // internal + DownloadBufferAttribute, // internal User = 1000, UserMax = 32767 diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index e4023c8..d61c686 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -50,6 +50,8 @@ #include <qdatastream.h> #include <qendian.h> #include <qstring.h> +#include <qdatetime.h> + QT_BEGIN_NAMESPACE @@ -83,6 +85,44 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas Note that, in particular, NTLM version 2 is not supported. + \section1 Options + + In addition to the username and password required for authentication, a + QAuthenticator object can also contain additional options. The + options() function can be used to query incoming options sent by + the server; the setOption() function can + be used to set outgoing options, to be processed by the authenticator + calculation. The options accepted and provided depend on the authentication + type (see method()). + + The following tables list known incoming options as well as accepted + outgoing options. The list of incoming options is not exhaustive, since + servers may include additional information at any time. The list of + outgoing options is exhaustive, however, and no unknown options will be + treated or sent back to the server. + + \section2 Basic + + \table + \header \o Option \o Direction \o Description + \row \o \tt{realm} \o Incoming \o Contains the realm of the authentication, the same as realm() + \endtable + + The Basic authentication mechanism supports no outgoing options. + + \section2 NTLM version 1 + + The NTLM authentication mechanism currently supports no incoming or outgoing options. + + \section2 Digest-MD5 + + \table + \header \o Option \o Direction \o Description + \row \o \tt{realm} \o Incoming \o Contains the realm of the authentication, the same as realm() + \endtable + + The Digest-MD5 authentication mechanism supports no outgoing options. + \sa QSslSocket */ @@ -138,7 +178,8 @@ bool QAuthenticator::operator==(const QAuthenticator &other) const return d->user == other.d->user && d->password == other.d->password && d->realm == other.d->realm - && d->method == other.d->method; + && d->method == other.d->method + && d->options == other.d->options; } /*! @@ -162,7 +203,18 @@ QString QAuthenticator::user() const void QAuthenticator::setUser(const QString &user) { detach(); - d->user = user; + + int separatorPosn = 0; + separatorPosn = user.indexOf(QLatin1String("\\")); + + if (separatorPosn == -1) { + //No domain name present + d->user = user; + } else { + //domain name is present + d->realm = user.left(separatorPosn); + d->user = user.mid(separatorPosn+1); + } } /*! @@ -205,9 +257,49 @@ QString QAuthenticator::realm() const return d ? d->realm : QString(); } +/*! + \since 4.7 + Returns the value related to option \a opt if it was set by the server. + See \l{QAuthenticator#Options} for more information on incoming options. + If option \a opt isn't found, an invalid QVariant will be returned. + + \sa options(), QAuthenticator#Options +*/ +QVariant QAuthenticator::option(const QString &opt) const +{ + return d ? d->options.value(opt) : QVariant(); +} /*! - returns true if the authenticator is null. + \since 4.7 + Returns all incoming options set in this QAuthenticator object by parsing + the server reply. See \l{QAuthenticator#Options} for more information + on incoming options. + + \sa option(), QAuthenticator#Options +*/ +QVariantHash QAuthenticator::options() const +{ + return d ? d->options : QVariantHash(); +} + +/*! + \since 4.7 + + Sets the outgoing option \a opt to value \a value. + See \l{QAuthenticator#Options} for more information on outgoing options. + + \sa options(), option(), QAuthenticator#Options +*/ +void QAuthenticator::setOption(const QString &opt, const QVariant &value) +{ + detach(); + d->options.insert(opt, value); +} + + +/*! + Returns true if the authenticator is null. */ bool QAuthenticator::isNull() const { @@ -228,7 +320,20 @@ QAuthenticatorPrivate::QAuthenticatorPrivate() #ifndef QT_NO_HTTP void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, bool isProxy) { - QList<QPair<QString, QString> > values = header.values(); + const QList<QPair<QString, QString> > values = header.values(); + QList<QPair<QByteArray, QByteArray> > rawValues; + + QList<QPair<QString, QString> >::const_iterator it, end; + for (it = values.constBegin(), end = values.constEnd(); it != end; ++it) + rawValues.append(qMakePair(it->first.toLatin1(), it->second.toUtf8())); + + // continue in byte array form + parseHttpResponse(rawValues, isProxy); +} +#endif + +void QAuthenticatorPrivate::parseHttpResponse(const QList<QPair<QByteArray, QByteArray> > &values, bool isProxy) +{ const char *search = isProxy ? "proxy-authenticate" : "www-authenticate"; method = None; @@ -242,38 +347,40 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, authentication parameters. */ - QString headerVal; + QByteArray headerVal; for (int i = 0; i < values.size(); ++i) { - const QPair<QString, QString> ¤t = values.at(i); - if (current.first.toLower() != QLatin1String(search)) + const QPair<QByteArray, QByteArray> ¤t = values.at(i); + if (current.first.toLower() != search) continue; - QString str = current.second; - if (method < Basic && str.startsWith(QLatin1String("Basic"), Qt::CaseInsensitive)) { - method = Basic; headerVal = str.mid(6); - } else if (method < Ntlm && str.startsWith(QLatin1String("NTLM"), Qt::CaseInsensitive)) { + QByteArray str = current.second.toLower(); + if (method < Basic && str.startsWith("basic")) { + method = Basic; + headerVal = current.second.mid(6); + } else if (method < Ntlm && str.startsWith("ntlm")) { method = Ntlm; - headerVal = str.mid(5); - } else if (method < DigestMd5 && str.startsWith(QLatin1String("Digest"), Qt::CaseInsensitive)) { + headerVal = current.second.mid(5); + } else if (method < DigestMd5 && str.startsWith("digest")) { method = DigestMd5; - headerVal = str.mid(7); + headerVal = current.second.mid(7); } } - challenge = headerVal.trimmed().toLatin1(); + challenge = headerVal.trimmed(); QHash<QByteArray, QByteArray> options = parseDigestAuthenticationChallenge(challenge); switch(method) { case Basic: - realm = QString::fromLatin1(options.value("realm")); + if(realm.isEmpty()) + this->options[QLatin1String("realm")] = realm = QString::fromLatin1(options.value("realm")); if (user.isEmpty()) phase = Done; break; case Ntlm: // #### extract from header - realm.clear(); break; case DigestMd5: { - realm = QString::fromLatin1(options.value("realm")); + if(realm.isEmpty()) + this->options[QLatin1String("realm")] = realm = QString::fromLatin1(options.value("realm")); if (options.value("stale").toLower() == "true") phase = Start; if (user.isEmpty()) @@ -286,7 +393,6 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, phase = Invalid; } } -#endif QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMethod, const QByteArray &path) { @@ -661,6 +767,20 @@ QByteArray QAuthenticatorPrivate::digestMd5Response(const QByteArray &challenge, */ #define NTLMSSP_NEGOTIATE_56 0x80000000 +/* + * AvId values + */ +#define AVTIMESTAMP 7 + +//#define NTLMV1_CLIENT + + +//************************Global variables*************************** + +const int blockSize = 64; //As per RFC2104 Block-size is 512 bits +const int nDigestLen = 16; //Trunctaion Length of the Hmac-Md5 digest +const quint8 respversion = 1; +const quint8 hirespversion = 1; /* usage: // fill up ctx with what we know. @@ -803,6 +923,7 @@ public: // extracted QString targetNameStr, targetInfoStr; + QByteArray targetInfoBuff; }; @@ -818,6 +939,7 @@ public: // extracted QByteArray lmResponseBuf, ntlmResponseBuf; QString domainStr, userStr, workstationStr, sessionKeyStr; + QByteArray v2Hash; }; @@ -899,7 +1021,7 @@ static QString qStringFromUcs2Le(const QByteArray& src) return QString((const QChar *)src.data(), src.size()/2); } - +#ifdef NTLMV1_CLIENT static QByteArray qEncodeNtlmResponse(const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block& ch) { QCryptographicHash md4(QCryptographicHash::Md4); @@ -941,7 +1063,232 @@ static QByteArray qEncodeLmResponse(const QAuthenticatorPrivate *ctx, const QNtl hash.fill(0); return rc; } +#endif + +/********************************************************************* +* Function Name: qEncodeHmacMd5 +* Params: +* key: Type - QByteArray +* - It is the Authentication key +* message: Type - QByteArray +* - This is the actual message which will be encoded +* using HMacMd5 hash algorithm +* +* Return Value: +* hmacDigest: Type - QByteArray +* +* Description: +* This function will be used to encode the input message using +* HMacMd5 hash algorithm. +* +* As per the RFC2104 the HMacMd5 algorithm can be specified +* --------------------------------------- +* MD5(K XOR opad, MD5(K XOR ipad, text)) +* --------------------------------------- +* +*********************************************************************/ +QByteArray qEncodeHmacMd5(QByteArray &key, const QByteArray &message) +{ + Q_ASSERT_X(!(message.isEmpty()),"qEncodeHmacMd5", "Empty message check"); + Q_ASSERT_X(!(key.isEmpty()),"qEncodeHmacMd5", "Empty key check"); + + QCryptographicHash hash(QCryptographicHash::Md5); + QByteArray hMsg; + + QByteArray iKeyPad(blockSize, 0x36); + QByteArray oKeyPad(blockSize, 0x5c); + + hash.reset(); + // Adjust the key length to blockSize + + if(blockSize < key.length()) { + hash.addData(key); + key = hash.result(); //MD5 will always return 16 bytes length output + } + + //Key will be <= 16 or 20 bytes as hash function (MD5 or SHA hash algorithms) + //key size can be max of Block size only + key = key.leftJustified(blockSize,0,true); + + //iKeyPad, oKeyPad and key are all of same size "blockSize" + + //xor of iKeyPad with Key and store the result into iKeyPad + for(int i = 0; i<key.size();i++) { + iKeyPad[i] = key[i]^iKeyPad[i]; + } + + //xor of oKeyPad with Key and store the result into oKeyPad + for(int i = 0; i<key.size();i++) { + oKeyPad[i] = key[i]^oKeyPad[i]; + } + + iKeyPad.append(message); // (K0 xor ipad) || text + + hash.reset(); + hash.addData(iKeyPad); + hMsg = hash.result(); + //Digest gen after pass-1: H((K0 xor ipad)||text) + + QByteArray hmacDigest; + oKeyPad.append(hMsg); + hash.reset(); + hash.addData(oKeyPad); + hmacDigest = hash.result(); + // H((K0 xor opad )|| H((K0 xor ipad) || text)) + + /*hmacDigest should not be less than half the length of the HMAC output + (to match the birthday attack bound) and not less than 80 bits + (a suitable lower bound on the number of bits that need to be + predicted by an attacker). + Refer RFC 2104 for more details on truncation part */ + + /*MD5 hash always returns 16 byte digest only and HMAC-MD5 spec + (RFC 2104) also says digest length should be 16 bytes*/ + return hmacDigest; +} + +static QByteArray qCreatev2Hash(const QAuthenticatorPrivate *ctx, + QNtlmPhase3Block *phase3) +{ + Q_ASSERT(phase3 != 0); + // since v2 Hash is need for both NTLMv2 and LMv2 it is calculated + // only once and stored and reused + if(phase3->v2Hash.size() == 0) { + QCryptographicHash md4(QCryptographicHash::Md4); + QByteArray passUnicode = qStringAsUcs2Le(ctx->password); + md4.addData(passUnicode.data(), passUnicode.size()); + + QByteArray hashKey = md4.result(); + Q_ASSERT(hashKey.size() == 16); + // Assuming the user and domain is always unicode in challenge + QByteArray message = + qStringAsUcs2Le(ctx->user.toUpper()) + + qStringAsUcs2Le(ctx->realm); + + phase3->v2Hash = qEncodeHmacMd5(hashKey, message); + } + return phase3->v2Hash; +} + +static QByteArray clientChallenge(const QAuthenticatorPrivate *ctx) +{ + Q_ASSERT(ctx->cnonce.size() >= 8); + QByteArray clientCh = ctx->cnonce.right(8); + return clientCh; +} + +// caller has to ensure a valid targetInfoBuff +static bool qExtractServerTime(const QByteArray& targetInfoBuff, + quint64 *serverTime) +{ + Q_ASSERT(serverTime != 0); + bool retValue = false; + QDataStream ds(targetInfoBuff); + ds.setByteOrder(QDataStream::LittleEndian); + + quint16 avId; + quint16 avLen; + + ds >> avId; + ds >> avLen; + while(avId != 0) { + if(avId == AVTIMESTAMP) { + QByteArray timeArray(avLen, 0); + //avLen size of QByteArray is allocated + ds.readRawData(timeArray.data(), avLen); + bool ok; + *serverTime = timeArray.toHex().toLongLong(&ok, 16); + retValue = true; + break; + } + ds.skipRawData(avLen); + ds >> avId; + ds >> avLen; + } + return retValue; +} + +static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx, + const QNtlmPhase2Block& ch, + QNtlmPhase3Block *phase3) +{ + Q_ASSERT(phase3 != 0); + // return value stored in phase3 + qCreatev2Hash(ctx, phase3); + + QByteArray temp; + QDataStream ds(&temp, QIODevice::WriteOnly); + ds.setByteOrder(QDataStream::LittleEndian); + + ds << respversion; + ds << hirespversion; + //Reserved + QByteArray reserved1(6, 0); + ds.writeRawData(reserved1.constData(), reserved1.size()); + + quint64 time = 0; + + //if server sends time, use it instead of current time + if(!(ch.targetInfo.len && qExtractServerTime(ch.targetInfoBuff, &time))) { + QDateTime currentTime(QDate::currentDate(), + QTime::currentTime(), Qt::UTC); + + // number of seconds between 1601 and epoc(1970) + // 369 years, 89 leap years + // ((369 * 365) + 89) * 24 * 3600 = 11644473600 + + time = Q_UINT64_C(currentTime.toTime_t() + 11644473600); + + // represented as 100 nano seconds + time = Q_UINT64_C(time * 10000000); + } + ds << time; + + //8 byte client challenge + QByteArray clientCh = clientChallenge(ctx); + ds.writeRawData(clientCh.constData(), clientCh.size()); + + //Reserved + QByteArray reserved2(4, 0); + ds.writeRawData(reserved2.constData(), reserved2.size()); + + if (ch.targetInfo.len > 0) { + ds.writeRawData(ch.targetInfoBuff.constData(), + ch.targetInfoBuff.size()); + } + + //Reserved + QByteArray reserved3(4, 0); + ds.writeRawData(reserved3.constData(), reserved3.size()); + + QByteArray message((const char*)ch.challenge, sizeof(ch.challenge)); + message.append(temp); + + QByteArray ntChallengeResp = qEncodeHmacMd5(phase3->v2Hash, message); + ntChallengeResp.append(temp); + + return ntChallengeResp; +} + +static QByteArray qEncodeLmv2Response(const QAuthenticatorPrivate *ctx, + const QNtlmPhase2Block& ch, + QNtlmPhase3Block *phase3) +{ + Q_ASSERT(phase3 != 0); + // return value stored in phase3 + qCreatev2Hash(ctx, phase3); + + QByteArray message((const char*)ch.challenge, sizeof(ch.challenge)); + QByteArray clientCh = clientChallenge(ctx); + + message.append(clientCh); + + QByteArray lmChallengeResp = qEncodeHmacMd5(phase3->v2Hash, message); + lmChallengeResp.append(clientCh); + + return lmChallengeResp; +} static bool qNtlmDecodePhase2(const QByteArray& data, QNtlmPhase2Block& ch) { @@ -976,7 +1323,10 @@ static bool qNtlmDecodePhase2(const QByteArray& data, QNtlmPhase2Block& ch) } if (ch.targetInfo.len > 0) { - // UNUSED right now + if (ch.targetInfo.len + ch.targetInfo.offset > (unsigned)data.size()) + return false; + + ch.targetInfoBuff = data.mid(ch.targetInfo.offset, ch.targetInfo.len); } return true; @@ -996,7 +1346,8 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas bool unicode = ch.flags & NTLMSSP_NEGOTIATE_UNICODE; - ctx->realm = ch.targetNameStr; + if(ctx->realm.isEmpty()) + ctx->realm = ch.targetNameStr; pb.flags = NTLMSSP_NEGOTIATE_NTLM; if (unicode) @@ -1010,6 +1361,7 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas offset = qEncodeNtlmString(pb.domain, offset, ctx->realm, unicode); pb.domainStr = ctx->realm; + offset = qEncodeNtlmString(pb.user, offset, ctx->user, unicode); pb.userStr = ctx->user; @@ -1017,11 +1369,23 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas pb.workstationStr = ctx->workstation; // Get LM response +#ifdef NTLMV1_CLIENT pb.lmResponseBuf = qEncodeLmResponse(ctx, ch); +#else + if (ch.targetInfo.len > 0) { + pb.lmResponseBuf = QByteArray(); + } else { + pb.lmResponseBuf = qEncodeLmv2Response(ctx, ch, &pb); + } +#endif offset = qEncodeNtlmBuffer(pb.lmResponse, offset, pb.lmResponseBuf); // Get NTLM response +#ifdef NTLMV1_CLIENT pb.ntlmResponseBuf = qEncodeNtlmResponse(ctx, ch); +#else + pb.ntlmResponseBuf = qEncodeNtlmv2Response(ctx, ch, &pb); +#endif offset = qEncodeNtlmBuffer(pb.ntlmResponse, offset, pb.ntlmResponseBuf); diff --git a/src/network/kernel/qauthenticator.h b/src/network/kernel/qauthenticator.h index 13ce593..983b7c0 100644 --- a/src/network/kernel/qauthenticator.h +++ b/src/network/kernel/qauthenticator.h @@ -43,6 +43,7 @@ #define QAUTHENTICATOR_H #include <QtCore/qstring.h> +#include <QtCore/qvariant.h> QT_BEGIN_HEADER @@ -73,6 +74,10 @@ public: QString realm() const; + QVariant option(const QString &opt) const; + QVariantHash options() const; + void setOption(const QString &opt, const QVariant &value); + bool isNull() const; void detach(); private: diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h index e9ce9ac..1096601 100644 --- a/src/network/kernel/qauthenticator_p.h +++ b/src/network/kernel/qauthenticator_p.h @@ -57,12 +57,13 @@ #include <qbytearray.h> #include <qstring.h> #include <qauthenticator.h> +#include <qvariant.h> QT_BEGIN_NAMESPACE class QHttpResponseHeader; -class QAuthenticatorPrivate +class Q_AUTOTEST_EXPORT QAuthenticatorPrivate { public: enum Method { None, Basic, Plain, Login, Ntlm, CramMd5, DigestMd5 }; @@ -71,7 +72,7 @@ public: QAtomicInt ref; QString user; QString password; - QHash<QByteArray, QByteArray> options; + QVariantHash options; Method method; QString realm; QByteArray challenge; @@ -102,6 +103,7 @@ public: #ifndef QT_NO_HTTP void parseHttpResponse(const QHttpResponseHeader &, bool isProxy); #endif + void parseHttpResponse(const QList<QPair<QByteArray, QByteArray> >&, bool isProxy); }; diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp index 1e22212..4139a7e 100644 --- a/src/network/kernel/qnetworkproxy_mac.cpp +++ b/src/network/kernel/qnetworkproxy_mac.cpp @@ -157,8 +157,10 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query) return result; // failed } - if (isHostExcluded(dict, query.peerHostName())) + if (isHostExcluded(dict, query.peerHostName())) { + CFRelease(dict); return result; // no proxy for this host + } // is there a PAC enabled? If so, use it first. CFNumberRef pacEnabled; @@ -222,6 +224,7 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query) result << https; } + CFRelease(dict); return result; } diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index 55f926d..0640c7c 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -577,7 +577,7 @@ void QTcpServer::incomingConnection(int socketDescriptor) /*! This function is called by QTcpServer::incomingConnection() - to add a socket to the list of pending incoming connections. + to add the \a socket to the list of pending incoming connections. \note Don't forget to call this member from reimplemented incomingConnection() if you do not want to break the diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index f85fa84..f73068e 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -574,7 +574,7 @@ void QSslSocket::setProtocol(QSsl::SslProtocol protocol) certificate is valid. The default mode is AutoVerifyPeer, which tells QSslSocket to use - VerifyPeer for clients, QueryPeer for clients. + VerifyPeer for clients and QueryPeer for servers. \sa setPeerVerifyMode(), peerVerifyDepth(), mode() */ @@ -594,7 +594,7 @@ QSslSocket::PeerVerifyMode QSslSocket::peerVerifyMode() const certificate is valid. The default mode is AutoVerifyPeer, which tells QSslSocket to use - VerifyPeer for clients, QueryPeer for clients. + VerifyPeer for clients and QueryPeer for servers. Setting this mode after encryption has started has no effect on the current connection. diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 770c168..c297eea 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -475,27 +475,12 @@ bool QSslSocketPrivate::ensureLibraryLoaded() void QSslSocketPrivate::ensureCiphersAndCertsLoaded() { + QMutexLocker locker(openssl_locks()->initLock()); if (s_loadedCiphersAndCerts) return; s_loadedCiphersAndCerts = true; resetDefaultCiphers(); - setDefaultCaCertificates(systemCaCertificates()); -} - -/*! - \internal - - Declared static in QSslSocketPrivate, makes sure the SSL libraries have - been initialized. -*/ - -void QSslSocketPrivate::ensureInitialized() -{ - if (!supportsSsl()) - return; - - ensureCiphersAndCertsLoaded(); //load symbols needed to receive certificates from system store #if defined(Q_OS_MAC) @@ -532,6 +517,22 @@ void QSslSocketPrivate::ensureInitialized() qWarning("could not load crypt32 library"); // should never happen } #endif + setDefaultCaCertificates(systemCaCertificates()); +} + +/*! + \internal + + Declared static in QSslSocketPrivate, makes sure the SSL libraries have + been initialized. +*/ + +void QSslSocketPrivate::ensureInitialized() +{ + if (!supportsSsl()) + return; + + ensureCiphersAndCertsLoaded(); } /*! @@ -1117,17 +1118,16 @@ bool QSslSocketBackendPrivate::startHandshake() QString peerName = (verificationPeerName.isEmpty () ? q->peerName() : verificationPeerName); QString commonName = configuration.peerCertificate.subjectInfo(QSslCertificate::CommonName); - QRegExp regexp(commonName, Qt::CaseInsensitive, QRegExp::Wildcard); - if (!regexp.exactMatch(peerName)) { + if (!isMatchingHostname(commonName.toLower(), peerName.toLower())) { bool matched = false; foreach (const QString &altName, configuration.peerCertificate .alternateSubjectNames().values(QSsl::DnsEntry)) { - regexp.setPattern(altName); - if (regexp.exactMatch(peerName)) { + if (isMatchingHostname(altName.toLower(), peerName.toLower())) { matched = true; break; } } + if (!matched) { // No matches in common names or alternate names. QSslError error(QSslError::HostNameMismatch, configuration.peerCertificate); @@ -1257,4 +1257,39 @@ QList<QSslCertificate> QSslSocketBackendPrivate::STACKOFX509_to_QSslCertificates return certificates; } +bool QSslSocketBackendPrivate::isMatchingHostname(const QString &cn, const QString &hostname) +{ + int wildcard = cn.indexOf(QLatin1Char('*')); + + // Check this is a wildcard cert, if not then just compare the strings + if (wildcard < 0) + return cn == hostname; + + int firstCnDot = cn.indexOf(QLatin1Char('.')); + int secondCnDot = cn.indexOf(QLatin1Char('.'), firstCnDot+1); + + // Check at least 3 components + if ((-1 == secondCnDot) || (secondCnDot+1 >= cn.length())) + return false; + + // Check * is last character of 1st component (ie. there's a following .) + if (wildcard+1 != firstCnDot) + return false; + + // Check only one star + if (cn.lastIndexOf(QLatin1Char('*')) != wildcard) + return false; + + // Check characters preceding * (if any) match + if (wildcard && (hostname.leftRef(wildcard) != cn.leftRef(wildcard))) + return false; + + // Check characters following first . match + if (hostname.midRef(hostname.indexOf(QLatin1Char('.'))) != cn.midRef(firstCnDot)) + return false; + + // Ok, I guess this was a wildcard CN and the hostname matches. + return true; +} + QT_END_NAMESPACE diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h index 987dfae..7a4e6b6 100644 --- a/src/network/ssl/qsslsocket_openssl_p.h +++ b/src/network/ssl/qsslsocket_openssl_p.h @@ -116,6 +116,7 @@ public: static QSslCipher QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher); static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509); + Q_AUTOTEST_EXPORT static bool isMatchingHostname(const QString &cn, const QString &hostname); }; #if defined(Q_OS_SYMBIAN) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index ee49a3d..d3f6a29 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1128,7 +1128,7 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) d->fill(path); } -extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp +extern Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index af016cf..6120a85 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1334,6 +1334,10 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co \value OpenGL_Version_3_2 OpenGL version 3.2 or higher is present. + \value OpenGL_Version_3_3 OpenGL version 3.3 or higher is present. + + \value OpenGL_Version_4_0 OpenGL version 4.0 or higher is present. + \value OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present. \value OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present. @@ -5037,8 +5041,9 @@ void QGLWidget::deleteTexture(QMacCompatGLuint id) /*! \since 4.4 - Calls the corresponding QGLContext::drawTexture() on - this widget's context. + Calls the corresponding QGLContext::drawTexture() with + \a target, \a textureId, and \a textureTarget for this + widget's context. */ void QGLWidget::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) { @@ -5058,8 +5063,9 @@ void QGLWidget::drawTexture(const QRectF &target, QMacCompatGLuint textureId, QM /*! \since 4.4 - Calls the corresponding QGLContext::drawTexture() on - this widget's context. + Calls the corresponding QGLContext::drawTexture() with + \a point, \a textureId, and \a textureTarget for this + widget's context. */ void QGLWidget::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) { diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro index f95e8af..6d8f7f2 100644 --- a/src/plugins/bearer/bearer.pro +++ b/src/plugins/bearer/bearer.pro @@ -4,7 +4,8 @@ contains(QT_CONFIG, dbus) { contains(QT_CONFIG, icd) { SUBDIRS += icd } else { - SUBDIRS += networkmanager generic + SUBDIRS += generic + !mac:SUBDIRS += connman networkmanager } } diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro new file mode 100644 index 0000000..4be752b --- /dev/null +++ b/src/plugins/bearer/connman/connman.pro @@ -0,0 +1,19 @@ +TARGET = qconnmanbearer +include(../../qpluginbase.pri) + +QT = core network dbus + +HEADERS += qconnmanservice_linux_p.h \ + qconnmanengine.h \ + ../qnetworksession_impl.h \ + ../qbearerengine_impl.h + +SOURCES += main.cpp \ + qconnmanservice_linux.cpp \ + qconnmanengine.cpp \ + ../qnetworksession_impl.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target + diff --git a/src/plugins/bearer/connman/main.cpp b/src/plugins/bearer/connman/main.cpp new file mode 100644 index 0000000..d483cf0 --- /dev/null +++ b/src/plugins/bearer/connman/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 "qconnmanengine.h" + +#include <QtNetwork/private/qbearerplugin_p.h> + +#include <QtCore/qdebug.h> + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +class QConnmanEnginePlugin : public QBearerEnginePlugin +{ +public: + QConnmanEnginePlugin(); + ~QConnmanEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QConnmanEnginePlugin::QConnmanEnginePlugin() +{ +} + +QConnmanEnginePlugin::~QConnmanEnginePlugin() +{ +} + +QStringList QConnmanEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("connman"); +} + +QBearerEngine *QConnmanEnginePlugin::create(const QString &key) const +{ + if (key == QLatin1String("connman")) { + QConnmanEngine *engine = new QConnmanEngine; + if (engine->connmanAvailable()) + return engine; + else + delete engine; + } + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QConnmanEnginePlugin) +Q_EXPORT_PLUGIN2(qconnmanbearer, QConnmanEnginePlugin) + +QT_END_NAMESPACE + +#endif +#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp new file mode 100644 index 0000000..8775623 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -0,0 +1,787 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 "qconnmanengine.h" +#include "qconnmanservice_linux_p.h" +#include "../qnetworksession_impl.h" + +#include <QtNetwork/private/qnetworkconfiguration_p.h> + +#include <QtNetwork/qnetworksession.h> + +#include <QtCore/qdebug.h> + +#include <QtDBus/QtDBus> +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusInterface> +#include <QtDBus/QDBusMessage> +#include <QtDBus/QDBusReply> + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +QConnmanEngine::QConnmanEngine(QObject *parent) +: QBearerEngineImpl(parent), + connmanManager(new QConnmanManagerInterface(this)) +{ +} + +QConnmanEngine::~QConnmanEngine() +{ +} + +bool QConnmanEngine::connmanAvailable() const +{ + QMutexLocker locker(&mutex); + return connmanManager->isValid(); +} + +void QConnmanEngine::initialize() +{ + connect(connmanManager,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(propertyChangedContext(QString,QString,QDBusVariant))); + + foreach(const QString techPath, connmanManager->getTechnologies()) { + QConnmanTechnologyInterface *tech; + tech = new QConnmanTechnologyInterface(techPath, this); + + connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + + foreach(const QString devicePath,tech->getDevices()) { + QConnmanDeviceInterface *dev; + dev = new QConnmanDeviceInterface(devicePath); + if(!deviceMap.value(techPath).contains(devicePath)) { + connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); + deviceMap.insert(techPath,QStringList() << devicePath); + foreach(const QString network,dev->getNetworks()) { + serviceNetworks.insert(getServiceForNetwork(network),network); + } + } + } + } + + // Get current list of access points. + getConfigurations(); +} + +QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations() +{ + QMutexLocker locker(&mutex); + // foundConfigurations.clear(); + getNetworkListing(); + QList<QNetworkConfigurationPrivate *> fetchedConfigurations; + QNetworkConfigurationPrivate* cpPriv = 0; + + for (int i = 0; i < foundConfigurations.count(); ++i) { + QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate; + cpPriv = foundConfigurations.at(i); + + config->name = cpPriv->name; + config->isValid = cpPriv->isValid; + config->id = cpPriv->id; + config->state = cpPriv->state; + config->type = cpPriv->type; + config->roamingSupported = cpPriv->roamingSupported; + config->purpose = cpPriv->purpose; + config->bearer = cpPriv->bearer; + + fetchedConfigurations.append(config); + } + return fetchedConfigurations; +// return foundConfigurations; +} + +void QConnmanEngine::getNetworkListing() +{ + QMutexLocker locker(&mutex); + QMapIterator<QString,QStringList> i(deviceMap); + while(i.hasNext()) { + i.next(); + QConnmanDeviceInterface dev(i.value().at(0)); + if(dev.isValid()) { + foreach(const QString network,dev.getNetworks()) { + addNetworkConfiguration(network); + } + } + } +} + + + +void QConnmanEngine::doRequestUpdate() +{ + connmanManager->requestScan(""); + getConfigurations(); + emit updateCompleted(); +} + +QString QConnmanEngine::getInterfaceFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + return configInterfaces.value(id); +} + +bool QConnmanEngine::hasIdentifier(const QString &id) +{ + QMutexLocker locker(&mutex); + return accessPointConfigurations.contains(id); +} + +QString QConnmanEngine::bearerName(const QString &id) +{ + QMutexLocker locker(&mutex); + QConnmanServiceInterface serv(serviceFromId(id)); + QString connectionType = serv.getType(); + + if (connectionType == "ethernet") + return QLatin1String("Ethernet"); + else if (connectionType == "wifi") + return QLatin1String("WLAN"); + else if (connectionType == "cellular") { + QString mode = serv.getMode(); + if(mode == "gprs" || mode == "edge") { + return QLatin1String("2G"); + } else if(mode == "umts") { + return QLatin1String("WCDMA"); + } + } + else if (connectionType == "wimax") + return QLatin1String("WIMAX"); + + return QString(); +} + +void QConnmanEngine::connectToId(const QString &id) +{ + QMutexLocker locker(&mutex); + QConnmanConnectThread *thread; + thread = new QConnmanConnectThread(this); + thread->setServicePath(serviceFromId(id)); + thread->setIdentifier(id); + connect(thread,SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)), + this,SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError))); + thread->start(); +} + +void QConnmanEngine::disconnectFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + QConnmanServiceInterface serv(serviceFromId(id)); + if(!serv.isValid()) { + emit connectionError(id, DisconnectionError); + } else { + serv.disconnect(); + } +} + +void QConnmanEngine::requestUpdate() +{ + QMutexLocker locker(&mutex); + QTimer::singleShot(0, this, SLOT(doRequestUpdate())); +} + +QString QConnmanEngine::serviceFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + foreach(const QString service, serviceNetworks.keys()) { + if (id == QString::number(qHash(service))) + return service; + } + + return QString(); +} + +QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id) +{ + QMutexLocker locker(&mutex); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + if (!ptr) + return QNetworkSession::Invalid; + + if (!ptr->isValid) { + return QNetworkSession::Invalid; + + } + QString service = serviceFromId(id); + QConnmanServiceInterface serv(service); + QString servState = serv.getState(); + + if(serv.isFavorite() && (servState == "idle" || servState == "failure")) { + return QNetworkSession::Disconnected; + } + + if(servState == "association" || servState == "configuration" || servState == "login") { + return QNetworkSession::Connecting; + } + if(servState == "ready" || servState == "online") { + return QNetworkSession::Connected; + } + + if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + return QNetworkSession::Disconnected; + } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { + return QNetworkSession::NotAvailable; + } else if ((ptr->state & QNetworkConfiguration::Undefined) == + QNetworkConfiguration::Undefined) { + return QNetworkSession::NotAvailable; + } + + return QNetworkSession::Invalid; +} + +quint64 QConnmanEngine::bytesWritten(const QString &id) +{//TODO use connman counter API + QMutexLocker locker(&mutex); + quint64 result = 0; + QString devFile = getInterfaceFromId(id); + QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes"); + if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&tx); + in >> result; + tx.close(); + } + + return result; +} + +quint64 QConnmanEngine::bytesReceived(const QString &id) +{//TODO use connman counter API + QMutexLocker locker(&mutex); + quint64 result = 0; + QString devFile = getInterfaceFromId(id); + QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes"); + if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&rx); + in >> result; + rx.close(); + } + return result; +} + +quint64 QConnmanEngine::startTime(const QString &/*id*/) +{ + // TODO + QMutexLocker locker(&mutex); + if (activeTime.isNull()) { + return 0; + } + return activeTime.secsTo(QDateTime::currentDateTime()); +} + +QNetworkConfigurationManager::Capabilities QConnmanEngine::capabilities() const +{ + return QNetworkConfigurationManager::ForcedRoaming | + QNetworkConfigurationManager::DataStatistics | + QNetworkConfigurationManager::CanStartAndStopInterfaces; +} + +QNetworkSessionPrivate *QConnmanEngine::createSessionBackend() +{ + return new QNetworkSessionPrivateImpl; +} + +QNetworkConfigurationPrivatePointer QConnmanEngine::defaultConfiguration() +{ + return QNetworkConfigurationPrivatePointer(); +} + + +QString QConnmanEngine::getServiceForNetwork(const QString &netPath) +{ + QMutexLocker locker(&mutex); + QConnmanNetworkInterface network(netPath, this); + foreach(QString service,connmanManager->getServices()) { + QConnmanServiceInterface serv(service,this); + if(serv.getName() == network.getName() + && network.getSignalStrength() == serv.getSignalStrength()) { + return service; + } + } + return QString(); +} + + +void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) +{ + Q_UNUSED(path); +// qDebug() << __FUNCTION__ << path << item << value.variant(); + + QMutexLocker locker(&mutex); + if(item == "Services") { + QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant()); + QStringList list = qdbus_cast<QStringList>(arg); + + if(list.count() > accessPointConfigurations.count()) { + foreach(const QString service, list) { + addServiceConfiguration(service); + } + } + } + + if(item == "Technologies") { + QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant()); + QStringList newlist = qdbus_cast<QStringList>(arg); + if(newlist.count() > 0) { + QMap<QString,QConnmanTechnologyInterface *> oldtech = technologies; + + foreach(const QString listPath, newlist) { + if(!oldtech.contains(listPath)) { + QConnmanTechnologyInterface *tech; + tech = new QConnmanTechnologyInterface(listPath,this); + connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + technologies.insert(listPath, tech); + } + } + + foreach(const QString old, oldtech.keys()) { + if(!newlist.contains(old)) { + QConnmanTechnologyInterface *tech = oldtech.value(old); + disconnect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + + technologies.remove(old); + getNetworkListing(); + } + } + } + } + if(item == "State") { +// qDebug() << value.variant(); + } +} + +void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) +{ + QMutexLocker locker(&mutex); + if(item == "State") { + configurationChange(QString::number(qHash(path))); + + if(value.variant().toString() == "failure") { + QConnmanServiceInterface serv(path); + emit connectionError(QString::number(qHash(path)), ConnectError); + } + } +} + +void QConnmanEngine::networkPropertyChangedContext(const QString &/*path*/,const QString &/*item*/, const QDBusVariant &/*value*/) +{ + QMutexLocker locker(&mutex); +} + +void QConnmanEngine::devicePropertyChangedContext(const QString &devpath,const QString &item,const QDBusVariant &value) +{ + QMutexLocker locker(&mutex); + if(item == "Networks") { + QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant()); + QStringList remainingNetworks = qdbus_cast<QStringList>(arg); + QString devicetype; + QMapIterator<QString,QStringList> i(deviceMap); + while(i.hasNext()) { + i.next(); + if(i.value().contains(devpath)) { + devicetype = i.key().section("/",-1); + } + } + + QStringList oldnetworks = knownNetworks[devicetype]; + + if(remainingNetworks.count() > oldnetworks.count()) { + foreach(const QString netPath, remainingNetworks) { + if(!oldnetworks.contains(netPath)) { + addNetworkConfiguration(netPath); + } + } + } else { + foreach(const QString netPath, oldnetworks) { + QString servicePath = serviceNetworks.key(netPath); + if(!remainingNetworks.contains(netPath)) { + if(servicePath.isEmpty()) { + removeConfiguration(QString::number(qHash(netPath))); + } else { + removeConfiguration(QString::number(qHash(servicePath))); + } + knownNetworks[devicetype].removeAll(netPath); + } + } + } + } +} + +void QConnmanEngine::technologyPropertyChangedContext(const QString & path, const QString &item, const QDBusVariant &value) +{ + if(item == "Devices") { + QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant()); + QStringList list = qdbus_cast<QStringList>(arg); + } + if(item == "State") { + + if(value.variant().toString() == "available") { + QConnmanTechnologyInterface tech(connmanManager->getPathForTechnology(path)); + foreach(const QString devPath, tech.getDevices()) { + + if(!deviceMap.value(path).contains(devPath)) { + QConnmanDeviceInterface *dev; + dev = new QConnmanDeviceInterface(devPath,this); + connect(dev,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(devicePropertyChangedContext(QString,QString,QDBusVariant))); + deviceMap.insert(path,QStringList() << devPath); + } + } + } + if(value.variant().toString() == "offline") { + deviceMap.remove(path); + } + } +} + +void QConnmanEngine::configurationChange(const QString &id) +{ + QMutexLocker locker(&mutex); + + if (accessPointConfigurations.contains(id)) { + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + QString servicePath = serviceFromId(id); + QConnmanServiceInterface *serv; + serv = new QConnmanServiceInterface(servicePath); + QString networkName = serv->getName(); + + QNetworkConfiguration::StateFlags curState = getStateForService(servicePath); + + ptr->mutex.lock(); + + if (!ptr->isValid) { + ptr->isValid = true; + } + + if (ptr->name != networkName) { + ptr->name = networkName; + } + + if (ptr->state != curState) { + ptr->state = curState; + } + + ptr->mutex.unlock(); + + locker.unlock(); + emit configurationChanged(ptr); + locker.relock(); + + } + locker.unlock(); + emit updateCompleted(); +} + +QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QString &service) +{ + QMutexLocker locker(&mutex); + QConnmanServiceInterface serv(service); + QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; + if(serv.isFavorite()) { + flag = ( flag | QNetworkConfiguration::Discovered); + } else { + flag = QNetworkConfiguration::Undefined; + } + + if(serv.getState() == "ready" || serv.getState() == "online") { + flag = ( flag | QNetworkConfiguration::Active); + } + + return flag; +} + +QString QConnmanEngine::typeToBearer(const QString &type) +{ + QMutexLocker locker(&mutex); + if(type == "wifi") + return "WLAN"; + if(type == "ethernet") + return "Ethernet"; + if(type == "bluetooth") + return "Bluetooth"; + if(type == "cellular") { + return "Cellular"; + // not handled: CDMA2000 HSPA + } + if(type == "wimax") + return "WiMax"; +// if(type == "gps") +// if(type == "vpn") + + return "Unknown"; +} + +void QConnmanEngine::removeConfiguration(const QString &id) +{ + QMutexLocker locker(&mutex); + + if (accessPointConfigurations.contains(id)) { + + QString service = serviceFromId(id); + QConnmanServiceInterface serv(service); + + disconnect(&serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + + QString netPath = serviceNetworks.value(service); + serviceNetworks.remove(service); + + QConnmanServiceInterface network(netPath); + disconnect(&network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(networkPropertyChangedContext(QString,QString, QDBusVariant))); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id); + locker.unlock(); + emit configurationRemoved(ptr); + locker.relock(); + } +} + +void QConnmanEngine::addServiceConfiguration(const QString &servicePath) +{ + + QMutexLocker locker(&mutex); + QConnmanServiceInterface *serv; + serv = new QConnmanServiceInterface(servicePath); + const QString netPath = serviceNetworks.value(servicePath); + + QConnmanNetworkInterface *network; + network = new QConnmanNetworkInterface(netPath, this); + + + const QString id = QString::number(qHash(servicePath)); + + if (!accessPointConfigurations.contains(id)) { + QConnmanDeviceInterface device(netPath.section("/",0,5),this); + + serviceNetworks.insert(servicePath,netPath); + + knownNetworks[device.getType()].append(netPath); + + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); + + QString networkName = serv->getName(); + + if(serv->getType() == "Cellular") { + networkName = serv->getAPN(); + } + + cpPriv->name = networkName; + cpPriv->isValid = true; + cpPriv->id = id; + cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + cpPriv->bearer = bearerName(id); + + if(serv->getSecurity() == "none") { + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + } else { + cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; + } + + connect(network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(networkPropertyChangedContext(QString,QString, QDBusVariant))); + + cpPriv->state = getStateForService(servicePath); + + QNetworkConfigurationPrivatePointer ptr(cpPriv); + accessPointConfigurations.insert(ptr->id, ptr); + foundConfigurations.append(cpPriv); + configInterfaces[cpPriv->id] = device.getInterface(); + + + locker.unlock(); + emit configurationAdded(ptr); + locker.relock(); + emit updateCompleted(); + } +} + +void QConnmanEngine::addNetworkConfiguration(const QString &networkPath) +{ + QMutexLocker locker(&mutex); + + QConnmanNetworkInterface *network; + network = new QConnmanNetworkInterface(networkPath, this); + QString servicePath = getServiceForNetwork(networkPath); + QConnmanServiceInterface *serv; + + QString id; + QConnmanDeviceInterface device(networkPath.section("/",0,5),this); + + if(servicePath.isEmpty()) { + id = QString::number(qHash(networkPath)); + } else { + id = QString::number(qHash(servicePath)); + serv = new QConnmanServiceInterface(servicePath,this); + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + } + + if (!accessPointConfigurations.contains(id)) { + + knownNetworks[device.getType()].append(networkPath); + + serviceNetworks.insert(servicePath,networkPath); + + connect(network,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(networkPropertyChangedContext(QString,QString, QDBusVariant))); + + QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); + + QString networkName = network->getName(); + + if(networkName.isEmpty()) + networkName = "Hidden Network"; + + QString bearerName; + + if(servicePath.isEmpty()) { + QString devicePath = networkPath.section("/",0,5); + QConnmanDeviceInterface device(devicePath,this); + bearerName = typeToBearer(device.getType()); + } else { + bearerName = typeToBearer(serv->getType()); + } + + if(bearerName == "Cellular") { + QString mode = serv->getMode(); + if(mode == "gprs" || mode == "edge") { + bearerName = "2G"; + } else if(mode == "umts") { + bearerName = "WCDMA"; + } + networkName = serv->getAPN(); + } + + cpPriv->name = networkName; + cpPriv->isValid = true; + cpPriv->id = id; + cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + cpPriv->bearer = bearerName; + + if(network->getWifiSecurity() == "none") { + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + } else { + cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; + } + + if(servicePath.isEmpty()) + cpPriv->state = QNetworkConfiguration::Undefined; + else + cpPriv->state = getStateForService(servicePath); + + QNetworkConfigurationPrivatePointer ptr(cpPriv); + accessPointConfigurations.insert(ptr->id, ptr); + foundConfigurations.append(cpPriv); + configInterfaces[cpPriv->id] = device.getInterface(); + + locker.unlock(); + emit configurationAdded(ptr); + locker.relock(); + emit updateCompleted(); + } +} + +bool QConnmanEngine::requiresPolling() const +{ + return false; +} + + +QConnmanConnectThread::QConnmanConnectThread(QObject *parent) + :QThread(parent), + servicePath(), identifier() +{ +} + +QConnmanConnectThread::~QConnmanConnectThread() +{ +} + +void QConnmanConnectThread::stop() +{ + if(currentThread() != this) { + QMetaObject::invokeMethod(this, "quit", + Qt::QueuedConnection); + } else { + quit(); + } + wait(); +} + +void QConnmanConnectThread::run() +{ + QConnmanServiceInterface serv(servicePath); + if(!serv.isValid()) { + emit connectionError(identifier, QBearerEngineImpl::InterfaceLookupError); + } else { + serv.connect(); + } +} + +void QConnmanConnectThread::setServicePath(const QString &path) +{ + QMutexLocker locker(&mutex); + servicePath = path; +} + +void QConnmanConnectThread::setIdentifier(const QString &id) +{ + QMutexLocker locker(&mutex); + identifier = id; +} + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h new file mode 100644 index 0000000..0f6dc1c --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 QCONNMANENGINE_P_H +#define QCONNMANENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "../qbearerengine_impl.h" + +#include "qconnmanservice_linux_p.h" + +#include <QMap> +#include <QVariant> +#include <QtCore/qthread.h> + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +class QConnmanConnectThread; +class QConnmanEngine : public QBearerEngineImpl +{ + Q_OBJECT + +public: + QConnmanEngine(QObject *parent = 0); + ~QConnmanEngine(); + + bool connmanAvailable() const; + + virtual QString getInterfaceFromId(const QString &id); + bool hasIdentifier(const QString &id); + + virtual QString bearerName(const QString &id); + + virtual void connectToId(const QString &id); + virtual void disconnectFromId(const QString &id); + + Q_INVOKABLE void initialize(); + Q_INVOKABLE void requestUpdate(); + + QNetworkSession::State sessionStateForId(const QString &id); + QNetworkSessionPrivate *createSessionBackend(); + + virtual quint64 bytesWritten(const QString &id); + virtual quint64 bytesReceived(const QString &id); + virtual quint64 startTime(const QString &id); + + + virtual QNetworkConfigurationManager::Capabilities capabilities() const; + virtual QNetworkConfigurationPrivatePointer defaultConfiguration(); + + void configurationChange(const QString &id); + QList<QNetworkConfigurationPrivate *> getConfigurations(); + + +private Q_SLOTS: + + void doRequestUpdate(); + void servicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void networkPropertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void devicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void technologyPropertyChangedContext(const QString &,const QString &, const QDBusVariant &); + +private: + QConnmanManagerInterface *connmanManager; + + QList<QNetworkConfigurationPrivate *> foundConfigurations; + + void getNetworkListing(); + + QString getServiceForNetwork(const QString &network); + + QString serviceFromId(const QString &id); + QString networkFromId(const QString &id); + + QNetworkConfiguration::StateFlags getStateForService(const QString &service); + QString typeToBearer(const QString &type); + + void removeConfiguration(const QString &servicePath); + void addServiceConfiguration(const QString &servicePath); + void addNetworkConfiguration(const QString &worknetPath); + QDateTime activeTime; + + + QMap<QString,QConnmanTechnologyInterface *> technologies; // techpath, tech interface + QMap<QString,QString> configInterfaces; // id, interface name + QMap<QString,QStringList> knownNetworks; //device path, net paths list + QMap<QString,QStringList> deviceMap; //tech path, device path + QMap<QString, QString> serviceNetworks; //service, network + + +protected: + bool requiresPolling() const; + QConnmanConnectThread *connThread; +}; + +class QConnmanConnectThread : public QThread +{ + Q_OBJECT + +public: + QConnmanConnectThread(QObject *parent = 0); + ~QConnmanConnectThread(); + bool keepRunning; + void stop(); + void setServicePath(const QString &path); + void setIdentifier(const QString &id); + +Q_SIGNALS: + void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error); + +protected: + void run(); + QString servicePath; + QString identifier; + +private: + QMutex mutex; + +}; + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT + +#endif + diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp new file mode 100644 index 0000000..b20e7c1 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -0,0 +1,1072 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <QObject> +#include <QList> +#include <QtDBus/QtDBus> +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusError> +#include <QtDBus/QDBusInterface> +#include <QtDBus/QDBusMessage> +#include <QtDBus/QDBusReply> +#include <QtDBus/QDBusPendingCallWatcher> +#include <QtDBus/QDBusObjectPath> +#include <QtDBus/QDBusPendingCall> + +#include "qconnmanservice_linux_p.h" + + +QT_BEGIN_NAMESPACE +static QDBusConnection dbusConnection = QDBusConnection::systemBus(); + + +QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + CONNMAN_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanManagerInterface::~QConnmanManagerInterface() +{ +} + +void QConnmanManagerInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(stateChanged(QString))) { + if (!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("StateChanged"), + this,SIGNAL(stateChanged(const QString&)))) { + qWarning() << "StateChanged not connected"; + + } + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanManagerInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QConnmanManagerInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << "does not contain" << property; + } + return var; +} + +QVariantMap QConnmanManagerInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QString QConnmanManagerInterface::getState() +{ + QDBusReply<QString > reply = this->call("GetState"); + return reply.value(); +} + +bool QConnmanManagerInterface::setProperty(const QString &name, const QDBusVariant &value) +{ + Q_UNUSED(name); + Q_UNUSED(value); + return false; +} + +QDBusObjectPath QConnmanManagerInterface::createProfile(const QString &/*name*/) +{ + return QDBusObjectPath(); +} + +bool QConnmanManagerInterface::removeProfile(QDBusObjectPath /*path*/) +{ + return false; +} + +bool QConnmanManagerInterface::requestScan(const QString &type) +{ + QDBusReply<QString> reply = this->call(QLatin1String("RequestScan"), QVariant::fromValue(type)); + + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +bool QConnmanManagerInterface::enableTechnology(const QString &type) +{ + QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("EnableTechnology"), QVariant::fromValue(type)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +bool QConnmanManagerInterface::disableTechnology(const QString &type) +{ + QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("DisableTechnology"), QVariant::fromValue(type)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +QDBusObjectPath QConnmanManagerInterface::connectService(QVariantMap &map) +{ + QDBusReply<QDBusObjectPath > reply = this->call(QLatin1String("ConnectService"), QVariant::fromValue(map)); + if(!reply.isValid()) { + qDebug() << reply.error().message(); + + } + return reply; +} + +void QConnmanManagerInterface::registerAgent(QDBusObjectPath &/*path*/) +{ +} + +void QConnmanManagerInterface::unregisterAgent(QDBusObjectPath /*path*/) +{ +} + +void QConnmanManagerInterface::registerCounter(const QString &path, quint32 interval) +{ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("RegisterCounter"), + QVariant::fromValue(path), + QVariant::fromValue(interval)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + } +} + +void QConnmanManagerInterface::unregisterCounter(const QString &path) +{ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("UnregisterCounter"), + QVariant::fromValue(path)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + } +} + +QString QConnmanManagerInterface::requestSession(const QString &bearerName) +{ + QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("RequestSession"), + QVariant::fromValue(bearerName)); + return QString(); +} + +void QConnmanManagerInterface::releaseSession() +{ + QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("ReleaseSession")); +} + + +QDBusObjectPath QConnmanManagerInterface::lookupService(const QString &service) +{ + QDBusReply<QDBusObjectPath > reply = this->call(QLatin1String("LookupService"), QVariant::fromValue(service)); + if(!reply.isValid()) { + qDebug() << reply.error().message(); + } + return reply; +} + +// properties + +QStringList QConnmanManagerInterface::getAvailableTechnologies() +{ + QVariant var = getProperty("AvailableTechnologies"); + return qdbus_cast<QStringList>(var); +} + +QStringList QConnmanManagerInterface::getEnabledTechnologies() +{ + QVariant var = getProperty("EnabledTechnologies"); + return qdbus_cast<QStringList>(var); +} + +QStringList QConnmanManagerInterface::getConnectedTechnologies() +{ + QVariant var = getProperty("ConnectedTechnologies"); + return qdbus_cast<QStringList>(var); +} + +QString QConnmanManagerInterface::getDefaultTechnology() +{ + QVariant var = getProperty("DefaultTechnology"); + return qdbus_cast<QString>(var); +} + +bool QConnmanManagerInterface::getOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast<bool>(var); +} + +QString QConnmanManagerInterface::getActiveProfile() +{ + QVariant var = getProperty("ActiveProfile"); + return qdbus_cast<QString>(var); +} + +QStringList QConnmanManagerInterface::getProfiles() +{ + QVariant var = getProperty("Profiles"); + return qdbus_cast<QStringList>(var); +} + +QStringList QConnmanManagerInterface::getTechnologies() +{ + QVariant var = getProperty("Technologies"); + return qdbus_cast<QStringList >(var); +} + +QStringList QConnmanManagerInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast<QStringList >(var); +} + +QString QConnmanManagerInterface::getPathForTechnology(const QString &name) +{ + foreach(const QString path, getTechnologies()) { + if(path.contains(name)) { + return path; + } + } + return ""; +} + +QConnmanNetworkInterface::QConnmanNetworkInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_NETWORK_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanNetworkInterface::~QConnmanNetworkInterface() +{ +} + +void QConnmanNetworkInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_NETWORK_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))) ) { + qWarning() << "network properties not connected"; + } + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_NETWORK_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanNetworkInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + + } +} + +QVariantMap QConnmanNetworkInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanNetworkInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +//properties + +QString QConnmanNetworkInterface::getAddress() +{ + QVariant var = getProperty("Address"); + return qdbus_cast<QString>(var); +} + +QString QConnmanNetworkInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +bool QConnmanNetworkInterface::isConnected() +{ + QVariant var = getProperty("Connected"); + return qdbus_cast<bool>(var); +} + +quint8 QConnmanNetworkInterface::getSignalStrength() +{ + QVariant var = getProperty("Strength"); + return qdbus_cast<quint8>(var); +} + +QString QConnmanNetworkInterface::getDevice() +{ + QVariant var = getProperty("Device"); + return qdbus_cast<QString>(var); +} + +QString QConnmanNetworkInterface::getWifiSsid() +{ + QVariant var = getProperty("WiFi.SSID"); + return qdbus_cast<QString>(var); +} + +QString QConnmanNetworkInterface::getWifiMode() +{ + QVariant var = getProperty("WiFi.Mode"); + return qdbus_cast<QString>(var); +} + +QString QConnmanNetworkInterface::getWifiSecurity() +{ + QVariant var = getProperty("WiFi.Security"); + return qdbus_cast<QString>(var); +} + +QString QConnmanNetworkInterface::getWifiPassphrase() +{ + QVariant var = getProperty("WiFi.Passphrase"); + return qdbus_cast<QString>(var); +} + + +////////////////////////// + +QConnmanProfileInterface::QConnmanProfileInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_PROFILE_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanProfileInterface::~QConnmanProfileInterface() +{ +} + +void QConnmanProfileInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_PROFILE_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } +} + +void QConnmanProfileInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QVariant))) { + + } +} + +QVariantMap QConnmanProfileInterface::getProperties() +{ + QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanProfileInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() <<__FUNCTION__<< "Could not find" << property; + } + return var; +} + +// properties +QString QConnmanProfileInterface::getName() +{ + + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +bool QConnmanProfileInterface::isOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast<bool>(var); +} + +QStringList QConnmanProfileInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast<QStringList>(var); +} + +/////////////////////////// +QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_SERVICE_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanServiceInterface::~QConnmanServiceInterface() +{ +} + +void QConnmanServiceInterface::connectNotify(const char *signal) +{ +// qWarning() << __FUNCTION__ << signal << this->path(); + + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanServiceInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QConnmanServiceInterface::getProperties() +{ + QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanServiceInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { +// qDebug() <<__FUNCTION__<< "Could not find" << property; + } + return var; +} + +// clearProperty +void QConnmanServiceInterface::connect() +{ + QDBusReply<QVariantMap> reply = this->call(QLatin1String("Connect")); +} + +void QConnmanServiceInterface::disconnect() +{ + QDBusReply<QVariantMap> reply = this->call(QLatin1String("Disconnect")); +} + +void QConnmanServiceInterface::remove() +{ + QDBusReply<QVariantMap> reply = this->call(QLatin1String("Remove")); +} + +// void moveBefore(QDBusObjectPath &service); +// void moveAfter(QDBusObjectPath &service); + +// properties +QString QConnmanServiceInterface::getState() +{ + QVariant var = getProperty("State"); + return qdbus_cast<QString>(var); +} + +QString QConnmanServiceInterface::getError() +{ + QVariant var = getProperty("Error"); + return qdbus_cast<QString>(var); +} + +QString QConnmanServiceInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +QString QConnmanServiceInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast<QString>(var); +} + +QString QConnmanServiceInterface::getMode() +{ + QVariant var = getProperty("Mode"); + return qdbus_cast<QString>(var); +} + +QString QConnmanServiceInterface::getSecurity() +{ + QVariant var = getProperty("Security"); + return qdbus_cast<QString>(var); +} + +QString QConnmanServiceInterface::getPassphrase() +{ + QVariant var = getProperty("Passphrase"); + return qdbus_cast<QString>(var); +} + +bool QConnmanServiceInterface::isPassphraseRequired() +{ + QVariant var = getProperty("PassphraseRequired"); + return qdbus_cast<bool>(var); +} + +quint8 QConnmanServiceInterface::getSignalStrength() +{ + QVariant var = getProperty("Strength"); + return qdbus_cast<quint8>(var); +} + +bool QConnmanServiceInterface::isFavorite() +{ + QVariant var = getProperty("Favorite"); + return qdbus_cast<bool>(var); +} + +bool QConnmanServiceInterface::isImmutable() +{ + QVariant var = getProperty("Immutable"); + return qdbus_cast<bool>(var); +} + +bool QConnmanServiceInterface::isAutoConnect() +{ + QVariant var = getProperty("AutoConnect"); + return qdbus_cast<bool>(var); +} + +bool QConnmanServiceInterface::isSetupRequired() +{ + QVariant var = getProperty("SetupRequired"); + return qdbus_cast<bool>(var); +} + +QString QConnmanServiceInterface::getAPN() +{ + QVariant var = getProperty("APN"); + return qdbus_cast<QString>(var); +} + +QString QConnmanServiceInterface::getMCC() +{ + QVariant var = getProperty("MCC"); + return qdbus_cast<QString>(var); +} + +QString QConnmanServiceInterface::getMNC() +{ + QVariant var = getProperty("MNC"); + return qdbus_cast<QString>(var); +} + +bool QConnmanServiceInterface::isRoaming() +{ + QVariant var = getProperty("Roaming"); + return qdbus_cast<bool>(var); +} + +QStringList QConnmanServiceInterface::getNameservers() +{ + QVariant var = getProperty("NameServers"); + return qdbus_cast<QStringList>(var); +} + +QStringList QConnmanServiceInterface::getDomains() +{ + QVariant var = getProperty("Domains"); + return qdbus_cast<QStringList>(var); +} + +QVariantMap QConnmanServiceInterface::getIPv4() +{ + QVariant var = getProperty("IPv4"); + return qdbus_cast<QVariantMap >(var); +} + +QVariantMap QConnmanServiceInterface::getIPv4Configuration() +{ + QVariant var = getProperty("IPv4.Configuration"); + return qdbus_cast<QVariantMap >(var); +} + +QVariantMap QConnmanServiceInterface::getProxy() +{ + QVariant var = getProperty("Proxy"); + return qdbus_cast<QVariantMap >(var); +} + +QVariantMap QConnmanServiceInterface::getEthernet() +{ + QVariant var = getProperty("Ethernet"); + return qdbus_cast<QVariantMap >(var); +} + +bool QConnmanServiceInterface::isOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast<bool>(var); +} + +QStringList QConnmanServiceInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast<QStringList>(var); +} + + +////////////////////////// +QConnmanTechnologyInterface::QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_TECHNOLOGY_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanTechnologyInterface::~QConnmanTechnologyInterface() +{ +} + +void QConnmanTechnologyInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanTechnologyInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QConnmanTechnologyInterface::getProperties() +{ + QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanTechnologyInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +// properties +QString QConnmanTechnologyInterface::getState() +{ + QVariant var = getProperty("State"); + return qdbus_cast<QString>(var); +} + +QString QConnmanTechnologyInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +QString QConnmanTechnologyInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast<QString>(var); +} + + +QStringList QConnmanTechnologyInterface::getDevices() +{ + QVariant var = getProperty("Devices"); + return qdbus_cast<QStringList>(var); +} + + +////////////////////////////////// +QConnmanAgentInterface::QConnmanAgentInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_AGENT_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanAgentInterface::~QConnmanAgentInterface() +{ +} + +void QConnmanAgentInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { +// dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), +// this->path(), +// QLatin1String(CONNMAN_NETWORK_INTERFACE), +// QLatin1String("PropertyChanged"), +// this,SIGNAL(propertyChanged(const QString &, QVariant &))); + } +} + +void QConnmanAgentInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QDBusVariant))) { + + } +} + + +void QConnmanAgentInterface::release() +{ +} + +void QConnmanAgentInterface::reportError(QDBusObjectPath &/*path*/, const QString &/*error*/) +{ +} + +//dict QConnmanAgentInterface::requestInput(QDBusObjectPath &path, dict fields) +//{ +//} + +void QConnmanAgentInterface::cancel() +{ +} + + +///////////////////////////////////////// +QConnmanCounterInterface::QConnmanCounterInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_COUNTER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanCounterInterface::~QConnmanCounterInterface() +{ +} + +quint32 QConnmanCounterInterface::getReceivedByteCount() +{ +return 0; +} + +quint32 QConnmanCounterInterface::getTransmittedByteCount() +{ +return 0; +} + +///////////////////////////////////////// +QConnmanDeviceInterface::QConnmanDeviceInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_DEVICE_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanDeviceInterface::~QConnmanDeviceInterface() +{ +} + +void QConnmanDeviceInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_DEVICE_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_DEVICE_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QConnmanDeviceInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QConnmanDeviceInterface::getProperties() +{ + QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +bool QConnmanDeviceInterface::setProperty(const QString &name, const QDBusVariant &value) +{ + +// QList<QVariant> args; + qWarning() << __FUNCTION__ << name << value.variant(); +// args << qVariantFromValue(name); +// args << qVariantFromValue(value); + + QDBusMessage reply = this->call(QLatin1String("SetProperty"),name, qVariantFromValue(value)); +qWarning() << reply.errorMessage(); + + return true; +} + +void QConnmanDeviceInterface::scan() +{ + QDBusReply<QVariantMap> reply = this->call(QLatin1String("ProposeScan")); + if(!reply.isValid()) { + qDebug() << reply.error().message(); + } +} + +QVariant QConnmanDeviceInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +//properties +QString QConnmanDeviceInterface::getAddress() +{ + QVariant var = getProperty("Address"); + return qdbus_cast<QString>(var); +} + +QString QConnmanDeviceInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast<QString>(var); +} + +QString QConnmanDeviceInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast<QString>(var); +} + +QString QConnmanDeviceInterface::getInterface() +{ + QVariant var = getProperty("Interface"); + return qdbus_cast<QString>(var); +} + +bool QConnmanDeviceInterface::isPowered() +{ + QVariant var = getProperty("Powered"); + return qdbus_cast<bool>(var); +} + +quint16 QConnmanDeviceInterface::getScanInterval() +{ + QVariant var = getProperty("ScanInterval"); + return qdbus_cast<quint16>(var); +} + +bool QConnmanDeviceInterface::setScanInterval(const QString & interval) +{ +// QList<QVariant> args; +// args << qVariantFromValue(name) +// << value.variant(); + +// QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args); + + return setProperty("ScanInterval", QDBusVariant(interval)); +} + +bool QConnmanDeviceInterface::isScanning() +{ + QVariant var = getProperty("Scanning"); + return qdbus_cast<bool>(var); +} + +QStringList QConnmanDeviceInterface::getNetworks() +{ + QVariant var = getProperty("Networks"); + return qdbus_cast<QStringList>(var); +} + +bool QConnmanDeviceInterface::setEnabled(bool powered) +{ + QList<QVariant> args; + args << qVariantFromValue(QString("Powered")) + << qVariantFromValue(QDBusVariant(powered)); + + QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args); + qWarning() << reply.errorMessage() << reply.errorName(); + return true; +} + +QConnmanDBusHelper::QConnmanDBusHelper(QObject * parent) + : QObject(parent) +{ +} + +QConnmanDBusHelper::~QConnmanDBusHelper() +{ +} + +void QConnmanDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var) +{ + QDBusMessage msg = this->message(); +// qWarning() << sender(); + // qWarning() << msg.interface() << msg.path() << item << var.variant() <<"\n"; + Q_EMIT propertyChangedContext(msg.path() ,item, var); +} + +///////////////// +QT_END_NAMESPACE diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h new file mode 100644 index 0000000..35e3f3d --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -0,0 +1,381 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 QCONNMANSERVICE_H +#define QCONNMANSERVICE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtDBus/QtDBus> +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusError> +#include <QtDBus/QDBusInterface> +#include <QtDBus/QDBusMessage> +#include <QtDBus/QDBusReply> + +#include <QtDBus/QDBusPendingCallWatcher> +#include <QtDBus/QDBusObjectPath> +#include <QtDBus/QDBusContext> +#include <QMap> + +#ifndef __CONNMAN_DBUS_H + +#define CONNMAN_SERVICE "org.moblin.connman" +#define CONNMAN_PATH "/org/moblin/connman" + +#define CONNMAN_DEBUG_INTERFACE CONNMAN_SERVICE ".Debug" +#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error" +#define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent" +#define CONNMAN_COUNTER_INTERFACE CONNMAN_SERVICE ".Counter" + +#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager" +#define CONNMAN_MANAGER_PATH "/" + +#define CONNMAN_TASK_INTERFACE CONNMAN_SERVICE ".Task" +#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile" +#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service" +#define CONNMAN_DEVICE_INTERFACE CONNMAN_SERVICE ".Device" +#define CONNMAN_NETWORK_INTERFACE CONNMAN_SERVICE ".Network" +#define CONNMAN_PROVIDER_INTERFACE CONNMAN_SERVICE ".Provider" +#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology" +#endif + +QT_BEGIN_NAMESPACE + +QT_END_NAMESPACE + + +QT_BEGIN_NAMESPACE + +class QConnmanManagerInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanManagerInterface( QObject *parent = 0); + ~QConnmanManagerInterface(); + + QDBusObjectPath path() const; + + QVariantMap getProperties(); + bool setProperty(const QString &name, const QDBusVariant &value); + QDBusObjectPath createProfile(const QString &name); + bool removeProfile(QDBusObjectPath path); + bool requestScan(const QString &type); + bool enableTechnology(const QString &type); + bool disableTechnology(const QString &type); + QDBusObjectPath connectService(QVariantMap &map); + void registerAgent(QDBusObjectPath &path); + void unregisterAgent(QDBusObjectPath path); + void registerCounter(const QString &path, quint32 interval); + void unregisterCounter(const QString &path); + + QString requestSession(const QString &bearerName); + void releaseSession(); + + // properties + QString getState(); + QStringList getAvailableTechnologies(); + QStringList getEnabledTechnologies(); + QStringList getConnectedTechnologies(); + QString getDefaultTechnology(); + bool getOfflineMode(); + QString getActiveProfile(); + QStringList getProfiles(); + QStringList getTechnologies(); + QStringList getServices(); + QDBusObjectPath lookupService(const QString &); + + QString getPathForTechnology(const QString &tech); + + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void stateChanged(const QString &); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + + +class QConnmanNetworkInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanNetworkInterface(const QString &dbusPathName, QObject *parent = 0); + ~QConnmanNetworkInterface(); + + QVariantMap getProperties(); + + //properties + QString getAddress(); + QString getName(); + bool isConnected(); + quint8 getSignalStrength(); + QString getDevice(); + QString getWifiSsid(); + QString getWifiMode(); + QString getWifiSecurity(); + QString getWifiPassphrase(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanProfileInterfacePrivate; +class QConnmanProfileInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanProfileInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanProfileInterface(); + + QVariantMap getProperties(); +// properties + QString getName(); + bool isOfflineMode(); + QStringList getServices(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); +private: + QConnmanProfileInterfacePrivate *d; + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanServiceInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanServiceInterface(); + + QVariantMap getProperties(); + // clearProperty + void connect(); + void disconnect(); + void remove(); + // void moveBefore(QDBusObjectPath &service); + // void moveAfter(QDBusObjectPath &service); + +// properties + QString getState(); + QString getError(); + QString getName(); + QString getType(); + QString getMode(); + QString getSecurity(); + QString getPassphrase(); + bool isPassphraseRequired(); + quint8 getSignalStrength(); + bool isFavorite(); + bool isImmutable(); + bool isAutoConnect(); + bool isSetupRequired(); + QString getAPN(); + QString getMCC(); + QString getMNC(); + bool isRoaming(); + QStringList getNameservers(); + QStringList getDomains(); + QVariantMap getIPv4(); + QVariantMap getIPv4Configuration(); + QVariantMap getProxy(); + QVariantMap getEthernet(); + + bool isOfflineMode(); + QStringList getServices(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanTechnologyInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanTechnologyInterface(); + + QVariantMap getProperties(); +// properties + QString getState(); + QString getName(); + QString getType(); + + QStringList getDevices(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +}; + +class QConnmanAgentInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanAgentInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanAgentInterface(); + + void release(); + void reportError(QDBusObjectPath &path, const QString &error); +// dict requestInput(QDBusObjectPath &path, dict fields); + void cancel(); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); +}; + +class QConnmanCounterInterfacePrivate; +class QConnmanCounterInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanCounterInterface(const QString &dbusPathName, QObject *parent = 0); + ~QConnmanCounterInterface(); + +// void release(); + QString getInterface(); + quint32 getReceivedByteCount(); + quint32 getTransmittedByteCount(); + +private: + QConnmanCounterInterfacePrivate *d; +}; + +class QConnmanDeviceInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanDeviceInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanDeviceInterface(); + + QVariantMap getProperties(); + void scan(); + +//properties + QString getAddress(); + QString getName(); + QString getType(); + QString getInterface(); + bool isPowered(); + quint16 getScanInterval(); + bool setScanInterval(const QString &interval); + + bool isScanning(); + QStringList getNetworks(); + bool setEnabled(bool powered); + bool setProperty(const QString &name, const QDBusVariant &value); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +}; + +class QConnmanDBusHelper: public QObject, protected QDBusContext + { + Q_OBJECT + public: + QConnmanDBusHelper(QObject *parent = 0); + ~QConnmanDBusHelper(); + + public slots: + void propertyChanged(const QString &, const QDBusVariant &); + +Q_SIGNALS: + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +}; + +QT_END_NAMESPACE + +#endif //QCONNMANSERVICE_H diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp index e375b4f..aeac620 100644 --- a/src/plugins/bearer/icd/qnetworksession_impl.cpp +++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp @@ -620,6 +620,9 @@ static QString get_network_interface() return iface; } + if (addr_results.first().ip_info.isEmpty()) + return QString(); + const char *address = addr_results.first().ip_info.first().address.toAscii().constData(); struct in_addr addr; if (inet_aton(address, &addr) == 0) { diff --git a/src/plugins/sqldrivers/db2/db2.pro b/src/plugins/sqldrivers/db2/db2.pro index 5223beb..e053f37 100644 --- a/src/plugins/sqldrivers/db2/db2.pro +++ b/src/plugins/sqldrivers/db2/db2.pro @@ -1,10 +1,6 @@ -TARGET = qsqldb2 +TARGET = qsqldb2 -HEADERS = ../../../sql/drivers/db2/qsql_db2.h -SOURCES = main.cpp \ - ../../../sql/drivers/db2/qsql_db2.cpp - -unix:!contains( LIBS, .*db2.* ):LIBS *= -ldb2 -win32:!contains( LIBS, .*db2.* ):LIBS *= -ldb2cli +SOURCES = main.cpp +include(../../../sql/drivers/db2/qsql_db2.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/ibase/ibase.pro b/src/plugins/sqldrivers/ibase/ibase.pro index ec2bc7b..7870ec8 100644 --- a/src/plugins/sqldrivers/ibase/ibase.pro +++ b/src/plugins/sqldrivers/ibase/ibase.pro @@ -1,14 +1,6 @@ -TARGET = qsqlibase +TARGET = qsqlibase -HEADERS = ../../../sql/drivers/ibase/qsql_ibase.h -SOURCES = main.cpp \ - ../../../sql/drivers/ibase/qsql_ibase.cpp - -unix:!contains( LIBS, .*gds.* ):!contains( LIBS, .*libfb.* ):LIBS *= -lgds - -win32:!contains( LIBS, .*gds.* ):!contains( LIBS, .*fbclient.* ) { - !win32-borland:LIBS *= -lgds32_ms - win32-borland:LIBS += gds32.lib -} +SOURCES = main.cpp +include(../../../sql/drivers/ibase/qsql_ibase.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/mysql/mysql.pro b/src/plugins/sqldrivers/mysql/mysql.pro index 9f5c619..b6d42ff 100644 --- a/src/plugins/sqldrivers/mysql/mysql.pro +++ b/src/plugins/sqldrivers/mysql/mysql.pro @@ -1,23 +1,6 @@ -TARGET = qsqlmysql +TARGET = qsqlmysql -HEADERS = ../../../sql/drivers/mysql/qsql_mysql.h -SOURCES = main.cpp \ - ../../../sql/drivers/mysql/qsql_mysql.cpp - -unix: { - isEmpty(QT_LFLAGS_MYSQL) { - !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) { - use_libmysqlclient_r:LIBS *= -lmysqlclient_r - else:LIBS *= -lmysqlclient - } - } else { - LIBS *= $$QT_LFLAGS_MYSQL - QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL - } -} - -win32:!contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*) { - LIBS *= -llibmysql -} +SOURCES = main.cpp +include(../../../sql/drivers/mysql/qsql_mysql.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/oci/oci.pro b/src/plugins/sqldrivers/oci/oci.pro index 3bf70a1..d7dcce9 100644 --- a/src/plugins/sqldrivers/oci/oci.pro +++ b/src/plugins/sqldrivers/oci/oci.pro @@ -1,13 +1,6 @@ -TARGET = qsqloci +TARGET = qsqloci -HEADERS = ../../../sql/drivers/oci/qsql_oci.h -SOURCES = main.cpp \ - ../../../sql/drivers/oci/qsql_oci.cpp - -win32:LIBS *= -loci - -unix:!contains( LIBS, .*clnts.* ):LIBS *= -lclntsh - -macx:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ +SOURCES = main.cpp +include(../../../sql/drivers/oci/qsql_oci.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro index 2bf85f1..677eb6e 100644 --- a/src/plugins/sqldrivers/odbc/odbc.pro +++ b/src/plugins/sqldrivers/odbc/odbc.pro @@ -1,19 +1,6 @@ -TARGET = qsqlodbc +TARGET = qsqlodbc -HEADERS = ../../../sql/drivers/odbc/qsql_odbc.h -SOURCES = main.cpp \ - ../../../sql/drivers/odbc/qsql_odbc.cpp - -unix { - !contains( LIBS, .*odbc.* ) { - LIBS *= $$QT_LFLAGS_ODBC - } - DEFINES += UNICODE -} - -win32 { - !win32-borland:LIBS *= -lodbc32 - win32-borland:LIBS *= $(BCB)/lib/PSDK/odbc32.lib -} +SOURCES = main.cpp +include(../../../sql/drivers/odbc/qsql_odbc.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/psql/psql.pro b/src/plugins/sqldrivers/psql/psql.pro index 80a5348..8276c0a 100644 --- a/src/plugins/sqldrivers/psql/psql.pro +++ b/src/plugins/sqldrivers/psql/psql.pro @@ -1,18 +1,6 @@ -TARGET = qsqlpsql +TARGET = qsqlpsql -HEADERS = ../../../sql/drivers/psql/qsql_psql.h -SOURCES = main.cpp \ - ../../../sql/drivers/psql/qsql_psql.cpp - -unix|win32-g++*: { - !isEmpty(QT_LFLAGS_PSQL) { - !contains(QT_CONFIG, system-zlib): QT_LFLAGS_PSQL -= -lz - !static:LIBS *= $$QT_LFLAGS_PSQL - QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL - } - !contains(LIBS, .*pq.*):LIBS *= -lpq -} - -win32:!win32-g++*:!contains(LIBS, .*pq.* ) LIBS *= -llibpq -lws2_32 -ladvapi32 +SOURCES = main.cpp +include(../../../sql/drivers/psql/qsql_psql.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/sqlite/sqlite.pro b/src/plugins/sqldrivers/sqlite/sqlite.pro index fb31233..f4c1671 100644 --- a/src/plugins/sqldrivers/sqlite/sqlite.pro +++ b/src/plugins/sqldrivers/sqlite/sqlite.pro @@ -1,18 +1,7 @@ -TARGET = qsqlite +TARGET = qsqlite -HEADERS = ../../../sql/drivers/sqlite/qsql_sqlite.h -SOURCES = smain.cpp \ - ../../../sql/drivers/sqlite/qsql_sqlite.cpp - -!system-sqlite:!contains( LIBS, .*sqlite.* ) { - CONFIG(release, debug|release):DEFINES *= NDEBUG - DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE - INCLUDEPATH += ../../../3rdparty/sqlite - SOURCES += ../../../3rdparty/sqlite/sqlite3.c -} else { - LIBS *= $$QT_LFLAGS_SQLITE - QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE -} +SOURCES = smain.cpp +include(../../../sql/drivers/sqlite/qsql_sqlite.pri) wince*: DEFINES += HAVE_LOCALTIME_S=0 diff --git a/src/plugins/sqldrivers/sqlite2/sqlite2.pro b/src/plugins/sqldrivers/sqlite2/sqlite2.pro index 88db22a..e6197b9 100644 --- a/src/plugins/sqldrivers/sqlite2/sqlite2.pro +++ b/src/plugins/sqldrivers/sqlite2/sqlite2.pro @@ -1,9 +1,6 @@ -TARGET = qsqlite2 +TARGET = qsqlite2 -HEADERS = ../../../sql/drivers/sqlite2/qsql_sqlite2.h -SOURCES = smain.cpp \ - ../../../sql/drivers/sqlite2/qsql_sqlite2.cpp - -!contains(LIBS, .*sqlite.*):LIBS *= -lsqlite +SOURCES = smain.cpp +include(../../../sql/drivers/sqlite2/qsql_sqlite2.pri) include(../qsqldriverbase.pri) diff --git a/src/plugins/sqldrivers/tds/tds.pro b/src/plugins/sqldrivers/tds/tds.pro index 08a166b..b8e8ded 100644 --- a/src/plugins/sqldrivers/tds/tds.pro +++ b/src/plugins/sqldrivers/tds/tds.pro @@ -1,15 +1,6 @@ -TARGET = qsqltds +TARGET = qsqltds -HEADERS = ../../../sql/drivers/tds/qsql_tds.h - -SOURCES = main.cpp \ - ../../../sql/drivers/tds/qsql_tds.cpp - -unix:!contains( LIBS, .*sybdb.* ):LIBS *= -lsybdb - -win32 { - !win32-borland:LIBS *= -lNTWDBLIB - win32-borland:LIBS *= $(BCB)/lib/PSDK/NTWDBLIB.LIB -} +SOURCES = main.cpp +include(../../../sql/drivers/tds/qsql_tds.pri) include(../qsqldriverbase.pri) diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def index 9d4507b..9911b36 100644 --- a/src/s60installs/bwins/QtNetworku.def +++ b/src/s60installs/bwins/QtNetworku.def @@ -1144,4 +1144,7 @@ EXPORTS ?startPolling@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1143 NONAME ; void QNetworkConfigurationManagerPrivate::startPolling(void) ?capabilities@QNetworkConfigurationManagerPrivate@@QAE?AV?$QFlags@W4Capability@QNetworkConfigurationManager@@@@XZ @ 1144 NONAME ; class QFlags<enum QNetworkConfigurationManager::Capability> QNetworkConfigurationManagerPrivate::capabilities(void) ?addPendingConnection@QTcpServer@@IAEXPAVQTcpSocket@@@Z @ 1145 NONAME ; void QTcpServer::addPendingConnection(class QTcpSocket *) + ?option@QAuthenticator@@QBE?AVQVariant@@ABVQString@@@Z @ 1146 NONAME ; class QVariant QAuthenticator::option(class QString const &) const + ?options@QAuthenticator@@QBE?AV?$QHash@VQString@@VQVariant@@@@XZ @ 1147 NONAME ; class QHash<class QString, class QVariant> QAuthenticator::options(void) const + ?setOption@QAuthenticator@@QAEXABVQString@@ABVQVariant@@@Z @ 1148 NONAME ; void QAuthenticator::setOption(class QString const &, class QVariant const &) diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def index 3cc3644..eb30832 100644 --- a/src/s60installs/eabi/QtNetworku.def +++ b/src/s60installs/eabi/QtNetworku.def @@ -1164,4 +1164,7 @@ EXPORTS _ZTV35QNetworkConfigurationManagerPrivate @ 1163 NONAME _ZThn8_N19QBearerEnginePluginD0Ev @ 1164 NONAME _ZThn8_N19QBearerEnginePluginD1Ev @ 1165 NONAME + _ZN14QAuthenticator9setOptionERK7QStringRK8QVariant @ 1166 NONAME + _ZNK14QAuthenticator6optionERK7QString @ 1167 NONAME + _ZNK14QAuthenticator7optionsEv @ 1168 NONAME diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 451d1b0..f6390bb 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1268,6 +1268,7 @@ QDateTime QScriptValue::toDateTime() const Q_D(const QScriptValue); if (!d || !d->engine) return QDateTime(); + QScript::APIShim shim(d->engine); return QScriptEnginePrivate::toDateTime(d->engine->currentFrame, d->jscValue); } @@ -1284,6 +1285,7 @@ QRegExp QScriptValue::toRegExp() const Q_D(const QScriptValue); if (!d || !d->engine) return QRegExp(); + QScript::APIShim shim(d->engine); return QScriptEnginePrivate::toRegExp(d->engine->currentFrame, d->jscValue); } #endif // QT_NO_REGEXP @@ -1303,6 +1305,7 @@ QObject *QScriptValue::toQObject() const Q_D(const QScriptValue); if (!d || !d->engine) return 0; + QScript::APIShim shim(d->engine); return QScriptEnginePrivate::toQObject(d->engine->currentFrame, d->jscValue); } @@ -1317,6 +1320,7 @@ const QMetaObject *QScriptValue::toQMetaObject() const Q_D(const QScriptValue); if (!d || !d->engine) return 0; + QScript::APIShim shim(d->engine); return QScriptEnginePrivate::toQMetaObject(d->engine->currentFrame, d->jscValue); } @@ -1407,6 +1411,7 @@ QScriptValue QScriptValue::property(quint32 arrayIndex, Q_D(const QScriptValue); if (!d || !d->isObject()) return QScriptValue(); + QScript::APIShim shim(d->engine); return d->engine->scriptValueFromJSCValue(d->property(arrayIndex, mode)); } @@ -1434,6 +1439,7 @@ void QScriptValue::setProperty(quint32 arrayIndex, const QScriptValue &value, "cannot set value created in a different engine"); return; } + QScript::APIShim shim(d->engine); JSC::JSValue jsValue = d->engine->scriptValueToJSCValue(value); d->setProperty(arrayIndex, jsValue, flags); } diff --git a/src/sql/drivers/db2/qsql_db2.pri b/src/sql/drivers/db2/qsql_db2.pri new file mode 100644 index 0000000..16557f0 --- /dev/null +++ b/src/sql/drivers/db2/qsql_db2.pri @@ -0,0 +1,8 @@ +HEADERS += $$PWD/qsql_db2.h +SOURCES += $$PWD/qsql_db2.cpp + +unix { + !contains(LIBS, .*db2.*):LIBS += -ldb2 +} else:!win32-borland { + !contains(LIBS, .*db2.*):LIBS += -ldb2cli +} diff --git a/src/sql/drivers/drivers.pri b/src/sql/drivers/drivers.pri index 05e7265..87cc0b1 100644 --- a/src/sql/drivers/drivers.pri +++ b/src/sql/drivers/drivers.pri @@ -1,119 +1,11 @@ -contains(sql-drivers, all ) { - sql-driver += psql mysql odbc oci tds db2 sqlite ibase -} - -contains(sql-drivers, psql) { - HEADERS += drivers/psql/qsql_psql.h - SOURCES += drivers/psql/qsql_psql.cpp - - unix|win32-g++* { - !static:!isEmpty(QT_LFLAGS_PSQL) { - !contains(QT_CONFIG, system-zlib): QT_LFLAGS_PSQL -= -lz - !static:LIBS *= $$QT_LFLAGS_PSQL - QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL - } - !contains(LIBS, .*pq.*):LIBS *= -lpq - } else:win32:!contains(LIBS, .*pq.* ) LIBS *= -llibpq -lws2_32 -ladvapi32 -} - -contains(sql-drivers, mysql) { - HEADERS += drivers/mysql/qsql_mysql.h - SOURCES += drivers/mysql/qsql_mysql.cpp - - unix { - isEmpty(QT_LFLAGS_MYSQL) { - !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) { - use_libmysqlclient_r:LIBS *= -lmysqlclient_r - else:LIBS *= -lmysqlclient - } - } else { - LIBS *= $$QT_LFLAGS_MYSQL - QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL - } - } - - win32:!contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*) { - !win32-g++*:LIBS *= -llibmysql - else:LIBS *= -lmysql - } -} - -contains(sql-drivers, odbc) { - HEADERS += drivers/odbc/qsql_odbc.h - SOURCES += drivers/odbc/qsql_odbc.cpp - - mac:!contains( LIBS, .*odbc.* ):LIBS *= -liodbc - unix:!contains( LIBS, .*odbc.* ):LIBS *= -lodbc - unix:DEFINES += UNICODE - - win32 { - !win32-borland:LIBS *= -lodbc32 - else:LIBS *= $(BCB)/lib/PSDK/odbc32.lib - } -} - -contains(sql-drivers, oci) { - HEADERS += drivers/oci/qsql_oci.h - SOURCES += drivers/oci/qsql_oci.cpp - - unix:!contains( LIBS, .*clnts.* ):LIBS += -lclntsh - - win32:LIBS += -loci -} - -contains(sql-drivers, tds) { - HEADERS += drivers/tds/qsql_tds.h - SOURCES += drivers/tds/qsql_tds.cpp - - unix:LIBS += -L$SYBASE/lib -lsybdb - - win32 { - !win32-borland:LIBS += -lNTWDBLIB - else:LIBS += $(BCB)/lib/PSDK/NTWDBLIB.LIB - } -} - -contains(sql-drivers, db2) { - HEADERS += drivers/db2/qsql_db2.h - SOURCES += drivers/db2/qsql_db2.cpp - - unix:LIBS += -ldb2 - - win32 { - !win32-borland:LIBS += -ldb2cli -# else:LIBS += $(BCB)/lib/PSDK/db2cli.lib - } -} - -contains(sql-drivers, ibase) { - HEADERS += drivers/ibase/qsql_ibase.h - SOURCES += drivers/ibase/qsql_ibase.cpp - - unix:LIBS *= -lgds - - win32 { - !win32-borland:LIBS *= -lgds32_ms - else:LIBS += gds32.lib - } -} - -contains(sql-drivers, sqlite2) { - HEADERS += drivers/sqlite2/qsql_sqlite2.h - SOURCES += drivers/sqlite2/qsql_sqlite2.cpp - !contains(LIBS, .*sqlite.*):LIBS *= -lsqlite -} - -contains(sql-drivers, sqlite) { - !system-sqlite:!contains( LIBS, .*sqlite3.* ) { - CONFIG(release, debug|release):DEFINES *= NDEBUG - DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE - INCLUDEPATH += ../3rdparty/sqlite - SOURCES += ../3rdparty/sqlite/sqlite3.c - } else { - LIBS *= $$QT_LFLAGS_SQLITE - QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE - } - - HEADERS += drivers/sqlite/qsql_sqlite.h - SOURCES += drivers/sqlite/qsql_sqlite.cpp -} +contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase + +contains(sql-drivers, psql):include($$PWD/psql/qsql_psql.pri) +contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri) +contains(sql-drivers, odbc):include($$PWD/odbc/qsql_odbc.pri) +contains(sql-drivers, oci):include($$PWD/oci/qsql_oci.pri) +contains(sql-drivers, tds):include($$PWD/tds/qsql_tds.pri) +contains(sql-drivers, db2):include($$PWD/db2/qsql_db2.pri) +contains(sql-drivers, ibase):include($$PWD/ibase/qsql_ibase.pri) +contains(sql-drivers, sqlite2):include($$PWD/sqlite2/qsql_sqlite2.pri) +contains(sql-drivers, sqlite):include($$PWD/sqlite/qsql_sqlite.pri) diff --git a/src/sql/drivers/ibase/qsql_ibase.pri b/src/sql/drivers/ibase/qsql_ibase.pri new file mode 100644 index 0000000..33fbb0d --- /dev/null +++ b/src/sql/drivers/ibase/qsql_ibase.pri @@ -0,0 +1,11 @@ +HEADERS += $$PWD/qsql_ibase.h +SOURCES += $$PWD/qsql_ibase.cpp + +unix { + !contains(LIBS, .*gds.*):!contains(LIBS, .*libfb.*):LIBS += -lgds +} else { + !contains(LIBS, .*gds.*):!contains(LIBS, .*fbclient.*) { + win32-borland:LIBS += gds32.lib + else:LIBS += -lgds32_ms + } +} diff --git a/src/sql/drivers/mysql/qsql_mysql.pri b/src/sql/drivers/mysql/qsql_mysql.pri new file mode 100644 index 0000000..1b9c3dd --- /dev/null +++ b/src/sql/drivers/mysql/qsql_mysql.pri @@ -0,0 +1,16 @@ +HEADERS += $$PWD/qsql_mysql.h +SOURCES += $$PWD/qsql_mysql.cpp + +unix { + isEmpty(QT_LFLAGS_MYSQL) { + !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) { + use_libmysqlclient_r:LIBS += -lmysqlclient_r + else:LIBS += -lmysqlclient + } + } else { + LIBS *= $$QT_LFLAGS_MYSQL + QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL + } +} else { + !contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*):LIBS += -llibmysql +} diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index 2f0cfdc..c56b995 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -648,7 +648,7 @@ QByteArray qMakeOraDate(const QDateTime& dt) QDateTime qMakeDate(const char* oraDate) { - int century = oraDate[0]; + int century = uchar(oraDate[0]); if(century >= 100){ int year = uchar(oraDate[1]); year = ((century-100)*100) + (year-100); diff --git a/src/sql/drivers/oci/qsql_oci.pri b/src/sql/drivers/oci/qsql_oci.pri new file mode 100644 index 0000000..60ccc4c --- /dev/null +++ b/src/sql/drivers/oci/qsql_oci.pri @@ -0,0 +1,9 @@ +HEADERS += $$PWD/qsql_oci.h +SOURCES += $$PWD/qsql_oci.cpp + +unix { + !contains(LIBS, .*clnts.*):LIBS += -lclntsh +} else { + LIBS *= -loci +} +macx:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ diff --git a/src/sql/drivers/odbc/qsql_odbc.pri b/src/sql/drivers/odbc/qsql_odbc.pri new file mode 100644 index 0000000..66a8d51 --- /dev/null +++ b/src/sql/drivers/odbc/qsql_odbc.pri @@ -0,0 +1,13 @@ +HEADERS += $$PWD/qsql_odbc.h +SOURCES += $$PWD/qsql_odbc.cpp + +unix { + DEFINES += UNICODE + !contains(LIBS, .*odbc.*) { + macx:LIBS += -liodbc + else:LIBS += $$QT_LFLAGS_ODBC + } +} else { + win32-borland:LIBS *= $(BCB)/lib/PSDK/odbc32.lib + else:LIBS *= -lodbc32 +} diff --git a/src/sql/drivers/psql/qsql_psql.pri b/src/sql/drivers/psql/qsql_psql.pri new file mode 100644 index 0000000..97db4be --- /dev/null +++ b/src/sql/drivers/psql/qsql_psql.pri @@ -0,0 +1,13 @@ +HEADERS += $$PWD/qsql_psql.h +SOURCES += $$PWD/qsql_psql.cpp + +unix|win32-g++* { + !static:!isEmpty(QT_LFLAGS_PSQL) { + !contains(QT_CONFIG, system-zlib): QT_LFLAGS_PSQL -= -lz + LIBS *= $$QT_LFLAGS_PSQL + QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL + } + !contains(LIBS, .*pq.*):LIBS += -lpq +} else { + !contains(LIBS, .*pq.*):LIBS += -llibpq -lws2_32 -ladvapi32 +} diff --git a/src/sql/drivers/sqlite/qsql_sqlite.pri b/src/sql/drivers/sqlite/qsql_sqlite.pri new file mode 100644 index 0000000..7ad5936 --- /dev/null +++ b/src/sql/drivers/sqlite/qsql_sqlite.pri @@ -0,0 +1,9 @@ +HEADERS += $$PWD/qsql_sqlite.h +SOURCES += $$PWD/qsql_sqlite.cpp + +!system-sqlite:!contains(LIBS, .*sqlite3.*) { + include($$PWD/../../../3rdparty/sqlite.pri) +} else { + LIBS *= $$QT_LFLAGS_SQLITE + QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE +} diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.pri b/src/sql/drivers/sqlite2/qsql_sqlite2.pri new file mode 100644 index 0000000..9a9f6cd --- /dev/null +++ b/src/sql/drivers/sqlite2/qsql_sqlite2.pri @@ -0,0 +1,4 @@ +HEADERS += $$PWD/qsql_sqlite2.h +SOURCES += $$PWD/qsql_sqlite2.cpp + +!contains(LIBS, .*sqlite.*):LIBS += -lsqlite diff --git a/src/sql/drivers/tds/qsql_tds.pri b/src/sql/drivers/tds/qsql_tds.pri new file mode 100644 index 0000000..c552ead --- /dev/null +++ b/src/sql/drivers/tds/qsql_tds.pri @@ -0,0 +1,10 @@ +HEADERS += $$PWD/qsql_tds.h +SOURCES += $$PWD/qsql_tds.cpp + +unix { + !contains(LIBS, .*sybdb.*):LIBS += -lsybdb +} else:win32-borland { + LIBS *= $(BCB)/lib/PSDK/NTWDBLIB.LIB +} else { + LIBS *= -lNTWDBLIB +} |