From 8f0e2e8a995f16fe737e538ce6f35e91b5a100b5 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 26 Jul 2010 14:04:52 +0100 Subject: Clear Qt::WA_OutsideWSRange when making window fullscreen Task-number: QTBUG-10269 Reviewed-by: Jason Barron --- src/gui/kernel/qwidget_s60.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 46f3254..d06328c 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1130,8 +1130,10 @@ void QWidget::setWindowState(Qt::WindowStates newstate) const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint; if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) { + setAttribute(Qt::WA_OutsideWSRange, false); window->SetExtentToWholeScreen(); } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) { + setAttribute(Qt::WA_OutsideWSRange, false); TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this)); window->SetExtent(maxExtent.iTl, maxExtent.Size()); } else { -- cgit v0.12 From f1257358b4432abf874460f58cba73bce17981ab Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 27 Jul 2010 16:23:52 +0100 Subject: Ensure that window rectangle is updated when CBA visibility changes In S60, there are two pieces of screen furniture, changes in whose visibility or size can affect the size of the Qt application window. These are the status pane, at the top of the screen, and the CBA at the bottom. QSymbianControl listens for changes in status pane visibility and size by implementing MEikStatusPaneObserver. Notifications received via this interface trigger a call to QSymbianControl::handleClientAreaChange() which resizes the control. There is no corresponding interface through which to receive notifications of changes in CBA visibility. This patch introduces a utility function for setting the visibility of both the status pane and CBA, which ensures that the control's rectangle is updated when either one changes. Task-number: QTBUG-5320 Reviewed-by: Jason Barron --- src/gui/kernel/qapplication_s60.cpp | 36 +++++++++++++++++++++++++----------- src/gui/kernel/qt_s60_p.h | 3 +++ src/gui/kernel/qwidget_s60.cpp | 15 +++++---------- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index d5ff792..7dbf4b7 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -102,6 +102,25 @@ QS60Data* qGlobalS60Data() return qt_s60Data(); } +#ifdef Q_WS_S60 +void QS60Data::setStatusPaneAndButtonGroupVisibility(bool statusPaneVisible, bool buttonGroupVisible) +{ + bool buttonGroupVisibilityChanged = false; + if (CEikButtonGroupContainer *const b = buttonGroupContainer()) { + buttonGroupVisibilityChanged = (b->IsVisible() != buttonGroupVisible); + b->MakeVisible(buttonGroupVisible); + } + bool statusPaneVisibilityChanged = false; + if (CEikStatusPane *const s = statusPane()) { + statusPaneVisibilityChanged = (s->IsVisible() != statusPaneVisible); + s->MakeVisible(statusPaneVisible); + } + if (buttonGroupVisibilityChanged && !statusPaneVisibilityChanged) + // Ensure that control rectangle is updated + static_cast(QApplication::activeWindow()->winId())->handleClientAreaChange(); +} +#endif + bool qt_nograb() // application no-grab option { #if defined(QT_DEBUG) @@ -999,17 +1018,12 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); #ifdef Q_WS_S60 // If widget is fullscreen/minimized, hide status pane and button container otherwise show them. - CEikStatusPane *statusPane = S60->statusPane(); - CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer(); - TBool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); - if (statusPane) - statusPane->MakeVisible(visible); - if (buttonGroup) { - // Visibility - const TBool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; - const TBool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; - buttonGroup->MakeVisible(visible || (isFullscreen && cbaVisibilityHint)); - } + const bool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); + const bool statusPaneVisibility = visible; + const bool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; + const bool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; + const bool buttonGroupVisibility = (visible || (isFullscreen && cbaVisibilityHint)); + S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility); #endif } else if (QApplication::activeWindow() == qwidget->window()) { if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || S60->menuBeingConstructed) { diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index bec51b8..bf71062 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -148,6 +148,7 @@ public: static inline CAknTitlePane* titlePane(); static inline CAknContextPane* contextPane(); static inline CEikButtonGroupContainer* buttonGroupContainer(); + static void setStatusPaneAndButtonGroupVisibility(bool statusPaneVisible, bool buttonGroupVisible); TTrapHandler *s60InstalledTrapHandler; #endif @@ -226,6 +227,8 @@ private: #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event); #endif + +public: void handleClientAreaChange(); private: diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index d06328c..fe0d083 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1110,15 +1110,10 @@ void QWidget::setWindowState(Qt::WindowStates newstate) // The window decoration visibility has to be changed before doing actual window state // change since in that order the availableGeometry will return directly the right size and // we will avoid unnecessarty redraws - CEikStatusPane *statusPane = S60->statusPane(); - CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer(); - TBool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); - if (statusPane) - statusPane->MakeVisible(visible); - if (buttonGroup) { - // Visibility - buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested)); - } + const bool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); + const bool statusPaneVisibility = visible; + const bool buttonGroupVisibility = (visible || (isFullscreen && cbaRequested)); + S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility); #endif // Q_WS_S60 // Ensure the initial size is valid, since we store it as normalGeometry below. @@ -1142,7 +1137,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) // accurate because it did not consider the status pane. This means that when returning // normal mode after showing the status pane, the geometry would overlap so we should // move it if it never had an explicit position. - if (!wasMoved && statusPane && visible) { + if (!wasMoved && S60->statusPane() && visible) { TPoint tl = static_cast(S60->appUi())->ClientRect().iTl; normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY)); } -- cgit v0.12 From 9a059c53caaf19cd2ff722df6e47870a2843ee43 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 30 Jul 2010 11:38:37 +0200 Subject: Fix proxy widgets with the OpenVG paint engine. Proxy widgets use the shared painter functionality and this implies that the paint engine's begin function does not get called for each new widget that gets painted. This causes a problem because the system clip gets modified by QPainter, but the paint engine does not realize that this happened and fails to use the new clip. The result is that you can end up painting outside the intended clip area. The fix is to reimplement the virtual systemStateChanged() function in QVGPaintEnginePrivate and make it call updateScissor() to re-evaluate the clipping flags and update the current clip accordingly. A similar fix was done to the OpenGL paint engine way back in 307c2954. Task-number: QTBUG-12486 Reviewed-by: Rhys Weatherley --- src/openvg/qpaintengine_vg.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 7de09ce..e368c32 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -120,6 +120,7 @@ private: class QVGPaintEnginePrivate : public QPaintEngineExPrivate { + Q_DECLARE_PUBLIC(QVGPaintEngine) public: // Extra blending modes from VG_KHR_advanced_blending extension. // Use the QT_VG prefix to avoid conflicts with any definitions @@ -150,7 +151,7 @@ public: QT_VG_BLEND_XOR_KHR = 0x2026 }; - QVGPaintEnginePrivate(); + QVGPaintEnginePrivate(QVGPaintEngine *q_ptr); ~QVGPaintEnginePrivate(); void init(); @@ -171,6 +172,7 @@ public: void setBrushTransform(const QBrush& brush, VGMatrixMode mode); void setupColorRamp(const QGradient *grad, VGPaint paint); void setImageOptions(); + void systemStateChanged(); #if !defined(QVG_SCISSOR_CLIP) void ensureMask(QVGPaintEngine *engine, int width, int height); void modifyMask @@ -299,6 +301,9 @@ public: // Clear all lazily-set modes. void clearModes(); + +private: + QVGPaintEngine *q; }; inline void QVGPaintEnginePrivate::setImageMode(VGImageMode mode) @@ -350,7 +355,7 @@ void QVGPaintEnginePrivate::clearModes() imageQuality = (VGImageQuality)0; } -QVGPaintEnginePrivate::QVGPaintEnginePrivate() +QVGPaintEnginePrivate::QVGPaintEnginePrivate(QVGPaintEngine *q_ptr) : q(q_ptr) { init(); } @@ -1452,7 +1457,7 @@ QVGPainterState::~QVGPainterState() } QVGPaintEngine::QVGPaintEngine() - : QPaintEngineEx(*new QVGPaintEnginePrivate) + : QPaintEngineEx(*new QVGPaintEnginePrivate(this)) { } @@ -2995,6 +3000,11 @@ void QVGPaintEnginePrivate::setImageOptions() } } +void QVGPaintEnginePrivate::systemStateChanged() +{ + q->updateScissor(); +} + static void drawVGImage(QVGPaintEnginePrivate *d, const QRectF& r, VGImage vgImg, const QSize& imageSize, const QRectF& sr) -- cgit v0.12 From 4cf313be8d440e2ef9bdb4a586fbcba20c3ee317 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 28 Jul 2010 14:05:52 +0100 Subject: Added support to Phonon MMF backend for playback of Qt resource files The backend accesses the resource file path via MediaSource::url(). A small patch to Phonon was required to enable this, because by default, Phonon passes a QIODevice, rather than the resource file path, to the backend. The backend uses this path to create a QResource object, through which the memory buffer into which the resource file has been read can be accessed. This buffer is wrapped in a Symbian 8-bit descriptor and passed to the OpenDesL() function of the appropriate MMF client utility API. Task-number: QTBUG-6562 --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 28 ++++++++-- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 6 ++- src/3rdparty/phonon/mmf/abstractplayer.h | 4 +- src/3rdparty/phonon/mmf/abstractvideoplayer.cpp | 6 +++ src/3rdparty/phonon/mmf/abstractvideoplayer.h | 1 + src/3rdparty/phonon/mmf/audioplayer.cpp | 6 +++ src/3rdparty/phonon/mmf/audioplayer.h | 1 + src/3rdparty/phonon/mmf/dummyplayer.cpp | 2 +- src/3rdparty/phonon/mmf/dummyplayer.h | 2 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 71 ++++++++++++++++++++++--- src/3rdparty/phonon/mmf/mediaobject.h | 11 ++-- src/3rdparty/phonon/phonon/mediasource.cpp | 5 ++ 12 files changed, 123 insertions(+), 20 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index be2a568..bca0891 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -16,6 +16,7 @@ along with this library. If not, see . */ +#include #include #include "abstractmediaplayer.h" @@ -216,9 +217,10 @@ void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) TRACE_EXIT_0(); } -void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file) +void MMF::AbstractMediaPlayer::open() { - TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi); + TRACE_CONTEXT(AbstractMediaPlayer::open, EAudioApi); + const MediaSource source = m_parent->source(); TRACE_ENTRY("state %d source.type %d", privateState(), source.type()); close(); @@ -229,7 +231,9 @@ void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file) switch (source.type()) { case MediaSource::LocalFile: { - symbianErr = openFile(file); + RFile *const file = m_parent->file(); + Q_ASSERT(file); + symbianErr = openFile(*file); if (KErrNone != symbianErr) errorMessage = tr("Error opening file"); break; @@ -237,9 +241,10 @@ void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file) case MediaSource::Url: { const QUrl url(source.url()); - if (url.scheme() == QLatin1String("file")) { - symbianErr = openFile(file); + RFile *const file = m_parent->file(); + Q_ASSERT(file); + symbianErr = openFile(*file); if (KErrNone != symbianErr) errorMessage = tr("Error opening file"); } else { @@ -251,6 +256,19 @@ void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file) break; } + case MediaSource::Stream: { + QResource *const resource = m_parent->resource(); + if (resource && resource->isValid()) { + m_buffer.Set(resource->data(), resource->size()); + symbianErr = openDescriptor(m_buffer); + if (KErrNone != symbianErr) + errorMessage = tr("Error opening resource"); + } else { + errorMessage = tr("Error opening source: resource not valid"); + } + break; + } + // Other source types are handled in MediaObject::createPlayer // Protection against adding new media types and forgetting to update this switch diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 7d28caf..e795ecb 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -47,7 +47,7 @@ protected: AbstractMediaPlayer(MediaObject *parent, const AbstractPlayer *player); public: - virtual void open(const Phonon::MediaSource&, RFile&); + virtual void open(); // MediaObjectInterface virtual void play(); @@ -70,6 +70,7 @@ protected: virtual int setDeviceVolume(int mmfVolume) = 0; virtual int openFile(RFile& file) = 0; virtual int openUrl(const QString& url) = 0; + virtual int openDescriptor(const TDesC8 &des) = 0; virtual int bufferStatus() const = 0; void updateMetaData(); @@ -123,6 +124,9 @@ private: bool m_prefinishMarkSent; bool m_aboutToFinishSent; + // Used for playback of resource files + TPtrC8 m_buffer; + QMultiMap m_metaData; }; diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 30d5243..dd98c7c 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -26,8 +26,6 @@ along with this library. If not, see . #include "abstractvideooutput.h" -class RFile; - QT_BEGIN_NAMESPACE namespace Phonon @@ -54,7 +52,7 @@ class AbstractPlayer : public QObject public: AbstractPlayer(const AbstractPlayer *player); - virtual void open(const Phonon::MediaSource&, RFile&) = 0; + virtual void open() = 0; virtual void close() = 0; // MediaObjectInterface (implemented) diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp index 9ea4d18..fb20bea 100644 --- a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp @@ -144,6 +144,12 @@ int MMF::AbstractVideoPlayer::openUrl(const QString &url) return err; } +int MMF::AbstractVideoPlayer::openDescriptor(const TDesC8 &des) +{ + TRAPD(err, m_player->OpenDesL(des)); + return err; +} + int MMF::AbstractVideoPlayer::bufferStatus() const { int result = 0; diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.h b/src/3rdparty/phonon/mmf/abstractvideoplayer.h index d854793..3ff3c75 100644 --- a/src/3rdparty/phonon/mmf/abstractvideoplayer.h +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.h @@ -66,6 +66,7 @@ public: virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile &file); virtual int openUrl(const QString &url); + virtual int openDescriptor(const TDesC8 &des); virtual int bufferStatus() const; virtual void close(); diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index f49e898..7c8b9bd 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -137,6 +137,12 @@ int MMF::AudioPlayer::openUrl(const QString& /*url*/) return 0; } +int MMF::AudioPlayer::openDescriptor(const TDesC8 &des) +{ + TRAPD(err, m_player->OpenDesL(des)); + return err; +} + int MMF::AudioPlayer::bufferStatus() const { int result = 0; diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index 0eb8bb7..e43cadd 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -67,6 +67,7 @@ typedef CMdaAudioPlayerUtility NativePlayer; virtual int setDeviceVolume(int mmfVolume); virtual int openFile(RFile& file); virtual int openUrl(const QString& url); + virtual int openDescriptor(const TDesC8 &des); virtual int bufferStatus() const; virtual void close(); diff --git a/src/3rdparty/phonon/mmf/dummyplayer.cpp b/src/3rdparty/phonon/mmf/dummyplayer.cpp index d39ef76..ba75b02 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.cpp +++ b/src/3rdparty/phonon/mmf/dummyplayer.cpp @@ -92,7 +92,7 @@ qint64 MMF::DummyPlayer::totalTime() const return 0; } -void MMF::DummyPlayer::open(const Phonon::MediaSource &, RFile &) +void MMF::DummyPlayer::open() { } diff --git a/src/3rdparty/phonon/mmf/dummyplayer.h b/src/3rdparty/phonon/mmf/dummyplayer.h index 9d45696..5b00411 100644 --- a/src/3rdparty/phonon/mmf/dummyplayer.h +++ b/src/3rdparty/phonon/mmf/dummyplayer.h @@ -57,7 +57,7 @@ public: virtual qint64 totalTime() const; // AbstractPlayer - virtual void open(const Phonon::MediaSource&, RFile&); + virtual void open(); virtual void close(); virtual void doSetTickInterval(qint32 interval); }; diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index d264377..e16bdf3 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -34,6 +34,7 @@ along with this library. If not, see . #include "mediaobject.h" #include +#include #include QT_BEGIN_NAMESPACE @@ -52,6 +53,8 @@ using namespace Phonon::MMF; MMF::MediaObject::MediaObject(QObject *parent) : MMF::MediaNode::MediaNode(parent) , m_recognizerOpened(false) , m_nextSourceSet(false) + , m_file(0) + , m_resource(0) { m_player.reset(new DummyPlayer()); @@ -68,7 +71,12 @@ MMF::MediaObject::~MediaObject() TRACE_CONTEXT(MediaObject::~MediaObject, EAudioApi); TRACE_ENTRY_0(); - m_file.Close(); + delete m_resource; + + if (m_file) + m_file->Close(); + delete m_file; + m_fileServer.Close(); m_recognizer.Close(); @@ -122,12 +130,13 @@ MMF::MediaType MMF::MediaObject::fileMediaType const QHBufC fileNameSymbian(QDir::toNativeSeparators(fileName)); - m_file.Close(); - TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly); + Q_ASSERT(!m_file); + m_file = new RFile; + TInt err = m_file->Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly); if (KErrNone == err) { TDataRecognitionResult recognizerResult; - err = m_recognizer.RecognizeData(m_file, recognizerResult); + err = m_recognizer.RecognizeData(*m_file, recognizerResult); if (KErrNone == err) { const TPtrC mimeType = recognizerResult.iDataType.Des(); result = Utils::mimeTypeToMediaType(mimeType); @@ -142,6 +151,23 @@ MMF::MediaType MMF::MediaObject::fileMediaType return result; } +MMF::MediaType MMF::MediaObject::bufferMediaType(const uchar *data, qint64 size) +{ + TRACE_CONTEXT(MediaObject::bufferMediaType, EAudioInternal); + MediaType result = MediaTypeUnknown; + if (openRecognizer()) { + TDataRecognitionResult recognizerResult; + const TPtrC8 des(data, size); + const TInt err = m_recognizer.RecognizeData(des, recognizerResult); + if (KErrNone == err) { + const TPtrC mimeType = recognizerResult.iDataType.Des(); + result = Utils::mimeTypeToMediaType(mimeType); + } else { + TRACE("RApaLsSession::RecognizeData error %d", err); + } + } + return result; +} //----------------------------------------------------------------------------- // MediaObjectInterface @@ -228,9 +254,17 @@ void MMF::MediaObject::setSource(const MediaSource &source) void MMF::MediaObject::switchToSource(const MediaSource &source) { + if (m_file) + m_file->Close(); + delete m_file; + m_file = 0; + + delete m_resource; + m_resource = 0; + createPlayer(source); m_source = source; - m_player->open(m_source, m_file); + m_player->open(); emit currentSourceChanged(m_source); } @@ -272,10 +306,25 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) case MediaSource::Invalid: case MediaSource::Disc: - case MediaSource::Stream: errorMessage = tr("Error opening source: type not supported"); break; + case MediaSource::Stream: + { + const QString fileName = source.url().toLocalFile(); + if (fileName.startsWith(QLatin1String(":/")) || fileName.startsWith(QLatin1String("qrc://"))) { + Q_ASSERT(!m_resource); + m_resource = new QResource(fileName); + if (m_resource->isValid()) + mediaType = bufferMediaType(m_resource->data(), m_resource->size()); + else + errorMessage = tr("Error opening source: resource not valid"); + } else { + errorMessage = tr("Error opening source: type not supported"); + } + } + break; + case MediaSource::Empty: TRACE_0("Empty media source"); break; @@ -374,6 +423,16 @@ void MMF::MediaObject::volumeChanged(qreal volume) m_player->volumeChanged(volume); } +RFile* MMF::MediaObject::file() const +{ + return m_file; +} + +QResource* MMF::MediaObject::resource() const +{ + return m_resource; +} + //----------------------------------------------------------------------------- // MediaNode //----------------------------------------------------------------------------- diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index f15eb21..5399e27 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -33,6 +33,8 @@ along with this library. If not, see . QT_BEGIN_NAMESPACE +class QResource; + namespace Phonon { namespace MMF @@ -87,6 +89,9 @@ public: void setVideoOutput(AbstractVideoOutput* videoOutput); + RFile* file() const; + QResource* resource() const; + public Q_SLOTS: void volumeChanged(qreal volume); void switchToNextSource(); @@ -117,6 +122,7 @@ private: // Audio / video media type recognition MediaType fileMediaType(const QString& fileName); + MediaType bufferMediaType(const uchar *data, qint64 size); // TODO: urlMediaType function static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); @@ -132,9 +138,8 @@ private: MediaSource m_nextSource; bool m_nextSourceSet; - // Storing the file handle here to work around KErrInUse error - // from MMF player utility OpenFileL functions - RFile m_file; + RFile* m_file; + QResource* m_resource; QScopedPointer m_player; diff --git a/src/3rdparty/phonon/phonon/mediasource.cpp b/src/3rdparty/phonon/phonon/mediasource.cpp index be22dc3..925ff32 100644 --- a/src/3rdparty/phonon/phonon/mediasource.cpp +++ b/src/3rdparty/phonon/phonon/mediasource.cpp @@ -58,6 +58,11 @@ MediaSource::MediaSource(const QString &filename) d->type = Stream; d->ioDevice = new QFile(filename); d->setStream(new IODeviceStream(d->ioDevice, d->ioDevice)); +#ifdef Q_OS_SYMBIAN + // On Symbian, we need to access the resource buffer directly, rather than + // via QFile indirection + d->url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); +#endif #else d->type = Invalid; #endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM -- cgit v0.12 From 2e0a41f304e7505602699c9623a96b6174165150 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 28 Jul 2010 17:12:10 +0100 Subject: Updated tst_mediaobject resource playback test cases * Removed Q_SKIP on Symbian * Divided test into two, to exercise the two possible ways of providing the resource path to Phonon::MediaSource Task-number: QTBUG-6562 --- tests/auto/mediaobject/tst_mediaobject.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 994057b..99a16db 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -124,7 +124,8 @@ class tst_MediaObject : public QObject void init(); void cleanup(); - void testPlayFromResource(); + void testPlayFromResourceDirect(); + void testPlayFromResourceFile(); void testPlayIllegalFile(); void initTestCase(); void checkForDefaults(); @@ -199,11 +200,22 @@ void tst_MediaObject::stateChanged(Phonon::State newstate, Phonon::State oldstat QWARN(QByteArray(QByteArray(QTest::toString(oldstate)) + " to " + QByteArray(QTest::toString(newstate)))); } -void tst_MediaObject::testPlayFromResource() +void tst_MediaObject::testPlayFromResourceDirect() +{ + MediaObject media; + media.setCurrentSource(Phonon::MediaSource(MEDIA_FILEPATH)); + QVERIFY(media.state() != Phonon::ErrorState); + if (media.state() != Phonon::StoppedState) + QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); + QCOMPARE(media.state(), Phonon::StoppedState); + media.play(); + if (media.state() != Phonon::PlayingState) + QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); + QCOMPARE(media.state(), Phonon::PlayingState); +} + +void tst_MediaObject::testPlayFromResourceFile() { -#ifdef Q_OS_SYMBIAN - QSKIP("Not implemented yet.", SkipAll); -#else QFile file(MEDIA_FILEPATH); MediaObject media; media.setCurrentSource(&file); @@ -215,7 +227,6 @@ void tst_MediaObject::testPlayFromResource() if (media.state() != Phonon::PlayingState) QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); QCOMPARE(media.state(), Phonon::PlayingState); -#endif } void tst_MediaObject::testPlayIllegalFile() -- cgit v0.12 From 7b70dd1d7f5f6819b1aa28647826e2137504de54 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 28 Jul 2010 14:05:52 +0100 Subject: Added support to Phonon MMF backend for playback of Qt resource files The backend accesses the resource file path via MediaSource::url(). A small patch to Phonon was required to enable this, because by default, Phonon passes a QIODevice, rather than the resource file path, to the backend. The backend uses this path to create a QResource object, through which the memory buffer into which the resource file has been read can be accessed. This buffer is wrapped in a Symbian 8-bit descriptor and passed to the OpenDesL() function of the appropriate MMF client utility API. Playback only works for certain file formats, as the Symbian MIME type recognizer does not always work. For example, playback of an audio WAV resource file works, while playback of an MP3 resource file does not. Task-number: QTBUG-6562 Reviewed-by: Justin McPherson --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 4 ++-- src/3rdparty/phonon/mmf/mediaobject.cpp | 10 +++++++--- src/3rdparty/phonon/phonon/mediasource.cpp | 4 ---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index bca0891..3702560 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -258,13 +258,13 @@ void MMF::AbstractMediaPlayer::open() case MediaSource::Stream: { QResource *const resource = m_parent->resource(); - if (resource && resource->isValid()) { + if (resource) { m_buffer.Set(resource->data(), resource->size()); symbianErr = openDescriptor(m_buffer); if (KErrNone != symbianErr) errorMessage = tr("Error opening resource"); } else { - errorMessage = tr("Error opening source: resource not valid"); + errorMessage = tr("Error opening source: resource not opened"); } break; } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index e16bdf3..b476535 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -315,10 +315,14 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) if (fileName.startsWith(QLatin1String(":/")) || fileName.startsWith(QLatin1String("qrc://"))) { Q_ASSERT(!m_resource); m_resource = new QResource(fileName); - if (m_resource->isValid()) - mediaType = bufferMediaType(m_resource->data(), m_resource->size()); - else + if (m_resource->isValid()) { + if (m_resource->isCompressed()) + errorMessage = tr("Error opening source: resource is compressed"); + else + mediaType = bufferMediaType(m_resource->data(), m_resource->size()); + } else { errorMessage = tr("Error opening source: resource not valid"); + } } else { errorMessage = tr("Error opening source: type not supported"); } diff --git a/src/3rdparty/phonon/phonon/mediasource.cpp b/src/3rdparty/phonon/phonon/mediasource.cpp index 925ff32..8bde565 100644 --- a/src/3rdparty/phonon/phonon/mediasource.cpp +++ b/src/3rdparty/phonon/phonon/mediasource.cpp @@ -58,11 +58,7 @@ MediaSource::MediaSource(const QString &filename) d->type = Stream; d->ioDevice = new QFile(filename); d->setStream(new IODeviceStream(d->ioDevice, d->ioDevice)); -#ifdef Q_OS_SYMBIAN - // On Symbian, we need to access the resource buffer directly, rather than - // via QFile indirection d->url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); -#endif #else d->type = Invalid; #endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM -- cgit v0.12 From 7f4e72f438362da7b862ea682f36ec959070e1cb Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 2 Aug 2010 10:09:49 +0100 Subject: Enabled tst_mediaobject::testPlayFromResource on Symbian Task-number: QTBUG-6562 Reviewed-by: Justin McPherson --- tests/auto/mediaobject/tst_mediaobject.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 99a16db..613a086 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -124,8 +124,7 @@ class tst_MediaObject : public QObject void init(); void cleanup(); - void testPlayFromResourceDirect(); - void testPlayFromResourceFile(); + void testPlayFromResource(); void testPlayIllegalFile(); void initTestCase(); void checkForDefaults(); @@ -200,7 +199,7 @@ void tst_MediaObject::stateChanged(Phonon::State newstate, Phonon::State oldstat QWARN(QByteArray(QByteArray(QTest::toString(oldstate)) + " to " + QByteArray(QTest::toString(newstate)))); } -void tst_MediaObject::testPlayFromResourceDirect() +void tst_MediaObject::testPlayFromResource() { MediaObject media; media.setCurrentSource(Phonon::MediaSource(MEDIA_FILEPATH)); @@ -214,21 +213,6 @@ void tst_MediaObject::testPlayFromResourceDirect() QCOMPARE(media.state(), Phonon::PlayingState); } -void tst_MediaObject::testPlayFromResourceFile() -{ - QFile file(MEDIA_FILEPATH); - MediaObject media; - media.setCurrentSource(&file); - QVERIFY(media.state() != Phonon::ErrorState); - if (media.state() != Phonon::StoppedState) - QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); - QCOMPARE(media.state(), Phonon::StoppedState); - media.play(); - if (media.state() != Phonon::PlayingState) - QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); - QCOMPARE(media.state(), Phonon::PlayingState); -} - void tst_MediaObject::testPlayIllegalFile() { QString filename = QDir::tempPath() + QString("/test.wav"); -- cgit v0.12 From 1c7c6e2326b2f89bdf564cebe89ff6f95c3f17d7 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 2 Aug 2010 12:10:14 +0100 Subject: Fixed build break on Symbian versions earlier than S^3 The following overload was added in S^3: TInt RApaLsSession::RecognizeData(const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const In order to allow the backend to compile against earlier versions of the platform, this patch calls the RecognizeData overload which taking the same arguments as above, plus a filename (for which KNullDesC is passed). Task-number: QTBUG-6562 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/mediaobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index b476535..98326b8 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -158,7 +158,7 @@ MMF::MediaType MMF::MediaObject::bufferMediaType(const uchar *data, qint64 size) if (openRecognizer()) { TDataRecognitionResult recognizerResult; const TPtrC8 des(data, size); - const TInt err = m_recognizer.RecognizeData(des, recognizerResult); + const TInt err = m_recognizer.RecognizeData(KNullDesC, des, recognizerResult); if (KErrNone == err) { const TPtrC mimeType = recognizerResult.iDataType.Des(); result = Utils::mimeTypeToMediaType(mimeType); -- cgit v0.12 From 88917087b64a014a69d12946a162ab6588e733e6 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 3 Aug 2010 10:52:26 +1000 Subject: setUniformValue(QSize) was setting (w,w) not (w,h) Task-number: QTBUG-12591 Reviewed-by: Daniel Pope --- src/opengl/qglshaderprogram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index bbfc2d5..edbb635 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -1971,7 +1971,7 @@ void QGLShaderProgram::setUniformValue(int location, const QSize& size) Q_D(QGLShaderProgram); Q_UNUSED(d); if (location != -1) { - GLfloat values[4] = {size.width(), size.width()}; + GLfloat values[4] = {size.width(), size.height()}; glUniform2fv(location, 1, values); } } -- cgit v0.12 From bf5c25c4e7571475255e1d9de307913bee228d10 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 3 Aug 2010 11:23:37 +1000 Subject: Don't resolve GLSL extensions if no shaders If the GL server is 1.x, but the client is 2.x, then the qt_resolve_glsl_extensions() function was returning true because the functions existed client-side, when it should have returned false because the functionality didn't exist server-side. Task-number: QTBUG-12478 Reviewed-by: Sarah Smith --- src/opengl/qglextensions.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp index c091191..433ccae 100644 --- a/src/opengl/qglextensions.cpp +++ b/src/opengl/qglextensions.cpp @@ -233,6 +233,10 @@ bool qt_resolve_glsl_extensions(QGLContext *ctx) if (glCreateShader) return true; + // Must at least have the FragmentShader extension to continue. + if (!(QGLExtensions::glExtensions() & QGLExtensions::FragmentShader)) + return false; + glCreateShader = (_glCreateShader) ctx->getProcAddress(QLatin1String("glCreateShader")); if (glCreateShader) { glShaderSource = (_glShaderSource) ctx->getProcAddress(QLatin1String("glShaderSource")); -- cgit v0.12 From 3246586d5a98465c38c21f191e9714e821788958 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 3 Aug 2010 10:17:33 +0100 Subject: Fixed test regression on Mac Mac Phonon backend does not support opening a resource file via the MediaSource(const QString &) overload. The MediaSource(QIODevice *) overload must be used. The Symbian backend, on the other hand, requires the former overload to be used. Task-number: QTBUG-6562 Reviewed-by: trustme --- tests/auto/mediaobject/tst_mediaobject.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 613a086..6367392 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -202,7 +202,12 @@ void tst_MediaObject::stateChanged(Phonon::State newstate, Phonon::State oldstat void tst_MediaObject::testPlayFromResource() { MediaObject media; +#ifdef Q_OS_SYMBIAN media.setCurrentSource(Phonon::MediaSource(MEDIA_FILEPATH)); +#else + QFile file(MEDIA_FILEPATH); + media.setCurrentSource(&file); +#endif QVERIFY(media.state() != Phonon::ErrorState); if (media.state() != Phonon::StoppedState) QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); -- cgit v0.12 From c7b9ee03339774bd1cae7793d91dad7809be987a Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 3 Aug 2010 19:41:55 +0200 Subject: Add QDir::homePath() for the log file in QTestFileLogger in testlib on Symbian, both hardware and emulator. Task-number: QTBUG-12622 Reviewed-by: Shane Kearns --- src/testlib/qtestfilelogger.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/testlib/qtestfilelogger.cpp b/src/testlib/qtestfilelogger.cpp index a5cdc80..9d1ee6a 100644 --- a/src/testlib/qtestfilelogger.cpp +++ b/src/testlib/qtestfilelogger.cpp @@ -44,6 +44,8 @@ #include "QtTest/private/qtestlog_p.h" #include "QtTest/private/qtestresult_p.h" +#include + #include #include @@ -69,11 +71,19 @@ QTestFileLogger::~QTestFileLogger() void QTestFileLogger::init() { char filename[100]; + int index = 0; +#if defined(Q_OS_SYMBIAN) + QByteArray ba(QDir::toNativeSeparators(QString(QDir::homePath()+QDir::separator())).toUtf8()); + index = ba.length(); + QTest::qt_snprintf(filename, sizeof(filename), "%s%s.log", + ba.constData(), QTestResult::currentTestObjectName()); +#else QTest::qt_snprintf(filename, sizeof(filename), "%s.log", QTestResult::currentTestObjectName()); - - // Keep filenames simple - for (uint i = 0; i < sizeof(filename) && filename[i]; ++i) { +#endif + + // Keep filenames simple + for (uint i = index; i < sizeof(filename) && filename[i]; ++i) { char& c = filename[i]; if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '.')) { -- cgit v0.12 From 22e95ba2502f893d741b774c37fc8c7bdc4b05c5 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 4 Aug 2010 17:16:33 +0200 Subject: Improving text coordinate rounding in the OpenVG paint engine Commit b0bbabe728fedb8531fc2837403856bd5ed44e1b fixed text blurriness in the OpenVG paint engine by forcing the coordinates of the text items to integer coordinates (for unrotated, unscaled text). That was not yet enough. In addition to the coordinates, also the d->pathTransform in QVGPaintEngine can have a non-integer translation. This patch makes sure that the text item coordinate combined with the translation result in final integer coordinates. Since it is not possible to set an absolute translation of a QTransform (only relative is possible), first dx() is added to p.x(), then after rounding, it is again substracted. Sam for y, but with opposite prefix, since the y-axis in Qt and in transformation matrices are in opposite directions. The ceil stunt (which I cerated by trial and error) was replaced by floor(x + aliasedCoordinateDelta), which *exactly* what other paint engines do. Task-number: QTBUG-12330 Reviewed-by: Jason Barron --- src/openvg/qpaintengine_vg.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index e368c32..318e2b1 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -76,6 +76,9 @@ QT_BEGIN_NAMESPACE #if !defined(QVG_NO_DRAW_GLYPHS) +// use the same rounding as in qrasterizer.cpp (6 bit fixed point) +static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; + Q_DECL_IMPORT extern int qt_defaultDpiX(); Q_DECL_IMPORT extern int qt_defaultDpiY(); @@ -3439,9 +3442,10 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) // Set the transformation to use for drawing the current glyphs. QTransform glyphTransform(d->pathTransform); if (d->transform.type() <= QTransform::TxTranslate) { - // Prevent blurriness of unscaled, unrotated text by using integer coordinates. - // Using ceil(x-0.5) instead of qRound() or int-cast, behave like other paint engines. - glyphTransform.translate(ceil(p.x() - 0.5), ceil(p.y() - 0.5)); + // Prevent blurriness of unscaled, unrotated text by forcing integer coordinates. + glyphTransform.translate( + floor(p.x() + glyphTransform.dx() + aliasedCoordinateDelta) - glyphTransform.dx(), + floor(p.y() - glyphTransform.dy() + aliasedCoordinateDelta) + glyphTransform.dy()); } else { glyphTransform.translate(p.x(), p.y()); } -- cgit v0.12 From 9423ef31eb40e2bd0209621de1d1caf796ec7501 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 5 Aug 2010 11:24:10 +0200 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( bbff6182e525fcf58dbc7426a1fbbf8f31588214 ) Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2010-08-05 David Leong Reviewed by Simon Hausmann. [Qt] Input mode states are not reset after entering a password field https://bugs.webkit.org/show_bug.cgi?id=43530 Input mode hints are not reset if clicking on password elements then clicking on
+ diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp index facee59..14f2362 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -251,30 +251,37 @@ void tst_QWebView::focusInputTypes() #else QVERIFY(webView->inputMethodHints() == Qt::ImhNone); #endif + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field webView->fireMouseClick(QPoint(20, 60)); QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'tel' field webView->fireMouseClick(QPoint(20, 110)); QVERIFY(webView->inputMethodHints() == Qt::ImhDialableCharactersOnly); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'number' field webView->fireMouseClick(QPoint(20, 160)); QVERIFY(webView->inputMethodHints() == Qt::ImhDigitsOnly); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'email' field webView->fireMouseClick(QPoint(20, 210)); QVERIFY(webView->inputMethodHints() == Qt::ImhEmailCharactersOnly); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'url' field webView->fireMouseClick(QPoint(20, 260)); QVERIFY(webView->inputMethodHints() == Qt::ImhUrlCharactersOnly); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'password' field webView->fireMouseClick(QPoint(20, 60)); QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); // 'text' type webView->fireMouseClick(QPoint(20, 10)); @@ -284,6 +291,18 @@ void tst_QWebView::focusInputTypes() #else QVERIFY(webView->inputMethodHints() == Qt::ImhNone); #endif + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); + + // 'password' field + webView->fireMouseClick(QPoint(20, 60)); + QVERIFY(webView->inputMethodHints() == Qt::ImhHiddenText); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); + + qWarning("clicking on text area"); + // 'text area' field + webView->fireMouseClick(QPoint(20, 320)); + QVERIFY(webView->inputMethodHints() == Qt::ImhNone); + QVERIFY(webView->testAttribute(Qt::WA_InputMethodEnabled)); delete webView; -- cgit v0.12 From 6b61a2787759673f246493453c0809d24c9d6ae5 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 6 Aug 2010 10:56:44 +0100 Subject: Make input methods work correctly with Symbian^3 FEP in numeric mode Enable alphanumeric modes to use EAknEditorFlagUseSCTNumericCharmap flag so that all symbols are shown when you press the * key when the FEP is in portrait mode (traditional 4x3 mobile phone keypad emulation) Enable text input mode as well as numeric input mode for ImhFormattedNumbersOnly or ImhDialableCharactersOnly, as the '*' key on the virtual keypad does not work to launch the symbols menu otherwise. Task-number: QT-3681 Reviewed-by: Jason Barron --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 999edda..cd05e38 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -359,10 +359,10 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) commitTemporaryPreeditString(); - bool numbersOnly = hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly - || hints & ImhDialableCharactersOnly; - bool noOnlys = !(numbersOnly || hints & ImhUppercaseOnly - || hints & ImhLowercaseOnly); + bool numbersOnly = (hints & ImhDigitsOnly) || (hints & ImhFormattedNumbersOnly) + || (hints & ImhDialableCharactersOnly); + bool noOnlys = !(numbersOnly || (hints & ImhUppercaseOnly) + || (hints & ImhLowercaseOnly)); TInt flags; Qt::InputMethodHints oldHints = hints; @@ -388,8 +388,7 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) hints |= ImhPreferLowercase; } else if (hints & ImhUppercaseOnly) { hints |= ImhPreferUppercase; - } else if (hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly - || hints & ImhDialableCharactersOnly) { + } else if (numbersOnly) { hints |= ImhPreferNumbers; } } @@ -406,6 +405,11 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) if (numbersOnly) { flags |= EAknEditorNumericInputMode; } + if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 + && ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly)) { + //workaround - the * key does not launch the symbols menu, making it impossible to use these modes unless text mode is enabled. + flags |= EAknEditorTextInputMode; + } if (hints & ImhUppercaseOnly || hints & ImhLowercaseOnly) { flags |= EAknEditorTextInputMode; } @@ -456,6 +460,9 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) if (hints & ImhNoPredictiveText || hints & ImhHiddenText) { flags |= EAknEditorFlagNoT9; } + // if alphanumeric input, then make all symbols available in numeric mode too. + if (!numbersOnly) + flags |= EAknEditorFlagUseSCTNumericCharmap; m_fepState->SetFlags(flags); ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateFlagsUpdate); -- cgit v0.12 From d2a52ba7d5fa48632d6f0092da8db97188993252 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 6 Aug 2010 11:38:18 +0100 Subject: Test code for input method hints A simple test application to set any combination of input method hints on a QLineEdit widget. This makes it easier to debug when the original report relies on webkit. Task-number: QT-3681 Reviewed-by: Miikka Heikkinen --- tests/manual/inputmethodhints/inputmethodhints.cpp | 99 +++++++++++++++ tests/manual/inputmethodhints/inputmethodhints.h | 63 ++++++++++ tests/manual/inputmethodhints/inputmethodhints.pro | 13 ++ tests/manual/inputmethodhints/inputmethodhints.ui | 138 +++++++++++++++++++++ tests/manual/inputmethodhints/main.cpp | 53 ++++++++ 5 files changed, 366 insertions(+) create mode 100644 tests/manual/inputmethodhints/inputmethodhints.cpp create mode 100644 tests/manual/inputmethodhints/inputmethodhints.h create mode 100644 tests/manual/inputmethodhints/inputmethodhints.pro create mode 100644 tests/manual/inputmethodhints/inputmethodhints.ui create mode 100644 tests/manual/inputmethodhints/main.cpp diff --git a/tests/manual/inputmethodhints/inputmethodhints.cpp b/tests/manual/inputmethodhints/inputmethodhints.cpp new file mode 100644 index 0000000..0c00b8d --- /dev/null +++ b/tests/manual/inputmethodhints/inputmethodhints.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 examples 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 "inputmethodhints.h" + +inputmethodhints::inputmethodhints(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); + connect(ui.cbDialableOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbDigitsOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbEmailOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbFormattedNumbersOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbHiddenText, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbLowercaseOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbNoAutoUppercase, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbNoPredictiveText, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbPreferLowercase, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbPreferNumbers, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbPreferUpperCase, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbUppercaseOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); + connect(ui.cbUrlOnly, SIGNAL(stateChanged(int)), this, SLOT(checkboxChanged(int))); +} + +inputmethodhints::~inputmethodhints() +{ + +} + +void inputmethodhints::checkboxChanged(int) +{ + int flags = 0; + if (ui.cbDialableOnly->isChecked()) + flags |= Qt::ImhDialableCharactersOnly; + if (ui.cbDigitsOnly->isChecked()) + flags |= Qt::ImhDigitsOnly; + if (ui.cbEmailOnly->isChecked()) + flags |= Qt::ImhEmailCharactersOnly; + if (ui.cbFormattedNumbersOnly->isChecked()) + flags |= Qt::ImhFormattedNumbersOnly; + if (ui.cbHiddenText->isChecked()) + flags |= Qt::ImhHiddenText; + if (ui.cbLowercaseOnly->isChecked()) + flags |= Qt::ImhLowercaseOnly; + if (ui.cbNoAutoUppercase->isChecked()) + flags |= Qt::ImhNoAutoUppercase; + if (ui.cbNoPredictiveText->isChecked()) + flags |= Qt::ImhNoPredictiveText; + if (ui.cbPreferLowercase->isChecked()) + flags |= Qt::ImhPreferLowercase; + if (ui.cbPreferNumbers->isChecked()) + flags |= Qt::ImhPreferNumbers; + if (ui.cbPreferUpperCase->isChecked()) + flags |= Qt::ImhPreferUppercase; + if (ui.cbUppercaseOnly->isChecked()) + flags |= Qt::ImhUppercaseOnly; + if (ui.cbUrlOnly->isChecked()) + flags |= Qt::ImhUrlCharactersOnly; + ui.lineEdit->clear(); + ui.lineEdit->setInputMethodHints(Qt::InputMethodHints(flags)); +} diff --git a/tests/manual/inputmethodhints/inputmethodhints.h b/tests/manual/inputmethodhints/inputmethodhints.h new file mode 100644 index 0000000..988a4be --- /dev/null +++ b/tests/manual/inputmethodhints/inputmethodhints.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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 examples 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 INPUTMETHODHINTS_H +#define INPUTMETHODHINTS_H + +#include +#include "ui_tst_inputmethodhints.h" + +class inputmethodhints : public QMainWindow +{ + Q_OBJECT + +public: + inputmethodhints(QWidget *parent = 0); + ~inputmethodhints(); + +public slots: + void checkboxChanged(int); + +private: + Ui::MainWindow ui; +}; + +#endif // INPUTMETHODHINTS_H diff --git a/tests/manual/inputmethodhints/inputmethodhints.pro b/tests/manual/inputmethodhints/inputmethodhints.pro new file mode 100644 index 0000000..7298ec6 --- /dev/null +++ b/tests/manual/inputmethodhints/inputmethodhints.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +TARGET = tst_inputmethodhints + +QT += core \ + gui + +HEADERS += inputmethodhints.h +SOURCES += main.cpp \ + inputmethodhints.cpp +FORMS += inputmethodhints.ui +RESOURCES += + +symbian:TARGET.UID3 = 0xE4938ABC diff --git a/tests/manual/inputmethodhints/inputmethodhints.ui b/tests/manual/inputmethodhints/inputmethodhints.ui new file mode 100644 index 0000000..d0dc01d --- /dev/null +++ b/tests/manual/inputmethodhints/inputmethodhints.ui @@ -0,0 +1,138 @@ + + + MainWindow + + + + 0 + 0 + 360 + 640 + + + + MainWindow + + + + + + + 1 + + + + behaviour + + + + + + ImhHiddenText + + + + + + + ImhNoAutoUppercase + + + + + + + ImhPreferNumbers + + + + + + + ImhPreferUppercase + + + + + + + ImhPreferLowercase + + + + + + + ImhNoPredictiveText + + + + + + + + restrictions + + + + + + ImhDigitsOnly + + + + + + + ImhFormattedNumbersOnly + + + + + + + ImhUppercaseOnly + + + + + + + ImhLowercaseOnly + + + + + + + ImhDialableCharactersOnly + + + + + + + ImhEmailCharactersOnly + + + + + + + ImhUrlCharactersOnly + + + + + + + + + + + + + + + + diff --git a/tests/manual/inputmethodhints/main.cpp b/tests/manual/inputmethodhints/main.cpp new file mode 100644 index 0000000..022bf3f --- /dev/null +++ b/tests/manual/inputmethodhints/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** 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 examples 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 "inputmethodhints.h" + +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + inputmethodhints w; + w.showMaximized(); + return a.exec(); +} -- cgit v0.12 From e4c144db1cde192745a198160a01fca1416fe855 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 6 Aug 2010 12:00:54 +0100 Subject: fix compile error Task-number: QT-3681 Reviewed-by: Trust Me --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index cd05e38..ae51b1c 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -406,7 +406,7 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) flags |= EAknEditorNumericInputMode; } if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 - && ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly)) { + && ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly))) { //workaround - the * key does not launch the symbols menu, making it impossible to use these modes unless text mode is enabled. flags |= EAknEditorTextInputMode; } -- cgit v0.12 From 6eb7a210eed1b392431fc913d13d205b8ccc1933 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 6 Aug 2010 16:25:15 +0100 Subject: Fixes for combining multiple Qt::ImhXXXOnly with S60 FEP When one restriction is a superset of another (e.g. ImhDigitsOnly | ImhDialableCharactersOnly), the less restrictive one is used When two restrictions are incompatible (e.g. ImhDialableCharactersOnly | ImhFormattedNumbersOnly), fall back to allowing all symbols Note for some combinations additional characters not in the union can be entered, this is a limitation of the API to AVKON FEP. Before this change, some characters in the union could not be entered at all, which is worse. Tested on I8510 (3.2), 5800XM (5.0), N8(symbian^3) Task Number: QTBUG-12726 Reviewed-by: Alessandro Portale --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 52 ++++++++++++++----------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index ae51b1c..44fe7da 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -359,10 +359,10 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) commitTemporaryPreeditString(); - bool numbersOnly = (hints & ImhDigitsOnly) || (hints & ImhFormattedNumbersOnly) - || (hints & ImhDialableCharactersOnly); - bool noOnlys = !(numbersOnly || (hints & ImhUppercaseOnly) - || (hints & ImhLowercaseOnly)); + const bool anynumbermodes = hints & (ImhDigitsOnly | ImhFormattedNumbersOnly | ImhDialableCharactersOnly); + const bool anytextmodes = hints & (ImhUppercaseOnly | ImhLowercaseOnly | ImhEmailCharactersOnly | ImhUrlCharactersOnly); + const bool numbersOnly = anynumbermodes && !anytextmodes; + const bool noOnlys = !(hints & ImhExclusiveInputMask); TInt flags; Qt::InputMethodHints oldHints = hints; @@ -374,8 +374,7 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) } if (!noOnlys) { // Make sure that the preference is within the permitted set. - if (hints & ImhPreferNumbers && !(hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly - || hints & ImhDialableCharactersOnly)) { + if (hints & ImhPreferNumbers && !anynumbermodes) { hints &= ~ImhPreferNumbers; } else if (hints & ImhPreferUppercase && !(hints & ImhUppercaseOnly)) { hints &= ~ImhPreferUppercase; @@ -402,18 +401,21 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) m_fepState->SetCurrentInputMode(EAknEditorTextInputMode); } flags = 0; - if (numbersOnly) { - flags |= EAknEditorNumericInputMode; + if (noOnlys || (anynumbermodes && anytextmodes)) { + flags = EAknEditorAllInputModes; } - if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 - && ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly))) { - //workaround - the * key does not launch the symbols menu, making it impossible to use these modes unless text mode is enabled. - flags |= EAknEditorTextInputMode; + else if (anynumbermodes) { + flags |= EAknEditorNumericInputMode; + if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 + && ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly))) { + //workaround - the * key does not launch the symbols menu, making it impossible to use these modes unless text mode is enabled. + flags |= EAknEditorTextInputMode; + } } - if (hints & ImhUppercaseOnly || hints & ImhLowercaseOnly) { + else if (anytextmodes) { flags |= EAknEditorTextInputMode; } - if (flags == 0) { + else { flags = EAknEditorAllInputModes; } m_fepState->SetPermittedInputModes(flags); @@ -460,27 +462,33 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) if (hints & ImhNoPredictiveText || hints & ImhHiddenText) { flags |= EAknEditorFlagNoT9; } - // if alphanumeric input, then make all symbols available in numeric mode too. - if (!numbersOnly) + // if alphanumeric input, or if multiple incompatible number modes are selected; + // then make all symbols available in numeric mode too. + if (!numbersOnly || ((hints & ImhFormattedNumbersOnly) && (hints & ImhDialableCharactersOnly))) flags |= EAknEditorFlagUseSCTNumericCharmap; m_fepState->SetFlags(flags); ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateFlagsUpdate); - if (hints & ImhFormattedNumbersOnly) { + if (hints & ImhDialableCharactersOnly) { + // This is first, because if (ImhDialableCharactersOnly | ImhFormattedNumbersOnly) + // is specified, this one is more natural (# key enters a #) + flags = EAknEditorStandardNumberModeKeymap; + } else if (hints & ImhFormattedNumbersOnly) { + // # key enters decimal point flags = EAknEditorCalculatorNumberModeKeymap; } else if (hints & ImhDigitsOnly) { + // This is last, because it is most restrictive (# key is inactive) flags = EAknEditorPlainNumberModeKeymap; } else { - // ImhDialableCharactersOnly is the fallback as well, so we don't need to check for - // that flag. flags = EAknEditorStandardNumberModeKeymap; } m_fepState->SetNumericKeymap(static_cast(flags)); - if (hints & ImhEmailCharactersOnly) { - m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG); - } else if (hints & ImhUrlCharactersOnly) { + if (hints & ImhUrlCharactersOnly) { + // URL characters is everything except space, so a superset of the other restrictions m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG); + } else if (hints & ImhEmailCharactersOnly) { + m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG); } else { m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); } -- cgit v0.12 From 362641ec2bdf5e05b4adfc54275c1c4869759d56 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 9 Aug 2010 11:01:45 +0200 Subject: Doc: typo fixed in qlibraryinfo.cpp Reviewed-by: TrustMe --- src/corelib/global/qlibraryinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index a9ea44a..4b56efc 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -467,7 +467,7 @@ QLibraryInfo::location(LibraryLocation loc) \value PrefixPath The default prefix for all paths. \value DocumentationPath The location for documentation upon install. \value HeadersPath The location for all headers. - \value LibrariesPath The location of installed librarires. + \value LibrariesPath The location of installed libraries. \value BinariesPath The location of installed Qt binaries (tools and applications). \value PluginsPath The location of installed Qt plugins. \value DataPath The location of general Qt data. -- cgit v0.12 From ca9270722b4412d9f70efe1ef4ad51635deca75a Mon Sep 17 00:00:00 2001 From: "Richard J. Moore" Date: Sun, 6 Jun 2010 22:10:08 +0100 Subject: Fix handling of SSL certificates with wildcard domain names Merge-request: 731 Task-number: QTBUG-4455 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslsocket_openssl.cpp | 42 +++++++++++++++++++++++++++++--- src/network/ssl/qsslsocket_openssl_p.h | 1 + tests/auto/qsslsocket/tst_qsslsocket.cpp | 24 ++++++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 6f77600..6f0ccff 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -827,17 +827,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.lower(), peerName.lower())) { bool matched = false; foreach (const QString &altName, configuration.peerCertificate .alternateSubjectNames().values(QSsl::DnsEntry)) { - regexp.setPattern(altName); - if (regexp.exactMatch(peerName)) { + if (isMatchingHostname(altName.lower(), peerName.lower())) { matched = true; break; } } + if (!matched) { // No matches in common names or alternate names. QSslError error(QSslError::HostNameMismatch, configuration.peerCertificate); @@ -962,4 +961,39 @@ QList 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 836f064..05eb4fa 100644 --- a/src/network/ssl/qsslsocket_openssl_p.h +++ b/src/network/ssl/qsslsocket_openssl_p.h @@ -115,6 +115,7 @@ public: static QSslCipher QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher); static QList STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509); + Q_AUTOTEST_EXPORT static bool isMatchingHostname(const QString &cn, const QString &hostname); }; QT_END_NAMESPACE diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 5dd7c19..225e2e8 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -55,6 +55,7 @@ #include #include "private/qhostinfo_p.h" +#include "private/qsslsocket_openssl_p.h" #include "../network-settings.h" @@ -163,6 +164,7 @@ private slots: void setDefaultCiphers(); void supportedCiphers(); void systemCaCertificates(); + void wildcardCertificateNames(); void wildcard(); void setEmptyKey(); void spontaneousWrite(); @@ -1048,6 +1050,28 @@ void tst_QSslSocket::systemCaCertificates() QCOMPARE(certs, QSslSocket::defaultCaCertificates()); } +void tst_QSslSocket::wildcardCertificateNames() +{ + // Passing CN matches + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("www.example.com"), QString("www.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example.com"), QString("www.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("xxx*.example.com"), QString("xxxwww.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("f*.example.com"), QString("foo.example.com")), true ); + + // Failing CN matches + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("xxx.example.com"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.*.com"), QString("www.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example.com"), QString("baa.foo.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("f*.example.com"), QString("baa.example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.com"), QString("example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*fail.com"), QString("example.com")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example."), QString("www.example.")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example."), QString("www.example")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString(""), QString("www")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*"), QString("www")), false ); +} + void tst_QSslSocket::wildcard() { QSKIP("TODO: solve wildcard problem", SkipAll); -- cgit v0.12 From b5f95fbf615b113e3e6d2b42f6b84309d6588b1f Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 12 Jul 2010 10:47:00 +0200 Subject: fix build for -no-qt3support QString::lower() is QT3_SUPPORT, the correct method is QString::toLower(). --- src/network/ssl/qsslsocket_openssl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 6f0ccff..103a7ef 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -827,11 +827,11 @@ bool QSslSocketBackendPrivate::startHandshake() QString peerName = (verificationPeerName.isEmpty () ? q->peerName() : verificationPeerName); QString commonName = configuration.peerCertificate.subjectInfo(QSslCertificate::CommonName); - if (!isMatchingHostname(commonName.lower(), peerName.lower())) { + if (!isMatchingHostname(commonName.toLower(), peerName.toLower())) { bool matched = false; foreach (const QString &altName, configuration.peerCertificate .alternateSubjectNames().values(QSsl::DnsEntry)) { - if (isMatchingHostname(altName.lower(), peerName.lower())) { + if (isMatchingHostname(altName.toLower(), peerName.toLower())) { matched = true; break; } -- cgit v0.12 From 87c62128266a4e2289c1854e35aba3fc17d44045 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 10 Aug 2010 13:59:57 +0200 Subject: QSslSocket: fix security vulnerability with wildcard IP addresses This fixes Westpoint Security issue with Advisory ID#: wp-10-0001. Before, we would allow wildcards in IP addresses like *.2.3.4 ; now, IP addresses must match excatly. Patch-by: Richard J. Moore Task-number: QT-3704 --- src/network/ssl/qsslsocket_openssl.cpp | 5 +++++ tests/auto/qsslsocket/tst_qsslsocket.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 103a7ef..625d739 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -992,6 +992,11 @@ bool QSslSocketBackendPrivate::isMatchingHostname(const QString &cn, const QStri if (hostname.midRef(hostname.indexOf(QLatin1Char('.'))) != cn.midRef(firstCnDot)) return false; + // Check if the hostname is an IP address, if so then wildcards are not allowed + QHostAddress addr(hostname); + if (!addr.isNull()) + return false; + // Ok, I guess this was a wildcard CN and the hostname matches. return true; } diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 225e2e8..8f7e0d9 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -1057,6 +1057,7 @@ void tst_QSslSocket::wildcardCertificateNames() QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example.com"), QString("www.example.com")), true ); QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("xxx*.example.com"), QString("xxxwww.example.com")), true ); QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("f*.example.com"), QString("foo.example.com")), true ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("192.168.0.0"), QString("192.168.0.0")), true ); // Failing CN matches QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("xxx.example.com"), QString("www.example.com")), false ); @@ -1070,6 +1071,7 @@ void tst_QSslSocket::wildcardCertificateNames() QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.example."), QString("www.example")), false ); QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString(""), QString("www")), false ); QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*"), QString("www")), false ); + QCOMPARE( QSslSocketBackendPrivate::isMatchingHostname(QString("*.168.0.0"), QString("192.168.0.0")), false ); } void tst_QSslSocket::wildcard() -- cgit v0.12