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