metadataengine/server/src/mdsdbconnectionpool.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 26 Jan 2010 12:13:20 +0200
changeset 1 acef663c1218
parent 0 c53acadfccc6
permissions -rw-r--r--
Revision: 201001 Kit: 201004

/*
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implementations of methods for connection pool*
*/

// INCLUDE FILES
#include "mdsdbconnectionpool.h"
#include "mdssqliteconnection.h"
#include "mdsindexer.h"
#include "mdccommon.h"
#include "mdccommon.pan"

void MMdSDbConnectionPool::DisconnectAll()
	{
	iConnection->CloseDb();
	iDBValid = EFalse;
	}
        
void MMdSDbConnectionPool::ConnectAllL()
	{
	if ( iConnection && !iDBValid )
		{
		iConnection->OpenDbL( KMdsSqlDbDefaultName );
		iDBValid = ETrue;

	    MMdSIndexer::StartIndexL();
		}
	else
		{
		User::Leave( KErrBadHandle );
		}
	}

void MMdSDbConnectionPool::SetDefaultDB( CMdSSqLiteConnection* aConnection )
	{
   	iConnection = aConnection;
	}

CMdSSqLiteConnection& MMdSDbConnectionPool::GetDefaultDBL()
	{
	__ASSERT_DEBUG( iConnection, User::Panic( _L("Incorrect DB connection"), KErrArgument ) );
	if ( !iConnection || !iDBValid )
		{
		User::Leave( KErrBadHandle );
		}
   	return *iConnection;
	}

//----------------------------------------------
// INITIALIZE STATIC DATA
//----------------------------------------------

CMdSSqLiteConnection* MMdSDbConnectionPool::iConnection = NULL;
TBool MMdSDbConnectionPool::iDBValid = EFalse;