os/persistentdata/persistentstorage/centralrepository/cenrepsrv/backup.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
//
sl@0
    15
sl@0
    16
#include "srvparams.h"
sl@0
    17
sl@0
    18
inline void TRepositoryBackupStreamIndexElement::Set (TUid aUid, TStreamId aSettingsStream, TStreamId aDeletedSettingsStream, TStreamId aInstalledSettingsStream) 
sl@0
    19
	{
sl@0
    20
	iUid = aUid;
sl@0
    21
	iSettingsStream = aSettingsStream ;
sl@0
    22
	iDeletedSettingsStream = aDeletedSettingsStream;
sl@0
    23
	iInstalledSettingsStream = aInstalledSettingsStream; 
sl@0
    24
	} 
sl@0
    25
sl@0
    26
inline void TRepositoryBackupStreamIndexElement::Get (TUid& aUid, TStreamId& aSettingsStreamId, TStreamId& aDeletedSettingsStreamId, TStreamId& aInstalledSettingsStream) 
sl@0
    27
	{
sl@0
    28
	aUid = iUid;
sl@0
    29
	aSettingsStreamId = iSettingsStream;
sl@0
    30
	aDeletedSettingsStreamId = iDeletedSettingsStream ;
sl@0
    31
	aInstalledSettingsStream = iInstalledSettingsStream ;	
sl@0
    32
	} 
sl@0
    33
sl@0
    34
inline void TRepositoryBackupStreamIndexElement::ExternalizeL(RWriteStream& aStream) const
sl@0
    35
	{
sl@0
    36
	aStream << iUid ;
sl@0
    37
	aStream << iSettingsStream ;
sl@0
    38
	aStream << iDeletedSettingsStream ;
sl@0
    39
	aStream << iInstalledSettingsStream ;	
sl@0
    40
	}
sl@0
    41
sl@0
    42
inline void TRepositoryBackupStreamIndexElement::InternalizeL(RReadStream& aStream, TUint32 aBackupStreamExtensions)
sl@0
    43
	{
sl@0
    44
	TUint32 intUid ;
sl@0
    45
	aStream >> intUid ;
sl@0
    46
	iUid.iUid = intUid ;
sl@0
    47
	aStream >> iSettingsStream ;
sl@0
    48
	if (aBackupStreamExtensions & EDeletedKeysSupported)
sl@0
    49
		{
sl@0
    50
		aStream >> iDeletedSettingsStream ;
sl@0
    51
		}
sl@0
    52
	if (aBackupStreamExtensions & EInstalledKeysSupported)
sl@0
    53
		{
sl@0
    54
		aStream >> iInstalledSettingsStream ;
sl@0
    55
		}
sl@0
    56
		
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
inline CRepositoryBackupStreamIndex* CRepositoryBackupStreamIndex::NewL()
sl@0
    61
	{
sl@0
    62
	return new (ELeave) CRepositoryBackupStreamIndex ;
sl@0
    63
	} 
sl@0
    64
sl@0
    65
inline CRepositoryBackupStreamIndex* CRepositoryBackupStreamIndex::NewLC()
sl@0
    66
	{
sl@0
    67
	CRepositoryBackupStreamIndex* self = CRepositoryBackupStreamIndex::NewL();
sl@0
    68
	CleanupStack::PushL(self) ;
sl@0
    69
	return self ;
sl@0
    70
	}
sl@0
    71
sl@0
    72
inline CRepositoryBackupStreamIndex::~CRepositoryBackupStreamIndex() 
sl@0
    73
	{
sl@0
    74
	iStreamIndex.Close() ;
sl@0
    75
	}
sl@0
    76
	
sl@0
    77
inline void CRepositoryBackupStreamIndex::Close(void) 
sl@0
    78
	{
sl@0
    79
	iStreamIndex.Close() ;
sl@0
    80
	} 
sl@0
    81
sl@0
    82
inline void CRepositoryBackupStreamIndex::Reset() 
sl@0
    83
	{
sl@0
    84
	iIndex = 0;
sl@0
    85
	}
sl@0
    86
sl@0
    87
inline void CRepositoryBackupStreamIndex::ExternalizeL(RWriteStream& aStream) const
sl@0
    88
	{
sl@0
    89
	TCardinality nElements = iStreamIndex.Count() ;
sl@0
    90
	aStream << nElements ;
sl@0
    91
	for (int i = 0; i < nElements; i++)
sl@0
    92
		{
sl@0
    93
		aStream << iStreamIndex[i] ;
sl@0
    94
		}
sl@0
    95
	} 
sl@0
    96
	
sl@0
    97
inline void CRepositoryBackupStreamIndex::InternalizeL(RReadStream& aStream, TUint32 aBackupStreamExtensions) 
sl@0
    98
	{
sl@0
    99
	TCardinality nElements ;
sl@0
   100
	aStream >> nElements ;
sl@0
   101
		
sl@0
   102
	TRepositoryBackupStreamIndexElement indexElement ;
sl@0
   103
	iStreamIndex.ReserveL(nElements);
sl@0
   104
	for (int i = 0; i < nElements; i++)
sl@0
   105
		{			
sl@0
   106
		indexElement.InternalizeL(aStream, aBackupStreamExtensions);
sl@0
   107
		iStreamIndex.AppendL(indexElement);
sl@0
   108
		}		
sl@0
   109
	}
sl@0
   110
	
sl@0
   111
sl@0
   112
inline TRepositoryBackupStreamHeader::TRepositoryBackupStreamHeader(TStreamId aIndexStreamId) : iBackupStreamUid(KServerUid3), iBackupStreamVersion(KBackupStreamVersion), iIndexStreamId(aIndexStreamId), iBackupExtensionsSupported(KBackupExtensionsSupported)
sl@0
   113
	{
sl@0
   114
	iReserved1 = 0 ;
sl@0
   115
	iReserved2 = 0 ;
sl@0
   116
	iReserved3 = 0 ;
sl@0
   117
	iReserved4 = 0 ;
sl@0
   118
	}
sl@0
   119
	
sl@0
   120
inline TRepositoryBackupStreamHeader::TRepositoryBackupStreamHeader()
sl@0
   121
	{	
sl@0
   122
	iReserved1 = 0 ;
sl@0
   123
	iReserved2 = 0 ;
sl@0
   124
	iReserved3 = 0 ;
sl@0
   125
	iReserved4 = 0 ;
sl@0
   126
	}
sl@0
   127
		
sl@0
   128
inline void TRepositoryBackupStreamHeader::ExternalizeL(RWriteStream& aStream) const
sl@0
   129
	{
sl@0
   130
	aStream << iBackupStreamUid ;
sl@0
   131
	aStream << iBackupStreamVersion ;
sl@0
   132
	aStream << iIndexStreamId ;
sl@0
   133
	aStream << iBackupExtensionsSupported ;
sl@0
   134
	aStream << iReserved1 ;
sl@0
   135
	aStream << iReserved2 ;
sl@0
   136
	aStream << iReserved3 ;
sl@0
   137
	aStream << iReserved4 ;	
sl@0
   138
	} 
sl@0
   139
	
sl@0
   140
inline void TRepositoryBackupStreamHeader::InternalizeL(RReadStream& aStream) 
sl@0
   141
	{
sl@0
   142
	aStream >> iBackupStreamUid ;
sl@0
   143
	aStream >> iBackupStreamVersion ;
sl@0
   144
	if ((iBackupStreamUid != KServerUid3) || 
sl@0
   145
	    (iBackupStreamVersion > KBackupStreamVersion))
sl@0
   146
	    {
sl@0
   147
	    // No valid header found in stream - bail out before we
sl@0
   148
	    // read off the end of the stream!
sl@0
   149
	    User::Leave(KErrNotSupported) ;
sl@0
   150
	    }
sl@0
   151
	    
sl@0
   152
	aStream >> iIndexStreamId ;
sl@0
   153
	aStream >> iBackupExtensionsSupported ;
sl@0
   154
	aStream >> iReserved1 ;
sl@0
   155
	aStream >> iReserved2 ;
sl@0
   156
	aStream >> iReserved3 ;
sl@0
   157
	aStream >> iReserved4 ;	
sl@0
   158
	}
sl@0
   159
sl@0
   160
inline TUid TRepositoryBackupStreamHeader::getUid()
sl@0
   161
	{
sl@0
   162
	return iBackupStreamUid ;		
sl@0
   163
	}
sl@0
   164
sl@0
   165
inline TStreamId TRepositoryBackupStreamHeader::getIndexStreamId() 
sl@0
   166
	{
sl@0
   167
	return iIndexStreamId ;
sl@0
   168
	}
sl@0
   169
	
sl@0
   170
inline TUint32 TRepositoryBackupStreamHeader::getVersion()
sl@0
   171
	{
sl@0
   172
	return iBackupStreamVersion ;
sl@0
   173
	}
sl@0
   174
	
sl@0
   175
inline TUint32 TRepositoryBackupStreamHeader::getBackupExtensionsSupported()
sl@0
   176
	{
sl@0
   177
	return iBackupExtensionsSupported ;
sl@0
   178
	}