Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // DBMS server proxy database
24 SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version of the method.
25 Standard phase-one factory method for creation of CDbsDatabase instances.
26 @param aDbs A reference to the client side DBMS session object
27 @param aDatabase Database file path
28 @param aFormat Database format string
29 @return A pointer to teh created CDbsDatabase instance.
30 @leave System-wide error code, including KErrNoMemory
32 CDbsDatabase* CDbsDatabase::NewL(const RDbs& aDbs, const TDesC& aDatabase, const TDesC& aFormat)
34 CDbsDatabase* self=new(ELeave) CDbsDatabase;
35 CleanupStack::PushL(self);
37 TIpcArgs args(&aDatabase,&aFormat,TIpcArgs::ENothing,NULL);
38 self->ConstructL(aDbs,args); // two phase construction
39 CleanupStack::Pop(); // self
44 SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version of the method.
45 Standard phase-two construction method for creation of CDbsDatabase instances.
46 @param aDbs A reference to the client side DBMS session object
47 @param aArgs A reference to the packed parameters needed for the database instance creation.
48 @leave System-wide error code, including KErrNoMemory
50 void CDbsDatabase::ConstructL(const RDbs& aDbs, TIpcArgs& aArgs)
52 iObject.OpenL(aDbs,EDbsOpenDatabase,aArgs);
56 CDbsDatabase::~CDbsDatabase()
61 TInt CDbsDatabase::Destroy()
63 return iObject.SendReceive(EDbsDatabaseDestroy);
66 TInt CDbsDatabase::Begin()
68 return iObject.SendReceive(EDbsDatabaseBegin);
71 TInt CDbsDatabase::Commit()
73 return iObject.SendReceive(EDbsDatabaseCommit);
76 void CDbsDatabase::Rollback()
78 iObject.SendReceive(EDbsDatabaseRollback);
81 TInt CDbsDatabase::Property(CDbDatabase::TProperty aProperty)
83 return iObject.SendReceive(EDbsDatabaseProperty,TIpcArgs(aProperty));
86 void CDbsDatabase::CreateTableL(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey)
88 TPtrC8 colset(TDbsParam::PrepareLC(aColSet));
89 TIpcArgs m(&aName,&colset,0);
93 primary.Set(TDbsParam::PrepareLC(*aPrimaryKey));
96 iObject.SendReceiveL(EDbsDatabaseCreateTable,m);
98 CleanupStack::PopAndDestroy(); // primary
99 CleanupStack::PopAndDestroy(); // colset
102 void CDbsDatabase::TablesL(CDbTableNames& aNames)
105 RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseTables,m));
107 CleanupStack::PopAndDestroy(); // dbsbuf
110 void CDbsDatabase::ColumnsL(CDbColSet& aColSet,const TDesC& aName)
113 RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseColumns,m));
115 CleanupStack::PopAndDestroy();
118 void CDbsDatabase::IndexesL(CDbIndexNames& aNames,const TDesC& aTable)
121 RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseIndexes,m));
123 CleanupStack::PopAndDestroy(); // dbsbuf
126 void CDbsDatabase::KeysL(CDbKey& aKey,const TDesC& aName,const TDesC& aTable)
128 TIpcArgs args(&aName,&aTable);
129 RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseKeys,args));
131 CleanupStack::PopAndDestroy(); // dbsbuf
134 CDbNotifier* CDbsDatabase::OpenNotifierL()
136 return CDbsNotifier::NewL(iObject);
139 CDbIncremental* CDbsDatabase::OpenUtilityL(CDbDatabase::TUtility aType,TInt& aStep)
141 TIpcArgs args(aType);
142 return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenUtility,args,aStep);
145 CDbIncremental* CDbsDatabase::OpenDropTableL(const TDesC& aTable,TInt& aStep)
147 TIpcArgs args(&aTable);
148 return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenDropTable,args,aStep);
151 CDbIncremental* CDbsDatabase::OpenAlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep)
153 TPtrC8 colset(TDbsParam::PrepareLC(aNewDef));
154 TIpcArgs args(&aTable,&colset);
155 CDbIncremental* inc=CDbsIncremental::NewL(iObject,EDbsDatabaseOpenAlterTable,args,aStep);
156 CleanupStack::PopAndDestroy(); // colset
160 CDbIncremental* CDbsDatabase::OpenCreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep)
162 TPtrC8 key(TDbsParam::PrepareLC(aKey));
163 TIpcArgs args(&aName,&aTable,&key);
164 CDbIncremental* inc=CDbsIncremental::NewL(iObject,EDbsDatabaseOpenCreateIndex,args,aStep);
165 CleanupStack::PopAndDestroy(); // key
169 CDbIncremental* CDbsDatabase::OpenDropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep)
171 TIpcArgs args(&aName,&aTable);
172 return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenDropIndex,args,aStep);
175 CDbIncremental* CDbsDatabase::OpenExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit)
177 TIpcArgs args(&aSql,aComparison);
178 return CDbsIncremental::NewL(iObject,EDbsDatabaseExecute,args,aInit);
181 CDbCursor* CDbsDatabase::PrepareViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess aAccess)
183 const TDesC& des = aQuery.Query();
184 TPckgC<TDbWindow> pckg(aWindow);
185 TIpcArgs args(&des,aQuery.Comparison()|(aAccess<<8),&pckg);
186 return CDbsCursor::NewL(iObject,EDbsDatabasePrepareView,args);
189 CDbCursor* CDbsDatabase::OpenTableL(const TDesC& aName,RDbRowSet::TAccess aAccess)
191 TIpcArgs args(&aName,aAccess);
192 return CDbsCursor::NewL(iObject,EDbsDatabaseOpenTable,args);