|
1 /* |
|
2 * Copyright (c) 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: This implementation enumerates and returns the plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "AspPreSyncPluginInterface.h" |
|
21 #include "CPreSyncPlugin.h" |
|
22 |
|
23 _LIT(kDefault,"DEFAULT"); |
|
24 |
|
25 // ============================== MEMBER FUNCTIONS ============================ |
|
26 |
|
27 // ---------------------------------------------------------------------------- |
|
28 // CPreSyncPluginInterface::NewL |
|
29 // Two Phase Construction |
|
30 // ---------------------------------------------------------------------------- |
|
31 CPreSyncPluginInterface* CPreSyncPluginInterface::NewL() |
|
32 { |
|
33 CPreSyncPluginInterface* self = CPreSyncPluginInterface::NewLC(); |
|
34 CleanupStack::Pop( self ); |
|
35 |
|
36 return self; |
|
37 } |
|
38 |
|
39 // ---------------------------------------------------------------------------- |
|
40 // CPreSyncPluginInterface::NewLC |
|
41 // Two Phase Construction |
|
42 // ---------------------------------------------------------------------------- |
|
43 CPreSyncPluginInterface* CPreSyncPluginInterface::NewLC() |
|
44 { |
|
45 CPreSyncPluginInterface* self = new( ELeave ) CPreSyncPluginInterface(); |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // CPreSyncPluginInterface::CPreSyncPluginInterface |
|
54 // Constructor |
|
55 // ---------------------------------------------------------------------------- |
|
56 CPreSyncPluginInterface::CPreSyncPluginInterface() |
|
57 { |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CPreSyncPluginInterface::ConstructL |
|
62 // 2nd phase constructor |
|
63 // ---------------------------------------------------------------------------- |
|
64 void CPreSyncPluginInterface::ConstructL() |
|
65 { |
|
66 } |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CPreSyncPluginInterface::~CPreSyncPluginInterface |
|
70 // Constructor |
|
71 // ---------------------------------------------------------------------------- |
|
72 CPreSyncPluginInterface::~CPreSyncPluginInterface( ) |
|
73 { |
|
74 UnloadPlugIns(); |
|
75 } |
|
76 |
|
77 /** |
|
78 * Lists all implementations which satisfy this ecom interface |
|
79 * |
|
80 * @param aImplInfoArray On return, contains the list of available implementations |
|
81 * |
|
82 */ |
|
83 inline void CPreSyncPluginInterface::ListAllImplementationsL( RImplInfoPtrArray& aImplInfoArray ) |
|
84 { |
|
85 REComSession::ListImplementationsL( KPreSyncPluginInterfaceUid, aImplInfoArray ); |
|
86 } |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // CPreSyncPluginInterface::InstantiateAllPlugInsL |
|
90 // Instantiates all plugins |
|
91 // ---------------------------------------------------------------------------- |
|
92 CPreSyncPlugin* CPreSyncPluginInterface::InstantiateRoamingPluginLC( TSmlProfileId aProfileId ) |
|
93 { |
|
94 RImplInfoPtrArray infoArray; |
|
95 TBool bHandleSync = EFalse; |
|
96 CPreSyncPlugin* syncPlugin = NULL; |
|
97 CPreSyncPlugin* defaultSyncPlugin = NULL; |
|
98 |
|
99 // Get list of all implementations |
|
100 TRAPD(error, ListAllImplementationsL( infoArray )); |
|
101 |
|
102 if (error != KErrNone) |
|
103 { |
|
104 return NULL; |
|
105 } |
|
106 // Instantiate plugins for all impUIds by calling |
|
107 // InstantiatePlugInFromImpUidLC |
|
108 for ( TInt i=0; i<infoArray.Count(); i++ ) |
|
109 { |
|
110 // Get imp info |
|
111 CImplementationInformation& info( *infoArray[i] ); |
|
112 |
|
113 TUid impUid ( info.ImplementationUid() ); |
|
114 |
|
115 |
|
116 if ( info.DisplayName().Compare(kDefault) == 0 ) |
|
117 { |
|
118 //instantiate plugin for impUid |
|
119 defaultSyncPlugin = InstantiatePlugInFromImpUidLC( impUid ); |
|
120 defaultSyncPlugin->SetProfile(aProfileId); |
|
121 } |
|
122 else |
|
123 { |
|
124 syncPlugin = InstantiatePlugInFromImpUidLC( impUid ); |
|
125 syncPlugin->SetProfile(aProfileId); |
|
126 if(syncPlugin->IsSupported()) |
|
127 { |
|
128 bHandleSync = ETrue; |
|
129 break; |
|
130 } |
|
131 else |
|
132 { |
|
133 CleanupStack::PopAndDestroy(syncPlugin); |
|
134 } |
|
135 } |
|
136 } |
|
137 |
|
138 infoArray.ResetAndDestroy(); |
|
139 if(bHandleSync) |
|
140 { |
|
141 //delete defaultSyncPlugin; |
|
142 if(defaultSyncPlugin != NULL) |
|
143 { |
|
144 CleanupStack::PopAndDestroy(defaultSyncPlugin); |
|
145 } |
|
146 return syncPlugin; |
|
147 } |
|
148 else |
|
149 { |
|
150 return defaultSyncPlugin; |
|
151 } |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CPreSyncPluginInterface::UnloadPlugIns |
|
156 // Unloads plugins |
|
157 // ----------------------------------------------------------------------------- |
|
158 void CPreSyncPluginInterface::UnloadPlugIns() |
|
159 { |
|
160 REComSession::FinalClose(); |
|
161 } |
|
162 |
|
163 // ---------------------------------------------------------------------------- |
|
164 // CPreSyncPluginInterface::InstantiatePlugInFromImpUidLC |
|
165 // Instantiates plugin |
|
166 // ---------------------------------------------------------------------------- |
|
167 CPreSyncPlugin* CPreSyncPluginInterface::InstantiatePlugInFromImpUidLC( const TUid& aImpUid ) |
|
168 { |
|
169 // REComSession |
|
170 CPreSyncPlugin *preSyncPlugin = CPreSyncPlugin::NewL(aImpUid); |
|
171 CleanupStack::PushL(preSyncPlugin); |
|
172 return preSyncPlugin; |
|
173 } |
|
174 |
|
175 |