tstaskmonitor/server/src/hsdataobservertask.cpp
changeset 80 397d00875918
equal deleted inserted replaced
73:4bc7b118b3df 80:397d00875918
       
     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 "hsdataobservertask.h"
       
    19 #include "tstaskmonitorglobals.h"
       
    20 // -----------------------------------------------------------------------------
       
    21 //
       
    22 // -----------------------------------------------------------------------------
       
    23 //
       
    24 CHsDataObserverTask::CHsDataObserverTask(MHsDataObserverStorage& storage, 
       
    25                                          const RMessage2& msg)
       
    26 :
       
    27     mStorage(storage),
       
    28     mMsg(msg)
       
    29 {
       
    30     // No implementation required
       
    31 }
       
    32 
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CHsDataObserverTask::~CHsDataObserverTask()
       
    39 {
       
    40     if (EFalse == mMsg.IsNull()) {
       
    41         mMsg.Complete(mDataChanged ? KErrNone : KErrCancel);
       
    42     }
       
    43 }
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 void CHsDataObserverTask::ExecuteLD(MHsDataObserverStorage& storage,const RMessage2& msg)
       
    49 {
       
    50     CHsDataObserver *self = new (ELeave)CHsDataObserverTask(storage, msg);
       
    51     CleanupStack::PushL(self);
       
    52     storage.PushL(self);
       
    53     CleanupStack::Pop(self);
       
    54 }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 void CHsDataObserverTask::DataChanged()
       
    61 {
       
    62     mDataChanged = ETrue;
       
    63     mStorage.Pop(this);
       
    64     delete this; 
       
    65 }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CHsDataObserverTask::Cancel(const RMessage2& reason)
       
    72 {
       
    73     if (CancelSubscribeRunningAppChanges == reason.Function() &&
       
    74         mMsg.Session() == reason.Session()) {
       
    75         mStorage.Pop(this);
       
    76         delete this;
       
    77    }
       
    78 }