ipsservices/ipssosaoplugin/src/IpsSosAOPluginEComInterface.cpp
changeset 0 8466d47a6819
child 24 d189ee25cf9d
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 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 *     Main plugin class
       
    16 *
       
    17 */
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include <e32base.h>
       
    21 
       
    22 #include <AlwaysOnlineManagerCommon.h>
       
    23 #include <AlwaysOnlineManagerClient.h>
       
    24 
       
    25 #include "IpsSosAOPluginEComInterface.h"
       
    26 #include "IpsSosAOSmtpSendWatcher.h"
       
    27 #include "IpsSosAOImapPopLogic.h"
       
    28 
       
    29 const TInt KIpsSosAOPluginCommandBufferGra = 1;
       
    30 
       
    31 
       
    32 // ----------------------------------------------------------------------------
       
    33 // ----------------------------------------------------------------------------
       
    34 //
       
    35 CIpsSosAOPluginEComInterface::CIpsSosAOPluginEComInterface( ) : 
       
    36     CAlwaysOnlineEComInterface(), 
       
    37     iBufferedAOCommands( KIpsSosAOPluginCommandBufferGra )
       
    38     {
       
    39     FUNC_LOG;
       
    40     }
       
    41 
       
    42 // ----------------------------------------------------------------------------
       
    43 // ----------------------------------------------------------------------------
       
    44 //
       
    45 EXPORT_C CIpsSosAOPluginEComInterface* CIpsSosAOPluginEComInterface::NewL( )
       
    46     {
       
    47     FUNC_LOG;
       
    48     CIpsSosAOPluginEComInterface* self = new (
       
    49             ELeave ) CIpsSosAOPluginEComInterface();
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop( self );
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ----------------------------------------------------------------------------
       
    57 // ----------------------------------------------------------------------------
       
    58 //
       
    59 void CIpsSosAOPluginEComInterface::ConstructL()
       
    60     {
       
    61     FUNC_LOG;
       
    62     iSession = CMsvSession::OpenAsyncL( *this );
       
    63     }
       
    64 
       
    65 // ----------------------------------------------------------------------------
       
    66 // ----------------------------------------------------------------------------
       
    67 //
       
    68 void CIpsSosAOPluginEComInterface::CompleteConstructL()
       
    69     {
       
    70     FUNC_LOG;
       
    71     iSendWatcher = CIpsSosAOSmtpSendWatcher::NewL( 
       
    72             CActive::EPriorityStandard, *iSession );
       
    73     iImapPopLogic = CIpsSosAOImapPopLogic::NewL( *iSession );
       
    74     
       
    75     // send buffered command at this point when logic objects is created
       
    76     if ( iBufferedAOCommands.Count() > 0 )
       
    77         {
       
    78         for ( TInt i = 0; i < iBufferedAOCommands.Count(); i++ )
       
    79             {
       
    80             HandleServerCommandL( iBufferedAOCommands[i], NULL );
       
    81             }
       
    82         }
       
    83     iBufferedAOCommands.Reset();
       
    84     }
       
    85 
       
    86 // ----------------------------------------------------------------------------
       
    87 // ----------------------------------------------------------------------------
       
    88 //
       
    89 CIpsSosAOPluginEComInterface::~CIpsSosAOPluginEComInterface()
       
    90     {
       
    91     FUNC_LOG;
       
    92     delete iSendWatcher;
       
    93     delete iImapPopLogic;
       
    94     delete iSession;
       
    95     iBufferedAOCommands.Close();
       
    96     }
       
    97     
       
    98 // ----------------------------------------------------------------------------
       
    99 // ----------------------------------------------------------------------------
       
   100 //
       
   101 EXPORT_C TAny* CIpsSosAOPluginEComInterface::HandleServerCommandL( 
       
   102     TInt aCommand, 
       
   103     TDesC8* aParameters )
       
   104     {
       
   105     FUNC_LOG;
       
   106     TInt result = KErrNotSupported;
       
   107     if ( iSendWatcher && iImapPopLogic )
       
   108         {
       
   109         TInt imapPopResult = KErrNone;
       
   110         imapPopResult = iImapPopLogic->HandleAOServerCommandL( aCommand, aParameters );
       
   111         
       
   112         //don't care about smtp problems
       
   113         result = imapPopResult;
       
   114         }
       
   115     else
       
   116         {
       
   117         // buffer important commands if iSmtpLogic and iImapPopLogic 
       
   118         // is no created. This needed because plugin is created in 
       
   119         // boot and there might be situation where AO server is created
       
   120         // before MSV server
       
   121         if ( aCommand == EAOManagerPluginStart
       
   122              || aCommand == EAOManagerPluginStop
       
   123              || aCommand == EAOManagerNWOpsNotAllowed
       
   124              || aCommand == EAOManagerNWOpsAllowed
       
   125              || aCommand == EAOManagerStartedRoaming
       
   126              || aCommand == EAOManagerStoppedRoaming
       
   127              || aCommand == EAOManagerDiskSpaceAboveCritical
       
   128              || aCommand == EAOManagerDiskSpaceBelowCritical )
       
   129             {
       
   130             iBufferedAOCommands.AppendL( aCommand );
       
   131             result = KErrNone;
       
   132             }
       
   133         }
       
   134     return reinterpret_cast<TAny*>( result );
       
   135     }
       
   136 
       
   137 
       
   138 // ----------------------------------------------------------------------------
       
   139 // ----------------------------------------------------------------------------    
       
   140 void CIpsSosAOPluginEComInterface::HandleSessionEventL(    
       
   141     MMsvSessionObserver::TMsvSessionEvent aEvent,
       
   142     TAny* aArg1, 
       
   143     TAny* aArg2, 
       
   144     TAny* aArg3 )
       
   145     {
       
   146     FUNC_LOG;
       
   147     switch( aEvent )
       
   148         {
       
   149         case EMsvServerReady:
       
   150             CompleteConstructL();
       
   151             break;
       
   152         case EMsvEntriesCreated:
       
   153         case EMsvEntriesChanged:
       
   154         case EMsvEntriesDeleted:
       
   155         case EMsvEntriesMoved:
       
   156             // send only to ImapPopLogic, because
       
   157             // SmtpLogic not need these events
       
   158             iImapPopLogic->HandleMsvSessionEventL( 
       
   159                     aEvent, aArg1, aArg2, aArg3 );
       
   160             break;
       
   161         // handle these so that this process not panic if
       
   162         // CMsvServer panics and restarts
       
   163         case EMsvGeneralError:
       
   164         case EMsvCloseSession:
       
   165         case EMsvServerFailedToStart:
       
   166         case EMsvCorruptedIndexRebuilt:
       
   167         case EMsvServerTerminated:
       
   168             break;
       
   169         // are we intrest about these events at the moment
       
   170         // FSEmail not support msv store changes?
       
   171         case EMsvMtmGroupInstalled:
       
   172         case EMsvMtmGroupDeInstalled:
       
   173         case EMsvMediaChanged:
       
   174         case EMsvMediaUnavailable:
       
   175         case EMsvMediaAvailable:
       
   176         case EMsvMediaIncorrect:
       
   177         case EMsvCorruptedIndexRebuilding:
       
   178         default:
       
   179             break;
       
   180         };
       
   181     }
       
   182 
       
   183 //EOF
       
   184