|
1 /* |
|
2 * Copyright (c) 2009-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: CCCaFactoryExtensionNotifier |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ccafactoryextensionnotifier.h" |
|
20 #include <ecom.h> |
|
21 #include <ccaextensionfactory.hrh> |
|
22 #include <ccaextensionfactory.h> |
|
23 |
|
24 // -------------------------------------------------------------------------- |
|
25 // CleanupResetAndDestroy |
|
26 // -------------------------------------------------------------------------- |
|
27 void CleanupResetAndDestroy( TAny* aObj ) |
|
28 { |
|
29 static_cast<RImplInfoPtrArray*>( aObj )->ResetAndDestroy(); |
|
30 } |
|
31 |
|
32 // =========================== MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CCCaFactoryExtensionNotifier::CCCaFactoryExtensionNotifier() |
|
36 // ---------------------------------------------------------------------------- |
|
37 // |
|
38 inline CCCaFactoryExtensionNotifier::CCCaFactoryExtensionNotifier() |
|
39 : CActive( EPriorityStandard ) |
|
40 { |
|
41 CActiveScheduler::Add(this); |
|
42 } |
|
43 |
|
44 // ---------------------------------------------------------------------------- |
|
45 // CCCaFactoryExtensionNotifier::~CCCaFactoryExtensionNotifier() |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 CCCaFactoryExtensionNotifier::~CCCaFactoryExtensionNotifier() |
|
49 { |
|
50 Cancel(); |
|
51 if( iEComSession ) |
|
52 { |
|
53 iEComSession->Close(); |
|
54 } |
|
55 |
|
56 delete iExtensionFactory; |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // CCCaFactoryExtensionNotifier* CCCaFactoryExtensionNotifier::NewL() |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C CCCaFactoryExtensionNotifier* CCCaFactoryExtensionNotifier::NewL() |
|
64 { |
|
65 CCCaFactoryExtensionNotifier* self = |
|
66 new (ELeave) CCCaFactoryExtensionNotifier(); |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop(); // self; |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CCCaFactoryExtensionNotifier::ConstructL() |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 inline void CCCaFactoryExtensionNotifier::ConstructL() |
|
78 { |
|
79 iEComSession = &(REComSession::OpenL()); |
|
80 SetActive(); |
|
81 iEComSession->NotifyOnChange( iStatus ); |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // CCCAExtensionFactory* CCCaFactoryExtensionNotifier::CreateExtensionFactoryL() |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 void CCCaFactoryExtensionNotifier::CreateExtensionFactoryL() |
|
89 { |
|
90 RImplInfoPtrArray implementations; |
|
91 CleanupStack::PushL( TCleanupItem( CleanupResetAndDestroy, |
|
92 &implementations) ); |
|
93 |
|
94 // get the list of available plugins |
|
95 REComSession::ListImplementationsL( |
|
96 TUid::Uid( CCCAEXTENSIONFACTORY_ECOM_INTERFACE ), |
|
97 implementations ); |
|
98 |
|
99 if( implementations.Count() > 0) |
|
100 { |
|
101 if(!iExtensionFactory) |
|
102 { |
|
103 CImplementationInformation* implInfo = implementations[0]; |
|
104 iExtensionFactory = |
|
105 CCCAExtensionFactory::NewL( implInfo->ImplementationUid() ); |
|
106 // extension factory is created -> notify clients |
|
107 iCallBack.CallBack(); |
|
108 } |
|
109 } |
|
110 else if( iExtensionFactory ) |
|
111 { |
|
112 delete iExtensionFactory; |
|
113 iExtensionFactory = NULL; |
|
114 iCallBack.CallBack(); // extension factory is removed -> notify clients |
|
115 } |
|
116 CleanupStack::PopAndDestroy(); //implementations |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CCCAExtensionFactory* CCCaFactoryExtensionNotifier::ExtensionFactory() |
|
121 // ---------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C CCCAExtensionFactory* CCCaFactoryExtensionNotifier::ExtensionFactory() |
|
124 { |
|
125 return iExtensionFactory; |
|
126 } |
|
127 |
|
128 // ---------------------------------------------------------------------------- |
|
129 // CCCaFactoryExtensionNotifier::ObserveExtensionFactory( TCallBack& aCallBack ) |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C void CCCaFactoryExtensionNotifier::ObserveExtensionFactoryL( |
|
133 TCallBack& aCallBack ) |
|
134 { |
|
135 iCallBack = aCallBack; |
|
136 CreateExtensionFactoryL(); |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------------------------------- |
|
140 // CCCaFactoryExtensionNotifier::DoCancel() |
|
141 // ---------------------------------------------------------------------------- |
|
142 // |
|
143 void CCCaFactoryExtensionNotifier::DoCancel() |
|
144 { |
|
145 iEComSession->CancelNotifyOnChange( iStatus ); |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CCCaFactoryExtensionNotifier::RunL() |
|
150 // ---------------------------------------------------------------------------- |
|
151 // |
|
152 void CCCaFactoryExtensionNotifier::RunL() |
|
153 { |
|
154 if( iStatus.Int() == KErrNone ) |
|
155 { |
|
156 CreateExtensionFactoryL(); |
|
157 } |
|
158 SetActive(); |
|
159 iEComSession->NotifyOnChange( iStatus ); |
|
160 } |
|
161 |
|
162 |