emailservices/emailserver/cmailhandlerplugin/src/PSSubscriber.cpp
changeset 0 8466d47a6819
child 10 f5907b1a1053
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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 *       Subscriber class for Publish & Subsribe events
       
    16 */
       
    17 
       
    18 #include <e32svr.h>
       
    19 
       
    20 #include "PSSubscriber.h"
       
    21 #include "PSSubscribeHandler.h"
       
    22 #include "emailtrace.h"
       
    23 
       
    24 // ----------------------------------------------------------------------------
       
    25 // CPSSubscriber::NewL()
       
    26 // ----------------------------------------------------------------------------
       
    27 CPSSubscriber* CPSSubscriber::NewL( MPSSubscribeHandler& aPropertyResponder, const TUid& aCategory, TUint aKey )
       
    28     {
       
    29     FUNC_LOG;
       
    30     CPSSubscriber* self = new(ELeave) CPSSubscriber( aPropertyResponder, aCategory, aKey );
       
    31     CleanupStack::PushL( self );
       
    32     self->ConstructL();
       
    33     CleanupStack::Pop(); //self
       
    34     return self;
       
    35     }
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // CPSSubscriber::ConstructL()
       
    39 // ----------------------------------------------------------------------------
       
    40 void CPSSubscriber::ConstructL()
       
    41     {
       
    42     FUNC_LOG;
       
    43     CActiveScheduler::Add( this );
       
    44     TInt ret = iProperty.Attach( iCategory, iKey );
       
    45     INFO_1("iProperty.Attach, ret == %d", ret);
       
    46     }
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // CPSSubscriber::Subscribe()
       
    50 // ----------------------------------------------------------------------------
       
    51 void CPSSubscriber::Subscribe()
       
    52     {
       
    53     FUNC_LOG;
       
    54     if ( !IsActive() )
       
    55         {
       
    56         iProperty.Cancel();
       
    57         iProperty.Subscribe( iStatus );
       
    58         SetActive();
       
    59         }
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // CPSSubscriber::CPSSubscriber()
       
    64 // ----------------------------------------------------------------------------
       
    65 CPSSubscriber::CPSSubscriber( MPSSubscribeHandler& aPropertyResponder, const TUid& aCategory, TUint aKey ) :
       
    66     CActive( EPriorityStandard ),
       
    67     iPropertyResponder( aPropertyResponder ),
       
    68     iCategory( aCategory),
       
    69     iKey( aKey )
       
    70     {
       
    71     }
       
    72 
       
    73 // ----------------------------------------------------------------------------
       
    74 // CPSSubscriber::RunL()
       
    75 // ----------------------------------------------------------------------------
       
    76 void CPSSubscriber::RunL()
       
    77     {
       
    78     FUNC_LOG;
       
    79     Subscribe();
       
    80     iPropertyResponder.HandlePropertyChangedL( iCategory, iKey );
       
    81     }
       
    82 
       
    83 // ----------------------------------------------------------------------------
       
    84 // CPSSubscriber::DoCancel()
       
    85 // ----------------------------------------------------------------------------
       
    86 void CPSSubscriber::DoCancel()
       
    87     {
       
    88     FUNC_LOG;
       
    89     iProperty.Cancel();
       
    90     }
       
    91 
       
    92 // ----------------------------------------------------------------------------
       
    93 // CPSSubscriber::RunError()
       
    94 // ----------------------------------------------------------------------------
       
    95 TInt CPSSubscriber::RunError( TInt aError )
       
    96     {
       
    97     FUNC_LOG;
       
    98     return aError;
       
    99     }
       
   100 
       
   101 // ----------------------------------------------------------------------------
       
   102 // CPSSubscriber::~CPSSubscriber()
       
   103 // ----------------------------------------------------------------------------
       
   104 CPSSubscriber::~CPSSubscriber()
       
   105     {
       
   106     FUNC_LOG;
       
   107     Cancel();
       
   108     iProperty.Close();
       
   109     }