ipsservices/ipssosaoplugin/src/IpsSosAOBaseAgent.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 *     Contains mailbox specified always online logic
       
    16 *
       
    17 */
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include <e32property.h>
       
    21 
       
    22 #include "ipsplgsosbaseplugin.hrh"
       
    23 
       
    24 #include "IpsSosAOBaseAgent.h"
       
    25 #include "IpsSosAOImapAgent.h"
       
    26 #include "IpsSosAOPopAgent.h"
       
    27 
       
    28 _LIT( KIpsAOPlgPanicLit, "IpsAOPlg");
       
    29 // ----------------------------------------------------------------------------
       
    30 // ----------------------------------------------------------------------------
       
    31 CIpsSosAOBaseAgent* CIpsSosAOBaseAgent::CreateAgentL( 
       
    32         CMsvSession& aSession,
       
    33         MIpsSosAOAgentOperationResponse& aOpResponse,
       
    34         TMsvId aServiceId )
       
    35     {
       
    36     FUNC_LOG;
       
    37     TMsvEntry tentry;
       
    38     TMsvId service;
       
    39     aSession.GetEntry( aServiceId, service, tentry );
       
    40     
       
    41     CIpsSosAOBaseAgent* self = NULL;
       
    42     if ( tentry.iMtm.iUid == KSenduiMtmImap4UidValue )
       
    43         {
       
    44         CIpsSosAOImapAgent* imap = CIpsSosAOImapAgent::NewL( 
       
    45                 aSession,  aOpResponse, aServiceId );
       
    46         self = static_cast<CIpsSosAOBaseAgent*>(imap);
       
    47         self->iMtmType = KSenduiMtmImap4Uid;
       
    48         }
       
    49     else if ( tentry.iMtm.iUid == KSenduiMtmPop3UidValue )
       
    50         {
       
    51         CIpsSosAOPopAgent* pop = CIpsSosAOPopAgent::NewL( 
       
    52                 aSession,  aOpResponse, aServiceId );
       
    53         self = static_cast<CIpsSosAOBaseAgent*>(pop);
       
    54         self->iMtmType = KSenduiMtmPop3Uid;
       
    55         }
       
    56     else
       
    57         {
       
    58         User::Panic( KIpsAOPlgPanicLit, KErrGeneral );
       
    59         }
       
    60     
       
    61     return self;
       
    62     }
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // ----------------------------------------------------------------------------
       
    66 CIpsSosAOBaseAgent::CIpsSosAOBaseAgent() : 
       
    67     CActive( CActive::EPriorityStandard ), iSyncStartedSignaled( EFalse )
       
    68     {
       
    69     FUNC_LOG;
       
    70     }
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // ----------------------------------------------------------------------------
       
    74 CIpsSosAOBaseAgent::~CIpsSosAOBaseAgent()
       
    75     {
       
    76     FUNC_LOG;
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // ----------------------------------------------------------------------------
       
    81 void CIpsSosAOBaseAgent::ClearSignaledFlags()
       
    82     {
       
    83     FUNC_LOG;
       
    84     iSyncStartedSignaled = EFalse;
       
    85     }
       
    86 
       
    87 // ----------------------------------------------------------------------------
       
    88 // ----------------------------------------------------------------------------
       
    89 void CIpsSosAOBaseAgent::SignalSyncStarted( TInt aMailbox )
       
    90     {
       
    91     FUNC_LOG;
       
    92     if ( !iSyncStartedSignaled )
       
    93         {
       
    94         iSyncStartedSignaled = ETrue;
       
    95         SetPropertyEvent( 
       
    96                 KIpsSosEmailSyncStarted, aMailbox, KErrNone );
       
    97         }
       
    98     }
       
    99 
       
   100 // ----------------------------------------------------------------------------
       
   101 // ----------------------------------------------------------------------------       
       
   102 void CIpsSosAOBaseAgent::SignalSyncCompleted( TInt aMailbox, TInt aError )
       
   103     {
       
   104     FUNC_LOG;
       
   105     if ( iSyncStartedSignaled )
       
   106         {
       
   107         SetPropertyEvent( 
       
   108                 KIpsSosEmailSyncCompleted, aMailbox, aError );
       
   109         iSyncStartedSignaled = EFalse;
       
   110         }
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // ----------------------------------------------------------------------------       
       
   115 void CIpsSosAOBaseAgent::SetPropertyEvent( 
       
   116         TInt aEvent, TInt aMailbox, TInt aError )
       
   117     {
       
   118     FUNC_LOG;
       
   119     TInt error = RProperty::Define( 
       
   120             KIpsPlgPropertyCatUid, 
       
   121         KIPSSosEventPropertyKey, RProperty::EByteArray,
       
   122         KAllowAllPolicy,
       
   123         KAllowWriteDeviceDataPolicy );
       
   124     
       
   125     TIpsPlgPropertyEvent pEvent(  aEvent, aMailbox, 
       
   126             GetFSPluginId(), aError );
       
   127     iPropertyBuf = pEvent;
       
   128 
       
   129     // if definition was success
       
   130     if ( error == KErrNone || 
       
   131          error == KErrAlreadyExists || 
       
   132          error == KErrPermissionDenied )
       
   133         {
       
   134         error = RProperty::Set(
       
   135                 KIpsPlgPropertyCatUid, 
       
   136                 KIPSSosEventPropertyKey, iPropertyBuf );
       
   137     
       
   138         }
       
   139     }
       
   140 
       
   141 // ----------------------------------------------------------------------------
       
   142 // ----------------------------------------------------------------------------
       
   143 TBool CIpsSosAOBaseAgent::IsTypeImap4() const
       
   144     {
       
   145     FUNC_LOG;
       
   146     if ( iMtmType.iUid == KSenduiMtmImap4UidValue )
       
   147         {
       
   148         return ETrue;
       
   149         }
       
   150     return EFalse;
       
   151     }
       
   152 
       
   153 // ----------------------------------------------------------------------------
       
   154 // ----------------------------------------------------------------------------
       
   155 TInt CIpsSosAOBaseAgent::GetFSPluginId() const
       
   156     {
       
   157     FUNC_LOG;
       
   158     TInt pluginId = 0;
       
   159     if ( iMtmType.iUid == KSenduiMtmImap4UidValue )
       
   160         {
       
   161         pluginId = IPSSOSIMAP4PLUGIN_IMPLEMENTATION_UID;
       
   162         }
       
   163     else if ( iMtmType.iUid == KSenduiMtmPop3UidValue )
       
   164         {
       
   165         pluginId = IPSSOSPOP3PLUGIN_IMPLEMENTATION_UID;
       
   166         }
       
   167     return pluginId;
       
   168     }
       
   169 
       
   170 // End of file
       
   171