|
1 /* |
|
2 * Copyright (c) 2006-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: Plugin for messagingplugin information search. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 //SYSTEM INCLUDES |
|
22 #include <aknnotewrappers.h> |
|
23 #include <AknsConstants.h> |
|
24 #include <eikenv.h> |
|
25 #include <mtmuibas.h> |
|
26 #include <mtmuidef.hrh> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 #include <messagessearchplugin.mbg> |
|
29 #include <messagespluginresource.rsg> |
|
30 #include <apgcli.h> |
|
31 #include <apacmdln.h> |
|
32 #include <utf.h> |
|
33 #include <apgcli.h> |
|
34 #include <apacmdln.h> |
|
35 #include <searchpluginobserver.h> |
|
36 #include <searchcontent.h> |
|
37 #include <searchcommon.h> |
|
38 #include <searchiconinfo.h> |
|
39 #include <searchdocumentid.h> |
|
40 #include <searchpluginobserver.h> |
|
41 #include <bautils.h> |
|
42 |
|
43 #include <w32std.h> |
|
44 |
|
45 #include <searchcontent.h> |
|
46 |
|
47 //User includes |
|
48 #include "messagessearcher.h" |
|
49 #include "messagessearchplugin.h" |
|
50 #include "messagessearchplugindefines.h" |
|
51 |
|
52 // Definition of service |
|
53 const TUid KMuiuMsgEditorServiceUid = { 0x101F8820 }; |
|
54 |
|
55 // Service types |
|
56 const TInt KMsgServiceView = 0x00000001; |
|
57 const TInt KMsgServiceEdit = 0x00000002; |
|
58 // |
|
59 |
|
60 |
|
61 // ------------------------------------------------------------------------------------------------ |
|
62 // CMessagesSearchPlugIn::NewL( TUid aImpUid ) |
|
63 // Symbian 1st phase constructor |
|
64 // ------------------------------------------------------------------------------------------------ |
|
65 // |
|
66 CMessagesSearchPlugIn* CMessagesSearchPlugIn::NewL() |
|
67 { |
|
68 |
|
69 CMessagesSearchPlugIn* self = new(ELeave) CMessagesSearchPlugIn(); |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop( self ); |
|
73 return self; |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CMessagesSearchPlugIn::CMessagesSearchPlugIn |
|
79 // Performs the first phase of two phase construction. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CMessagesSearchPlugIn::CMessagesSearchPlugIn() |
|
83 { |
|
84 |
|
85 } |
|
86 |
|
87 |
|
88 // ------------------------------------------------------------------------------------------------ |
|
89 // CMessagesSearchPlugIn::ConstructL() |
|
90 // Symbian 2nd phase constructor |
|
91 // ------------------------------------------------------------------------------------------------ |
|
92 // |
|
93 void CMessagesSearchPlugIn::ConstructL() |
|
94 { |
|
95 RFs fsSession; |
|
96 RResourceFile resourceFile; |
|
97 TFileName resourceFileName; |
|
98 User::LeaveIfError( fsSession.Connect() ); |
|
99 TPtrC driveLetter = TParsePtrC( RProcess().FileName() ).Drive(); |
|
100 |
|
101 _LIT( KMessagesMifFileName, "messagessearchplugin.mif" ); |
|
102 mifFileName = driveLetter; |
|
103 mifFileName.Append( KDC_APP_BITMAP_DIR ); |
|
104 mifFileName.Append( KMessagesMifFileName ); |
|
105 iMsgPluginId = KSearchCClassMessagesUid; |
|
106 |
|
107 resourceFileName.Copy( driveLetter ); |
|
108 resourceFileName.Append( KDC_ECOM_RESOURCE_DIR ); |
|
109 resourceFileName.Append( KResoureFileName ); |
|
110 BaflUtils::NearestLanguageFile( fsSession, resourceFileName ); |
|
111 resourceFile.OpenL(fsSession, resourceFileName ); |
|
112 resourceFile.ConfirmSignatureL(0); |
|
113 |
|
114 // Fetch Caption "Messages" |
|
115 { |
|
116 HBufC8* readBuffer=resourceFile.AllocReadLC( R_QTN_SEARCH_TYPES_MESSAGES ); |
|
117 const TPtrC16 ptrReadBuffer(( TText16*) readBuffer->Ptr(), |
|
118 ( readBuffer->Length()+1 )>>1 ); |
|
119 |
|
120 iMessagesCaption = ptrReadBuffer.AllocL(); |
|
121 CleanupStack::PopAndDestroy( readBuffer ); |
|
122 } |
|
123 |
|
124 // Fetch Caption "Inbox" |
|
125 { |
|
126 HBufC8* readBuffer=resourceFile.AllocReadLC( R_QTN_SEARCH_SUBFOLDERS_INBOXMSG ); |
|
127 const TPtrC16 ptrReadBuffer(( TText16*) readBuffer->Ptr(), |
|
128 ( readBuffer->Length()+1 )>>1 ); |
|
129 |
|
130 iInboxCaption = ptrReadBuffer.AllocL(); |
|
131 CleanupStack::PopAndDestroy( readBuffer ); |
|
132 } |
|
133 |
|
134 // Fetch Caption "Outbox" |
|
135 { |
|
136 HBufC8* readBuffer=resourceFile.AllocReadLC( R_QTN_SEARCH_SUBFOLDERS_OUTBOXMSG ); |
|
137 const TPtrC16 ptrReadBuffer(( TText16*) readBuffer->Ptr(), |
|
138 ( readBuffer->Length()+1 )>>1 ); |
|
139 |
|
140 iOutboxCaption = ptrReadBuffer.AllocL(); |
|
141 CleanupStack::PopAndDestroy( readBuffer ); |
|
142 } |
|
143 |
|
144 // Fetch caption "Sentbox" |
|
145 { |
|
146 HBufC8* readBuffer=resourceFile.AllocReadLC( R_QTN_SEARCH_SUBFOLDERS_SENTMSG ); |
|
147 const TPtrC16 ptrReadBuffer(( TText16*) readBuffer->Ptr(), |
|
148 ( readBuffer->Length()+1 )>>1 ); |
|
149 |
|
150 iSentboxCaption = ptrReadBuffer.AllocL(); |
|
151 CleanupStack::PopAndDestroy( readBuffer ); |
|
152 } |
|
153 |
|
154 // Fetch Caption "Drafts" |
|
155 { |
|
156 HBufC8* readBuffer=resourceFile.AllocReadLC( R_QTN_SEARCH_SUBFOLDERS_DRAFTS ); |
|
157 const TPtrC16 ptrReadBuffer(( TText16*) readBuffer->Ptr(), |
|
158 ( readBuffer->Length()+1 )>>1 ); |
|
159 |
|
160 iDraftsCaption = ptrReadBuffer.AllocL(); |
|
161 CleanupStack::PopAndDestroy( readBuffer ); |
|
162 } |
|
163 |
|
164 resourceFile.Close(); |
|
165 fsSession.Close(); |
|
166 |
|
167 } |
|
168 |
|
169 // ------------------------------------------------------------------------------------------------ |
|
170 // CMessagesSearchPlugIn::~CMessagesSearchPlugIn() |
|
171 // Destructor |
|
172 // ------------------------------------------------------------------------------------------------ |
|
173 // |
|
174 CMessagesSearchPlugIn::~CMessagesSearchPlugIn() |
|
175 { |
|
176 if (iMessagesCaption) |
|
177 { |
|
178 delete iMessagesCaption; |
|
179 iMessagesCaption = NULL; |
|
180 } |
|
181 |
|
182 if (iInboxCaption) |
|
183 { |
|
184 delete iInboxCaption; |
|
185 iInboxCaption = NULL; |
|
186 } |
|
187 |
|
188 if (iSentboxCaption) |
|
189 { |
|
190 delete iSentboxCaption; |
|
191 iSentboxCaption = NULL; |
|
192 } |
|
193 |
|
194 if (iDraftsCaption) |
|
195 { |
|
196 delete iDraftsCaption; |
|
197 iDraftsCaption = NULL; |
|
198 } |
|
199 |
|
200 if (iOutboxCaption) |
|
201 { |
|
202 delete iOutboxCaption; |
|
203 iOutboxCaption = NULL; |
|
204 } |
|
205 |
|
206 |
|
207 } |
|
208 |
|
209 |
|
210 // ------------------------------------------------------------------------------------------------ |
|
211 // CMessagesSearchPlugIn::GetSupportedContentL() |
|
212 // |
|
213 // ------------------------------------------------------------------------------------------------ |
|
214 // |
|
215 |
|
216 void CMessagesSearchPlugIn::GetSupportedContentL( |
|
217 RPointerArray<CSearchContent>& aContent ) |
|
218 { |
|
219 |
|
220 CSearchContent::TSearchContentType aType = CSearchContent::ETypeContentClass; |
|
221 |
|
222 CSearchContent* messagesContent = NULL; |
|
223 CSearchContent* inboxMsgContent = NULL; |
|
224 CSearchContent* sentMsgContent = NULL; |
|
225 CSearchContent* outboxMsgContent = NULL; |
|
226 CSearchContent* draftsMsgContent = NULL; |
|
227 |
|
228 messagesContent = CSearchContent::NewL( aType ); |
|
229 CleanupStack::PushL( messagesContent ); |
|
230 |
|
231 CSearchIconInfo* messagesIconInfo = CSearchIconInfo::NewL(); |
|
232 CleanupStack::PushL( messagesIconInfo ); |
|
233 |
|
234 if( messagesIconInfo ) |
|
235 { |
|
236 // For Meeting Skin Icon Const and KAknsIIDQgnPropMceSmsInfo for Day Messages. |
|
237 messagesIconInfo->SetSkinId( KAknsIIDQgnPropMceSmsInfo ); |
|
238 messagesIconInfo->SetIconFileL( mifFileName ); |
|
239 messagesIconInfo->SetIconIndex( EMbmMessagessearchpluginQgn_prop_wml_sms ); |
|
240 messagesIconInfo->SetIconMaskIndex( EMbmMessagessearchpluginQgn_prop_wml_sms_mask ); |
|
241 } |
|
242 |
|
243 if( messagesContent && messagesIconInfo ) |
|
244 messagesContent->SetIconInfo( messagesIconInfo ); |
|
245 |
|
246 if(messagesContent) |
|
247 { |
|
248 messagesContent->SetContentId( KSearchCClassMessagesUid ); |
|
249 messagesContent->SetSubContentId( 0 ); |
|
250 messagesContent->SetPluginId( iMsgPluginId ); |
|
251 messagesContent->SetCaptionL( *iMessagesCaption ); |
|
252 aContent.Append( messagesContent ); |
|
253 |
|
254 } |
|
255 |
|
256 aType = CSearchContent::ETypeContentFolder; |
|
257 |
|
258 inboxMsgContent = CSearchContent::NewL( aType ); |
|
259 CleanupStack::PushL( inboxMsgContent ); |
|
260 CSearchIconInfo* inboxMsgIconInfo = CSearchIconInfo::NewL(); |
|
261 CleanupStack::PushL( inboxMsgIconInfo ); |
|
262 |
|
263 if( inboxMsgIconInfo ) |
|
264 { |
|
265 inboxMsgIconInfo->SetIconFileL( mifFileName ); |
|
266 inboxMsgIconInfo->SetIconIndex( EMbmMessagessearchpluginQgn_prop_mce_inbox_small ); |
|
267 inboxMsgIconInfo->SetIconMaskIndex( EMbmMessagessearchpluginQgn_prop_mce_inbox_small_mask); |
|
268 inboxMsgIconInfo->SetSkinId( KAknsIIDQgnPropMceInboxSmall ); |
|
269 } |
|
270 |
|
271 if( inboxMsgIconInfo && inboxMsgContent ) |
|
272 inboxMsgContent->SetIconInfo( inboxMsgIconInfo ); |
|
273 |
|
274 if(inboxMsgContent) |
|
275 { |
|
276 inboxMsgContent->SetContentId( KSearchCClassMessagesUid ); |
|
277 inboxMsgContent->SetSubContentId( KSearchCFolderInboxUid.iUid ); |
|
278 inboxMsgContent->SetPluginId( iMsgPluginId ); |
|
279 inboxMsgContent->SetCaptionL( *iInboxCaption ); |
|
280 } |
|
281 |
|
282 aType = CSearchContent::ETypeContentFolder; |
|
283 sentMsgContent = CSearchContent::NewL( aType ); |
|
284 CleanupStack::PushL( sentMsgContent ); |
|
285 CSearchIconInfo* sentMsgIconInfo = CSearchIconInfo::NewL(); |
|
286 CleanupStack::PushL( sentMsgIconInfo ); |
|
287 |
|
288 if( sentMsgIconInfo ) |
|
289 { |
|
290 sentMsgIconInfo->SetSkinId( KAknsIIDQgnPropMceSentTab4 ); |
|
291 sentMsgIconInfo->SetIconFileL( mifFileName ); |
|
292 sentMsgIconInfo->SetIconIndex( EMbmMessagessearchpluginQgn_prop_mce_sent ); |
|
293 sentMsgIconInfo->SetIconMaskIndex( EMbmMessagessearchpluginQgn_prop_mce_sent_mask ); |
|
294 } |
|
295 |
|
296 if( sentMsgIconInfo && sentMsgContent ) |
|
297 sentMsgContent->SetIconInfo( sentMsgIconInfo ); |
|
298 |
|
299 if(sentMsgContent) |
|
300 { |
|
301 sentMsgContent->SetContentId( KSearchCClassMessagesUid ); |
|
302 sentMsgContent->SetSubContentId( KSearchCFolderSentUid.iUid ); |
|
303 sentMsgContent->SetPluginId( iMsgPluginId ); |
|
304 sentMsgContent->SetCaptionL( *iSentboxCaption ); |
|
305 } |
|
306 |
|
307 aType = CSearchContent::ETypeContentFolder; |
|
308 outboxMsgContent = CSearchContent::NewL( aType ); |
|
309 CleanupStack::PushL( outboxMsgContent ); |
|
310 CSearchIconInfo* outboxMsgIconInfo = CSearchIconInfo::NewL(); |
|
311 CleanupStack::PushL( outboxMsgIconInfo ); |
|
312 |
|
313 if( outboxMsgIconInfo ) |
|
314 { |
|
315 |
|
316 outboxMsgIconInfo->SetSkinId( KAknsIIDQgnPropMceOutboxTab4 ); |
|
317 outboxMsgIconInfo->SetIconFileL( mifFileName ); |
|
318 outboxMsgIconInfo->SetIconIndex( EMbmMessagessearchpluginQgn_prop_mce_outbox_small ); |
|
319 outboxMsgIconInfo->SetIconMaskIndex( EMbmMessagessearchpluginQgn_prop_mce_outbox_small_mask); |
|
320 } |
|
321 |
|
322 if( outboxMsgIconInfo && outboxMsgContent ) |
|
323 outboxMsgContent->SetIconInfo( outboxMsgIconInfo ); |
|
324 |
|
325 if(outboxMsgContent) |
|
326 { |
|
327 outboxMsgContent->SetContentId( KSearchCClassMessagesUid ); |
|
328 outboxMsgContent->SetSubContentId( KSearchCFolderOutboxUid.iUid ); |
|
329 outboxMsgContent->SetPluginId( iMsgPluginId ); |
|
330 outboxMsgContent->SetCaptionL( *iOutboxCaption ); |
|
331 |
|
332 } |
|
333 |
|
334 aType = CSearchContent::ETypeContentFolder; |
|
335 draftsMsgContent = CSearchContent::NewL( aType ); |
|
336 CleanupStack::PushL( draftsMsgContent ); |
|
337 CSearchIconInfo* draftsMsgIconInfo = CSearchIconInfo::NewL(); |
|
338 CleanupStack::PushL( draftsMsgIconInfo ); |
|
339 |
|
340 if( draftsMsgIconInfo ) |
|
341 { |
|
342 draftsMsgIconInfo->SetSkinId( KAknsIIDQgnPropMceDrafts ); |
|
343 draftsMsgIconInfo->SetIconFileL( mifFileName ); |
|
344 draftsMsgIconInfo->SetIconIndex( EMbmMessagessearchpluginQgn_prop_mce_drafts ); |
|
345 draftsMsgIconInfo->SetIconMaskIndex( EMbmMessagessearchpluginQgn_prop_mce_drafts_mask); |
|
346 } |
|
347 |
|
348 if( draftsMsgIconInfo && draftsMsgContent ) |
|
349 draftsMsgContent->SetIconInfo( draftsMsgIconInfo ); |
|
350 |
|
351 if(draftsMsgContent) |
|
352 { |
|
353 draftsMsgContent->SetContentId( KSearchCClassMessagesUid ); |
|
354 draftsMsgContent->SetSubContentId( KSearchCFolderDraftsUid.iUid ); // KSearchCFolderDraftsUid |
|
355 draftsMsgContent->SetPluginId( iMsgPluginId ); |
|
356 draftsMsgContent->SetCaptionL( *iDraftsCaption ); |
|
357 } |
|
358 |
|
359 messagesContent->AddChildL( inboxMsgContent ); |
|
360 messagesContent->AddChildL( sentMsgContent ); |
|
361 messagesContent->AddChildL( outboxMsgContent ); |
|
362 messagesContent->AddChildL( draftsMsgContent ); |
|
363 |
|
364 CleanupStack::Pop( 10 ); |
|
365 |
|
366 } |
|
367 |
|
368 // ------------------------------------------------------------------------------------------------ |
|
369 // CMessagesSearchPlugIn::IsSupportedContent( const CSearchContent& aContent ) |
|
370 // |
|
371 // ------------------------------------------------------------------------------------------------ |
|
372 // |
|
373 |
|
374 TBool CMessagesSearchPlugIn::IsSupportedContent( TUid aContentId ) |
|
375 |
|
376 { |
|
377 if ( ( aContentId.iUid == KSearchCClassMessagesUid.iUid ) || |
|
378 ( aContentId.iUid == KSearchCFolderInboxUid.iUid ) || |
|
379 ( aContentId.iUid == KSearchCFolderDraftsUid.iUid ) || |
|
380 ( aContentId.iUid == KSearchCFolderSentUid.iUid) || |
|
381 ( aContentId.iUid == KSearchCFolderOutboxUid.iUid) ) |
|
382 return ETrue; |
|
383 else |
|
384 return EFalse; |
|
385 } |
|
386 |
|
387 // ------------------------------------------------------------------------------------------------ |
|
388 // CMessagesSearchPlugIn::LaunchApplicationL( ) |
|
389 // Launches the application for the result viewer |
|
390 // ------------------------------------------------------------------------------------------------ |
|
391 // |
|
392 void CMessagesSearchPlugIn::LaunchApplicationL(const TDesC8& aLaunchInfo) |
|
393 { |
|
394 iMsgsSearcher->LaunchApplicationL( aLaunchInfo); |
|
395 } |
|
396 |
|
397 |
|
398 // ------------------------------------------------------------------------------------------------ |
|
399 // CMessagesSearchPlugIn::ContentSearcherL |
|
400 // Creates an Instance of the ContentSearcher that will carrry out the search |
|
401 // ------------------------------------------------------------------------------------------------ |
|
402 // |
|
403 |
|
404 MSearchContentSearcher* CMessagesSearchPlugIn::ContentSearcherL( |
|
405 const RArray<TUid>& aContentIdArray, |
|
406 const CSearchCondition& aCondition , |
|
407 MSearchPluginObserver& aObserver) |
|
408 { |
|
409 |
|
410 for( TInt j = 0; j < aContentIdArray.Count(); j++ ) |
|
411 { |
|
412 // create the iImagesSearcher |
|
413 if( (aContentIdArray[j].iUid == KSearchCClassMessagesUid.iUid )) |
|
414 { |
|
415 |
|
416 iMsgsSearcher = CMessagesSearcher::NewL( aContentIdArray, aCondition, PluginId(),aObserver); |
|
417 return iMsgsSearcher; |
|
418 } |
|
419 } |
|
420 return NULL; |
|
421 |
|
422 } |
|
423 |
|
424 |
|
425 // ------------------------------------------------------------------------------------------------- |
|
426 // CMessagesSearchPlugIn::GetNumFromDes |
|
427 // Method for converting a descriptor into a number. |
|
428 // ------------------------------------------------------------------------------------------------- |
|
429 // |
|
430 TUint32 CMessagesSearchPlugIn::GetNumFromDes( const TDesC& aDes, TRadix aRadix ) |
|
431 { |
|
432 TUint32 num; |
|
433 TLex temp( aDes ); |
|
434 temp.Val( num, aRadix ); |
|
435 return num; |
|
436 } |
|
437 |
|
438 // ------------------------------------------------------------------------------------------------- |
|
439 // CMessagesSearchPlugIn::GetNumFromDes |
|
440 // Method for converting a descriptor into a number. |
|
441 // ------------------------------------------------------------------------------------------------- |
|
442 // |
|
443 TUint32 CMessagesSearchPlugIn::GetNumFromDes( const TDesC8& aDes, TRadix aRadix ) |
|
444 { |
|
445 TUint32 num; |
|
446 TLex8 temp( aDes ); |
|
447 temp.Val( num, aRadix ); |
|
448 return num; |
|
449 } |
|
450 |
|
451 |