mmsharing/mmshengine/src/musengsessionmanager.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
child 35 6c57ef9392d2
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
     1 /*
       
     2 * Copyright (c) 2009 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 "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 *
       
    16 */
       
    17 
       
    18 #include "musengsessionmanager.h"
       
    19 #include "musenglivesession.h"
       
    20 #include "musengclipsession.h"
       
    21 #include "musengreceivesession.h"
       
    22 #include "musengtwowaysession.h"
       
    23 #include "musengtwowayrecvsession.h"
       
    24 #include "mussessionproperties.h"
       
    25 #include "muspropertywatch.h"
       
    26 #include <lcsession.h>
       
    27 #include <lcuiprovider.h>
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CMusEngSessionManager* CMusEngSessionManager::NewL()
       
    34     {
       
    35     CMusEngSessionManager* self = new( ELeave )CMusEngSessionManager();
       
    36     CleanupStack::PushL( self );
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop( self );
       
    39     return self;
       
    40     }
       
    41         
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 // -----------------------------------------------------------------------------
       
    45 //  
       
    46 CMusEngSessionManager::~CMusEngSessionManager()
       
    47     {
       
    48     delete iUseCaseWatch;
       
    49     delete iSession;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CMusEngSessionManager::CMusEngSessionManager()
       
    57     {
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 void CMusEngSessionManager::ConstructL()
       
    65     {
       
    66     TInt useCase;
       
    67     User::LeaveIfError( RProperty::Get( NMusSessionApi::KCategoryUid, 
       
    68                                         NMusSessionApi::KUseCase, 
       
    69                                         useCase ) );    
       
    70     iSession = CreateMusSessionL( 
       
    71         static_cast< MultimediaSharing::TMusUseCase >( useCase ) );
       
    72     
       
    73     iUseCaseWatch = CMusPropertyWatch::NewL( 
       
    74         *this, NMusSessionApi::KCategoryUid, NMusSessionApi::KUseCase );
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 MLcSession& CMusEngSessionManager::Session()
       
    82     {
       
    83     return *iSession;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // If usecase changes while background startup is active, client is
       
    88 // notified about change by bringing it to foreground and changing current
       
    89 // active session. Old session is terminated immediately after notification.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CMusEngSessionManager::PropertyChanged( 
       
    93     const TUint /*aKey*/, 
       
    94     const TInt aValue )
       
    95     {
       
    96     MUS_LOG1( "mus: [ENGINE] -> CMusEngSessionManager::PropertyChanged, val:%d", 
       
    97               aValue )
       
    98     
       
    99     if ( iSession->IsBackgroundStartup() && aValue != iCurrentUseCase )
       
   100         {
       
   101         MUS_LOG( "mus: [ENGINE]    Usecase changed!" )
       
   102         MLcUiProvider* uiProvider = iSession->LcUiProvider();
       
   103         if ( uiProvider )
       
   104             {
       
   105             CMusEngMceSession* newSession = NULL;
       
   106             TRAP_IGNORE( newSession = CreateMusSessionL( 
       
   107                     static_cast< MultimediaSharing::TMusUseCase >( aValue ) ) );
       
   108             if ( newSession )
       
   109                 {
       
   110                 MUS_LOG( "mus: [ENGINE]     Set new active session" )
       
   111                 CMusEngMceSession* oldSession = iSession;
       
   112                 iSession = newSession;
       
   113                 iSession->SetForegroundStatus( ETrue );
       
   114                 uiProvider->HandleForegroundStatus( ETrue );
       
   115                 delete oldSession;
       
   116                 }
       
   117             }
       
   118         }
       
   119     
       
   120     MUS_LOG( "mus: [ENGINE] <- CMusEngSessionManager::PropertyChanged" )
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 void CMusEngSessionManager::HandlePropertyError( const TInt /*aReason*/ )
       
   128     {
       
   129     // NOP
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TBool CMusEngSessionManager::IsFeatureSupported( TLcFeature aLcFeature )
       
   137     {
       
   138     return ( aLcFeature == ELcShowInvitingNote ||
       
   139              aLcFeature == ELcShowWaitingNote ||
       
   140              aLcFeature == ELcShowAcceptQuery );
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 CMusEngMceSession* CMusEngSessionManager::CreateMusSessionL( 
       
   148     MultimediaSharing::TMusUseCase aUseCase )
       
   149     {
       
   150     CMusEngMceSession* session = NULL;
       
   151     switch ( aUseCase ) 
       
   152         {
       
   153         case MultimediaSharing::EMusLiveVideo:
       
   154             {
       
   155             session = CMusEngLiveSession::NewL();
       
   156             break;
       
   157             }
       
   158         case MultimediaSharing::EMusClipVideo:
       
   159             {
       
   160             session = CMusEngClipSession::NewL();
       
   161             break;
       
   162             }            
       
   163         case MultimediaSharing::EMusReceive:
       
   164             {
       
   165             session = CMusEngReceiveSession::NewL();
       
   166             break;
       
   167             }
       
   168         case MultimediaSharing::EMusTwoWayVideo:    
       
   169             {
       
   170             session = CMusEngTwoWaySession::NewL();
       
   171             break;
       
   172             }
       
   173         case MultimediaSharing::EMusReceiveTwoWayVideo:    
       
   174             {
       
   175             session = CMusEngTwoWayRecvSession::NewL();
       
   176             break;
       
   177             }
       
   178         default:
       
   179             User::Leave( KErrNotSupported );
       
   180             break;
       
   181         }
       
   182     iCurrentUseCase = aUseCase;
       
   183     return session;
       
   184     }
       
   185 
       
   186 // End of File