|
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: |
|
15 * Provides the CAknFepUIInterface methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "aknfepuiinterface.h" |
|
31 #include "AknFepUiInterfacePlugin.h" |
|
32 #include <ecom/ecom.h> |
|
33 |
|
34 void PanicNoImpl() |
|
35 { |
|
36 _LIT(KReason, "NoFepUiImpl"); |
|
37 User::Panic(KReason, 0); |
|
38 } |
|
39 |
|
40 const TUid KAvkonPluginUid = { 0x10285839 }; |
|
41 |
|
42 void EComDtorCleanup(TAny* aUid) |
|
43 { |
|
44 TUid dtor = {(TInt)aUid}; |
|
45 REComSession::DestroyedImplementation(dtor); |
|
46 } |
|
47 |
|
48 void EComImplCleanup(TAny* aArray) |
|
49 { |
|
50 RImplInfoPtrArray* array = (RImplInfoPtrArray*) aArray; |
|
51 array->ResetAndDestroy(); |
|
52 } |
|
53 |
|
54 // factory function |
|
55 EXPORT_C CAknFepUIInterface* CAknFepUIInterface::NewL() |
|
56 { |
|
57 RImplInfoPtrArray impls; |
|
58 CleanupStack::PushL(TCleanupItem(EComImplCleanup, &impls)); |
|
59 REComSession::ListImplementationsL(TUid::Uid(CFepUiInterfacePlugin::ETypeId), impls); |
|
60 |
|
61 // Move Avkon plugin to the back of the list to act as default implementation |
|
62 TInt count = impls.Count(); |
|
63 for (int i=0; i<count-1; i++) |
|
64 { |
|
65 CImplementationInformation* info = impls[i]; |
|
66 if (info->ImplementationUid() == KAvkonPluginUid) |
|
67 { |
|
68 impls.Remove(i); |
|
69 // Append will not fail as space has been freed by Remove |
|
70 impls.Append(info); |
|
71 break; |
|
72 } |
|
73 } |
|
74 |
|
75 // Find the first plugin that says it should be used |
|
76 CAknFepUIInterface* impl = NULL; |
|
77 for (int i=0; !impl && i<count; i++) |
|
78 { |
|
79 TUid dtorUid; |
|
80 CFepUiInterfacePlugin* plugin = (CFepUiInterfacePlugin*)REComSession::CreateImplementationL(impls[i]->ImplementationUid(), dtorUid); |
|
81 if (plugin->UseThisPlugin()) |
|
82 { |
|
83 CleanupStack::PushL(TCleanupItem(EComDtorCleanup, (TAny*)dtorUid.iUid)); |
|
84 CleanupStack::PushL(plugin); |
|
85 impl = plugin->NewImplL(); |
|
86 impl->iEcomDtorUid = dtorUid; |
|
87 CleanupStack::PopAndDestroy(plugin); |
|
88 CleanupStack::Pop(); |
|
89 } |
|
90 else |
|
91 { |
|
92 delete plugin; |
|
93 REComSession::DestroyedImplementation(dtorUid); |
|
94 } |
|
95 } |
|
96 |
|
97 CleanupStack::PopAndDestroy(&impls); |
|
98 |
|
99 __ASSERT_ALWAYS(impl, PanicNoImpl()); |
|
100 return impl; |
|
101 } |
|
102 |
|
103 EXPORT_C CAknFepUIInterface::~CAknFepUIInterface() |
|
104 { |
|
105 if (iEcomDtorUid.iUid) |
|
106 REComSession::DestroyedImplementation(iEcomDtorUid); |
|
107 } |