os/persistentdata/persistentstorage/dbms/security/SC_TextOut.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-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 // CPDTextPersister class
    15 // 
    16 //
    17 
    18 #include "SC_Strings.h"
    19 #include "SC_TextOut.h"
    20 
    21 namespace DBSC
    22 {
    23 
    24 /**
    25 Non-working implementation!
    26 There is no way to create text security poliicy representation from a TSecurityInfo instance.
    27 */
    28 inline CPDTextPersister::CPDTextPersister()
    29 	{
    30 	}
    31 
    32 /**
    33 Non-working implementation!
    34 There is no way to create text security poliicy representation from a TSecurityInfo instance.
    35 */
    36 CPDTextPersister* CPDTextPersister::NewLC(RFs& aFs, const TDesC& aTextFileName)
    37 	{
    38 	CPDTextPersister* self = new (ELeave) CPDTextPersister;
    39 	CleanupStack::PushL(self);
    40 	self->ConstructL(aFs, aTextFileName);
    41 	return self;
    42 	}
    43 
    44 /**
    45 Non-working implementation!
    46 There is no way to create text security poliicy representation from a TSecurityInfo instance.
    47 */
    48 void CPDTextPersister::ConstructL(RFs& aFs, const TDesC& aTextFileName)
    49 	{
    50 	__LEAVE_IF_ERROR(iOutFile.Create(aFs, aTextFileName, EFileRead | EFileWrite));
    51 	}
    52 
    53 /**
    54 Non-working implementation!
    55 There is no way to create text security poliicy representation from a TSecurityInfo instance.
    56 */
    57 CPDTextPersister::~CPDTextPersister()
    58 	{
    59 	iOutFile.Close();
    60 	}
    61 
    62 /**
    63 Non-working implementation!
    64 There is no way to create text security poliicy representation from a TSecurityInfo instance.
    65 */
    66 void CPDTextPersister::RunL(const TPolicyDomainReader& aPolicyDomainReader)
    67 	{
    68 	WriteDbPolicyL(aPolicyDomainReader);
    69 	WriteTblPoliciesL(aPolicyDomainReader);
    70 	}
    71 
    72 /**
    73 Non-working implementation!
    74 There is no way to create text security poliicy representation from a TSecurityInfo instance.
    75 */
    76 void CPDTextPersister::WriteDbPolicyL(const TPolicyDomainReader& aPolicyDomainReader)
    77 	{
    78 	const CDbPolicy& dbPolicy = aPolicyDomainReader.DbPolicy();
    79 
    80 	iStmt.Copy(KDbStr);
    81 	iStmt.Append(KCrLf);
    82 	__LEAVE_IF_ERROR(iOutFile.Write(iStmt));
    83 
    84 	WritePolicyCollection(dbPolicy.PolicyCollection());
    85 	}
    86 
    87 /**
    88 Non-working implementation!
    89 There is no way to create text security poliicy representation from a TSecurityInfo instance.
    90 */
    91 void CPDTextPersister::WriteTblPoliciesL(const TPolicyDomainReader& aPolicyDomainReader)
    92 	{
    93 	aPolicyDomainReader.ResetTblPos();
    94 	const CTblPolicy* tblPolicy;
    95 	while((tblPolicy = aPolicyDomainReader.NextTblPolicy()) != NULL)
    96 		{
    97 		iStmt.Copy(KTblStr);
    98 		iStmt.Append(KCrLf);
    99 		__LEAVE_IF_ERROR(iOutFile.Write(iStmt));
   100 
   101 		iStmt.Copy(KNameStr);
   102 		iStmt.Append(KEqStr);
   103 		iStmt.Append(tblPolicy->TableName());
   104 		iStmt.Append(KCrLf);
   105 		__LEAVE_IF_ERROR(iOutFile.Write(iStmt));
   106 
   107 		WritePolicyCollection(tblPolicy->PolicyCollection());
   108 		}
   109 	}
   110 
   111 /**
   112 Non-working implementation!
   113 There is no way to create text security poliicy representation from a TSecurityInfo instance.
   114 */
   115 void CPDTextPersister::WritePolicyCollection(const CPolicyBase::RPolicyCollection& aPolicyCollection)
   116 	{
   117 	TInt cnt = aPolicyCollection.Count();
   118 	for(TInt i=0;i<cnt;++i)
   119 		{
   120 		const CPolicyBase::TPolicy& policy = aPolicyCollection[i];
   121 		switch(policy.iType)
   122 			{
   123 			case EPTRead:
   124 				iStmt.Copy(KReadStr);
   125 				break;
   126 			case EPTWrite:
   127 				iStmt.Copy(KWriteStr);
   128 				break;
   129 			case EPTSchema:
   130 				iStmt.Copy(KSchemaStr);
   131 				break;
   132 			default:
   133 				__ASSERT(0);
   134 				break;
   135 			}
   136 		iStmt.Append(KEqStr);
   137 		}
   138 	__ASSERT(0);
   139 	}
   140 
   141 } //end of - namespace DBSC