IMPSengine/imapi/Inc/loginmngr.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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: Class for handling the login issues.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef IMAPI_LOGINMANAGER_H
       
    21 #define IMAPI_LOGINMANAGER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <impsaccesscli.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class MLoginObserver;
       
    28 class CImConnectionImpl;
       
    29 //class TImpsCspIdentifier;
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34 *  Handles the login issues to WV server
       
    35 *
       
    36 *  @lib
       
    37 *  @since S60 2.6
       
    38 */
       
    39 class CLoginManager : public CActive,
       
    40             public MImpsAccessHandler2,
       
    41             public MImpsErrorHandler2,
       
    42             public MImpsStatusHandler
       
    43 
       
    44     {
       
    45     public:  // Constructors and destructor
       
    46 
       
    47         /**
       
    48         * Two-phased constructor.
       
    49         */
       
    50         static CLoginManager* NewL(
       
    51             RImpsEng& aEngine,
       
    52             CImConnectionImpl& aConnection );
       
    53 
       
    54         /**
       
    55         * Destructor.
       
    56         */
       
    57         virtual ~CLoginManager();
       
    58 
       
    59     public: // New functions
       
    60 
       
    61         /**
       
    62         * Starts the login sequence to WV server
       
    63         * @since S60 2.6
       
    64         * @param aObserver Observer of the completion
       
    65         * @return
       
    66         */
       
    67         TInt StartLogin( MLoginObserver* aObserver );
       
    68 
       
    69         /**
       
    70         * Cancels the login
       
    71         * @since S60 2.6
       
    72         */
       
    73         void CancelLogin( );
       
    74 
       
    75         /**
       
    76         * Is the LoginManager logged in
       
    77         * @since S60 2.6
       
    78         * @param
       
    79         * @return
       
    80         */
       
    81         TBool IsLoggedIn() const;
       
    82 
       
    83         /**
       
    84         * Returns the current state of the IMPS engine
       
    85         * @since S60 2.6
       
    86         * @param
       
    87         * @return
       
    88         */
       
    89         TImpsServiceStatus EngineStatus() const;
       
    90 
       
    91     public: // from MImpsAccessHandler2
       
    92 
       
    93         void HandleLoginL(
       
    94             TInt aId,
       
    95             TImpsCspIdentifier& aCspId );
       
    96 
       
    97         void HandleLoginCancelL(
       
    98             TInt aCancelledOpId,
       
    99             TImpsCspIdentifier& aCspId );
       
   100 
       
   101         void HandleLogoutL(
       
   102             TInt aId,
       
   103             TImpsCspIdentifier& aCspId );
       
   104 
       
   105 //        void HandleLoginStatusL(
       
   106 //            TInt aId,
       
   107 //            TInt aStatus,
       
   108 //            TBool aIsLoggedIn
       
   109 //            );
       
   110 
       
   111         void HandleNbrSessionsL(
       
   112             TInt aId,
       
   113             TInt aNbr,
       
   114             TImpsCspIdentifier& aCspId
       
   115         );
       
   116 
       
   117         void HandleErrorL(
       
   118             TInt                 aStatus,
       
   119             TInt                 aOpId,
       
   120             const TDesC*         aDescription,
       
   121             const CImpsDetailed* aDetailedRes,
       
   122             TImpsCspIdentifier&  aCspId );
       
   123 
       
   124     public: // from MImpsStatusHandler
       
   125         void HandleStatusChangeL( TImpsServiceStatus aStatus );
       
   126 
       
   127     protected:  // New functions
       
   128 
       
   129         /**
       
   130         * Notifies the login observers
       
   131         * @since 2.6
       
   132         * @param aError the error code
       
   133         */
       
   134         void NotifyObserver( TInt aError );
       
   135 
       
   136     protected:  // From CActive
       
   137         void RunL();
       
   138 
       
   139         void DoCancel();
       
   140 
       
   141         TInt RunError( TInt aError );
       
   142 
       
   143     private:
       
   144 
       
   145         /**
       
   146         * C++ default constructor.
       
   147         */
       
   148         CLoginManager( RImpsEng& aEngine, CImConnectionImpl& aConnection );
       
   149 
       
   150         /**
       
   151         * By default Symbian 2nd phase constructor is private.
       
   152         */
       
   153         void ConstructL();
       
   154 
       
   155     private:     // Data
       
   156         // Internal state enum of the class
       
   157         enum TState
       
   158             {
       
   159             EInitializing = 0,
       
   160             ELoggingIn,
       
   161             EFinishing,
       
   162             EReady
       
   163             };
       
   164 
       
   165         TState                          iState; // Internal state
       
   166         TBool                           iLoggedIn; // Is the object logged in
       
   167         RImpsAccessClient2              iAccessClient; // IMPS access client
       
   168         RImpsEng&                       iEngine; // Reference to the IMPS engine
       
   169         TImpsServiceStatus              iEngineState; // ImpsEngine State
       
   170 
       
   171         MLoginObserver*                 iObserver;
       
   172         CImConnectionImpl&              iConnection;
       
   173 
       
   174     };
       
   175 
       
   176 
       
   177 
       
   178 // CLASS DECLARATION
       
   179 
       
   180 /**
       
   181 *  Login observer interface
       
   182 *
       
   183 *  @lib
       
   184 *  @since S60 2.6
       
   185 */
       
   186 
       
   187 class MLoginObserver
       
   188     {
       
   189     public:
       
   190         /**
       
   191         * This is called when login is complete
       
   192         * @since S60 2.6
       
   193         * @param aErrorCode Error status of the operation
       
   194         */
       
   195         virtual void HandleLogin( const TInt aErrorCode ) = 0;
       
   196 
       
   197         /**
       
   198         * This is called when logout even is received
       
   199         * @since S60 2.6
       
   200         */
       
   201         virtual void HandleNotLogged() = 0;
       
   202     };
       
   203 
       
   204 #endif      // IMAPI_LOGINMANAGER_H   
       
   205 
       
   206 // End of File