1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/cenrepsrv/backup.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,178 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "srvparams.h"
1.20 +
1.21 +inline void TRepositoryBackupStreamIndexElement::Set (TUid aUid, TStreamId aSettingsStream, TStreamId aDeletedSettingsStream, TStreamId aInstalledSettingsStream)
1.22 + {
1.23 + iUid = aUid;
1.24 + iSettingsStream = aSettingsStream ;
1.25 + iDeletedSettingsStream = aDeletedSettingsStream;
1.26 + iInstalledSettingsStream = aInstalledSettingsStream;
1.27 + }
1.28 +
1.29 +inline void TRepositoryBackupStreamIndexElement::Get (TUid& aUid, TStreamId& aSettingsStreamId, TStreamId& aDeletedSettingsStreamId, TStreamId& aInstalledSettingsStream)
1.30 + {
1.31 + aUid = iUid;
1.32 + aSettingsStreamId = iSettingsStream;
1.33 + aDeletedSettingsStreamId = iDeletedSettingsStream ;
1.34 + aInstalledSettingsStream = iInstalledSettingsStream ;
1.35 + }
1.36 +
1.37 +inline void TRepositoryBackupStreamIndexElement::ExternalizeL(RWriteStream& aStream) const
1.38 + {
1.39 + aStream << iUid ;
1.40 + aStream << iSettingsStream ;
1.41 + aStream << iDeletedSettingsStream ;
1.42 + aStream << iInstalledSettingsStream ;
1.43 + }
1.44 +
1.45 +inline void TRepositoryBackupStreamIndexElement::InternalizeL(RReadStream& aStream, TUint32 aBackupStreamExtensions)
1.46 + {
1.47 + TUint32 intUid ;
1.48 + aStream >> intUid ;
1.49 + iUid.iUid = intUid ;
1.50 + aStream >> iSettingsStream ;
1.51 + if (aBackupStreamExtensions & EDeletedKeysSupported)
1.52 + {
1.53 + aStream >> iDeletedSettingsStream ;
1.54 + }
1.55 + if (aBackupStreamExtensions & EInstalledKeysSupported)
1.56 + {
1.57 + aStream >> iInstalledSettingsStream ;
1.58 + }
1.59 +
1.60 + }
1.61 +
1.62 +
1.63 +inline CRepositoryBackupStreamIndex* CRepositoryBackupStreamIndex::NewL()
1.64 + {
1.65 + return new (ELeave) CRepositoryBackupStreamIndex ;
1.66 + }
1.67 +
1.68 +inline CRepositoryBackupStreamIndex* CRepositoryBackupStreamIndex::NewLC()
1.69 + {
1.70 + CRepositoryBackupStreamIndex* self = CRepositoryBackupStreamIndex::NewL();
1.71 + CleanupStack::PushL(self) ;
1.72 + return self ;
1.73 + }
1.74 +
1.75 +inline CRepositoryBackupStreamIndex::~CRepositoryBackupStreamIndex()
1.76 + {
1.77 + iStreamIndex.Close() ;
1.78 + }
1.79 +
1.80 +inline void CRepositoryBackupStreamIndex::Close(void)
1.81 + {
1.82 + iStreamIndex.Close() ;
1.83 + }
1.84 +
1.85 +inline void CRepositoryBackupStreamIndex::Reset()
1.86 + {
1.87 + iIndex = 0;
1.88 + }
1.89 +
1.90 +inline void CRepositoryBackupStreamIndex::ExternalizeL(RWriteStream& aStream) const
1.91 + {
1.92 + TCardinality nElements = iStreamIndex.Count() ;
1.93 + aStream << nElements ;
1.94 + for (int i = 0; i < nElements; i++)
1.95 + {
1.96 + aStream << iStreamIndex[i] ;
1.97 + }
1.98 + }
1.99 +
1.100 +inline void CRepositoryBackupStreamIndex::InternalizeL(RReadStream& aStream, TUint32 aBackupStreamExtensions)
1.101 + {
1.102 + TCardinality nElements ;
1.103 + aStream >> nElements ;
1.104 +
1.105 + TRepositoryBackupStreamIndexElement indexElement ;
1.106 + iStreamIndex.ReserveL(nElements);
1.107 + for (int i = 0; i < nElements; i++)
1.108 + {
1.109 + indexElement.InternalizeL(aStream, aBackupStreamExtensions);
1.110 + iStreamIndex.AppendL(indexElement);
1.111 + }
1.112 + }
1.113 +
1.114 +
1.115 +inline TRepositoryBackupStreamHeader::TRepositoryBackupStreamHeader(TStreamId aIndexStreamId) : iBackupStreamUid(KServerUid3), iBackupStreamVersion(KBackupStreamVersion), iIndexStreamId(aIndexStreamId), iBackupExtensionsSupported(KBackupExtensionsSupported)
1.116 + {
1.117 + iReserved1 = 0 ;
1.118 + iReserved2 = 0 ;
1.119 + iReserved3 = 0 ;
1.120 + iReserved4 = 0 ;
1.121 + }
1.122 +
1.123 +inline TRepositoryBackupStreamHeader::TRepositoryBackupStreamHeader()
1.124 + {
1.125 + iReserved1 = 0 ;
1.126 + iReserved2 = 0 ;
1.127 + iReserved3 = 0 ;
1.128 + iReserved4 = 0 ;
1.129 + }
1.130 +
1.131 +inline void TRepositoryBackupStreamHeader::ExternalizeL(RWriteStream& aStream) const
1.132 + {
1.133 + aStream << iBackupStreamUid ;
1.134 + aStream << iBackupStreamVersion ;
1.135 + aStream << iIndexStreamId ;
1.136 + aStream << iBackupExtensionsSupported ;
1.137 + aStream << iReserved1 ;
1.138 + aStream << iReserved2 ;
1.139 + aStream << iReserved3 ;
1.140 + aStream << iReserved4 ;
1.141 + }
1.142 +
1.143 +inline void TRepositoryBackupStreamHeader::InternalizeL(RReadStream& aStream)
1.144 + {
1.145 + aStream >> iBackupStreamUid ;
1.146 + aStream >> iBackupStreamVersion ;
1.147 + if ((iBackupStreamUid != KServerUid3) ||
1.148 + (iBackupStreamVersion > KBackupStreamVersion))
1.149 + {
1.150 + // No valid header found in stream - bail out before we
1.151 + // read off the end of the stream!
1.152 + User::Leave(KErrNotSupported) ;
1.153 + }
1.154 +
1.155 + aStream >> iIndexStreamId ;
1.156 + aStream >> iBackupExtensionsSupported ;
1.157 + aStream >> iReserved1 ;
1.158 + aStream >> iReserved2 ;
1.159 + aStream >> iReserved3 ;
1.160 + aStream >> iReserved4 ;
1.161 + }
1.162 +
1.163 +inline TUid TRepositoryBackupStreamHeader::getUid()
1.164 + {
1.165 + return iBackupStreamUid ;
1.166 + }
1.167 +
1.168 +inline TStreamId TRepositoryBackupStreamHeader::getIndexStreamId()
1.169 + {
1.170 + return iIndexStreamId ;
1.171 + }
1.172 +
1.173 +inline TUint32 TRepositoryBackupStreamHeader::getVersion()
1.174 + {
1.175 + return iBackupStreamVersion ;
1.176 + }
1.177 +
1.178 +inline TUint32 TRepositoryBackupStreamHeader::getBackupExtensionsSupported()
1.179 + {
1.180 + return iBackupExtensionsSupported ;
1.181 + }