Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/util/qdesktopservices_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4040****************************************************************************/
    4141
    42 // This flag changes the implementation to use S60 CDcoumentHandler
    43 // instead of apparch when opening the files
    44 #define USE_DOCUMENTHANDLER
    4542
    4643#include <qcoreapplication.h>
     
    4946#include <private/qcore_symbian_p.h>
    5047
     48#include <f32file.h>                // TDriveUnit etc
     49#include <pathinfo.h>               // PathInfo
     50
     51#ifndef USE_SCHEMEHANDLER
     52#ifdef Q_WS_S60
     53// This flag changes the implementation to use S60 CDcoumentHandler
     54// instead of apparc when opening the files
     55#define USE_DOCUMENTHANDLER
     56#endif
     57
    5158#include <txtrich.h>                // CRichText
    52 #include <f32file.h>                // TDriveUnit etc
    5359#include <eikenv.h>                 // CEikonEnv
    5460#include <apgcli.h>                 // RApaLsSession
     
    5763#include <rsendasmessage.h>         // RSendAsMessage
    5864
    59 // copied from miutset.h, so we don't get a dependency into the app layer
    60 const TUid KUidMsgTypeSMTP                      = {0x10001028}; // 268439592
    61 
    62 #ifdef Q_WS_S60
    63 #  include <pathinfo.h>             // PathInfo
    64 #  ifdef USE_DOCUMENTHANDLER
    65 #    include <DocumentHandler.h>    // CDocumentHandler
    66 #    include <AknServerApp.h>
    67 #  endif
    68 #else
    69 #  warning CDocumentHandler requires support for S60
    70 #  undef USE_DOCUMENTHANDLER        // Fallback to RApaLsSession based implementation
     65#ifdef USE_DOCUMENTHANDLER
     66#include <DocumentHandler.h>        // CDocumentHandler
     67#include <AknServerApp.h>
     68#endif
     69#else // USE_SCHEMEHANDLER
     70#include <schemehandler.h>
    7171#endif
    7272
     
    7777_LIT(KBrowserPrefix, "4 " );
    7878_LIT(KFontsDir, "z:\\resource\\Fonts\\");
     79
     80#ifndef USE_SCHEMEHANDLER
     81// copied from miutset.h, so we don't get a dependency into the app layer
     82const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592
    7983const TUid KUidBrowser = { 0x10008D39 };
    8084
     
    135139#endif
    136140
    137 
    138141static void handleMailtoSchemeLX(const QUrl &url)
    139142{
     
    153156    QStringList bccs = bcc.split(QLatin1String(","), QString::SkipEmptyParts);
    154157
    155 
    156158    RSendAs sendAs;
    157159    User::LeaveIfError(sendAs.Connect());
    158160    QAutoClose<RSendAs> sendAsCleanup(sendAs);
    159 
    160161
    161162    CSendAsAccounts* accounts = CSendAsAccounts::NewL();
     
    221222    if (task.Exists()){
    222223        // Switch to existing browser instance
     224        task.BringToForeground();
    223225        HBufC8* param8 = HBufC8::NewLC(buf16->Length());
    224226        param8->Des().Append(buf16->Des());
     
    246248}
    247249
    248 static TDriveUnit exeDrive()
    249 {
    250     RProcess me;
    251     TFileName processFileName = me.FileName();
    252     TDriveUnit drive(processFileName);
    253     return drive;
    254 }
    255 
    256 static TDriveUnit writableExeDrive()
    257 {
    258     TDriveUnit drive = exeDrive();
    259     if(drive.operator TInt() == EDriveZ)
    260         return TDriveUnit(EDriveC);
    261     return drive;
    262 }
    263 
    264 static TPtrC writableDataRoot()
    265 {
    266     TDriveUnit drive = exeDrive();
    267 #ifdef Q_WS_S60
    268     switch(drive.operator TInt()){
    269         case EDriveC:
    270             return PathInfo::PhoneMemoryRootPath();
    271             break;
    272         case EDriveE:
    273             return PathInfo::MemoryCardRootPath();
    274             break;
    275         case EDriveZ:
    276             // It is not possible to write on ROM drive ->
    277             // return phone mem root path instead
    278             return PathInfo::PhoneMemoryRootPath();
    279             break;
    280         default:
    281             return PathInfo::PhoneMemoryRootPath();
    282             break;
    283     }
    284 #else
    285 #warning No fallback implementation of writableDataRoot()
    286     return 0;
    287 #endif
    288 }
    289250
    290251static void openDocumentL(const TDesC& aUrl)
     
    311272}
    312273
    313 #ifdef USE_SCHEMEHANDLER
    314 // The schemehandler component only exist in private SDK. This implementation
    315 // exist here just for convenience in case that we need to use it later on
    316 // The schemehandle based implementation is not yet tested.
    317 
    318 // The biggest advantage of schemehandler is that it can handle
    319 // wide range of schemes and is extensible by plugins
    320 static bool handleUrl(const QUrl &url)
    321 {
    322     if (!url.isValid())
    323         return false;
    324 
    325     QString urlString(url.toString());
    326     TPtrC urlPtr(qt_QString2TPtrC(urlString));
    327     TRAPD( err, handleUrlL(urlPtr));
    328     return err ? false : true;
    329 }
    330 
    331 static void handleUrlL(const TDesC& aUrl)
    332 {
    333     CSchemeHandler* schemeHandler = CSchemeHandler::NewL(aUrl);
    334     CleanupStack::PushL(schemeHandler);
    335     schemeHandler->HandleUrlStandaloneL(); // Process the Url in standalone mode
    336     CleanupStack::PopAndDestroy();
    337 }
    338 static bool launchWebBrowser(const QUrl &url)
    339 {
    340     return handleUrl(url);
    341 }
    342 
    343 static bool openDocument(const QUrl &file)
    344 {
    345     return handleUrl(url);
    346 }
    347 #endif
    348 
    349274static bool launchWebBrowser(const QUrl &url)
    350275{
     
    370295}
    371296
     297#else //USE_SCHEMEHANDLER
     298// The schemehandler component only exist in private SDK. This implementation
     299// exist here just for convenience in case that we need to use it later on
     300// The schemehandle based implementation is not yet tested.
     301
     302// The biggest advantage of schemehandler is that it can handle
     303// wide range of schemes and is extensible by plugins
     304static void handleUrlL(const TDesC& aUrl)
     305{
     306    CSchemeHandler* schemeHandler = CSchemeHandler::NewL(aUrl);
     307    CleanupStack::PushL(schemeHandler);
     308    schemeHandler->HandleUrlStandaloneL(); // Process the Url in standalone mode
     309    CleanupStack::PopAndDestroy();
     310}
     311
     312static bool handleUrl(const QUrl &url)
     313{
     314    if (!url.isValid())
     315        return false;
     316
     317    QString urlString(url.toString());
     318    TPtrC urlPtr(qt_QString2TPtrC(urlString));
     319    TRAPD( err, handleUrlL(urlPtr));
     320    return err ? false : true;
     321}
     322
     323static bool launchWebBrowser(const QUrl &url)
     324{
     325    return handleUrl(url);
     326}
     327
     328static bool openDocument(const QUrl &file)
     329{
     330    return handleUrl(file);
     331}
     332
     333#endif //USE_SCHEMEHANDLER
     334
     335// Common functions to all implementations
     336
     337static TDriveUnit exeDrive()
     338{
     339    RProcess me;
     340    TFileName processFileName = me.FileName();
     341    TDriveUnit drive(processFileName);
     342    return drive;
     343}
     344
     345static TDriveUnit writableExeDrive()
     346{
     347    TDriveUnit drive = exeDrive();
     348    if (drive.operator TInt() == EDriveZ)
     349        return TDriveUnit(EDriveC);
     350    return drive;
     351}
     352
     353static TPtrC writableDataRoot()
     354{
     355    TDriveUnit drive = exeDrive();
     356    switch (drive.operator TInt()){
     357        case EDriveC:
     358            return PathInfo::PhoneMemoryRootPath();
     359            break;
     360        case EDriveE:
     361            return PathInfo::MemoryCardRootPath();
     362            break;
     363        case EDriveZ:
     364            // It is not possible to write on ROM drive ->
     365            // return phone mem root path instead
     366            return PathInfo::PhoneMemoryRootPath();
     367            break;
     368        default:
     369            return PathInfo::PhoneMemoryRootPath();
     370            break;
     371    }
     372}
     373
    372374QString QDesktopServices::storageLocation(StandardLocation type)
    373375{
     
    392394    case MusicLocation:
    393395        path.Append(writableDataRoot());
    394 #ifdef Q_WS_S60
    395396        path.Append(PathInfo::SoundsPath());
    396 #endif
    397397        break;
    398398    case MoviesLocation:
    399399        path.Append(writableDataRoot());
    400 #ifdef Q_WS_S60
    401400        path.Append(PathInfo::VideosPath());
    402 #endif
    403401        break;
    404402    case PicturesLocation:
    405403        path.Append(writableDataRoot());
    406 #ifdef Q_WS_S60
    407404        path.Append(PathInfo::ImagesPath());
    408 #endif
    409405        break;
    410406    case TempLocation:
     
    416412        break;
    417413    case DataLocation:
    418         CEikonEnv::Static()->FsSession().PrivatePath(path);
     414        qt_s60GetRFs().PrivatePath(path);
    419415        path.Insert(0, writableExeDrive().Name());
    420416        break;
    421417    case CacheLocation:
    422         CEikonEnv::Static()->FsSession().PrivatePath(path);
     418        qt_s60GetRFs().PrivatePath(path);
    423419        path.Insert(0, writableExeDrive().Name());
    424420        path.Append(KCacheSubDir);
Note: See TracChangeset for help on using the changeset viewer.