|
1 /* |
|
2 * Copyright (c) 2005-2006 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 <coemain.h> |
|
20 #include <f32file.h> |
|
21 #include <gulicon.h> |
|
22 #include <aicontentmodel.h> |
|
23 // #include <aipropertyextension.h> |
|
24 |
|
25 #include "profileobserver.h" |
|
26 //#include "caiplugintesterview.h" |
|
27 |
|
28 |
|
29 const char KAiProfileCaption[] = "ProfileCaption"; |
|
30 const char KAiProfileIcon[] = "ProfileIcon"; |
|
31 |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 ProfileObserver::ProfileObserver() |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 void ProfileObserver::ConstructL() |
|
49 { |
|
50 } |
|
51 |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 ProfileObserver* ProfileObserver::NewL() |
|
58 { |
|
59 ProfileObserver* self = new(ELeave) ProfileObserver(); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop(self); |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 ProfileObserver::~ProfileObserver() |
|
72 { |
|
73 } |
|
74 |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Invoked by the plug-in to inform that it initiates content publishing transaction |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 TInt ProfileObserver::StartTransaction(TInt aTxId) |
|
81 { |
|
82 if (iTransactionId != 0) |
|
83 { |
|
84 //TODO: report error |
|
85 } |
|
86 |
|
87 iTransactionId = aTxId; |
|
88 return KErrNone; |
|
89 } |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Invoked by the plug-in to request framework that content publishing is committed |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 TInt ProfileObserver::Commit(TInt aTxId) |
|
97 { |
|
98 TRAPD(err, DoCommitL(aTxId)); |
|
99 return err; |
|
100 } |
|
101 |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // Invoked by plug-in to indicate that content publishing transaction is cancelled |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 TInt ProfileObserver::Rollback(TInt aTxId) |
|
108 { |
|
109 if (iTransactionId == 0) |
|
110 { |
|
111 //TODO: report error |
|
112 } |
|
113 else if (iTransactionId != aTxId) |
|
114 { |
|
115 //TODO: report error |
|
116 } |
|
117 |
|
118 return KErrNone; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // Invoked by plug-in to test if content can be published. |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 TBool ProfileObserver::CanPublish(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, TInt /*aIndex*/) |
|
126 { |
|
127 return EFalse; //ETrue; |
|
128 } |
|
129 |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // Invoked by the plug-in to inform that content must be published |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 TInt ProfileObserver::Publish(CHsContentPublisher& aPlugin, TInt aContent, TInt aResource, TInt aIndex) |
|
136 { |
|
137 TRAPD(err, DoPublishL(aPlugin, aContent, aResource, aIndex)); |
|
138 return err; |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // Invoked by the plug-in to inform that content must be published |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 TInt ProfileObserver::Publish(CHsContentPublisher& aPlugin, TInt aContent, const TDesC16& aText, TInt aIndex) |
|
147 { |
|
148 TRAPD(err, DoPublishL(aPlugin, aContent, aText, aIndex)); |
|
149 return err; |
|
150 } |
|
151 |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // Invoked by the plug-in to inform that content must be published |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 TInt ProfileObserver::Publish(CHsContentPublisher& aPlugin, TInt aContent, const TDesC8& aBuf, TInt aIndex) |
|
158 { |
|
159 TRAPD(err, DoPublishL(aPlugin, aContent, aBuf, aIndex)); |
|
160 return err; |
|
161 } |
|
162 |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // Invoked by the plug-in to inform that content must be published |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 TInt ProfileObserver::Publish(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, RFile& /*aFile*/, TInt /*aIndex*/) |
|
169 { |
|
170 return KErrNotSupported; |
|
171 } |
|
172 |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // Invoked by the plug-in to inform that content must be cleaned in UI |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 TInt ProfileObserver::Clean(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, TInt /*aIndex*/) |
|
179 { |
|
180 // TODO: clean content. |
|
181 iTransactionId = 0; |
|
182 return 0; |
|
183 } |
|
184 |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // Returns interface extension. Not used in Series 60 v3.2 release. |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 TAny* ProfileObserver::Extension(TUid /*aUid*/) |
|
191 { |
|
192 return NULL; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 TBool ProfileObserver::RequiresSubscription( const THsPublisherInfo& /*aPublisherInfo*/ ) const |
|
200 { |
|
201 return EFalse; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // Leaving version of the publish operation |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void ProfileObserver::DoPublishL(CHsContentPublisher& aPlugin, TInt aContent, const TDesC8& /*aBuf*/, TInt /*aIndex*/) |
|
209 { |
|
210 MAiContentItemIterator* iter = static_cast<MAiContentItemIterator*>( |
|
211 aPlugin.GetProperty( CHsContentPublisher::EPublisherContent ) ); |
|
212 TAiContentItem item = iter->ItemL(aContent); |
|
213 /*if (*item.cid == *KAiShortcutIcon && *item.type == *KAiContentTypeBitmap) |
|
214 { |
|
215 CGulIcon* icon = UnpackPtr<CGulIcon>(aBuf); |
|
216 if (icon != NULL) |
|
217 { |
|
218 delete icon; |
|
219 // iView->SetShortcutIconL(aIndex, icon); |
|
220 } |
|
221 else |
|
222 { |
|
223 //TODO report error |
|
224 } |
|
225 }*/ |
|
226 } |
|
227 |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // Leaving version of the publish operation |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void ProfileObserver::DoPublishL(CHsContentPublisher& aPlugin, TInt aContent, TInt /*aResource*/, TInt /*aIndex*/) |
|
234 { |
|
235 MAiContentItemIterator* iter = static_cast<MAiContentItemIterator*>( |
|
236 aPlugin.GetProperty( CHsContentPublisher::EPublisherContent ) ); |
|
237 TAiContentItem item = iter->ItemL(aContent); |
|
238 |
|
239 /* Does not work for some reason. substitute with ugly magic numbers |
|
240 if (*item.cid == *KAiShortcutIcon) |
|
241 { |
|
242 iView->SetShortcutIconL(aIndex, aResource); |
|
243 } |
|
244 else if (*item.cid == *KAiShortcutCaption) |
|
245 { |
|
246 iView->SetShortcutCaptionL(aIndex, aResource); |
|
247 }*/ |
|
248 |
|
249 if (aContent == 0) |
|
250 { |
|
251 // iView->SetShortcutIconL(aIndex, aResource); |
|
252 } |
|
253 else if (aContent == 1) |
|
254 { |
|
255 // iView->SetShortcutCaptionL(aIndex, aResource); |
|
256 } |
|
257 |
|
258 } |
|
259 |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // Leaving version of the publish operation |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 void ProfileObserver::DoPublishL(CHsContentPublisher& aPlugin, TInt aContent, const TDesC& /*aText*/, TInt /*aIndex*/) |
|
266 { |
|
267 MAiContentItemIterator* iter = static_cast<MAiContentItemIterator*>( |
|
268 aPlugin.GetProperty( CHsContentPublisher::EPublisherContent ) ); |
|
269 TAiContentItem item = iter->ItemL(aContent); |
|
270 //if (*item.cid == *KAiShortcutCaption) |
|
271 //{ |
|
272 // iView->SetShortcutCaptionL(aIndex, aText); |
|
273 //} |
|
274 } |
|
275 |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // Leaving version of the commit operation |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 void ProfileObserver::DoCommitL(TInt aTxId) |
|
282 { |
|
283 if (iTransactionId == 0) |
|
284 { |
|
285 //TODO: report error |
|
286 } |
|
287 else if (iTransactionId != aTxId) |
|
288 { |
|
289 //TODO: report error |
|
290 } |
|
291 |
|
292 iTransactionId = 0; |
|
293 } |
|
294 |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // SetProperty |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 TInt ProfileObserver::SetProperty( CHsContentPublisher& /*aPlugin*/, |
|
301 const TDesC8& /*aElementId*/, |
|
302 const TDesC8& /*aPropertyName*/, |
|
303 const TDesC8& /*aPropertyValue*/ ) |
|
304 { |
|
305 return KErrNone; |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // SetProperty |
|
310 // --------------------------------------------------------------------------- |
|
311 // |
|
312 TInt ProfileObserver::SetProperty( CHsContentPublisher& /*aPlugin*/, |
|
313 const TDesC8& /*aElementId*/, |
|
314 const TDesC8& /*aPropertyName*/, |
|
315 const TDesC8& /*aPropertyValue*/, |
|
316 MAiContentObserver::TValueType /*aValueType*/ ) |
|
317 { |
|
318 return KErrNone; |
|
319 } |
|
320 |
|
321 // End of File. |