sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // DBMS server proxy database sl@0: // sl@0: // sl@0: sl@0: #include "SD_STD.H" sl@0: sl@0: // Class CDbsDatabase sl@0: sl@0: sl@0: /** sl@0: SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version of the method. sl@0: Standard phase-one factory method for creation of CDbsDatabase instances. sl@0: @param aDbs A reference to the client side DBMS session object sl@0: @param aDatabase Database file path sl@0: @param aFormat Database format string sl@0: @return A pointer to teh created CDbsDatabase instance. sl@0: @leave System-wide error code, including KErrNoMemory sl@0: */ sl@0: CDbsDatabase* CDbsDatabase::NewL(const RDbs& aDbs, const TDesC& aDatabase, const TDesC& aFormat) sl@0: { sl@0: CDbsDatabase* self=new(ELeave) CDbsDatabase; sl@0: CleanupStack::PushL(self); sl@0: sl@0: TIpcArgs args(&aDatabase,&aFormat,TIpcArgs::ENothing,NULL); sl@0: self->ConstructL(aDbs,args); // two phase construction sl@0: CleanupStack::Pop(); // self sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version of the method. sl@0: Standard phase-two construction method for creation of CDbsDatabase instances. sl@0: @param aDbs A reference to the client side DBMS session object sl@0: @param aArgs A reference to the packed parameters needed for the database instance creation. sl@0: @leave System-wide error code, including KErrNoMemory sl@0: */ sl@0: void CDbsDatabase::ConstructL(const RDbs& aDbs, TIpcArgs& aArgs) sl@0: { sl@0: iObject.OpenL(aDbs,EDbsOpenDatabase,aArgs); sl@0: } sl@0: sl@0: sl@0: CDbsDatabase::~CDbsDatabase() sl@0: { sl@0: iObject.Close(); sl@0: } sl@0: sl@0: TInt CDbsDatabase::Destroy() sl@0: { sl@0: return iObject.SendReceive(EDbsDatabaseDestroy); sl@0: } sl@0: sl@0: TInt CDbsDatabase::Begin() sl@0: { sl@0: return iObject.SendReceive(EDbsDatabaseBegin); sl@0: } sl@0: sl@0: TInt CDbsDatabase::Commit() sl@0: { sl@0: return iObject.SendReceive(EDbsDatabaseCommit); sl@0: } sl@0: sl@0: void CDbsDatabase::Rollback() sl@0: { sl@0: iObject.SendReceive(EDbsDatabaseRollback); sl@0: } sl@0: sl@0: TInt CDbsDatabase::Property(CDbDatabase::TProperty aProperty) sl@0: { sl@0: return iObject.SendReceive(EDbsDatabaseProperty,TIpcArgs(aProperty)); sl@0: } sl@0: sl@0: void CDbsDatabase::CreateTableL(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey) sl@0: { sl@0: TPtrC8 colset(TDbsParam::PrepareLC(aColSet)); sl@0: TIpcArgs m(&aName,&colset,0); sl@0: TPtrC8 primary; sl@0: if (aPrimaryKey) sl@0: { sl@0: primary.Set(TDbsParam::PrepareLC(*aPrimaryKey)); sl@0: m.Set(2,&primary); sl@0: } sl@0: iObject.SendReceiveL(EDbsDatabaseCreateTable,m); sl@0: if (aPrimaryKey) sl@0: CleanupStack::PopAndDestroy(); // primary sl@0: CleanupStack::PopAndDestroy(); // colset sl@0: } sl@0: sl@0: void CDbsDatabase::TablesL(CDbTableNames& aNames) sl@0: { sl@0: TIpcArgs m; sl@0: RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseTables,m)); sl@0: in>>aNames; sl@0: CleanupStack::PopAndDestroy(); // dbsbuf sl@0: } sl@0: sl@0: void CDbsDatabase::ColumnsL(CDbColSet& aColSet,const TDesC& aName) sl@0: { sl@0: TIpcArgs m(&aName); sl@0: RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseColumns,m)); sl@0: in>>aColSet; sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: sl@0: void CDbsDatabase::IndexesL(CDbIndexNames& aNames,const TDesC& aTable) sl@0: { sl@0: TIpcArgs m(&aTable); sl@0: RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseIndexes,m)); sl@0: in>>aNames; sl@0: CleanupStack::PopAndDestroy(); // dbsbuf sl@0: } sl@0: sl@0: void CDbsDatabase::KeysL(CDbKey& aKey,const TDesC& aName,const TDesC& aTable) sl@0: { sl@0: TIpcArgs args(&aName,&aTable); sl@0: RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseKeys,args)); sl@0: in>>aKey; sl@0: CleanupStack::PopAndDestroy(); // dbsbuf sl@0: } sl@0: sl@0: CDbNotifier* CDbsDatabase::OpenNotifierL() sl@0: { sl@0: return CDbsNotifier::NewL(iObject); sl@0: } sl@0: sl@0: CDbIncremental* CDbsDatabase::OpenUtilityL(CDbDatabase::TUtility aType,TInt& aStep) sl@0: { sl@0: TIpcArgs args(aType); sl@0: return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenUtility,args,aStep); sl@0: } sl@0: sl@0: CDbIncremental* CDbsDatabase::OpenDropTableL(const TDesC& aTable,TInt& aStep) sl@0: { sl@0: TIpcArgs args(&aTable); sl@0: return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenDropTable,args,aStep); sl@0: } sl@0: sl@0: CDbIncremental* CDbsDatabase::OpenAlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep) sl@0: { sl@0: TPtrC8 colset(TDbsParam::PrepareLC(aNewDef)); sl@0: TIpcArgs args(&aTable,&colset); sl@0: CDbIncremental* inc=CDbsIncremental::NewL(iObject,EDbsDatabaseOpenAlterTable,args,aStep); sl@0: CleanupStack::PopAndDestroy(); // colset sl@0: return inc; sl@0: } sl@0: sl@0: CDbIncremental* CDbsDatabase::OpenCreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep) sl@0: { sl@0: TPtrC8 key(TDbsParam::PrepareLC(aKey)); sl@0: TIpcArgs args(&aName,&aTable,&key); sl@0: CDbIncremental* inc=CDbsIncremental::NewL(iObject,EDbsDatabaseOpenCreateIndex,args,aStep); sl@0: CleanupStack::PopAndDestroy(); // key sl@0: return inc; sl@0: } sl@0: sl@0: CDbIncremental* CDbsDatabase::OpenDropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep) sl@0: { sl@0: TIpcArgs args(&aName,&aTable); sl@0: return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenDropIndex,args,aStep); sl@0: } sl@0: sl@0: CDbIncremental* CDbsDatabase::OpenExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit) sl@0: { sl@0: TIpcArgs args(&aSql,aComparison); sl@0: return CDbsIncremental::NewL(iObject,EDbsDatabaseExecute,args,aInit); sl@0: } sl@0: sl@0: CDbCursor* CDbsDatabase::PrepareViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess aAccess) sl@0: { sl@0: const TDesC& des = aQuery.Query(); sl@0: TPckgC pckg(aWindow); sl@0: TIpcArgs args(&des,aQuery.Comparison()|(aAccess<<8),&pckg); sl@0: return CDbsCursor::NewL(iObject,EDbsDatabasePrepareView,args); sl@0: } sl@0: sl@0: CDbCursor* CDbsDatabase::OpenTableL(const TDesC& aName,RDbRowSet::TAccess aAccess) sl@0: { sl@0: TIpcArgs args(&aName,aAccess); sl@0: return CDbsCursor::NewL(iObject,EDbsDatabaseOpenTable,args); sl@0: }