ipsservices/ipssosplugin/src/ipsplgeventtimer.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2006 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 CIpsPlgEventTimer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "emailtrace.h"
       
    21 #include "ipsplgheaders.h"
       
    22 
       
    23 const TInt KIpsEventDelay = 1000000;//1 sec
       
    24 
       
    25 // ----------------------------------------------------------------------------
       
    26 // CIpsPlgEventTimer::NewL()
       
    27 // ----------------------------------------------------------------------------
       
    28 //
       
    29 CIpsPlgEventTimer* CIpsPlgEventTimer::NewL( 
       
    30     CMsvSession& aMsvSession, 
       
    31     TInt aPriority, 
       
    32     TRequestStatus& aObserverRequestStatus,
       
    33     TIpsPlgEvent aEvent, 
       
    34     MFSMailEventObserver& aObserver )
       
    35     {
       
    36     FUNC_LOG;
       
    37     CIpsPlgEventTimer* self = new(ELeave)CIpsPlgEventTimer( 
       
    38         aMsvSession,
       
    39         aPriority,
       
    40         aObserverRequestStatus,
       
    41         aEvent,
       
    42         aObserver );
       
    43 
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     CleanupStack::Pop( self );
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // CIpsPlgEventTimer::CIpsPlgEventTimer()
       
    52 // ----------------------------------------------------------------------------
       
    53 //
       
    54 CIpsPlgEventTimer::CIpsPlgEventTimer(
       
    55     CMsvSession& aMsvSession, 
       
    56     TInt aPriority, 
       
    57     TRequestStatus& aObserverRequestStatus,
       
    58     TIpsPlgEvent aEvent,
       
    59     MFSMailEventObserver& aObserver )
       
    60 : CMsvOperation(aMsvSession, aPriority, aObserverRequestStatus),
       
    61 iEvent( aEvent ),
       
    62 iObserver( aObserver )
       
    63     {
       
    64     FUNC_LOG;
       
    65     }
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // CIpsPlgEventTimer::~CIpsPlgEventTimer()
       
    69 // ----------------------------------------------------------------------------
       
    70 //
       
    71 CIpsPlgEventTimer::~CIpsPlgEventTimer()
       
    72     {
       
    73     FUNC_LOG;
       
    74     Cancel();
       
    75     iTimer.Close();
       
    76     }
       
    77 
       
    78 // ----------------------------------------------------------------------------
       
    79 // CIpsPlgEventTimer::ConstructL()
       
    80 // ----------------------------------------------------------------------------
       
    81 //
       
    82 void CIpsPlgEventTimer::ConstructL()
       
    83     {
       
    84     FUNC_LOG;
       
    85     User::LeaveIfError( iTimer.CreateLocal() );
       
    86     CActiveScheduler::Add(this);
       
    87     
       
    88     After( KIpsEventDelay );
       
    89     }
       
    90 
       
    91 // ----------------------------------------------------------------------------
       
    92 // CIpsPlgEventTimer::ProgressL()
       
    93 // ----------------------------------------------------------------------------
       
    94 //
       
    95 const TDesC8& CIpsPlgEventTimer::ProgressL()
       
    96     {
       
    97     FUNC_LOG;
       
    98     return iProgress;
       
    99     }
       
   100 
       
   101 // ----------------------------------------------------------------------------
       
   102 // CIpsPlgEventTimer::After()
       
   103 // ----------------------------------------------------------------------------
       
   104 //
       
   105 void CIpsPlgEventTimer::After( TTimeIntervalMicroSeconds32 aInterval )
       
   106     {
       
   107     FUNC_LOG;
       
   108     iTimer.After(iStatus, aInterval);
       
   109     SetActive();
       
   110     }
       
   111     
       
   112 // ----------------------------------------------------------------------------
       
   113 // CIpsPlgEventTimer::DoCancel()
       
   114 // ----------------------------------------------------------------------------
       
   115 //
       
   116 void CIpsPlgEventTimer::DoCancel()
       
   117     {
       
   118     FUNC_LOG;
       
   119     iTimer.Cancel();
       
   120     TRequestStatus* status = &iObserverRequestStatus;
       
   121     if ( status && status->Int() == KRequestPending )
       
   122         {
       
   123         User::RequestComplete(status, KErrNone);
       
   124         }
       
   125     }
       
   126 
       
   127 // ----------------------------------------------------------------------------
       
   128 // CIpsPlgEventTimer::RunL()
       
   129 // ----------------------------------------------------------------------------
       
   130 //
       
   131 void CIpsPlgEventTimer::RunL()
       
   132     {
       
   133     FUNC_LOG;
       
   134     if( &iObserver )
       
   135         {        
       
   136         iObserver.EventL( 
       
   137             iEvent.iEvent, 
       
   138             iEvent.iAccountId, 
       
   139             iEvent.iArg1,
       
   140             iEvent.iArg2,
       
   141             iEvent.iArg3 );
       
   142         }
       
   143     
       
   144     TRequestStatus* status = &iObserverRequestStatus;
       
   145     User::RequestComplete(status, KErrNone);
       
   146     }
       
   147 
       
   148 
       
   149 
       
   150     
       
   151 //EOF    
       
   152