browserutilities/schemehandler/SchemeDispatcher/src/MmsHandler.cpp
changeset 0 dd21522fd290
child 26 cb62a4f66ebe
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 mms:// scheme
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "MmsHandler.h"
       
    24 #include "SchemeDispLogger.h"
       
    25 #include <ECom.h>		// For REComSession
       
    26 #include <eikenv.h>
       
    27 #include <DocumentHandler.h>
       
    28 #include <apgcli.h>
       
    29 #include <apparc.h>
       
    30 #include <eikdoc.h>
       
    31 #include <eikproc.h>
       
    32 #include <f32file.h>
       
    33 #include <AknLaunchAppService.h>
       
    34 
       
    35 // ================= CONSTANTS =======================
       
    36 
       
    37 LOCAL_C const TUid KUidMediaPlayer = { 0x10005A3E };
       
    38 
       
    39 // ================= MEMBER FUNCTIONS =======================
       
    40 
       
    41 // ---------------------------------------------------------
       
    42 // CMmsHandler::NewL()
       
    43 // ---------------------------------------------------------
       
    44 //
       
    45 CMmsHandler* CMmsHandler::NewL( const TDesC& aUrl )
       
    46 	{
       
    47 	CLOG_ENTERFN( "CMmsHandler::NewL()" );
       
    48 
       
    49 	CMmsHandler* self=new(ELeave) CMmsHandler();
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL( aUrl );
       
    52 	CleanupStack::Pop(self);
       
    53 
       
    54 	CLOG_LEAVEFN( "CMmsHandler::NewL()" );
       
    55 
       
    56 	return self;
       
    57 	}
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CMmsHandler::~CMmsHandler()
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 CMmsHandler::~CMmsHandler()
       
    64 	{
       
    65 	CLOG_ENTERFN( "CMmsHandler::~CMmsHandler()" );
       
    66 
       
    67 	if(iDoc != NULL)
       
    68 		{
       
    69 		CEikProcess*  hostProcess = CEikonEnv::Static()->Process();
       
    70 		hostProcess->DestroyDocument(iDoc);
       
    71 		iDoc = NULL;
       
    72 		}
       
    73 		
       
    74 	if( iLaunchAppService )
       
    75 		{
       
    76 		delete iLaunchAppService;
       
    77 		}		
       
    78 
       
    79 	CLOG_LEAVEFN( "CMmsHandler::~CMmsHandler()" );
       
    80 	}
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CMmsHandler::CMmsHandler()
       
    84 // ---------------------------------------------------------
       
    85 //
       
    86 CMmsHandler::CMmsHandler() : CBaseHandler()
       
    87 	{
       
    88 	// Deliberately do nothing here : See ConstructL() for initialisation completion.
       
    89 	}
       
    90 
       
    91 // ---------------------------------------------------------
       
    92 // CMmsHandler::ConstructL()
       
    93 // ---------------------------------------------------------
       
    94 //
       
    95 void CMmsHandler::ConstructL( const TDesC& aUrl )
       
    96 	{
       
    97 	BaseConstructL( aUrl );
       
    98 
       
    99 	iSync = EFalse;
       
   100 	}
       
   101 
       
   102 // ---------------------------------------------------------
       
   103 // CMmsHandler::HandleUrlEmbeddedL()
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 void CMmsHandler::HandleUrlEmbeddedL()
       
   107     {
       
   108     CLOG_ENTERFN( "CMmsHandler::HandleUrlEmbeddedL()" );
       
   109 
       
   110     /* Launch the appropriate application in embedded mode */
       
   111     
       
   112     CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();
       
   113 
       
   114     TAiwVariant filename( iParsedUrl );
       
   115     TAiwGenericParam param( EGenericParamFile, filename );
       
   116     paramList->AppendL( param );    
       
   117 
       
   118     // Allow save among Options
       
   119     TBool allowSave( ETrue );
       
   120     TAiwVariant allowSaveVariant( allowSave );
       
   121     TAiwGenericParam genericParamAllowSave
       
   122                      ( EGenericParamAllowSave, allowSaveVariant );
       
   123     paramList->AppendL( genericParamAllowSave );
       
   124 
       
   125     // If iParamList is not empty, let's get it and attach to the paramlist 
       
   126     if (iParamList)
       
   127     {
       
   128     	paramList->AppendL(*iParamList);  
       
   129     }
       
   130 
       
   131 
       
   132     iLaunchAppService = 
       
   133         CAknLaunchAppService::NewL( KUidMediaPlayer, this, paramList );
       
   134     iSync = ETrue;
       
   135     iWait.Start();
       
   136     CleanupStack::PopAndDestroy( paramList );   
       
   137 
       
   138     CLOG_LEAVEFN( "CMmsHandler::HandleUrlEmbeddedL()" );
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------
       
   142 // CMmsHandler::HandleUrlStandaloneL()
       
   143 // ---------------------------------------------------------
       
   144 //
       
   145 void CMmsHandler::HandleUrlStandaloneL()
       
   146 	{
       
   147 	CLOG_ENTERFN( "CMmsHandler::HandleUrlStandaloneL()" );
       
   148 
       
   149 	RApaLsSession appArcSession;
       
   150 	User::LeaveIfError( appArcSession.Connect() );
       
   151 	TThreadId id;
       
   152 
       
   153 	appArcSession.StartDocument( iParsedUrl->Des(), KUidMediaPlayer , id );
       
   154 
       
   155 	appArcSession.Close();
       
   156 
       
   157 	CLOG_LEAVEFN( "CMmsHandler::HandleUrlStandaloneL()" );
       
   158 	}
       
   159 		
       
   160 // ---------------------------------------------------------
       
   161 // CMmsHandler::HandleServerAppExit()
       
   162 // ---------------------------------------------------------
       
   163 //
       
   164 void CMmsHandler::HandleServerAppExit(TInt aReason)
       
   165 	{
       
   166 	CLOG_ENTERFN( "CMmsHandler::HandleServerAppExit" );
       
   167 
       
   168 	if( iSync )
       
   169 		{
       
   170 	    if( iWait.IsStarted() )
       
   171             {
       
   172             iWait.AsyncStop();   // stop the wait loop.                                  
       
   173             }                    // Now DoMakeCallL will return
       
   174 		}
       
   175 
       
   176 	if( NULL != iSchemeDoc )
       
   177 		{
       
   178 	    iSchemeDoc->HandleServerAppExit( aReason );
       
   179 		}
       
   180 
       
   181 	CLOG_LEAVEFN( "CMmsHandler::HandleServerAppExit" );	
       
   182 	}
       
   183