email/alwaysonlineemailplugin/inc/AlwaysOnlineEmailPlugin.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 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 *     Email plugin class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __ALWAYSONLINEEMAILPLUGIN_H__
       
    21 #define __ALWAYSONLINEEMAILPLUGIN_H__
       
    22 
       
    23 
       
    24 #include <e32base.h>    // CBase
       
    25 #include <msvstd.h>
       
    26 #include <msvapi.h>
       
    27 #include <AlwaysOnlineEComInterface.h>
       
    28 #include <AlwaysOnlineManagerClient.h>
       
    29 #include <MuiuMsvSingleOpWatcher.h>
       
    30 #include "AlwaysOnlineEmailAgent.h"
       
    31 
       
    32 //constants
       
    33 
       
    34 /**
       
    35 * class CAlwaysOnlineManagerServer;
       
    36 *
       
    37 */
       
    38 class CEComEmailPlugin : 
       
    39     public CAlwaysOnlineEComInterface, public MMsvSessionObserver
       
    40     {
       
    41     public:
       
    42         /**
       
    43         * NewL
       
    44         * Two phased constructor
       
    45         * @return CEComEmailPlugin*, self pointer
       
    46         */
       
    47         static CEComEmailPlugin* NewL();
       
    48 
       
    49         /**
       
    50         * ~CEComEmailPlugin
       
    51         * Destructor
       
    52         */
       
    53         virtual ~CEComEmailPlugin();
       
    54 
       
    55         /**
       
    56         * HandleServerCommandL
       
    57         * @param TInt, command Id
       
    58         * @param TDesC8*, parameter pack
       
    59         * @return TAny*, return value
       
    60         */
       
    61         virtual TAny* HandleServerCommandL( 
       
    62             TInt    aCommand, 
       
    63             TDesC8* aParameters );
       
    64 
       
    65         
       
    66     private:
       
    67         /**
       
    68         * CEComEmailPlugin
       
    69         */
       
    70         CEComEmailPlugin();
       
    71 
       
    72         /**
       
    73         * ConstructL
       
    74         * Second phase constructor
       
    75         */
       
    76         void ConstructL();
       
    77 
       
    78         /**
       
    79         * ActivateOnlineMailboxesL
       
    80         */
       
    81         void ActivateOnlineMailboxesL();
       
    82 
       
    83         /**
       
    84         * Turn mailbox on/off, depending on the parameter
       
    85         * @since Series60 2.6
       
    86         * @param aParameters Parameter to 
       
    87         * @param aSetState Turn mailbox on/off
       
    88         * @return KErrNone, if dispatching is ok
       
    89         */
       
    90         void HandleCmdMailboxL( 
       
    91             const TInt    aCommand,
       
    92             const TDesC8* aParameters );       
       
    93 
       
    94     public: //from MMsvSessionObserver
       
    95 
       
    96         /**
       
    97         * HandleSessionEventL
       
    98         * @param TMsvSessionEvent, session event
       
    99         * @param TAny* parameter 1
       
   100         * @param TAny* parameter 2
       
   101         * @param TAny* parameter 3
       
   102         */
       
   103         void HandleSessionEventL(
       
   104             TMsvSessionEvent    aEvent, 
       
   105             TAny*               aArg1, 
       
   106             TAny*               /*aArg2*/, 
       
   107             TAny*               /*aArg3*/);
       
   108 
       
   109 
       
   110         /**
       
   111         * static function for CPeriodic timer to start message server 
       
   112         * session after server termination
       
   113         * Calls LaunchSession function.
       
   114         * @since Series60 2.6
       
   115         * @param aSelf: pointer to CEComEmailPlugin object
       
   116         * @return error code
       
   117         */
       
   118         static TInt LaunchMsvSession( TAny* aSelf );
       
   119 
       
   120     private:
       
   121 
       
   122         /**
       
   123         * Tries to launch session and mail agents by calling 
       
   124         * ActivateOnlineMailboxesL function max 20 times.
       
   125         * If successfull deletes iSessionStarter
       
   126         * @since Series60 2.6
       
   127         * @return leave code trapped from function call ActivateOnlineMailboxesL.
       
   128         */
       
   129         TInt LaunchSession();
       
   130 
       
   131         /**
       
   132         * Deletes iSession and iEmailAgent and starts iSessionStarter
       
   133         * @since Series60 2.6
       
   134         */
       
   135         void HandleSessionTerminatedL();
       
   136 
       
   137         /**
       
   138         * Makes basic system health checks. Will initalize session and agent if 
       
   139         * they are not already initialized.
       
   140         * @since Series60 2.6
       
   141         */
       
   142         void VerifyPluginHealthL();
       
   143 
       
   144         //data
       
   145     private:
       
   146         CMsvSession*                iSession;
       
   147         CAlwaysOnlineEmailAgent*    iEmailAgent;
       
   148         TInt                        iError;
       
   149         TBool                       iPluginStarted;
       
   150         CPeriodic*                  iSessionStarter;
       
   151         TInt                        iLaunchCounter;
       
   152     };//CEComEmailPlugin
       
   153 
       
   154 #endif
       
   155 //EOF