ipsservices/ipssosplugin/src/ipsplgpropertywatcher.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2008 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: This file implements class CIpsPlgPropertyWatcher.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "ipsplgheaders.h"
       
    21 
       
    22 // ----------------------------------------------------------------------------
       
    23 // class CIpsPlgPropertyWatcher
       
    24 // ----------------------------------------------------------------------------
       
    25 
       
    26 // ----------------------------------------------------------------------------
       
    27 // ----------------------------------------------------------------------------
       
    28 CIpsPlgPropertyWatcher* CIpsPlgPropertyWatcher::NewL( 
       
    29     TInt aPriority, 
       
    30     CIpsPlgEventHandler& aEventHandler )
       
    31     {
       
    32     FUNC_LOG;
       
    33     CIpsPlgPropertyWatcher* self = new( 
       
    34         ELeave ) CIpsPlgPropertyWatcher( aPriority, aEventHandler );
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop( self );
       
    38     return self;
       
    39     }
       
    40 
       
    41 // ----------------------------------------------------------------------------
       
    42 // ----------------------------------------------------------------------------
       
    43 CIpsPlgPropertyWatcher::CIpsPlgPropertyWatcher( 
       
    44     TInt aPriority, 
       
    45     CIpsPlgEventHandler& aEventHandler )
       
    46     : CActive (aPriority), iEventHandler( aEventHandler )
       
    47     {
       
    48     FUNC_LOG;
       
    49     }
       
    50 
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // ----------------------------------------------------------------------------
       
    54 CIpsPlgPropertyWatcher::~CIpsPlgPropertyWatcher()
       
    55     {
       
    56     FUNC_LOG;
       
    57     Cancel(); 
       
    58     iProperty.Close();
       
    59     }
       
    60 
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // ----------------------------------------------------------------------------
       
    64 void CIpsPlgPropertyWatcher::ConstructL()
       
    65     {
       
    66     FUNC_LOG;
       
    67     CActiveScheduler::Add(this);
       
    68 
       
    69     User::LeaveIfError( iProperty.Attach( KIpsPlgPropertyCatUid,
       
    70             KIPSSosEventPropertyKey ) );
       
    71     StartWatch();
       
    72     }
       
    73 
       
    74 // ----------------------------------------------------------------------------
       
    75 // ----------------------------------------------------------------------------
       
    76 void CIpsPlgPropertyWatcher::StartWatch()
       
    77     {
       
    78     FUNC_LOG;
       
    79     iProperty.Subscribe( iStatus );
       
    80     SetActive();
       
    81     }
       
    82 
       
    83 // ----------------------------------------------------------------------------
       
    84 // ----------------------------------------------------------------------------
       
    85 void CIpsPlgPropertyWatcher::DoCancel()
       
    86     {
       
    87     FUNC_LOG;
       
    88     iProperty.Cancel();
       
    89     }
       
    90 
       
    91 // ----------------------------------------------------------------------------
       
    92 // ----------------------------------------------------------------------------
       
    93 void CIpsPlgPropertyWatcher::RunL()
       
    94     {
       
    95     FUNC_LOG;
       
    96     TPckgBuf<TIpsPlgPropertyEvent> event;
       
    97     TInt error = iProperty.Get( KIpsPlgPropertyCatUid,
       
    98             KIPSSosEventPropertyKey, event );
       
    99     
       
   100     if ( error == KErrNone )
       
   101         {
       
   102         TRAP_IGNORE( iEventHandler.NotifyPropertyEventL( event() ) );
       
   103         }
       
   104     
       
   105     StartWatch();
       
   106     }
       
   107