|
1 /* |
|
2 * Copyright (c) 2010 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: ECom interface for email interface factory inline implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "emailclientapi.hrh" |
|
19 |
|
20 // LOCAL FUNCTIONS |
|
21 |
|
22 inline void ResetAndDestroyCleanup( TAny* aAny ) |
|
23 { |
|
24 RImplInfoPtrArray* ptrArray = reinterpret_cast<RImplInfoPtrArray*>( aAny ); |
|
25 ptrArray->ResetAndDestroy(); |
|
26 } |
|
27 |
|
28 inline void CleanupResetAndDestroyPushL( RImplInfoPtrArray& aArray ) |
|
29 { |
|
30 TCleanupItem item( &ResetAndDestroyCleanup, &aArray ); |
|
31 CleanupStack::PushL( item ); |
|
32 } |
|
33 |
|
34 // ============================= MEMBER FUNCTIONS ============================= |
|
35 |
|
36 // ---------------------------------------------------------------------------- |
|
37 // CEmailInterfaceFactory::NewL |
|
38 // Two-phased constructor |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 inline CEmailInterfaceFactory* CEmailInterfaceFactory::NewL( ) |
|
42 { |
|
43 // Find implementation for our interface. |
|
44 RImplInfoPtrArray implArray; |
|
45 EmailInterface::CleanupResetAndDestroyPushL( implArray ); |
|
46 const TUid ifUid = {KEmailClientFactoryApiUid}; |
|
47 REComSession::ListImplementationsL( |
|
48 ifUid, |
|
49 implArray ); |
|
50 // there should be only one impl so take first |
|
51 TAny* interface = NULL; |
|
52 if ( implArray.Count() ) |
|
53 { |
|
54 const TUid uid = implArray[0]->ImplementationUid(); |
|
55 interface = REComSession::CreateImplementationL( |
|
56 uid, _FOFF( CEmailInterfaceFactory, iDtor_ID_Key ) ); |
|
57 } |
|
58 CleanupStack::PopAndDestroy(); // implArray |
|
59 |
|
60 return reinterpret_cast<CEmailInterfaceFactory*>( interface ); |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // CEmailInterfaceFactory::~CEmailInterfaceFactory |
|
65 // Destructor |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 inline CEmailInterfaceFactory::~CEmailInterfaceFactory() |
|
69 { |
|
70 REComSession::DestroyedImplementation( iDtor_ID_Key ); |
|
71 } |
|
72 |
|
73 template<class T> |
|
74 inline void CleanupResetAndRelease<T>::PushL( RPointerArray<T>& aItem ) { |
|
75 TCleanupItem item( &CleanupResetAndRelease<T>::ResetAndRelease, &aItem ); |
|
76 CleanupStack::PushL( item ); |
|
77 } |
|
78 template<class T> |
|
79 inline void CleanupResetAndRelease<T>::ResetAndRelease( TAny* aPtr ) |
|
80 { |
|
81 RPointerArray<T>* array = reinterpret_cast<RPointerArray<T>* >( aPtr ); |
|
82 for ( TInt i = 0; i < array->Count(); i++ ) |
|
83 { |
|
84 T* item = (*array)[i]; |
|
85 item->Release(); |
|
86 } |
|
87 array->Reset(); |
|
88 } |
|
89 |
|
90 // End Of File |