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.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // DBMS server proxy database
    15 // 
    16 //
    17 
    18 #include "SD_STD.H"
    19 
    20 // Class CDbsDatabase
    21 
    22 
    23 /**
    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
    31 */
    32 CDbsDatabase* CDbsDatabase::NewL(const RDbs& aDbs, const TDesC& aDatabase, const TDesC& aFormat)
    33 	{
    34 	CDbsDatabase* self=new(ELeave) CDbsDatabase;
    35 	CleanupStack::PushL(self);
    36 	
    37 	TIpcArgs args(&aDatabase,&aFormat,TIpcArgs::ENothing,NULL);
    38 	self->ConstructL(aDbs,args);	// two phase construction
    39 	CleanupStack::Pop();			// self
    40 	return self;
    41 	}
    42 
    43 /**
    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
    49 */
    50 void CDbsDatabase::ConstructL(const RDbs& aDbs, TIpcArgs& aArgs)
    51 	{
    52 	iObject.OpenL(aDbs,EDbsOpenDatabase,aArgs);
    53 	}
    54 	
    55 
    56 CDbsDatabase::~CDbsDatabase()
    57 	{
    58 	iObject.Close();
    59 	}
    60 
    61 TInt CDbsDatabase::Destroy()
    62 	{
    63 	return iObject.SendReceive(EDbsDatabaseDestroy);
    64 	}
    65 
    66 TInt CDbsDatabase::Begin()
    67 	{
    68 	return iObject.SendReceive(EDbsDatabaseBegin);
    69 	}
    70 
    71 TInt CDbsDatabase::Commit()
    72 	{
    73 	return iObject.SendReceive(EDbsDatabaseCommit);
    74 	}
    75 
    76 void CDbsDatabase::Rollback()
    77 	{
    78 	iObject.SendReceive(EDbsDatabaseRollback);
    79 	}
    80 
    81 TInt CDbsDatabase::Property(CDbDatabase::TProperty aProperty)
    82 	{
    83 	return iObject.SendReceive(EDbsDatabaseProperty,TIpcArgs(aProperty));
    84 	}
    85 
    86 void CDbsDatabase::CreateTableL(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey)
    87 	{
    88 	TPtrC8 colset(TDbsParam::PrepareLC(aColSet));
    89 	TIpcArgs m(&aName,&colset,0);
    90 	TPtrC8 primary;
    91 	if (aPrimaryKey)
    92 		{
    93 		primary.Set(TDbsParam::PrepareLC(*aPrimaryKey));
    94 		m.Set(2,&primary);
    95 		}
    96 	iObject.SendReceiveL(EDbsDatabaseCreateTable,m);
    97 	if (aPrimaryKey)
    98 		CleanupStack::PopAndDestroy();	// primary
    99 	CleanupStack::PopAndDestroy();	// colset
   100 	}
   101 
   102 void CDbsDatabase::TablesL(CDbTableNames& aNames)
   103 	{
   104 	TIpcArgs m;
   105 	RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseTables,m));
   106 	in>>aNames;
   107 	CleanupStack::PopAndDestroy();	// dbsbuf
   108 	}
   109 
   110 void CDbsDatabase::ColumnsL(CDbColSet& aColSet,const TDesC& aName)
   111 	{
   112 	TIpcArgs m(&aName);
   113 	RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseColumns,m));
   114 	in>>aColSet;
   115 	CleanupStack::PopAndDestroy();
   116 	}
   117 
   118 void CDbsDatabase::IndexesL(CDbIndexNames& aNames,const TDesC& aTable)
   119 	{
   120 	TIpcArgs m(&aTable);
   121 	RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseIndexes,m));
   122 	in>>aNames;
   123 	CleanupStack::PopAndDestroy();	// dbsbuf
   124 	}
   125 
   126 void CDbsDatabase::KeysL(CDbKey& aKey,const TDesC& aName,const TDesC& aTable)
   127 	{
   128 	TIpcArgs args(&aName,&aTable);
   129 	RReadStream in(HDbsBuf::NewLC(iObject,EDbsDatabaseKeys,args));
   130 	in>>aKey;
   131 	CleanupStack::PopAndDestroy();	// dbsbuf
   132 	}
   133 
   134 CDbNotifier* CDbsDatabase::OpenNotifierL()
   135 	{
   136 	return CDbsNotifier::NewL(iObject);
   137 	}
   138 
   139 CDbIncremental* CDbsDatabase::OpenUtilityL(CDbDatabase::TUtility aType,TInt& aStep)
   140 	{
   141 	TIpcArgs args(aType);
   142 	return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenUtility,args,aStep);
   143 	}
   144 
   145 CDbIncremental* CDbsDatabase::OpenDropTableL(const TDesC& aTable,TInt& aStep)
   146 	{
   147 	TIpcArgs args(&aTable);
   148 	return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenDropTable,args,aStep);
   149 	}
   150 
   151 CDbIncremental* CDbsDatabase::OpenAlterTableL(const TDesC& aTable,const CDbColSet& aNewDef,TInt& aStep)
   152 	{
   153 	TPtrC8 colset(TDbsParam::PrepareLC(aNewDef));
   154 	TIpcArgs args(&aTable,&colset);
   155 	CDbIncremental* inc=CDbsIncremental::NewL(iObject,EDbsDatabaseOpenAlterTable,args,aStep);
   156 	CleanupStack::PopAndDestroy();	// colset
   157 	return inc;
   158 	}
   159 
   160 CDbIncremental* CDbsDatabase::OpenCreateIndexL(const TDesC& aName,const TDesC& aTable,const CDbKey& aKey,TInt& aStep)
   161 	{
   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
   166 	return inc;
   167 	}
   168 
   169 CDbIncremental* CDbsDatabase::OpenDropIndexL(const TDesC& aName,const TDesC& aTable,TInt& aStep)
   170 	{
   171 	TIpcArgs args(&aName,&aTable);
   172 	return CDbsIncremental::NewL(iObject,EDbsDatabaseOpenDropIndex,args,aStep);
   173 	}
   174 
   175 CDbIncremental* CDbsDatabase::OpenExecuteL(const TDesC& aSql,TDbTextComparison aComparison,TInt& aInit)
   176 	{
   177 	TIpcArgs args(&aSql,aComparison);
   178 	return CDbsIncremental::NewL(iObject,EDbsDatabaseExecute,args,aInit);
   179 	}
   180 
   181 CDbCursor* CDbsDatabase::PrepareViewL(const TDbQuery& aQuery,const TDbWindow& aWindow,RDbRowSet::TAccess aAccess)
   182 	{
   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);
   187 	}
   188 
   189 CDbCursor* CDbsDatabase::OpenTableL(const TDesC& aName,RDbRowSet::TAccess aAccess)
   190 	{
   191 	TIpcArgs args(&aName,aAccess);
   192 	return CDbsCursor::NewL(iObject,EDbsDatabaseOpenTable,args);
   193 	}