|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <calremoteattachmentapidefs.h> |
|
19 #include <ecom/ecom.h> |
|
20 |
|
21 // simple wrapper class with array deletion on close |
|
22 class RImplInfoPtrArrayCalRemoteAttachment : public RImplInfoPtrArray |
|
23 { |
|
24 public: |
|
25 void Close() |
|
26 { |
|
27 ResetAndDestroy(); |
|
28 RImplInfoPtrArray::Close(); |
|
29 } |
|
30 }; |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CCalRemoteAttachmentApi::NewL |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 inline CCalRemoteAttachmentApi* CCalRemoteAttachmentApi::NewL( |
|
37 const TDesC8& aUri ) |
|
38 { |
|
39 TAny* ptr( NULL ); |
|
40 |
|
41 RImplInfoPtrArrayCalRemoteAttachment implArray; |
|
42 CleanupClosePushL( implArray ); |
|
43 REComSession::ListImplementationsL( |
|
44 TUid::Uid( KCalRemoteAttachmentAPIInterface ), |
|
45 implArray ); |
|
46 |
|
47 TInt implCount( implArray.Count() ); |
|
48 if ( !implCount ) |
|
49 { |
|
50 User::Leave( KErrNotFound ); |
|
51 } |
|
52 |
|
53 for ( TInt i(0); i < implCount && !ptr; ++i ) |
|
54 { |
|
55 TPtrC8 datatype( implArray[i]->DataType() ); |
|
56 if ( KErrNotFound != aUri.Find( datatype) ) |
|
57 { |
|
58 TInt32 keyOffset = _FOFF( CCalRemoteAttachmentApi, iDtor_ID_Key ); |
|
59 TUid implUid = implArray[i]->ImplementationUid(); |
|
60 ptr = REComSession::CreateImplementationL( implUid, |
|
61 keyOffset, |
|
62 NULL ); |
|
63 } |
|
64 } |
|
65 |
|
66 User::LeaveIfNull( ptr ); |
|
67 CleanupStack::PopAndDestroy( &implArray ); |
|
68 return reinterpret_cast<CCalRemoteAttachmentApi*>(ptr); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CCalRemoteAttachmentApi::~CCalRemoteAttachmentApi |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 inline CCalRemoteAttachmentApi::~CCalRemoteAttachmentApi() |
|
76 { |
|
77 REComSession::DestroyedImplementation( iDtor_ID_Key ); |
|
78 } |
|
79 |
|
80 // EOF |