idlefw/plugins/mcsplugin/commonsrc/mcspluginwatcher.cpp
branchRCL_3
changeset 114 a5a39a295112
equal deleted inserted replaced
113:0efa10d348c0 114:a5a39a295112
       
     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:  Menu item operation watcher. 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <mcsmenuoperation.h>
       
    19 #include "mcspluginwatcher.h"
       
    20 #include "../publisher/inc/mcspluginengine.h"
       
    21 
       
    22 // ---------------------------------------------------------------------------
       
    23 // two-phased constructor
       
    24 // ---------------------------------------------------------------------------
       
    25 CMCSPluginWatcher* CMCSPluginWatcher::NewL( const Type& aType )
       
    26 	{
       
    27 	CMCSPluginWatcher* self = new (ELeave) CMCSPluginWatcher( aType );
       
    28 	CleanupStack::PushL( self );
       
    29 	self->ConstructL();
       
    30 	CleanupStack::Pop( self );
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // default constructor
       
    36 // ---------------------------------------------------------------------------
       
    37 CMCSPluginWatcher::CMCSPluginWatcher( const Type& aType )
       
    38 	: CActive( CActive::EPriorityStandard ),
       
    39 	iType( aType )
       
    40     {
       
    41     CActiveScheduler::Add( this );
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // destructor
       
    46 // ---------------------------------------------------------------------------
       
    47 CMCSPluginWatcher::~CMCSPluginWatcher()
       
    48     {
       
    49     Cancel();
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // second phase constructor
       
    54 // ---------------------------------------------------------------------------
       
    55 void CMCSPluginWatcher::ConstructL()
       
    56 	{
       
    57 	
       
    58 	}
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // Watch  Async
       
    62 // ---------------------------------------------------------------------------
       
    63 void CMCSPluginWatcher::Watch( CMenuOperation* aOperation)
       
    64     {
       
    65     __ASSERT_DEBUG( KRequestPending == iStatus.Int(), User::Invariant() );
       
    66     //__ASSERT_DEBUG( !iOperation, User::Invariant() ); 
       
    67     iOperation = aOperation;
       
    68     SetActive();
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // Watch  Async
       
    73 // ---------------------------------------------------------------------------
       
    74 void CMCSPluginWatcher::WatchNotify( MMCSPluginWatcherObserver* aObserver )
       
    75     {
       
    76     __ASSERT_DEBUG( KRequestPending == iStatus.Int(), User::Invariant() );
       
    77     //__ASSERT_DEBUG( !iOperation, User::Invariant() ); 
       
    78     iObserver = aObserver;
       
    79     SetActive();
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // Inherited from CActive class 
       
    84 // ---------------------------------------------------------------------------
       
    85 void CMCSPluginWatcher::RunL()
       
    86     {
       
    87     delete iOperation;
       
    88     iOperation = NULL;  
       
    89     
       
    90     if( iType == ENotify )
       
    91         {
       
    92         iObserver->HandleNotifyL();
       
    93         }
       
    94     
       
    95     //CActiveScheduler::Stop();
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // Inherited from CActive class 
       
   100 // ---------------------------------------------------------------------------
       
   101 void CMCSPluginWatcher::DoCancel()
       
   102     {
       
   103     delete iOperation;
       
   104     iOperation = NULL;
       
   105     }
       
   106 
       
   107 TInt CMCSPluginWatcher::GetStatus()
       
   108     {
       
   109     return iStatus.Int();
       
   110     }
       
   111