1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
16 #include <mmf/plugin/mmfmediaclientextdisplayinterface.h> |
16 #include <mmf/plugin/mmfmediaclientextdisplayinterface.h> |
17 #include <mmf/plugin/mmfmediaclientextdisplayinterface.hrh> |
17 #include <mmf/plugin/mmfmediaclientextdisplayinterface.hrh> |
18 #include <e32cmn.h> |
18 #include <e32cmn.h> |
19 #include <ecom/ecom.h> |
19 #include <ecom/ecom.h> |
20 |
20 |
21 TBool CExtDisplayConnectionProviderInterface::ExternalDisplaySupportedL() |
21 void CleanupEComArray(TAny* aArray); |
|
22 |
|
23 CExtDisplayConnectionProviderInterface* CExtDisplayConnectionProviderInterface::NewL() |
22 { |
24 { |
23 RImplInfoPtrArray implInfoArray; |
25 RImplInfoPtrArray implInfoArray; |
24 REComSession::ListImplementationsL(TUid::Uid(KMediaDisplayExtProviderInterfaceUid), implInfoArray); |
26 TCleanupItem cleanup(CleanupEComArray, &implInfoArray); |
|
27 CleanupStack::PushL(cleanup); |
25 |
28 |
26 TBool ret = EFalse; |
|
27 if(implInfoArray.Count() > 0) |
|
28 { |
|
29 ret = ETrue; |
|
30 } |
|
31 |
|
32 implInfoArray.Close(); |
|
33 return ret; |
|
34 } |
|
35 |
|
36 CExtDisplayConnectionProviderInterface* CExtDisplayConnectionProviderInterface::NewL(MExtDisplayConnectionProviderCallback& aCallback, TSurfaceId& aSurfaceId) |
|
37 { |
|
38 RImplInfoPtrArray implInfoArray; |
|
39 CleanupClosePushL(implInfoArray); |
|
40 REComSession::ListImplementationsL(TUid::Uid(KMediaDisplayExtProviderInterfaceUid), implInfoArray); |
29 REComSession::ListImplementationsL(TUid::Uid(KMediaDisplayExtProviderInterfaceUid), implInfoArray); |
41 |
30 |
42 if(implInfoArray.Count() == 0) |
31 if(implInfoArray.Count() == 0) |
43 { |
32 { |
44 User::Leave(KErrNotSupported); |
33 CleanupStack::PopAndDestroy(); // implInfoArray |
|
34 return NULL; |
45 } |
35 } |
46 |
36 |
47 CExtDisplayConnectionProviderInterface* self = |
37 CExtDisplayConnectionProviderInterface* self = |
48 REINTERPRET_CAST(CExtDisplayConnectionProviderInterface*, REComSession::CreateImplementationL( |
38 REINTERPRET_CAST(CExtDisplayConnectionProviderInterface*, REComSession::CreateImplementationL( |
49 implInfoArray[0]->ImplementationUid(), _FOFF(CExtDisplayConnectionProviderInterface, iInstanceKey))); |
39 implInfoArray[0]->ImplementationUid(), _FOFF(CExtDisplayConnectionProviderInterface, iInstanceKey))); |
50 CleanupStack::PushL(self); |
|
51 |
|
52 self->ConstructL(aCallback, aSurfaceId); |
|
53 CleanupStack::Pop(self); |
|
54 |
40 |
55 CleanupStack::PopAndDestroy(); // implInfoArray |
41 CleanupStack::PopAndDestroy(); // implInfoArray |
56 return self; |
42 return self; |
57 } |
|
58 |
|
59 void CExtDisplayConnectionProviderInterface::ConstructL(MExtDisplayConnectionProviderCallback& aCallback, TSurfaceId& aSurfaceId) |
|
60 { |
|
61 iCallback = &aCallback; |
|
62 iSurfaceId = aSurfaceId; |
|
63 } |
43 } |
64 |
44 |
65 EXPORT_C CExtDisplayConnectionProviderInterface::~CExtDisplayConnectionProviderInterface() |
45 EXPORT_C CExtDisplayConnectionProviderInterface::~CExtDisplayConnectionProviderInterface() |
66 { |
46 { |
67 REComSession::DestroyedImplementation(iInstanceKey); |
47 REComSession::DestroyedImplementation(iInstanceKey); |
68 } |
48 } |
69 |
49 |
70 EXPORT_C CExtDisplayConnectionProviderInterface::CExtDisplayConnectionProviderInterface() |
50 EXPORT_C CExtDisplayConnectionProviderInterface::CExtDisplayConnectionProviderInterface() |
71 { |
51 { |
72 } |
52 } |
|
53 |
|
54 // CleanupEComArray function is used for cleanup support of locally declared arrays |
|
55 void CleanupEComArray(TAny* aArray) |
|
56 { |
|
57 (static_cast<RImplInfoPtrArray*> (aArray))->ResetAndDestroy(); |
|
58 (static_cast<RImplInfoPtrArray*> (aArray))->Close(); |
|
59 } |