browserutilities/schemehandler/SchemeDispatcher/src/BaseHandler.cpp
changeset 0 dd21522fd290
child 25 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *      Implementation of Scheme handler interface implementation for file:// scheme
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "BaseHandler.h"
       
    24 #include "BrowserTelService.h"
       
    25 #include "SchemeDispLogger.h"
       
    26 #include <e32base.h>
       
    27 #include <aknquerydialog.h>
       
    28 #include <stringloader.h>
       
    29 #include <bautils.h>
       
    30 #include <EscapeUtils.h>
       
    31 #include <BrowserUiSDKCRKeys.h>
       
    32 #include <centralrepository.h>
       
    33 
       
    34 #include <apgcli.h>
       
    35 #include <apparc.h>
       
    36 
       
    37 #include <e32std.h>
       
    38 #include <s32mem.h>
       
    39 
       
    40 // ================= CONSTANTS =======================
       
    41 
       
    42 
       
    43 // ================= MEMBER FUNCTIONS =======================
       
    44 
       
    45 
       
    46 // ---------------------------------------------------------
       
    47 // CBaseHandler::CBaseHandler()
       
    48 // ---------------------------------------------------------
       
    49 //
       
    50 CBaseHandler::CBaseHandler() : CSchemeHandler()
       
    51 	{
       
    52 	iSchemeDoc = NULL;
       
    53 	}
       
    54 
       
    55 // ---------------------------------------------------------
       
    56 // CCtiHandler::~CCtiHandler()
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 CBaseHandler::~CBaseHandler()
       
    60 	{
       
    61 	delete iParsedUrl;
       
    62 	}
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------
       
    66 // CBaseHandler::ConstructL()
       
    67 // ---------------------------------------------------------
       
    68 //
       
    69 void CBaseHandler::BaseConstructL( const TDesC& aUrl )
       
    70 	{
       
    71 	CLOG_ENTERFN( "CBaseHandler::BaseConstructL()" );
       
    72 
       
    73     iParsedUrl = EscapeUtils::EscapeDecodeL( aUrl );
       
    74 
       
    75 	CLOG_LEAVEFN( "CBaseHandler::BaseConstructL()" );
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CBaseHandler::Observer()
       
    80 // ---------------------------------------------------------
       
    81 //
       
    82 void CBaseHandler::Observer( MAknServerAppExitObserver* aSchemeDoc )
       
    83 	{
       
    84 	iSchemeDoc = aSchemeDoc;
       
    85 	}
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // CBaseHandler::RemoveSchemeFromUrlL()
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 TPtrC CBaseHandler::RemoveSchemeFromUrlL( const TDesC& aScheme )
       
    92 	{
       
    93 	/* Serach the beginning of the Url */
       
    94 	TInt schPos;
       
    95     schPos = iParsedUrl->Des().FindF( aScheme );
       
    96     if( schPos == KErrNotFound )
       
    97         {
       
    98         User::Leave( KErrNotFound );
       
    99         }
       
   100 	
       
   101 	/* Get the Url without scheme */
       
   102     TPtrC path = iParsedUrl->Des().Right
       
   103         ( iParsedUrl->Des().Length() - ( schPos + aScheme.Length()) );
       
   104 
       
   105 	if( 0 == path.Length() )
       
   106 		{
       
   107 		User::Leave( KErrArgument );
       
   108 		}
       
   109 
       
   110 	return path;
       
   111 	}
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 // CBaseHandler::ErrorHandler
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void CBaseHandler::ErrorHandlerL( TInt aErrorCode )
       
   118     {
       
   119     TInt errCode = aErrorCode;
       
   120     switch( aErrorCode )
       
   121         {
       
   122          /* There was no error */
       
   123         case KErrNone:
       
   124             return;
       
   125         /* to be shown note */
       
   126         case KErrInvocationError:
       
   127         case KErrNoCallActive:
       
   128         case KErrUserNoAnswer:
       
   129         case KErrNoService:
       
   130         case KErrUserBusy:
       
   131         case KErrPBPhoneBookFull:
       
   132         case KErrPBWriteError:
       
   133         case KErrPBNumberTooLong:
       
   134         case KErrPBNameTooLong:
       
   135         case KErrUnspecified:
       
   136         case KErrCancel:
       
   137             {
       
   138             errCode = KErrCancel;
       
   139             }
       
   140             break;
       
   141         default:
       
   142             break;
       
   143         }
       
   144     User::Leave( errCode );
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------
       
   148 // CBaseHandler::ReadSdConfirmDtmValueL
       
   149 // ---------------------------------------------------------
       
   150 //
       
   151 TBool CBaseHandler::ReadSdConfirmDtmfValueL()
       
   152     {
       
   153     CRepository* repository = CRepository::NewL( KCRUidBrowser );
       
   154     TInt retVal = 0;  
       
   155     repository->Get( KBrowserConfirmDTMFSending, retVal );    
       
   156     delete repository;
       
   157     return retVal;
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------
       
   161 // CBaseHandler::LaunchSchemeAppWithCommandLineL
       
   162 // ---------------------------------------------------------
       
   163 //
       
   164 void CBaseHandler::LaunchSchemeAppWithCommandLineL()
       
   165     {
       
   166     // Try launching...
       
   167     RApaLsSession   appArcSession;
       
   168     User::LeaveIfError( appArcSession.Connect() );
       
   169     CleanupClosePushL<RApaLsSession>( appArcSession );
       
   170     TThreadId dummyId;
       
   171 
       
   172     TApaAppInfo aInfo;
       
   173     appArcSession.GetAppInfo( aInfo, KUidSchemeApp );
       
   174 
       
   175     CApaCommandLine* cmdLine = CApaCommandLine::NewL();
       
   176     CleanupStack::PushL( cmdLine );
       
   177     cmdLine->SetDocumentNameL( *iParsedUrl );
       
   178     cmdLine->SetCommandL( EApaCommandCreate );
       
   179     cmdLine->SetExecutableNameL( aInfo.iFullName );
       
   180 
       
   181     // Get the whole parameter list and put to the command line
       
   182     if ( iParamList )
       
   183         {
       
   184         TInt size = iParamList->Size();
       
   185         CBufFlat* store = CBufFlat::NewL( size );
       
   186         CleanupStack::PushL( store );
       
   187 	    RBufWriteStream outStream;
       
   188 		outStream.Open( *store );
       
   189         CleanupClosePushL<RBufWriteStream>( outStream );
       
   190 		iParamList->ExternalizeL( outStream );
       
   191         cmdLine->SetTailEndL( store->Ptr( 0 ) );
       
   192         CleanupStack::PopAndDestroy( 2 );  // store, close outStream
       
   193         }
       
   194 
       
   195     User::LeaveIfError( appArcSession.StartApp( *cmdLine,dummyId) );
       
   196     CLOG_WRITE( "Launched SchemeApp succesfully" )
       
   197   
       
   198     CleanupStack::PopAndDestroy( 2 ); // close appArcSession, cmdLine
       
   199     }