ginebra2/emulator/BrowserMainS60.cpp
changeset 3 0954f5dd2cd0
child 12 afcd8e6d025b
equal deleted inserted replaced
1:b0dd75e285d2 3:0954f5dd2cd0
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 *
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 *
       
    20 */
       
    21 
       
    22 #include <coemain.h>
       
    23 #include "BrowserMainS60.h"
       
    24 
       
    25 /*
       
    26  * Handles calls from other apps to QDesktopServices.openUrl
       
    27  */
       
    28 
       
    29 // This function handles when an app calls QDesktopServices.openUrl when the browser is already started
       
    30 MCoeMessageObserver::TMessageResponse BrowserMainAppUiS60::HandleMessageL(TUint32 aClientHandleOfTargetWindowGroup, TUid aMessageUid, const TDesC8 &aMessageParameters)
       
    31 {
       
    32     QString url = QString::fromUtf8((const char *)aMessageParameters.Ptr(), aMessageParameters.Length());
       
    33     //qDebug() << "BrowserMainAppUiS60::HandleMessageL " <<
       
    34     //        QString::fromUtf16(aMessageUid.Name().Ptr(), aMessageUid.Name().Length()) << ", " << url;
       
    35     // I have no idea if the browser is thread-safe and what will happen when it receives this signal when it's in the middle of something else - mm
       
    36     GinebraBrowser *urlHandler = ((BrowserMainApplicationS60 *)Application())->UrlHandler();
       
    37     if (urlHandler != 0) {
       
    38         urlHandler->queueOpenUrl(url);
       
    39     }
       
    40     return(EMessageHandled);
       
    41 }
       
    42 
       
    43 //    void HandleApplicationSpecificEventL(TInt aType, const TWsEvent &aEvent)
       
    44 //    {
       
    45 //        qDebug() << "BrowserMainAppUiS60::HandleApplicationSpecificEvent " << aType << ", " << aEvent.EventData();
       
    46 //    }
       
    47 
       
    48 //    void OpenFileL(const TDesC& aFilename)
       
    49 //    {
       
    50 //        qDebug() << "BrowserMainAppUiS60::OpenFileL fn - " << QString::fromUtf16(aFilename.Ptr(), aFilename.Length());
       
    51 //    }
       
    52 
       
    53 //    void HandleCommandL(TInt aCommand)
       
    54 //    {
       
    55 //        qDebug() << "BrowserMainAppUiS60::HandleCommandL - " << aCommand;
       
    56 //    }
       
    57 
       
    58 // These functions handle when an app calls QDesktopServices.openUrl when the browser isn't already started
       
    59 TBool BrowserMainAppUiS60::ProcessCommandParametersL(TApaCommand aCommand,TFileName& aFilename)
       
    60 {
       
    61     //qDebug() << "BrowserMainAppUiS60:: ProcessCmdParms2 - " << aCommand << ", " << QString::fromUtf16(aFilename.Ptr(), aFilename.Length());
       
    62 //        ((RealBrowserApp *)QApplication::instance())->setInitialUrl(QString::fromUtf16(aFilename.Ptr(), aFilename.Length()));
       
    63     ((BrowserMainApplicationS60 *)Application())->SetInitialUrl(QString::fromUtf16(aFilename.Ptr(), aFilename.Length()));
       
    64     return ETrue;
       
    65 }
       
    66 
       
    67 TBool BrowserMainAppUiS60::ProcessCommandParametersL(TApaCommand aCommand,TFileName& aFilename, const TDesC8& aTail)
       
    68 {
       
    69     //qDebug()
       
    70     //       << "BrowserMainAppUiS60:: ProcessCmdParms3 - " << aCommand << ", "
       
    71     //       << QString::fromUtf16(aFilename.Ptr(), aFilename.Length()) << ", "
       
    72     //       << QString::fromUtf8((const char*)aTail.Ptr(), aTail.Length());
       
    73     ((BrowserMainApplicationS60 *)Application())->SetInitialUrl(QString::fromUtf16(aFilename.Ptr(), aFilename.Length()));
       
    74 //        ((RealBrowserApp *)QApplication::instance())->setInitialUrl(QString::fromUtf16(aFilename.Ptr(), aFilename.Length()));
       
    75     return ETrue;
       
    76 }
       
    77 
       
    78 CEikAppUi *BrowserMainDocumentS60::CreateAppUiL()
       
    79 {
       
    80 //    qDebug() << "BrowserMainDocumentS60::CreateAppUiL";
       
    81     return new (ELeave) BrowserMainAppUiS60;
       
    82 }
       
    83 //    CFileStore* OpenFileL(TBool aDoOpen, const TDesC &aFilename, RFs &aFs)
       
    84 //    {
       
    85 //        qDebug() << "BrowserMainDocumentS60::OpenFileL fn - " << QString::fromUtf16(aFilename.Ptr(), aFilename.Length());
       
    86 //        return 0;
       
    87 //    }
       
    88 //    void OpenFileL(CFileStore*& aFileStore, RFile& aFile)
       
    89 //    {
       
    90 //        aFileStore = NULL; //So the other OpenFileL version is not called
       
    91 //        TFileName name;
       
    92 //        aFile.FullName(name);
       
    93 //        qDebug() << "BrowserMainDocumentS60::OpenFileL fs - " << QString::fromUtf16(name.Ptr(), name.Length());
       
    94 //    }
       
    95 
       
    96 CApaDocument *BrowserMainApplicationS60::CreateDocumentL()
       
    97 {
       
    98 //    qDebug() << "BrowserMainApplicationS60::CreateDocumentL";
       
    99     return new (ELeave) BrowserMainDocumentS60(*this);
       
   100 }
       
   101 
       
   102 BrowserMainApplicationS60::BrowserMainApplicationS60() : QS60MainApplication(), urlHandler(0)
       
   103 {
       
   104 //        CApaCommandLine* commandLine = 0;
       
   105 //        TInt err = CApaCommandLine::GetCommandLineFromProcessEnvironment(commandLine);
       
   106 //        qDebug() << "BrowserMainApplicationS60 - " << QString::fromUtf16(commandLine->DocumentName().Ptr(), commandLine->DocumentName().Length());
       
   107 //        qDebug() << "BrowserMainApplicationS60";
       
   108 //    initialUrl = 0;
       
   109 }
       
   110 
       
   111 void BrowserMainApplicationS60::setUrlHandler(GinebraBrowser *uh)
       
   112 {
       
   113     urlHandler = uh;
       
   114 }