os/persistentdata/persistentstorage/dbms/sdbms/SD_DBS.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// DBMS server proxy database
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "SD_STD.H"
sl@0
    19
sl@0
    20
// Class CDbsDatabase
sl@0
    21
sl@0
    22
sl@0
    23
/**
sl@0
    24
SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version of the method.
sl@0
    25
Standard phase-one factory method for creation of CDbsDatabase instances.
sl@0
    26
@param aDbs A reference to the client side DBMS session object
sl@0
    27
@param aDatabase Database file path
sl@0
    28
@param aFormat Database format string
sl@0
    29
@return A pointer to teh created CDbsDatabase instance.
sl@0
    30
@leave System-wide error code, including KErrNoMemory
sl@0
    31
*/
sl@0
    32
CDbsDatabase* CDbsDatabase::NewL(const RDbs& aDbs, const TDesC& aDatabase, const TDesC& aFormat)
sl@0
    33
	{
sl@0
    34
	CDbsDatabase* self=new(ELeave) CDbsDatabase;
sl@0
    35
	CleanupStack::PushL(self);
sl@0
    36
	
sl@0
    37
	TIpcArgs args(&aDatabase,&aFormat,TIpcArgs::ENothing,NULL);
sl@0
    38
	self->ConstructL(aDbs,args);	// two phase construction
sl@0
    39
	CleanupStack::Pop();			// self
sl@0
    40
	return self;
sl@0
    41
	}
sl@0
    42
sl@0
    43
/**
sl@0
    44
SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version of the method.
sl@0
    45
Standard phase-two construction method for creation of CDbsDatabase instances.
sl@0
    46
@param aDbs A reference to the client side DBMS session object
sl@0
    47
@param aArgs A reference to the packed parameters needed for the database instance creation.
sl@0
    48
@leave System-wide error code, including KErrNoMemory
sl@0
    49
*/
sl@0
    50
void CDbsDatabase::ConstructL(const RDbs& aDbs, TIpcArgs& aArgs)
sl@0
    51
	{
sl@0
    52
	iObject.OpenL(aDbs,EDbsOpenDatabase,aArgs);
sl@0
    53
	}
sl@0
    54
	
sl@0
    55
sl@0
    56
CDbsDatabase::~CDbsDatabase()
sl@0
    57
	{
sl@0
    58
	iObject.Close();
sl@0
    59
	}
sl@0
    60
sl@0
    61
TInt CDbsDatabase::Destroy()
sl@0
    62
	{
sl@0
    63
	return iObject.SendReceive(EDbsDatabaseDestroy);
sl@0
    64
	}
sl@0
    65
sl@0
    66
TInt CDbsDatabase::Begin()
sl@0
    67
	{
sl@0
    68
	return iObject.SendReceive(EDbsDatabaseBegin);
sl@0
    69
	}
sl@0
    70
sl@0
    71
TInt CDbsDatabase::Commit()
sl@0
    72
	{
sl@0
    73
	return iObject.SendReceive(EDbsDatabaseCommit);
sl@0
    74
	}
sl@0
    75
sl@0
    76
void CDbsDatabase::Rollback()
sl@0
    77
	{
sl@0
    78
	iObject.SendReceive(EDbsDatabaseRollback);
sl@0
    79
	}
sl@0
    80
sl@0
    81
TInt CDbsDatabase::Property(CDbDatabase::TProperty aProperty)
sl@0
    82
	{
sl@0
    83
	return iObject.SendReceive(EDbsDatabaseProperty,TIpcArgs(aProperty));
sl@0
    84
	}
sl@0
    85
sl@0
    86
void CDbsDatabase::CreateTableL(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey)
sl@0
    87
	{
sl@0
    88
	TPtrC8 colset(TDbsParam::PrepareLC(aColSet));
sl@0
    89
	TIpcArgs m(&aName,&colset,0);
sl@0
    90
	TPtrC8 primary;
sl@0
    91
	if (aPrimaryKey)
sl@0
    92
		{
sl@0
    93
		primary.Set(TDbsParam::PrepareLC(*aPrimaryKey));
sl@0
    94
		m.Set(2,&primary);
sl@0
    95
		}
sl@0
    96
	iObject.SendReceiveL(EDbsDatabaseCreateTable,m);
sl@0
    97
	if (aPrimaryKey)
sl@0
    98
		CleanupStack::PopAndDestroy();	// primary
sl@0
    99
	CleanupStack::PopAndDestroy();	// colset
sl@0
   100
	}
sl@0
   101
sl@0
   102
void CDbsDatabase::TablesL(CDbTableNames& aNames)
sl@0
   103
	{
sl@0
   104
	TIpcArgs m;
sl@0
   105
	RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseTables,m));
sl@0
   106
	in>>aNames;
sl@0
   107
	CleanupStack::PopAndDestroy();	// dbsbuf
sl@0
   108
	}
sl@0
   109
sl@0
   110
void CDbsDatabase::ColumnsL(CDbColSet& aColSet,const TDesC& aName)
sl@0
   111
	{
sl@0
   112
	TIpcArgs m(&aName);
sl@0
   113
	RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseColumns,m));
sl@0
   114
	in>>aColSet;
sl@0
   115
	CleanupStack::PopAndDestroy();
sl@0
   116
	}
sl@0
   117
sl@0
   118
void CDbsDatabase::IndexesL(CDbIndexNames& aNames,const TDesC& aTable)
sl@0
   119
	{
sl@0
   120
	TIpcArgs m(&aTable);
sl@0
   121
	RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseIndexes,m));
sl@0
   122
	in>>aNames;
sl@0
   123
	CleanupStack::PopAndDestroy();	// dbsbuf
sl@0
   124
	}
sl@0
   125
sl@0
   126
void CDbsDatabase::KeysL(CDbKey& aKey,const TDesC& aName,const TDesC& aTable)
sl@0
   127
	{
sl@0
   128
	TIpcArgs args(&aName,&aTable);
sl@0
   129
	RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseKeys,args));
sl@0
   130
	in>>aKey;
sl@0
   131
	CleanupStack::PopAndDestroy();	// dbsbuf
sl@0
   132
	}
sl@0
   133
sl@0
   134
CDbNotifier* CDbsDatabase::OpenNotifierL()
sl@0
   135
	{
sl@0
   136
	return CDbsNotifier::NewL(iObject);
sl@0
   137
	}
sl@0
   138
sl@0
   139
CDbIncremental* CDbsDatabase::OpenUtilityL(CDbDatabase::TUtility aType,TInt& aStep)
sl@0
   140
	{
sl@0
   141
	TIpcArgs args(aType);
sl@0
   142
	return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenUtility,args,aStep);
sl@0
   143
	}
sl@0
   144
sl@0
   145
CDbIncremental* CDbsDatabase::OpenDropTableL(const TDesC& aTable,TInt& aStep)
sl@0
   146
	{
sl@0
   147
	TIpcArgs args(&aTable);
sl@0
   148
	return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenDropTable,args,aStep);
sl@0
   149
	}
sl@0
   150
sl@0
   151
CDbIncremental* CDbsDatabase::OpenAlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep)
sl@0
   152
	{
sl@0
   153
	TPtrC8 colset(TDbsParam::PrepareLC(aNewDef));
sl@0
   154
	TIpcArgs args(&aTable,&colset);
sl@0
   155
	CDbIncremental* inc=CDbsIncremental::NewL(iObject,EDbsDatabaseOpenAlterTable,args,aStep);
sl@0
   156
	CleanupStack::PopAndDestroy();	// colset
sl@0
   157
	return inc;
sl@0
   158
	}
sl@0
   159
sl@0
   160
CDbIncremental* CDbsDatabase::OpenCreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep)
sl@0
   161
	{
sl@0
   162
	TPtrC8 key(TDbsParam::PrepareLC(aKey));
sl@0
   163
	TIpcArgs args(&aName,&aTable,&key);
sl@0
   164
	CDbIncremental* inc=CDbsIncremental::NewL(iObject,EDbsDatabaseOpenCreateIndex,args,aStep);
sl@0
   165
	CleanupStack::PopAndDestroy();	// key
sl@0
   166
	return inc;
sl@0
   167
	}
sl@0
   168
sl@0
   169
CDbIncremental* CDbsDatabase::OpenDropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep)
sl@0
   170
	{
sl@0
   171
	TIpcArgs args(&aName,&aTable);
sl@0
   172
	return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenDropIndex,args,aStep);
sl@0
   173
	}
sl@0
   174
sl@0
   175
CDbIncremental* CDbsDatabase::OpenExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit)
sl@0
   176
	{
sl@0
   177
	TIpcArgs args(&aSql,aComparison);
sl@0
   178
	return CDbsIncremental::NewL(iObject,EDbsDatabaseExecute,args,aInit);
sl@0
   179
	}
sl@0
   180
sl@0
   181
CDbCursor* CDbsDatabase::PrepareViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess aAccess)
sl@0
   182
	{
sl@0
   183
	const TDesC& des = aQuery.Query();
sl@0
   184
	TPckgC<TDbWindow> pckg(aWindow);
sl@0
   185
	TIpcArgs args(&des,aQuery.Comparison()|(aAccess<<8),&pckg);
sl@0
   186
	return CDbsCursor::NewL(iObject,EDbsDatabasePrepareView,args);
sl@0
   187
	}
sl@0
   188
sl@0
   189
CDbCursor* CDbsDatabase::OpenTableL(const TDesC& aName,RDbRowSet::TAccess aAccess)
sl@0
   190
	{
sl@0
   191
	TIpcArgs args(&aName,aAccess);
sl@0
   192
	return CDbsCursor::NewL(iObject,EDbsDatabaseOpenTable,args);
sl@0
   193
	}