taskswitcher/server/src/hsrunningappsession.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     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 #include "hsrunningappsession.h"
       
    18 #include "tstaskmonitorglobals.h"
       
    19 
       
    20 #include "hsdataobservertask.h"
       
    21 #include "hsdataprovidertask.h"
       
    22 #include "tsdatatask.h"
       
    23 
       
    24 // -----------------------------------------------------------------------------
       
    25 //
       
    26 // -----------------------------------------------------------------------------
       
    27 //
       
    28 CRunningAppSession::CRunningAppSession(MTsDataObserverStorage& observerStorage,
       
    29                                        const MTsDataProvider& dataProvider)
       
    30 :
       
    31     mObserverStorage(observerStorage),
       
    32     mDataProvider(dataProvider)
       
    33 {
       
    34     // No implementation required
       
    35 }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CRunningAppSession::~CRunningAppSession()
       
    42 {
       
    43     mObserverStorage.Invalidate(this);
       
    44     mDataStorages.Close();
       
    45 }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CRunningAppSession* CRunningAppSession::NewL(MTsDataObserverStorage& observerStorage, 
       
    52                                              const MTsDataProvider& dataProvider,
       
    53                                              const TArray<MTsDataStorage*> &dataStorages)
       
    54 {
       
    55     CRunningAppSession* self = new (ELeave) CRunningAppSession(observerStorage, 
       
    56                                                                dataProvider);
       
    57     CleanupStack::PushL(self);
       
    58     self->ConstructL(dataStorages);
       
    59     CleanupStack::Pop(self);
       
    60     return self;
       
    61 }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 void CRunningAppSession::ConstructL(const TArray<MTsDataStorage*> &dataStorages)
       
    68 {
       
    69     for (TInt iter(0); iter < dataStorages.Count(); ++iter) {
       
    70         mDataStorages.AppendL(dataStorages[iter]);
       
    71     }
       
    72 }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CRunningAppSession::ServiceL(const RMessage2& message)
       
    79 {
       
    80     switch (message.Function()) {
       
    81     case SubscribeRunningAppChanges:
       
    82         CHsDataObserverTask::ExecuteLD(mObserverStorage, message);
       
    83         break;
       
    84     
       
    85     case CancelSubscribeRunningAppChanges:
       
    86         mObserverStorage.Cancel(message);
       
    87         break;
       
    88     
       
    89     case GetRunningAppInfo:
       
    90     case FlushData:
       
    91         HsDataProviderTask::ExecuteL(mDataProvider, message);
       
    92         break;
       
    93         
       
    94     case RegisterScreenshotMessage:
       
    95     case UnregisterScreenshotMessage:
       
    96     case VisibilityChange:
       
    97     case OpenTaskMessage:
       
    98     case CloseTaskMessage:
       
    99         TsDataTask::ExecuteL(mDataStorages.Array(), message);
       
   100         break;
       
   101     
       
   102     default:
       
   103         message.Complete(CServer2::EBadMessageNumber);
       
   104     }
       
   105 }