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