|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "aipluginsettingsimpl.h" |
|
20 #include "aipluginsettingsitemimpl.h" |
|
21 |
|
22 // ============================================================================ |
|
23 // Class CAiPluginSettings |
|
24 // ============================================================================ |
|
25 |
|
26 CAiPluginSettings* CAiPluginSettings::NewL() |
|
27 { |
|
28 CAiPluginSettings* self = new (ELeave) CAiPluginSettings(); |
|
29 |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(self); |
|
33 |
|
34 return self; |
|
35 } |
|
36 |
|
37 MAiPluginSettingsItem& CAiPluginSettings::AiPluginSettingsItem() |
|
38 { |
|
39 iItemType = 0; |
|
40 return *iSettingsItem; |
|
41 } |
|
42 |
|
43 void CAiPluginSettings::ConstructL() |
|
44 { |
|
45 iSettingsItem = new (ELeave) CAiPluginSettingsItem(); |
|
46 iSettingsItem->ConstructL(); |
|
47 } |
|
48 |
|
49 CAiPluginSettings::CAiPluginSettings(): iItemType( 0 ) |
|
50 { |
|
51 } |
|
52 |
|
53 CAiPluginSettings::~CAiPluginSettings() |
|
54 { |
|
55 delete iSettingsItem; |
|
56 } |
|
57 |
|
58 TInt CAiPluginSettings::AiPluginItemType() |
|
59 { |
|
60 return iItemType; |
|
61 } |
|
62 |
|
63 MAiPluginContentItem& CAiPluginSettings::AiPluginContentItem() |
|
64 { |
|
65 iItemType = 1; |
|
66 return *iSettingsItem; |
|
67 } |
|
68 |
|
69 MAiPluginConfigurationItem& CAiPluginSettings::AiPluginConfigurationItem() |
|
70 { |
|
71 iItemType = 2; |
|
72 return *iSettingsItem; |
|
73 } |
|
74 |
|
75 // ============================================================================ |
|
76 // Class CAiPluginSettingsItem |
|
77 // ============================================================================ |
|
78 |
|
79 CAiPluginSettingsItem::CAiPluginSettingsItem() |
|
80 : iKey( KErrNotFound ) |
|
81 { |
|
82 } |
|
83 |
|
84 void CAiPluginSettingsItem::ConstructL() |
|
85 { |
|
86 iValue = HBufC::NewL(KMaxSettingsValueStringLength); |
|
87 } |
|
88 |
|
89 CAiPluginSettingsItem::~CAiPluginSettingsItem() |
|
90 { |
|
91 delete iValue; |
|
92 delete iName; |
|
93 delete iType; |
|
94 delete iOwner; |
|
95 } |
|
96 |
|
97 TPtrC CAiPluginSettingsItem::Value() |
|
98 { |
|
99 if (iValue) |
|
100 { |
|
101 return TPtrC(*iValue); |
|
102 } |
|
103 else |
|
104 { |
|
105 return TPtrC(); |
|
106 } |
|
107 } |
|
108 |
|
109 void CAiPluginSettingsItem::SetValueL(const TDesC& aValue, TBool /*aSaveToStore*/) |
|
110 { |
|
111 |
|
112 delete iValue; |
|
113 iValue = NULL; |
|
114 iValue = aValue.AllocL(); |
|
115 } |
|
116 |
|
117 const TUid& CAiPluginSettingsItem::PublisherId() const |
|
118 { |
|
119 return iPublisherId; |
|
120 } |
|
121 |
|
122 void CAiPluginSettingsItem::SetPublisherId(const TUid& aUid) |
|
123 { |
|
124 iPublisherId = aUid; |
|
125 } |
|
126 |
|
127 TInt32 CAiPluginSettingsItem::Key() const |
|
128 { |
|
129 return iKey; |
|
130 } |
|
131 |
|
132 void CAiPluginSettingsItem::SetKey(TInt32 aKey) |
|
133 { |
|
134 iKey = aKey; |
|
135 } |
|
136 |
|
137 void CAiPluginSettingsItem::SetStorer(MAiPluginSettingsStorer* aStorer) |
|
138 { |
|
139 iStorer = aStorer; |
|
140 } |
|
141 |
|
142 void CAiPluginSettingsItem::ReadFromStoreL() |
|
143 { |
|
144 if (iStorer) |
|
145 { |
|
146 TPtr ptr = iValue->Des(); |
|
147 iStorer->ReadL(iKey, ptr); |
|
148 } |
|
149 } |
|
150 |
|
151 void CAiPluginSettingsItem::SaveToStoreL() |
|
152 { |
|
153 if (iStorer) |
|
154 { |
|
155 iStorer->SaveL(iKey, *iValue); |
|
156 } |
|
157 } |
|
158 |
|
159 |
|
160 void CAiPluginSettingsItem::SetValueL( const TDesC& aValue ) |
|
161 { |
|
162 delete iValue; |
|
163 iValue = NULL; |
|
164 iValue = aValue.AllocL(); |
|
165 } |
|
166 |
|
167 void CAiPluginSettingsItem::SetNameL( const TDesC& aName ) |
|
168 { |
|
169 delete iName; |
|
170 iName = NULL; |
|
171 iName = aName.AllocL(); |
|
172 } |
|
173 |
|
174 void CAiPluginSettingsItem::SetTypeL( const TDesC& aType ) |
|
175 { |
|
176 delete iType; |
|
177 iType = NULL; |
|
178 iType = aType.AllocL(); |
|
179 } |
|
180 |
|
181 TPtrC CAiPluginSettingsItem::Name() |
|
182 { |
|
183 if ( iName ) |
|
184 { |
|
185 return TPtrC( *iName ); |
|
186 } |
|
187 else |
|
188 { |
|
189 return TPtrC(); |
|
190 } |
|
191 } |
|
192 |
|
193 TPtrC CAiPluginSettingsItem::Type() |
|
194 { |
|
195 if ( iType ) |
|
196 { |
|
197 return TPtrC( *iType ); |
|
198 } |
|
199 else |
|
200 { |
|
201 return TPtrC(); |
|
202 } |
|
203 } |
|
204 |
|
205 TPtrC CAiPluginSettingsItem::Owner() |
|
206 { |
|
207 if ( iOwner ) |
|
208 { |
|
209 return TPtrC( *iOwner ); |
|
210 } |
|
211 else |
|
212 { |
|
213 return TPtrC(); |
|
214 } |
|
215 } |
|
216 |
|
217 void CAiPluginSettingsItem::SetOwnerL( const TDesC& aOwner ) |
|
218 { |
|
219 delete iOwner; |
|
220 iOwner = NULL; |
|
221 iOwner = aOwner.AllocL(); |
|
222 } |