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