|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: PSM storage for backups and configs |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "psmconfigstorage.h" |
|
20 #include "psmstoragedefines.h" |
|
21 #include "psmtrace.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CPsmConfigStorage::NewL |
|
25 // Two-phased constructor. |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 CPsmConfigStorage* CPsmConfigStorage::NewL( TPsmsrvMode aMode, RFs& aFile ) |
|
29 { |
|
30 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::NewL()" ) ) ); |
|
31 |
|
32 CPsmConfigStorage* self = CPsmConfigStorage::NewLC( aMode, aFile ); |
|
33 CleanupStack::Pop( self ); |
|
34 |
|
35 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::NewL - return 0x%x" ), self ) ); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CPsmConfigStorage::NewLC |
|
42 // Two-phased constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CPsmConfigStorage* CPsmConfigStorage::NewLC( TPsmsrvMode aMode, RFs& aFile ) |
|
46 { |
|
47 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::NewLC()" ) ) ); |
|
48 |
|
49 CPsmConfigStorage* self = new( ELeave ) CPsmConfigStorage( aMode, aFile ); |
|
50 |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 |
|
54 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::NewLC - return 0x%x" ), self ) ); |
|
55 |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CPsmConfigStorage::CPsmConfigStorage |
|
61 // C++ default constructor can NOT contain any code, that |
|
62 // might leave. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CPsmConfigStorage::CPsmConfigStorage( TPsmsrvMode aMode, RFs& aFile ) : |
|
66 CPsmStorage( aMode, aFile ) |
|
67 { |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CPsmConfigStorage::ConstructL |
|
72 // Symbian 2nd phase constructor can leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CPsmConfigStorage::ConstructL() |
|
76 { |
|
77 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::ConstructL()" ) ) ); |
|
78 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::ConstructL - return" ) ) ); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // Destructor |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CPsmConfigStorage::~CPsmConfigStorage() |
|
86 { |
|
87 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::~CPsmConfigStorage()" ) ) ); |
|
88 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::~CPsmConfigStorage - return") ) ); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CPsmConfigStorage::InitRootElementsL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CPsmConfigStorage::InitRootElementsL() |
|
96 { |
|
97 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::InitRootElementsL()" ) ) ); |
|
98 |
|
99 // Get root element |
|
100 if ( iStorageFile.NotNull() ) |
|
101 { |
|
102 iStorageRoot = iStorageFile.DocumentElement(); |
|
103 } |
|
104 |
|
105 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::InitRootElementsL() - return" ) ) ); |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CPsmConfigStorage::InitConfigL |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CPsmConfigStorage::InitStorageL( const TUint32 aStorageUid ) |
|
113 { |
|
114 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::InitStorageL()" ) ) ); |
|
115 |
|
116 iStorageUid = aStorageUid; |
|
117 |
|
118 // Create storage file parser |
|
119 iDOMImpl.OpenL( ); |
|
120 User::LeaveIfError( iStorageParser.Open( iDOMImpl ) ); |
|
121 |
|
122 // Generate file folder+name+extension |
|
123 TBuf<KPsmMaxPathLength> privatePath( KNullDesC ); |
|
124 iFileSession.PrivatePath( privatePath ); |
|
125 |
|
126 TBuf<KPsmMaxPathLength> storageFile( KNullDesC ); |
|
127 storageFile.Append( KPsmPrivateDrive ); |
|
128 storageFile.Append( privatePath ); |
|
129 storageFile.AppendNumUC( iStorageUid, EHex ); |
|
130 storageFile.Append( KPsmStorageExtension ); |
|
131 |
|
132 // Initialize PSM config file. Leave if config file is not found |
|
133 TRAPD( parseErr, iStorageFile = iStorageParser.ParseFileL( iFileSession, storageFile ) ); |
|
134 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::InitStorageL() - Parse file started: %i" ), parseErr ) ); |
|
135 User::LeaveIfError( parseErr ); |
|
136 |
|
137 // Initialize root elements |
|
138 InitRootElementsL(); |
|
139 |
|
140 COMPONENT_TRACE( ( _L( "PSM Server - CPsmConfigStorage::InitStorageL() - return" ) ) ); |
|
141 } |
|
142 |
|
143 // End of file |