ipsservices/ipssosaoplugin/src/IpsSosAOSmtpSendWatcher.cpp
changeset 0 8466d47a6819
child 24 d189ee25cf9d
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: 
       
    15 *     Timer for smtp plugin
       
    16 *
       
    17 */
       
    18 
       
    19 //#include <e32math.h>
       
    20 #include "emailtrace.h"
       
    21 #include <msvapi.h>
       
    22 
       
    23 #include "IpsSosAOSmtpSendWatcher.h"
       
    24 #include "IpsSosAOSmtpAgent.h"
       
    25 
       
    26 #include "ipsplgcommon.h"
       
    27 
       
    28 // ----------------------------------------------------------------------------
       
    29 // ----------------------------------------------------------------------------
       
    30 CIpsSosAOSmtpSendWatcher* CIpsSosAOSmtpSendWatcher::NewL( 
       
    31     TInt aPriority, 
       
    32     CMsvSession& aSession )
       
    33     {
       
    34     FUNC_LOG;
       
    35     CIpsSosAOSmtpSendWatcher* self = new( 
       
    36         ELeave ) CIpsSosAOSmtpSendWatcher( aPriority );
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL( aSession );
       
    39     CleanupStack::Pop( self );
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ----------------------------------------------------------------------------
       
    44 // ----------------------------------------------------------------------------
       
    45 CIpsSosAOSmtpSendWatcher::CIpsSosAOSmtpSendWatcher( 
       
    46     TInt aPriority )
       
    47     : CActive (aPriority)
       
    48     {
       
    49     FUNC_LOG;
       
    50     }
       
    51 
       
    52 
       
    53 // ----------------------------------------------------------------------------
       
    54 // ----------------------------------------------------------------------------
       
    55 CIpsSosAOSmtpSendWatcher::~CIpsSosAOSmtpSendWatcher()
       
    56     {
       
    57     FUNC_LOG;
       
    58     Cancel(); 
       
    59     iProperty.Close();
       
    60     delete iAgent;
       
    61     }
       
    62 
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // ----------------------------------------------------------------------------
       
    66 void CIpsSosAOSmtpSendWatcher::ConstructL( CMsvSession& aSession )
       
    67     {
       
    68     FUNC_LOG;
       
    69     CActiveScheduler::Add(this);
       
    70 
       
    71     User::LeaveIfError( iProperty.Attach( KIpsPlgPropertyCatUid,
       
    72             KIPSSosEventPropertyKey ) );
       
    73     
       
    74     iAgent = CIpsSosAOSmtpAgent::NewL( aSession );
       
    75     StartWatch();
       
    76     }
       
    77 
       
    78 
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // ----------------------------------------------------------------------------
       
    82 void CIpsSosAOSmtpSendWatcher::StartWatch()
       
    83     {
       
    84     FUNC_LOG;
       
    85     iProperty.Subscribe( iStatus );
       
    86     SetActive();
       
    87     
       
    88     }
       
    89 
       
    90 // ----------------------------------------------------------------------------
       
    91 // ----------------------------------------------------------------------------
       
    92 void CIpsSosAOSmtpSendWatcher::DoCancel()
       
    93     {
       
    94     FUNC_LOG;
       
    95     iProperty.Cancel();
       
    96     }
       
    97 
       
    98 
       
    99 // ----------------------------------------------------------------------------
       
   100 // ----------------------------------------------------------------------------
       
   101 void CIpsSosAOSmtpSendWatcher::RunL()
       
   102     {
       
   103     FUNC_LOG;
       
   104     TPckgBuf<TIpsPlgPropertyEvent> ebuf;
       
   105     TInt error = iProperty.Get( KIpsPlgPropertyCatUid,
       
   106             KIPSSosEventPropertyKey, ebuf );
       
   107     
       
   108     TIpsPlgPropertyEvent event = ebuf();
       
   109     
       
   110     if ( event.iEvent == KIPSSosSmtpEmptyOutboxNow )
       
   111         {
       
   112         iAgent->EmptyOutboxNowL( event.iMailbox );
       
   113         }
       
   114     StartWatch();
       
   115     }
       
   116     
       
   117 // ----------------------------------------------------------------------------
       
   118 // ----------------------------------------------------------------------------
       
   119 //
       
   120 TInt CIpsSosAOSmtpSendWatcher::RunError( TInt /* aError */ )
       
   121     {
       
   122     FUNC_LOG;
       
   123     // Just ignore any error and continue without
       
   124     // any handling to allow smooth execution. 
       
   125     StartWatch();
       
   126     return KErrNone;            
       
   127     }
       
   128 
       
   129 
       
   130 //EOF
       
   131