summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2009-12-04 14:23:24 +0200
committerJanne Anttila <janne.anttila@digia.com>2009-12-04 14:23:24 +0200
commit62fac968df5fb3632e458aeacfe5a8ef5cfd32bf (patch)
treef72c174d68c1d722aa71cf57d3c757a7bed13a08
parent14c01d35cd132bb1a5e5725877d28d5f75c086ab (diff)
Switched S60 QDesktopServices implementation to CDocumentHandler based.
RApaLsSession based implementation did not succeed to start music player in some S60 devices to playing mode. The only found solution to this problem was to start using CDocumentHandler based implementation. CDocumentHandler adds a new S60 dependency, but it is needed to make QDesktopServices APIs fully fuonctional. However if Qt is comfigured without S60 we still fallback to RApaLsSession implementation. With CDocumentHandler the files are also opened as embedded, due to the fact that swicthing files in stand-alone mode would require SwEvent capability. Task-number: QTBUG-4699 Reviewed-by: Miikka Heikkinen
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp72
-rw-r--r--tests/auto/qdesktopservices/tst_qdesktopservices.cpp16
2 files changed, 64 insertions, 24 deletions
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index 1890d569ce..c6932de0d0 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -41,7 +41,7 @@
// This flag changes the implementation to use S60 CDcoumentHandler
// instead of apparch when opening the files
-#undef USE_DOCUMENTHANDLER
+#define USE_DOCUMENTHANDLER
#include <qcoreapplication.h>
#include <qdir.h>
@@ -58,12 +58,14 @@
#include <rsendasmessage.h> // RSendAsMessage
#ifdef Q_WS_S60
-# include <pathinfo.h> // PathInfo
+# include <pathinfo.h> // PathInfo
# ifdef USE_DOCUMENTHANDLER
-# include <documenthandler.h> // CDocumentHandler
+# include <documenthandler.h> // CDocumentHandler
+# include <aknserverapp.h>
# endif
-#elif defined(USE_DOCUMENTHANDLER)
-# error CDocumentHandler requires support for S60
+#else
+# warning CDocumentHandler requires support for S60
+# undef USE_DOCUMENTHANDLER // Fallback to RApaLsSession based implementation
#endif
QT_BEGIN_NAMESPACE
@@ -95,6 +97,42 @@ private:
R* mPtr;
};
+#ifdef USE_DOCUMENTHANDLER
+class QS60DocumentHandler : public MAknServerAppExitObserver
+{
+public:
+ QS60DocumentHandler() :docHandler(0) {}
+
+ ~QS60DocumentHandler() {
+ delete docHandler;
+ }
+
+ CDocumentHandler& documentHandler() {
+ // In case user calls openUrl twice subsequently, before the first embedded app is closed
+ // we use the same CDocumentHandler instance. Using same instance makes sure the first
+ // launched embedded app is closed and latter one gets embedded to our app.
+ // Using different instance would help only theoretically since user cannot interact with
+ // several embedded apps at the same time.
+ if(!docHandler) {
+ QT_TRAP_THROWING(docHandler = CDocumentHandler::NewL());
+ docHandler->SetExitObserver(this);
+ }
+ return *docHandler;
+ }
+
+private: // From MAknServerAppExitObserver
+ void HandleServerAppExit(TInt /*aReason*/) {
+ delete docHandler;
+ docHandler = 0;
+ }
+
+private:
+ CDocumentHandler* docHandler;
+};
+Q_GLOBAL_STATIC(QS60DocumentHandler, qt_s60_documenthandler);
+#endif
+
+
static void handleMailtoSchemeLX(const QUrl &url)
{
// this function has many intermingled leaves and throws. Qt and Symbian objects do not have
@@ -264,21 +302,9 @@ static void openDocumentL(const TDesC& aUrl)
CleanupStack::PopAndDestroy(); // appArcSession
#else
// This is an alternative way to launch app associated to MIME type
- // CDocumentHandler would support opening apps in embedded mode,
- // but our Qt application window group seems to always get switched on top of embedded one
- // -> Cannot use menus etc of embedded app -> used
-
- CDocumentHandler* docHandler = CDocumentHandler::NewLC();
+ // CDocumentHandler also supports opening apps in embedded mode.
TDataType temp;
- //Standalone file opening fails for some file-types at least in S60 3.1 emulator
- //For example .txt file fails with KErrAlreadyInUse and music files with KERN-EXEC 0
- //Workaround is to use OpenFileEmbeddedL
- //docHandler->OpenFileL(aUrl, temp);
-
- // Opening file with CDocumentHandler will leave if file does not exist
- // Leave is trapped in openDocument and false returned to user.
- docHandler->OpenFileEmbeddedL(aUrl, temp);
- CleanupStack::PopAndDestroy(docHandler);
+ qt_s60_documenthandler()->documentHandler().OpenFileEmbeddedL(aUrl, temp);
#endif
}
@@ -349,7 +375,7 @@ QString QDesktopServices::storageLocation(StandardLocation type)
case DesktopLocation:
qWarning("No desktop concept in Symbian OS");
// But lets still use some feasible default
- path.Append(writableDataRoot());
+ path.Append(writableDataRoot());
break;
case DocumentsLocation:
path.Append(writableDataRoot());
@@ -380,7 +406,7 @@ QString QDesktopServices::storageLocation(StandardLocation type)
#endif
break;
case TempLocation:
- return QDir::tempPath();
+ return QDir::tempPath();
break;
case HomeLocation:
path.Append(writableDataRoot());
@@ -394,10 +420,10 @@ QString QDesktopServices::storageLocation(StandardLocation type)
CEikonEnv::Static()->FsSession().PrivatePath(path);
path.Insert(0, writableExeDrive().Name());
path.Append(KCacheSubDir);
- break;
+ break;
default:
// Lets use feasible default
- path.Append(writableDataRoot());
+ path.Append(writableDataRoot());
break;
}
diff --git a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp
index 2d9e5dcc94..c105a977a4 100644
--- a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp
+++ b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp
@@ -70,6 +70,7 @@ private slots:
void openMailtoUrl();
void openFileUrl_data();
void openFileUrl();
+ void openMultipleFileUrls();
#endif
void handlers();
void storageLocation_data();
@@ -197,6 +198,7 @@ void tst_qdesktopservices::openMailtoUrl()
QFETCH(QUrl, url);
QFETCH(bool, result);
QCOMPARE(QDesktopServices::openUrl(url), result);
+ QTest::qWait(5000);
}
void tst_qdesktopservices::openFileUrl_data()
@@ -239,7 +241,19 @@ void tst_qdesktopservices::openFileUrl()
QFETCH(QUrl, url);
QFETCH(bool, result);
QCOMPARE(QDesktopServices::openUrl(url), result);
- QTest::qWait(15000);
+ QTest::qWait(5000);
+}
+
+void tst_qdesktopservices::openMultipleFileUrls()
+{
+#ifndef RUN_MANUAL_TESTS
+ QSKIP("Test disabled -- only for manual purposes", SkipAll);
+#endif
+
+ QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/images/image.bmp")), true);
+ QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/images/image.png")), true);
+ QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/others/noendofline.txt")), true);
+ QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/installs/ErrRd.sisx")), true);
}
#endif