|
1 /* |
|
2 * Copyright (c) 2006 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: Media Fetch implementation plug-in loader |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ecom.h> |
|
20 |
|
21 #include "mediafetch.h" |
|
22 #include "mediafetch.hrh" |
|
23 #include <mediafetchimplementation.h> |
|
24 |
|
25 // ============================= LOCAL FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CleanupResetAndDestroy |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 void CleanupResetAndDestroy( TAny* aObj ) |
|
32 { |
|
33 if( aObj ) |
|
34 { |
|
35 static_cast<RImplInfoPtrArray*>( aObj )->ResetAndDestroy(); |
|
36 } |
|
37 } |
|
38 |
|
39 |
|
40 // ======== MEMBER FUNCTIONS ======== |
|
41 |
|
42 inline CMediaFetch::CMediaFetch() |
|
43 { |
|
44 } |
|
45 |
|
46 inline void CMediaFetch::ConstructL( TInt aMediaType ) |
|
47 { |
|
48 RImplInfoPtrArray implementations; |
|
49 CleanupStack::PushL( TCleanupItem( CleanupResetAndDestroy, |
|
50 &implementations) ); |
|
51 |
|
52 // Get a list of all Media Fetch plug-in implementations |
|
53 REComSession::ListImplementationsL( |
|
54 TUid::Uid( MEDIAFETCH_ECOM_INTERFACE ), |
|
55 implementations ); |
|
56 |
|
57 TUid uid( TUid::Null() ); |
|
58 TInt version( -1 ); |
|
59 |
|
60 const TInt count( implementations.Count() ); |
|
61 |
|
62 // Loop through all found implementations |
|
63 for( TInt i( 0 ); i < count; ++i ) |
|
64 { |
|
65 CImplementationInformation* implInfo = implementations[i]; |
|
66 |
|
67 // Get media types supported by the implementation |
|
68 // The value is assumed to be in hexadecimal as defined in the |
|
69 // Media Fetch Implementation API |
|
70 TUint val( 0 ); |
|
71 TLex8 lex( implInfo->DataType() ); |
|
72 User::LeaveIfError( lex.Val( val, EHex ) ); |
|
73 |
|
74 // Check that the implementation supports the wanted media type(s) |
|
75 if( ( aMediaType & val ) == aMediaType ) |
|
76 { |
|
77 // Pick implementation with highest version number |
|
78 if( implInfo->Version() > version ) |
|
79 { |
|
80 uid = implInfo->ImplementationUid(); |
|
81 version = implInfo->Version(); |
|
82 } |
|
83 } |
|
84 } |
|
85 |
|
86 if( uid == TUid::Null() ) |
|
87 { |
|
88 User::Leave( KErrNotSupported ); |
|
89 } |
|
90 |
|
91 |
|
92 // Instatiate the fetcher plug-in implementation |
|
93 iFetcher = CMediaFetchImplementation::NewL( uid ); |
|
94 |
|
95 CleanupStack::PopAndDestroy(); // implementations |
|
96 } |
|
97 |
|
98 CMediaFetch* CMediaFetch::NewL( TInt aMediaType ) |
|
99 { |
|
100 CMediaFetch* self = CMediaFetch::NewLC( aMediaType ); |
|
101 CleanupStack::Pop( self ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 CMediaFetch* CMediaFetch::NewLC( TInt aMediaType ) |
|
106 { |
|
107 CMediaFetch* self = new( ELeave ) CMediaFetch; |
|
108 CleanupStack::PushL( self ); |
|
109 self->ConstructL( aMediaType ); |
|
110 return self; |
|
111 } |
|
112 |
|
113 CMediaFetch::~CMediaFetch() |
|
114 { |
|
115 delete iFetcher; |
|
116 REComSession::FinalClose(); |
|
117 } |
|
118 |
|
119 void CMediaFetch::SetMultiSelectionL( TBool aMultiSelect ) |
|
120 { |
|
121 iFetcher->SetMultiSelectionL( aMultiSelect ); |
|
122 } |
|
123 |
|
124 void CMediaFetch::SetMimeTypesL( const MDesCArray& aMimeTypes ) |
|
125 { |
|
126 iFetcher->SetMimeTypesL( aMimeTypes ); |
|
127 } |
|
128 |
|
129 void CMediaFetch::SetSelectionSoftkeyL( const TDesC& aSelectionSoftkey ) |
|
130 { |
|
131 iFetcher->SetSelectionSoftkeyL( aSelectionSoftkey ); |
|
132 } |
|
133 |
|
134 void CMediaFetch::SetHeadingL( const TDesC& aHeading ) |
|
135 { |
|
136 iFetcher->SetHeadingL( aHeading ); |
|
137 } |
|
138 |
|
139 void CMediaFetch::SetVerifierL( MMGFetchVerifier& aVerifier ) |
|
140 { |
|
141 iFetcher->SetVerifierL( aVerifier ); |
|
142 } |
|
143 |
|
144 void CMediaFetch::GetCancelerL( MMGFetchCanceler*& aCanceler ) |
|
145 { |
|
146 iFetcher->GetCancelerL( aCanceler ); |
|
147 } |
|
148 |
|
149 TBool CMediaFetch::LaunchL( CDesCArray& aSelectedFiles, |
|
150 TMediaFileType aMediaType ) |
|
151 { |
|
152 return iFetcher->LaunchL( aSelectedFiles, aMediaType ); |
|
153 } |