diff options
author | Janne Anttila <janne.anttila@digia.com> | 2010-11-15 11:22:27 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2010-11-15 12:25:42 (GMT) |
commit | d92cbfc5d04d750dea1e49a377e62be564cac788 (patch) | |
tree | f23fb1b9b8e349fc8ccd0c3d3f4e3f216ae2f7b9 /src/gui | |
parent | 012c865ab30ed45fc57ee5b49b625697cc065e82 (diff) | |
download | Qt-d92cbfc5d04d750dea1e49a377e62be564cac788.zip Qt-d92cbfc5d04d750dea1e49a377e62be564cac788.tar.gz Qt-d92cbfc5d04d750dea1e49a377e62be564cac788.tar.bz2 |
Switched qdesktopservices to use SchemeHandler for Symbian^3 and later.
SchemeHandler is plugin extensible component to handle several
different URI schemes. By default schemes such as http, https, rtsp,
mailto, file, wtai, tel and cti are supported.
In some devices/platforms also other schemes might be supported.
This commit only defines the USE_SCHEMEHANDLER macro and re-orders
the qdesktopservices_s60 source code to make it more readable and to
make it compile both with and without the flag. The actual
implementation was provided at the same time when qdesktopservices
for symbian was initially implemented.
Why support is enabled only for Symbian^3 and later? SchemeHandler
component does not exist in S60 3.1 - 5.0 public SDKs, actually it does
not exist also in Forum Nokia provided Symbian^3 SDK, but is available
in Symbian^3 PDK. Since building Qt for Symbian^3 anyway require PDK
and because the release builds for Symbian^3 are done separately
from older Symbian versions, PDK dependency should be Ok.
It might be that SchemeHandler headers will be relicensed as part of Qt,
then SchemeHandler support also for older S60/Symbian releases can be
enabled. If this happens it will be separate commit.
Task-number: QTBUG-15282
Reviewed-by: Miikka Heikkinen
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/util/qdesktopservices_s60.cpp | 162 | ||||
-rw-r--r-- | src/gui/util/util.pri | 19 |
2 files changed, 97 insertions, 84 deletions
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp index d1eeeae..47b0cbe 100644 --- a/src/gui/util/qdesktopservices_s60.cpp +++ b/src/gui/util/qdesktopservices_s60.cpp @@ -45,27 +45,29 @@ #include <qurl.h> #include <private/qcore_symbian_p.h> -#include <txtrich.h> // CRichText #include <f32file.h> // TDriveUnit etc -#include <eikenv.h> // CEikonEnv -#include <apgcli.h> // RApaLsSession -#include <apgtask.h> // TApaTaskList, TApaTask -#include <rsendas.h> // RSendAs -#include <rsendasmessage.h> // RSendAsMessage +#include <pathinfo.h> // PathInfo +#ifndef USE_SCHEMEHANDLER #ifdef Q_WS_S60 // This flag changes the implementation to use S60 CDcoumentHandler -// instead of apparch when opening the files +// instead of apparc when opening the files #define USE_DOCUMENTHANDLER #endif -// copied from miutset.h, so we don't get a dependency into the app layer -const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592 +#include <txtrich.h> // CRichText +#include <eikenv.h> // CEikonEnv +#include <apgcli.h> // RApaLsSession +#include <apgtask.h> // TApaTaskList, TApaTask +#include <rsendas.h> // RSendAs +#include <rsendasmessage.h> // RSendAsMessage -#include <pathinfo.h> // PathInfo #ifdef USE_DOCUMENTHANDLER -# include <DocumentHandler.h> // CDocumentHandler -# include <AknServerApp.h> +#include <DocumentHandler.h> // CDocumentHandler +#include <AknServerApp.h> +#endif +#else // USE_SCHEMEHANDLER +#include <schemehandler.h> #endif QT_BEGIN_NAMESPACE @@ -74,6 +76,10 @@ _LIT(KCacheSubDir, "Cache\\"); _LIT(KSysBin, "\\Sys\\Bin\\"); _LIT(KBrowserPrefix, "4 " ); _LIT(KFontsDir, "z:\\resource\\Fonts\\"); + +#ifndef USE_SCHEMEHANDLER +// copied from miutset.h, so we don't get a dependency into the app layer +const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592 const TUid KUidBrowser = { 0x10008D39 }; template<class R> @@ -132,7 +138,6 @@ private: 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 @@ -150,12 +155,10 @@ static void handleMailtoSchemeLX(const QUrl &url) QStringList ccs = cc.split(QLatin1String(","), QString::SkipEmptyParts); QStringList bccs = bcc.split(QLatin1String(","), QString::SkipEmptyParts); - RSendAs sendAs; User::LeaveIfError(sendAs.Connect()); QAutoClose<RSendAs> sendAsCleanup(sendAs); - CSendAsAccounts* accounts = CSendAsAccounts::NewL(); CleanupStack::PushL(accounts); sendAs.AvailableAccountsL(KUidMsgTypeSMTP, *accounts); @@ -244,42 +247,6 @@ static bool handleOtherSchemes(const QUrl &url) return err ? false : true; } -static TDriveUnit exeDrive() -{ - RProcess me; - TFileName processFileName = me.FileName(); - TDriveUnit drive(processFileName); - return drive; -} - -static TDriveUnit writableExeDrive() -{ - TDriveUnit drive = exeDrive(); - if(drive.operator TInt() == EDriveZ) - return TDriveUnit(EDriveC); - return drive; -} - -static TPtrC writableDataRoot() -{ - TDriveUnit drive = exeDrive(); - switch(drive.operator TInt()){ - case EDriveC: - return PathInfo::PhoneMemoryRootPath(); - break; - case EDriveE: - return PathInfo::MemoryCardRootPath(); - break; - case EDriveZ: - // It is not possible to write on ROM drive -> - // return phone mem root path instead - return PathInfo::PhoneMemoryRootPath(); - break; - default: - return PathInfo::PhoneMemoryRootPath(); - break; - } -} static void openDocumentL(const TDesC& aUrl) { @@ -304,13 +271,44 @@ static void openDocumentL(const TDesC& aUrl) #endif } -#ifdef USE_SCHEMEHANDLER +static bool launchWebBrowser(const QUrl &url) +{ + if (!url.isValid()) + return false; + + if (url.scheme() == QLatin1String("mailto")) { + return handleMailtoScheme(url); + } + return handleOtherSchemes( url ); +} + +static bool openDocument(const QUrl &file) +{ + if (!file.isValid()) + return false; + + QString filePath = file.toLocalFile(); + filePath = QDir::toNativeSeparators(filePath); + TPtrC filePathPtr(qt_QString2TPtrC(filePath)); + TRAPD(err, openDocumentL(filePathPtr)); + return err ? false : true; +} + +#else //USE_SCHEMEHANDLER // The schemehandler component only exist in private SDK. This implementation // exist here just for convenience in case that we need to use it later on // The schemehandle based implementation is not yet tested. // The biggest advantage of schemehandler is that it can handle // wide range of schemes and is extensible by plugins +static void handleUrlL(const TDesC& aUrl) +{ + CSchemeHandler* schemeHandler = CSchemeHandler::NewL(aUrl); + CleanupStack::PushL(schemeHandler); + schemeHandler->HandleUrlStandaloneL(); // Process the Url in standalone mode + CleanupStack::PopAndDestroy(); +} + static bool handleUrl(const QUrl &url) { if (!url.isValid()) @@ -322,13 +320,6 @@ static bool handleUrl(const QUrl &url) return err ? false : true; } -static void handleUrlL(const TDesC& aUrl) -{ - CSchemeHandler* schemeHandler = CSchemeHandler::NewL(aUrl); - CleanupStack::PushL(schemeHandler); - schemeHandler->HandleUrlStandaloneL(); // Process the Url in standalone mode - CleanupStack::PopAndDestroy(); -} static bool launchWebBrowser(const QUrl &url) { return handleUrl(url); @@ -336,31 +327,48 @@ static bool launchWebBrowser(const QUrl &url) static bool openDocument(const QUrl &file) { - return handleUrl(url); + return handleUrl(file); } -#endif -static bool launchWebBrowser(const QUrl &url) -{ - if (!url.isValid()) - return false; +#endif //USE_SCHEMEHANDLER - if (url.scheme() == QLatin1String("mailto")) { - return handleMailtoScheme(url); - } - return handleOtherSchemes( url ); +// Common functions to all implementations + +static TDriveUnit exeDrive() +{ + RProcess me; + TFileName processFileName = me.FileName(); + TDriveUnit drive(processFileName); + return drive; } -static bool openDocument(const QUrl &file) +static TDriveUnit writableExeDrive() { - if (!file.isValid()) - return false; + TDriveUnit drive = exeDrive(); + if(drive.operator TInt() == EDriveZ) + return TDriveUnit(EDriveC); + return drive; +} - QString filePath = file.toLocalFile(); - filePath = QDir::toNativeSeparators(filePath); - TPtrC filePathPtr(qt_QString2TPtrC(filePath)); - TRAPD(err, openDocumentL(filePathPtr)); - return err ? false : true; +static TPtrC writableDataRoot() +{ + TDriveUnit drive = exeDrive(); + switch(drive.operator TInt()){ + case EDriveC: + return PathInfo::PhoneMemoryRootPath(); + break; + case EDriveE: + return PathInfo::MemoryCardRootPath(); + break; + case EDriveZ: + // It is not possible to write on ROM drive -> + // return phone mem root path instead + return PathInfo::PhoneMemoryRootPath(); + break; + default: + return PathInfo::PhoneMemoryRootPath(); + break; + } } QString QDesktopServices::storageLocation(StandardLocation type) diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index bea520e..d1c4ff8 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -43,12 +43,17 @@ embedded { } symbian { - LIBS += -lsendas2 -letext -lapmime -lplatformenv - contains(QT_CONFIG, s60) { - contains(CONFIG, is_using_gnupoc) { - LIBS += -lcommonui - } else { - LIBS += -lCommonUI + LIBS += -letext -lplatformenv + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + LIBS += -lsendas2 -lapmime + contains(QT_CONFIG, s60) { + contains(CONFIG, is_using_gnupoc) { + LIBS += -lcommonui + } else { + LIBS += -lCommonUI + } } + } else { + DEFINES += USE_SCHEMEHANDLER } -} +}
\ No newline at end of file |