metadataengine/server/src/mdsdbconnectionpool.cpp
changeset 0 c53acadfccc6
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Implementations of methods for connection pool*
       
    15 */
       
    16 
       
    17 // INCLUDE FILES
       
    18 #include "mdsdbconnectionpool.h"
       
    19 #include "mdssqliteconnection.h"
       
    20 #include "mdsindexer.h"
       
    21 #include "mdccommon.h"
       
    22 #include "mdccommon.pan"
       
    23 
       
    24 void MMdSDbConnectionPool::DisconnectAll()
       
    25 	{
       
    26 	iConnection->CloseDb();
       
    27 	iDBValid = EFalse;
       
    28 	}
       
    29         
       
    30 void MMdSDbConnectionPool::ConnectAllL()
       
    31 	{
       
    32 	if ( iConnection && !iDBValid )
       
    33 		{
       
    34 		iConnection->OpenDbL( KMdsSqlDbDefaultName );
       
    35 		iDBValid = ETrue;
       
    36 
       
    37 	    MMdSIndexer::StartIndexL();
       
    38 		}
       
    39 	else
       
    40 		{
       
    41 		User::Leave( KErrBadHandle );
       
    42 		}
       
    43 	}
       
    44 
       
    45 void MMdSDbConnectionPool::SetDefaultDB( CMdSSqLiteConnection* aConnection )
       
    46 	{
       
    47    	iConnection = aConnection;
       
    48 	}
       
    49 
       
    50 CMdSSqLiteConnection& MMdSDbConnectionPool::GetDefaultDBL()
       
    51 	{
       
    52 	__ASSERT_DEBUG( iConnection, User::Panic( _L("Incorrect DB connection"), KErrArgument ) );
       
    53 	if ( !iConnection || !iDBValid )
       
    54 		{
       
    55 		User::Leave( KErrBadHandle );
       
    56 		}
       
    57    	return *iConnection;
       
    58 	}
       
    59 
       
    60 //----------------------------------------------
       
    61 // INITIALIZE STATIC DATA
       
    62 //----------------------------------------------
       
    63 
       
    64 CMdSSqLiteConnection* MMdSDbConnectionPool::iConnection = NULL;
       
    65 TBool MMdSDbConnectionPool::iDBValid = EFalse;