|
1 /* |
|
2 * Copyright (c) 2004 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: Resource reader for DS-settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "NSmlDSResourceProfile.h" |
|
22 |
|
23 |
|
24 |
|
25 // ---------------------------------------------------------- |
|
26 // CNSmlDSResourceProfiles implementation |
|
27 // ---------------------------------------------------------- |
|
28 |
|
29 // ---------------------------------------------------------- |
|
30 // CNSmlDSResourceProfiles::~CNSmlDSResourceProfiles() |
|
31 // ---------------------------------------------------------- |
|
32 CNSmlDSResourceProfiles::~CNSmlDSResourceProfiles() |
|
33 { |
|
34 if(iProfileArray) |
|
35 { |
|
36 iProfileArray->ResetAndDestroy(); |
|
37 } |
|
38 |
|
39 delete iProfileArray; |
|
40 } |
|
41 |
|
42 |
|
43 // ---------------------------------------------------------- |
|
44 // CNSmlDSResourceProfiles* CNSmlDSResourceProfiles::NewLC( TResourceReader& aReader, CNSmlDSSettings& aSettings ) |
|
45 // ---------------------------------------------------------- |
|
46 CNSmlDSResourceProfiles* CNSmlDSResourceProfiles::NewLC( TResourceReader& aReader, CNSmlDSSettings* aSettings ) |
|
47 { |
|
48 CNSmlDSResourceProfiles* self = new (ELeave) CNSmlDSResourceProfiles; |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL( aReader, aSettings ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------- |
|
55 // void CNSmlDSResourceProfiles::SaveProfilesL() |
|
56 // ---------------------------------------------------------- |
|
57 void CNSmlDSResourceProfiles::SaveProfilesL(CNSmlProfileArray* aArray) |
|
58 { |
|
59 for ( TInt i = 0; i < iProfileArray->Count(); i++ ) |
|
60 { |
|
61 CNSmlDSProfile* profile = iSettings->CreateProfileL(); |
|
62 CleanupStack::PushL( profile ); |
|
63 iProfileArray->At(i)->SaveProfileL( profile ); |
|
64 profile->SaveL(); |
|
65 CNSmlDSProfile* tempProfile = iSettings->CreateProfileL(); |
|
66 tempProfile->SetStrValue(EDSProfileServerId, profile->StrValue(EDSProfileServerId)); |
|
67 aArray->AppendL(tempProfile); |
|
68 CleanupStack::PopAndDestroy(); // profile |
|
69 } |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------- |
|
73 // void CNSmlDSResourceProfiles::ConstructL( TResourceReader& aReader, CNSmlDSSettings* aSettings ) |
|
74 // ---------------------------------------------------------- |
|
75 void CNSmlDSResourceProfiles::ConstructL( TResourceReader& aReader, CNSmlDSSettings* aSettings ) |
|
76 { |
|
77 iSettings = aSettings; |
|
78 iProfileArray = new (ELeave) CArrayPtrFlat<CNSmlDSResourceProfile> (3); |
|
79 AddDataL( aReader ); |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------- |
|
83 // void CNSmlDSResourceProfiles::AddDataL( TResourceReader& aReader ) |
|
84 // ---------------------------------------------------------- |
|
85 void CNSmlDSResourceProfiles::AddDataL( TResourceReader& aReader ) |
|
86 { |
|
87 TInt number = aReader.ReadInt16(); |
|
88 for ( TInt index = 0; index < number; index++ ) |
|
89 { |
|
90 CNSmlDSResourceProfile* profile = CNSmlDSResourceProfile::NewLC( aReader ); |
|
91 iProfileArray->AppendL( profile ); |
|
92 CleanupStack::Pop(); |
|
93 } |
|
94 } |
|
95 |
|
96 // End of File |