metadataengine/server/src/mdsdbconnectionpool.cpp
changeset 0 c53acadfccc6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/metadataengine/server/src/mdsdbconnectionpool.cpp	Mon Jan 18 20:34:07 2010 +0200
@@ -0,0 +1,65 @@
+/*
+* 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;