os/security/authorisation/userpromptservice/database/inc/upsdb.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * Defines a read-only interface for UPS Database and classes to keep filter and record objects.
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @publishedPartner
    23  @released
    24 */
    25  
    26 #ifndef UPSDB_H
    27 #define UPSDB_H
    28 
    29 #include <s32file.h>
    30 #include <d32dbms.h>
    31 #include <ups/upstypes.h>
    32 
    33 namespace UserPromptService
    34 {
    35 
    36 _LIT(KDecisionViewPanic,"UpsDbView");
    37 
    38 NONSHARABLE_CLASS(CDecisionView):public CActive
    39 /**
    40    Stores a handle to a view object and provides a method to retrieve a record from the view.
    41  */
    42  	{	
    43  	friend class CDecisionDb;
    44  	friend class CDecisionDbW;
    45  	
    46 public:	
    47  	IMPORT_C static CDecisionView *NewLC();
    48  	
    49  	~CDecisionView();
    50  	
    51 	IMPORT_C void EvaluateView(TRequestStatus& aStatus);	
    52  	IMPORT_C CDecisionRecord* NextDecisionL();
    53 
    54 protected:
    55  	CDecisionView();
    56  	static CDecisionRecord* GenerateRecordL(RDbRowSet& aRowSet, CDbColSet* aColSet);	
    57 	/**
    58 		From CActive. Handles an evaluation request completion event and evaluate next part if required.
    59 	 */
    60 	void RunL();	
    61 	/**
    62 		From CActive. Cancels evaluation.
    63 	 */
    64 	void DoCancel();	
    65 	/**
    66 		From CActive. Handles errors.
    67 	 */
    68 	TInt RunError(TInt aError);
    69 	 	
    70 private:
    71 	/**
    72 	   Handle to the view object generated from an SQL query
    73 	 */
    74 	RDbView iDbView;	
    75 	/**
    76 	   Pointer to the decision database column set definition
    77 	 */
    78 	CDbColSet *iColSet;	
    79 	/**
    80 	   Copy of the status variable of the client which requested the evaluation service
    81 	 */
    82 	TRequestStatus* iClientStatus;
    83  	};
    84 
    85 
    86 NONSHARABLE_CLASS(CDecisionDb):public CBase
    87 /**
    88 	A read-only interface for UPS decision database. Provide methods to query database.
    89  */
    90 	{
    91 public:
    92 	IMPORT_C CDecisionView *CreateViewL(CDecisionFilter& aFilter);
    93 	
    94 	~CDecisionDb();
    95 
    96 protected:
    97 	CDecisionDb();
    98 	void CreateSqlStatementLC(CDecisionFilter& aFilter, RBuf& aSql);	
    99 	void DoubleSingleQuotesL(const TDesC& aSource, RBuf& aDestination);
   100 	
   101 private:
   102 	const TDesC* GetComparisonOperator(const TUint32& aFlag) const;
   103 	void AppendQueryInteger(const TUint32& aValue, TDes& aSql, TBool& aMultiple, const TUint32& aFlag, const TUint32& aSetCol, const TDesC& aColName);
   104 	void AppendQueryStringL(const TDesC& aValue, TDes& aSql, TBool& aMultiple, const TUint32& aFlag, const TUint32& aSetCol, const TDesC& aColName);
   105 	
   106 protected:
   107 	/**
   108 	 * Handle to the decision store database
   109 	 */
   110 	RDbStoreDatabase iDatabase;
   111 	/**
   112 	 * Pointer to the database file storage object
   113 	 */
   114 	CFileStore* iStore;	
   115 	};
   116 
   117 }//namespace UserPromptService
   118 
   119 #endif //UPSDB_H