metadataengine/client/src/mdesessionstartupao.cpp
changeset 0 c53acadfccc6
child 19 82c0024438c8
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  MdE session startup active object*
       
    15 */
       
    16 
       
    17 // INCLUDE FILES
       
    18 #include "mdesessionstartupao.h"
       
    19 
       
    20 #include "mdeenginesession.h"
       
    21 #include "mdesessionimpl.h"
       
    22 
       
    23 // ========================= MEMBER FUNCTIONS ==================================
       
    24 
       
    25 CMdESessionStartupAO* CMdESessionStartupAO::NewL(
       
    26     CMdESessionImpl& aSessionImpl, RMdEEngineSession& aSession )
       
    27     {
       
    28     CMdESessionStartupAO* self = 
       
    29     	CMdESessionStartupAO::NewLC( aSessionImpl, aSession );
       
    30     CleanupStack::Pop( self );
       
    31     return self;
       
    32     }
       
    33 
       
    34 CMdESessionStartupAO* CMdESessionStartupAO::NewLC(
       
    35     CMdESessionImpl& aSessionImpl, RMdEEngineSession& aSession )
       
    36     {
       
    37     CMdESessionStartupAO* self =
       
    38         new ( ELeave ) CMdESessionStartupAO( aSessionImpl, aSession );
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     return self;
       
    42     }
       
    43 
       
    44 CMdESessionStartupAO::CMdESessionStartupAO(
       
    45     CMdESessionImpl& aSessionImpl, RMdEEngineSession& aSession )
       
    46     : CActive( CActive::EPriorityStandard )
       
    47     , iSessionImpl( aSessionImpl )
       
    48     , iSession( aSession )
       
    49     {
       
    50     CActiveScheduler::Add( this );
       
    51     
       
    52     iState = EStartupOpenServer;
       
    53     }
       
    54 
       
    55 void CMdESessionStartupAO::ConstructL()
       
    56     {
       
    57 	SetActive();
       
    58 	TRequestStatus* status = &iStatus;
       
    59 	User::RequestComplete( status, KErrNone );
       
    60     }
       
    61 
       
    62 CMdESessionStartupAO::~CMdESessionStartupAO()
       
    63     {
       
    64     Cancel(); // Causes call to DoCancel()
       
    65     }
       
    66 
       
    67 void CMdESessionStartupAO::DoCancel()
       
    68     {
       
    69     iSession.OpenCancel( iStatus );
       
    70     }
       
    71 
       
    72 void CMdESessionStartupAO::RunL()
       
    73     {
       
    74     const TInt status = iStatus.Int();
       
    75     
       
    76     switch ( iState )
       
    77         {
       
    78         case EStartupOpenServer:
       
    79         	{
       
    80         	iSession.OpenL( iStatus );
       
    81 
       
    82 			iState = EStartupConnect;
       
    83 
       
    84         	SetActive();
       
    85 
       
    86         	break;
       
    87         	}
       
    88         case EStartupConnect:
       
    89         	{
       
    90         	iSession.ConnectL();
       
    91 
       
    92 			iState = EStartupLoadSchema;
       
    93 
       
    94 			SetActive();
       
    95 			TRequestStatus* status = &iStatus;
       
    96 			User::RequestComplete( status, KErrNone );
       
    97 
       
    98             break;
       
    99             }
       
   100         case EStartupLoadSchema:
       
   101         	{
       
   102         	iSessionImpl.DoLoadSchemaL();
       
   103 
       
   104 			iState = EStartupNotifyClient;
       
   105 
       
   106 			SetActive();
       
   107 			TRequestStatus* status = &iStatus;
       
   108 			User::RequestComplete( status, KErrNone );
       
   109 
       
   110         	break;
       
   111         	}
       
   112         case EStartupNotifyClient:
       
   113         	{
       
   114         	iSessionImpl.NotifySessionOpened( KErrNone );
       
   115 
       
   116         	break;
       
   117         	}
       
   118        	default:
       
   119        		{
       
   120        		User::Leave( KErrUnknown );
       
   121        		break;
       
   122        		}
       
   123         }
       
   124     }
       
   125 
       
   126 TInt CMdESessionStartupAO::RunError(TInt aError)
       
   127     {
       
   128     iSessionImpl.NotifyError( aError );
       
   129 
       
   130     return KErrNone;
       
   131     }