taskswitcher/client/s60/src/tstaskmonitorclientimpl.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 
       
    18 #include <e32base.h>
       
    19 
       
    20 #include "tstaskmonitorclientimpl.h"
       
    21 #include "tstaskmonitorobserver.h"
       
    22 
       
    23 CTsTaskMonitorClientImpl* CTsTaskMonitorClientImpl::NewL()
       
    24 {
       
    25     CTsTaskMonitorClientImpl* self = NewLC();
       
    26     CleanupStack::Pop(self);
       
    27     return self;
       
    28 }
       
    29 
       
    30 CTsTaskMonitorClientImpl* CTsTaskMonitorClientImpl::NewLC()
       
    31 {
       
    32     CTsTaskMonitorClientImpl* self = new (ELeave) CTsTaskMonitorClientImpl;
       
    33     CleanupStack::PushL(self);
       
    34     self->ConstructL();
       
    35     return self;
       
    36 }
       
    37 
       
    38 CTsTaskMonitorClientImpl::CTsTaskMonitorClientImpl() : CActive(CActive::EPriorityStandard)
       
    39 {
       
    40     CActiveScheduler::Add(this);
       
    41 }
       
    42 
       
    43 CTsTaskMonitorClientImpl::~CTsTaskMonitorClientImpl()
       
    44 {
       
    45     Cancel();
       
    46     iSession.Close();
       
    47 }
       
    48 
       
    49 void CTsTaskMonitorClientImpl::ConstructL()
       
    50 {
       
    51     User::LeaveIfError(iSession.Connect());
       
    52 }
       
    53 
       
    54 
       
    55 HBufC8* CTsTaskMonitorClientImpl::TasksContentLC()
       
    56 {
       
    57     return iSession.TasksContentLC();
       
    58 }
       
    59 
       
    60 void CTsTaskMonitorClientImpl::Subscribe(MTsTaskMonitorObserver& aObserver)
       
    61 {
       
    62     Cancel();
       
    63     iObserver = &aObserver;
       
    64     iSession.Subscribe(iStatus);
       
    65     SetActive();
       
    66 }
       
    67 
       
    68 void CTsTaskMonitorClientImpl::CancelSubscribe()
       
    69 {
       
    70     Cancel();
       
    71 }
       
    72 
       
    73 void CTsTaskMonitorClientImpl::OpenTask(const TDesC8 &key)
       
    74 {
       
    75     iSession.OpenTask(key);
       
    76 }
       
    77 
       
    78 void CTsTaskMonitorClientImpl::CloseTask(const TDesC8 &key)
       
    79 {
       
    80     iSession.CloseTask(key);
       
    81 }
       
    82 
       
    83 void CTsTaskMonitorClientImpl::RunL()
       
    84 {
       
    85     if (iStatus == KErrNone && iObserver) {
       
    86         iSession.Subscribe(iStatus);
       
    87         SetActive();
       
    88         iObserver->HandleRunningAppChange();
       
    89     }
       
    90 }
       
    91 
       
    92 void CTsTaskMonitorClientImpl::DoCancel()
       
    93 {
       
    94     iSession.CancelSubscribe();
       
    95 }