|
1 /* |
|
2 * Copyright (c) 2005-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aipropertyextension.h> |
|
20 #include "ainativerenderer.h" |
|
21 #include "ainativeuiplugins.h" |
|
22 |
|
23 using namespace AiNativeUiController; |
|
24 |
|
25 |
|
26 CAiNativeRenderer::~CAiNativeRenderer() |
|
27 { |
|
28 } |
|
29 |
|
30 |
|
31 TInt CAiNativeRenderer::Publish( MAiPropertyExtension& aPlugin, TInt aContent, |
|
32 TInt aResource, TInt aIndex ) |
|
33 { |
|
34 TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) ); |
|
35 |
|
36 if( err != KErrNone ) |
|
37 { |
|
38 return err; |
|
39 } |
|
40 |
|
41 TRAP( err, DoPublishL( aPlugin, aContent, aResource, aIndex ) ); |
|
42 return err; |
|
43 } |
|
44 |
|
45 |
|
46 TInt CAiNativeRenderer::Publish( MAiPropertyExtension& aPlugin, TInt aContent, |
|
47 const TDesC16& aText, TInt aIndex ) |
|
48 { |
|
49 TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) ); |
|
50 |
|
51 if( err != KErrNone ) |
|
52 { |
|
53 return err; |
|
54 } |
|
55 |
|
56 TRAP( err, DoPublishL( aPlugin, aContent, aText, aIndex ) ); |
|
57 return err; |
|
58 } |
|
59 |
|
60 |
|
61 TInt CAiNativeRenderer::Publish( MAiPropertyExtension& aPlugin, TInt aContent, |
|
62 const TDesC8& aBuf, TInt aIndex ) |
|
63 { |
|
64 TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) ); |
|
65 |
|
66 if( err != KErrNone ) |
|
67 { |
|
68 return err; |
|
69 } |
|
70 |
|
71 TRAP( err, DoPublishL( aPlugin, aContent, aBuf, aIndex ) ); |
|
72 return err; |
|
73 } |
|
74 |
|
75 |
|
76 TInt CAiNativeRenderer::Publish( MAiPropertyExtension& aPlugin, TInt aContent, |
|
77 RFile& aFile, TInt aIndex ) |
|
78 { |
|
79 TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) ); |
|
80 |
|
81 if( err != KErrNone ) |
|
82 { |
|
83 return err; |
|
84 } |
|
85 |
|
86 TRAP( err, DoPublishL( aPlugin, aContent, aFile, aIndex ) ); |
|
87 return err; |
|
88 } |
|
89 |
|
90 |
|
91 TInt CAiNativeRenderer::Clean( MAiPropertyExtension& aPlugin, TInt aContent ) |
|
92 { |
|
93 TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) ); |
|
94 |
|
95 if( err != KErrNone ) |
|
96 { |
|
97 return err; |
|
98 } |
|
99 |
|
100 TRAP( err, DoCleanL( aPlugin, aContent ) ); |
|
101 return err; |
|
102 } |
|
103 |
|
104 |
|
105 void CAiNativeRenderer::DoPublishL |
|
106 ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/, TInt /*aResource*/, TInt /*aIndex*/ ) |
|
107 { |
|
108 // Default implementation, overridden in subclass if needed. |
|
109 User::Leave( KErrNotFound ); |
|
110 } |
|
111 |
|
112 |
|
113 void CAiNativeRenderer::DoPublishL |
|
114 ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/, const TDesC16& /*aText*/, TInt /*aIndex*/ ) |
|
115 { |
|
116 // Default implementation, overridden in subclass if needed. |
|
117 User::Leave( KErrNotFound ); |
|
118 } |
|
119 |
|
120 |
|
121 void CAiNativeRenderer::DoPublishL |
|
122 ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/, const TDesC8& /*aBuf*/, TInt /*aIndex*/ ) |
|
123 { |
|
124 // Default implementation, overridden in subclass if needed. |
|
125 User::Leave( KErrNotFound ); |
|
126 } |
|
127 |
|
128 |
|
129 void CAiNativeRenderer::DoPublishL |
|
130 ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/, RFile& /*aFile*/, TInt /*aIndex*/ ) |
|
131 { |
|
132 // Default implementation, overridden in subclass if needed. |
|
133 User::Leave( KErrNotFound ); |
|
134 } |
|
135 |
|
136 |
|
137 void CAiNativeRenderer::DoCleanL |
|
138 ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/ ) |
|
139 { |
|
140 // Default implementation, overridden in subclass if needed. |
|
141 User::Leave( KErrNotFound ); |
|
142 } |
|
143 |
|
144 |
|
145 TInt CAiNativeRenderer::GetIntContentId( const TDesC& aCid ) const |
|
146 { |
|
147 for( TInt i( 0 ); i < KAiDeviceStatusContentCount; i++ ) |
|
148 { |
|
149 const TAiContentItem& item = KAiDeviceStatusContent[i]; |
|
150 if( ContentCid(item) == aCid ) |
|
151 { |
|
152 //match |
|
153 return item.id; |
|
154 } |
|
155 } |
|
156 |
|
157 for( TInt i( 0 ); i < KAiScutContentCount; i++ ) |
|
158 { |
|
159 const TAiContentItem& item = KAiScutContent[i]; |
|
160 if( ContentCid(item) == aCid ) |
|
161 { |
|
162 //match |
|
163 return item.id; |
|
164 } |
|
165 } |
|
166 |
|
167 return KErrNotFound; |
|
168 } |
|
169 |
|
170 |
|
171 TBool CAiNativeRenderer::MatchMimeType( MAiPropertyExtension& aPlugin, |
|
172 TInt aContentId, |
|
173 const TDesC8& aMimeType ) const |
|
174 { |
|
175 TUid pluginUid; |
|
176 TRAPD( err, pluginUid = aPlugin.PublisherInfoL()->iUid ); |
|
177 if ( err != KErrNone ) |
|
178 { |
|
179 return EFalse; |
|
180 } |
|
181 // loop through Device Status content items |
|
182 if ( pluginUid == KDeviceStatusPluginUid ) |
|
183 { |
|
184 for( TInt i( 0 ); i < KAiDeviceStatusContentCount; i++ ) |
|
185 { |
|
186 const TAiContentItem& item = KAiDeviceStatusContent[i]; |
|
187 |
|
188 if( item.id != aContentId ) |
|
189 { |
|
190 continue; |
|
191 } |
|
192 |
|
193 TBuf8<KAiContentTypeMaxLength> mimeType((TText8*) item.type); |
|
194 |
|
195 return ( mimeType.Match( aMimeType ) != KErrNotFound ); |
|
196 } |
|
197 } |
|
198 else if ( pluginUid == KShortcutPluginUid ) |
|
199 { |
|
200 // if match not found, loop through Shortcut content items |
|
201 for( TInt i( 0 ); i < KAiScutContentCount; i++ ) |
|
202 { |
|
203 const TAiContentItem& item = KAiScutContent[i]; |
|
204 |
|
205 if( item.id != aContentId ) |
|
206 { |
|
207 continue; |
|
208 } |
|
209 |
|
210 TBuf8<KAiContentTypeMaxLength> mimeType((TText8*) item.type); |
|
211 |
|
212 return ( mimeType.Match( aMimeType ) != KErrNotFound ); |
|
213 } |
|
214 } |
|
215 else if ( pluginUid == KProfilePluginUid ) |
|
216 { |
|
217 // if match not found, loop through Profile content items |
|
218 for( TInt i( 0 ); i < KAiProfileContentCount; i++ ) |
|
219 { |
|
220 const TAiContentItem& item = KAiProfileContent[i]; |
|
221 |
|
222 if( item.id != aContentId ) |
|
223 { |
|
224 continue; |
|
225 } |
|
226 |
|
227 TBuf8<KAiContentTypeMaxLength> mimeType((TText8*) item.type); |
|
228 |
|
229 return ( mimeType.Match( aMimeType ) != KErrNotFound ); |
|
230 } |
|
231 } |
|
232 |
|
233 return EFalse; |
|
234 } |
|
235 |
|
236 |
|
237 void CAiNativeRenderer::DoMimeTypeCheckL( MAiPropertyExtension& aPlugin, TInt aContentId ) |
|
238 { |
|
239 MAiContentItemIterator* iter = |
|
240 (MAiContentItemIterator*)aPlugin.GetPropertyL( EAiPublisherContent ); |
|
241 const TAiContentItem& item = iter->ItemL( aContentId ); |
|
242 |
|
243 aContentId = GetIntContentId( ContentCid(item) ); |
|
244 |
|
245 if( !MatchMimeType( aPlugin, aContentId, ContentType(item) ) ) |
|
246 { |
|
247 User::Leave( KErrNotSupported ); |
|
248 } |
|
249 |
|
250 } |
|
251 |