|
1 /* |
|
2 * Copyright (c) 2002 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 * Scanner that finds extensions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkExtensionScanner.h" |
|
22 #include <ecom/ecom.h> |
|
23 #include "CPbkExtGlobals.h" |
|
24 #include <ExtensionUID.h> |
|
25 #include "CPbkExtensionLoader.h" |
|
26 #include "PbkUID.h" |
|
27 |
|
28 #include <PbkDebug.h> // Phonebook debugging support |
|
29 #include "PbkProfiling.h" |
|
30 |
|
31 |
|
32 // Unnamed namespace for local definitions |
|
33 namespace { |
|
34 |
|
35 void CleanupResetAndDestroy(TAny* aObj) |
|
36 { |
|
37 if (aObj) |
|
38 { |
|
39 static_cast<RImplInfoPtrArray*>(aObj)->ResetAndDestroy(); |
|
40 } |
|
41 } |
|
42 |
|
43 } // namespace |
|
44 |
|
45 // ==================== MEMBER FUNCTIONS ==================== |
|
46 CPbkExtensionScanner::CPbkExtensionScanner(CPbkExtensionArray& aExtensions) : |
|
47 iExtensions(aExtensions) |
|
48 { |
|
49 } |
|
50 |
|
51 CPbkExtensionScanner::~CPbkExtensionScanner() |
|
52 { |
|
53 } |
|
54 |
|
55 |
|
56 CPbkExtensionScanner* |
|
57 CPbkExtensionScanner::NewLC(CPbkExtensionArray& aExtensions) |
|
58 { |
|
59 CPbkExtensionScanner* self = |
|
60 new (ELeave) CPbkExtensionScanner(aExtensions); |
|
61 CleanupStack::PushL( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 void CPbkExtensionScanner::ScanL() |
|
66 { |
|
67 __PBK_PROFILE_START(PbkProfiling::EEComUiExtensionScanPrepare); |
|
68 RImplInfoPtrArray implementations; |
|
69 TEComResolverParams resolverParams; |
|
70 |
|
71 resolverParams.SetWildcardMatch(ETrue); |
|
72 _LIT8(KPbkExtension, KPbkUiExtensionDefaultDataString); |
|
73 resolverParams.SetDataType(KPbkExtension); |
|
74 |
|
75 __PBK_PROFILE_END(PbkProfiling::EEComUiExtensionScanPrepare); |
|
76 PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Start ECom extension scan")); |
|
77 __PBK_PROFILE_START(PbkProfiling::EEComUiExtensionScan); |
|
78 |
|
79 // Use ROM only resolver |
|
80 REComSession::ListImplementationsL |
|
81 (TUid::Uid(KPbkUiExtensionInterfaceDefinitionUID), |
|
82 resolverParams, |
|
83 implementations); |
|
84 |
|
85 __PBK_PROFILE_END(PbkProfiling::EEComUiExtensionScan); |
|
86 PBK_DEBUG_PRINT(PBK_DEBUG_STRING("Done Ecom extension scan")); |
|
87 |
|
88 __PBK_PROFILE_START(PbkProfiling::EEComUiExtensionLoadPrepare); |
|
89 CleanupStack::PushL(TCleanupItem(CleanupResetAndDestroy, |
|
90 &implementations)); |
|
91 |
|
92 const TInt count = implementations.Count(); |
|
93 iExtensions.SetReserveL(iExtensions.Count() + count); |
|
94 __PBK_PROFILE_END(PbkProfiling::EEComUiExtensionLoadPrepare); |
|
95 for (TInt i = count-1; i >= 0; --i) |
|
96 { |
|
97 __PBK_PROFILE_START(PbkProfiling::EEComUiExtensionLoadPrepare); |
|
98 CImplementationInformation* implInfo = implementations[i]; |
|
99 CleanupStack::PushL(implInfo); |
|
100 implementations.Remove(i); |
|
101 __PBK_PROFILE_END(PbkProfiling::EEComUiExtensionLoadPrepare); |
|
102 |
|
103 CPbkExtensionLoader* extension = NULL; |
|
104 TRAPD(err, |
|
105 extension = CPbkExtensionLoader::NewL(implInfo->ImplementationUid())); |
|
106 if (err == KErrNone) |
|
107 { |
|
108 CleanupStack::PushL(extension); |
|
109 iExtensions.AppendL(extension); |
|
110 CleanupStack::Pop(extension); |
|
111 } |
|
112 |
|
113 CleanupStack::PopAndDestroy(implInfo); |
|
114 } |
|
115 CleanupStack::PopAndDestroy(); // implementations |
|
116 } |
|
117 |
|
118 // End of File |