|
1 /* |
|
2 * Copyright (c) 2004-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 /** |
|
20 @file |
|
21 @internalComponent |
|
22 @released |
|
23 */ |
|
24 |
|
25 #include "plplugins.h" |
|
26 #include "cntviewprivate.h" |
|
27 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
28 #include <cntphonenumparser.h> |
|
29 #include "cntdb_internal.h" |
|
30 #include "cntsyncecom.h" |
|
31 #endif |
|
32 |
|
33 |
|
34 // The name of the test phone book sync plugin. This plugin will be used in the |
|
35 // first instance (i.e. if it exists then use it rather than any other plugin). |
|
36 _LIT(KTestPluginName,"Test phone book synchronizer Implementation"); |
|
37 |
|
38 |
|
39 CContactPlugin::CContactPlugin() |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 CContactPlugin::~CContactPlugin() |
|
45 { |
|
46 iDll.Close(); |
|
47 } |
|
48 |
|
49 |
|
50 CContactPhoneParser* CContactPhoneParser::NewL() |
|
51 { |
|
52 CContactPhoneParser* self=new(ELeave) CContactPhoneParser; |
|
53 CleanupStack::PushL(self); |
|
54 self->LoadEComPluginL(); |
|
55 CleanupStack::Pop(self); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 CContactPhoneParser::~CContactPhoneParser() |
|
61 { |
|
62 delete iParser; |
|
63 } |
|
64 |
|
65 |
|
66 void CContactPhoneParser::SetPluginL(TLibraryFunction aGateFunction) |
|
67 { |
|
68 iParser=REINTERPRET_CAST(CContactPhoneNumberParser*,(*aGateFunction)()); |
|
69 User::LeaveIfNull(iParser); |
|
70 } |
|
71 |
|
72 |
|
73 void CContactPhoneParser::LoadEComPluginL() |
|
74 { |
|
75 #ifdef __PROFILE__ |
|
76 RDebug::Print(_L("[CNTMODEL] Entering CContactPhoneParser::LoadEComPluginL\n")); |
|
77 TTime now; |
|
78 now.UniversalTime(); |
|
79 #endif |
|
80 |
|
81 RImplInfoPtrArray implInfoArray; |
|
82 CleanupResetAndDestroyPushL(implInfoArray); |
|
83 |
|
84 // Use default resolver parameters. |
|
85 TEComResolverParams resolverParams; |
|
86 |
|
87 // List implementations, searching only in ROM for the plugin. |
|
88 REComSession::ListImplementationsL(KUidEcomCntPhoneNumberParserInterface, |
|
89 resolverParams, KRomOnlyResolverUid, implInfoArray); |
|
90 |
|
91 const TInt count = implInfoArray.Count(); |
|
92 __ASSERT_ALWAYS( count > 0, User::Leave(KErrNotFound)); |
|
93 |
|
94 // Create the first implementation found for |
|
95 // KUidEcomCntPhoneNumberParserInterface. |
|
96 const TUid firstImplementationFound = implInfoArray[0]->ImplementationUid(); |
|
97 iParser = CContactEcomPhoneNumberParser::NewL(firstImplementationFound); |
|
98 CleanupStack::PopAndDestroy(&implInfoArray); |
|
99 |
|
100 #ifdef __PROFILE__ |
|
101 TTime now2; |
|
102 now2.UniversalTime(); |
|
103 RDebug::Print(_L("[CNTMODEL] Spend %d microseconds in CContactPhoneParser::LoadEComPluginL\n"), now2.MicroSecondsFrom(now).Int64()); |
|
104 #endif |
|
105 } |
|
106 |
|
107 |
|
108 EXPORT_C CContactSynchroniser::~CContactSynchroniser() |
|
109 { |
|
110 REComSession::DestroyedImplementation(iDtor_ID_Key); |
|
111 } |
|
112 |
|
113 |
|
114 CContactSynchroniser* CContactSynchroniser::NewL() |
|
115 { |
|
116 #ifdef __PROFILE__ |
|
117 RDebug::Print(_L("[CNTMODEL] Entering CContactSynchroniser::NewL\n")); |
|
118 TTime now; |
|
119 now.UniversalTime(); |
|
120 #endif |
|
121 |
|
122 RImplInfoPtrArray implInfoArray; |
|
123 CleanupResetAndDestroyPushL(implInfoArray); |
|
124 REComSession::ListImplementationsL(KUidEcomCntPhBkSyncInterface, implInfoArray); |
|
125 // Load the implementation found for KUidEcomCntPhBkSyncInterface, prefer the test plugin |
|
126 const TInt count = implInfoArray.Count(); |
|
127 __ASSERT_ALWAYS(count > 0, User::Leave(KErrNotSupported)); |
|
128 |
|
129 TInt pluginToBeUsed = 0; |
|
130 CImplementationInformation *info; |
|
131 |
|
132 // Scan the list of plugins for the test plugin. |
|
133 for (TInt plugIn = 0 ; plugIn < count ; ++plugIn) |
|
134 { |
|
135 info = implInfoArray[plugIn]; |
|
136 if(info->DisplayName() == KTestPluginName) |
|
137 { |
|
138 // We have found the test plugin so use it rather than any other |
|
139 // plugin. |
|
140 pluginToBeUsed = plugIn; |
|
141 break; |
|
142 } |
|
143 } |
|
144 #ifdef __VERBOSE_DEBUG__ |
|
145 RDebug::Print(_L("[CNTMODEL] CntServer has loaded syncplugin: %S\n"), &info->DisplayName()); |
|
146 #endif |
|
147 |
|
148 // Create the implementation found for KUidEcomCntPhBkSyncInterface. |
|
149 const TUid theImplementationID = implInfoArray[pluginToBeUsed]->ImplementationUid(); |
|
150 TAny* ptr = REComSession::CreateImplementationL(theImplementationID, |
|
151 _FOFF(CContactSynchroniser,iDtor_ID_Key)); |
|
152 |
|
153 CleanupStack::PopAndDestroy(&implInfoArray); |
|
154 |
|
155 #ifdef __PROFILE__ |
|
156 TTime now2; |
|
157 now2.UniversalTime(); |
|
158 RDebug::Print(_L("[CNTMODEL] Spend %d microseconds in CContactSynchroniser::NewL()\n"), now2.MicroSecondsFrom(now).Int64()); |
|
159 #endif |
|
160 |
|
161 return reinterpret_cast<CContactSynchroniser*>(ptr); |
|
162 } |
|
163 |
|
164 |
|
165 /** |
|
166 Reserved (private) virtual function to allow further extension of the |
|
167 MContactSynchroniser interface without requiring changes to all derived classes. |
|
168 This can be used to return a pointer to an additional extension class. |
|
169 */ |
|
170 EXPORT_C void MContactSynchroniser::MContactSynchroniser_Reserved_1() |
|
171 { |
|
172 } |