|
1 /* |
|
2 * Copyright (c) 2009 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 |
|
24 #include "observer.h" |
|
25 //#include "caiplugintesterview.h" |
|
26 |
|
27 |
|
28 const char KAiShortcutCaption[] = "ShortcutCaption"; |
|
29 const char KAiShortcutIcon[] = "ShortcutIcon"; |
|
30 |
|
31 |
|
32 // ======== MEMBER FUNCTIONS ======== |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 Observer::Observer() |
|
39 { |
|
40 } |
|
41 |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 void Observer::ConstructL() |
|
48 { |
|
49 } |
|
50 |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 Observer* Observer::NewL() |
|
57 { |
|
58 Observer* self = new(ELeave) Observer(); |
|
59 CleanupStack::PushL(self); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop(self); |
|
62 return self; |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 Observer::~Observer() |
|
71 { |
|
72 } |
|
73 |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // Invoked by the plug-in to inform that it initiates content publishing transaction |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 TInt Observer::StartTransaction(TInt aTxId) |
|
80 { |
|
81 if (iTransactionId != 0) |
|
82 { |
|
83 //TODO: report error |
|
84 } |
|
85 |
|
86 iTransactionId = aTxId; |
|
87 return KErrNone; |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Invoked by the plug-in to request framework that content publishing is committed |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 TInt Observer::Commit(TInt aTxId) |
|
96 { |
|
97 TRAPD(err, DoCommitL(aTxId)); |
|
98 return err; |
|
99 } |
|
100 |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Invoked by plug-in to indicate that content publishing transaction is cancelled |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 TInt Observer::Rollback(TInt aTxId) |
|
107 { |
|
108 if (iTransactionId == 0) |
|
109 { |
|
110 //TODO: report error |
|
111 } |
|
112 else if (iTransactionId != aTxId) |
|
113 { |
|
114 //TODO: report error |
|
115 } |
|
116 |
|
117 return KErrNone; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // Invoked by plug-in to test if content can be published. |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 TBool Observer::CanPublish(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, TInt /*aIndex*/) |
|
125 { |
|
126 return ETrue; |
|
127 } |
|
128 |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // Invoked by the plug-in to inform that content must be published |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 TInt Observer::Publish(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, TInt /*aResource*/, TInt /*aIndex*/) |
|
135 { |
|
136 //TRAPD(err, DoPublishL(aPlugin, aContent, aResource, aIndex)); |
|
137 TInt err( KErrNone ); |
|
138 return err; |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // Invoked by the plug-in to inform that content must be published |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 TInt Observer::Publish(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, const TDesC16& /*aText*/, TInt /*aIndex*/) |
|
147 { |
|
148 //TRAPD(err, DoPublishL(aPlugin, aContent, aText, aIndex)); |
|
149 TInt err( KErrNone ); |
|
150 return err; |
|
151 } |
|
152 |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 TInt Observer::Publish(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, const TDesC8& aBuf, TInt /*aIndex*/) |
|
159 { |
|
160 CGulIcon* icon = UnpackPtr<CGulIcon>(aBuf); |
|
161 if (icon != NULL) |
|
162 { |
|
163 delete icon; |
|
164 } |
|
165 else |
|
166 { |
|
167 //TODO report error |
|
168 } |
|
169 return KErrNone; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // Invoked by the plug-in to inform that content must be published |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 TInt Observer::Publish(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, RFile& /*aFile*/, TInt /*aIndex*/) |
|
177 { |
|
178 return KErrNotSupported; |
|
179 } |
|
180 |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // Invoked by the plug-in to inform that content must be cleaned in UI |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 TInt Observer::Clean(CHsContentPublisher& /*aPlugin*/, TInt /*aContent*/, TInt /*aIndex*/) |
|
187 { |
|
188 // TODO: clean content. |
|
189 iTransactionId = 0; |
|
190 return 0; |
|
191 } |
|
192 |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // Returns interface extension. Not used in Series 60 v3.2 release. |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 TAny* Observer::Extension(TUid /*aUid*/) |
|
199 { |
|
200 return NULL; |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 TBool Observer::RequiresSubscription( const THsPublisherInfo& /*aPublisherInfo*/ ) const |
|
208 { |
|
209 return EFalse; |
|
210 } |
|
211 |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // Leaving version of the commit operation |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 void Observer::DoCommitL(TInt aTxId) |
|
218 { |
|
219 if (iTransactionId == 0) |
|
220 { |
|
221 //TODO: report error |
|
222 } |
|
223 else if (iTransactionId != aTxId) |
|
224 { |
|
225 //TODO: report error |
|
226 } |
|
227 |
|
228 iTransactionId = 0; |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // SetProperty |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 TInt Observer::SetProperty( CHsContentPublisher& /*aPlugin*/, |
|
236 const TDesC8& /*aElementId*/, |
|
237 const TDesC8& /*aPropertyName*/, |
|
238 const TDesC8& /*aPropertyValue*/ ) |
|
239 { |
|
240 return KErrNone; |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // SetProperty |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 TInt Observer::SetProperty( CHsContentPublisher& /*aPlugin*/, |
|
248 const TDesC8& /*aElementId*/, |
|
249 const TDesC8& /*aPropertyName*/, |
|
250 const TDesC8& /*aPropertyValue*/, |
|
251 MAiContentObserver::TValueType /*aValueType*/ ) |
|
252 { |
|
253 return KErrNone; |
|
254 } |
|
255 |
|
256 // End of File. |