9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <calremoteattachmentapidefs.h> |
18 #include "calremoteattachmentapidefs.h" |
19 #include <ecom/ecom.h> |
19 #include <ecom/ecom.h> |
20 |
20 |
21 // simple wrapper class with array deletion on close |
21 // simple wrapper class with array deletion on close |
22 class RImplInfoPtrArrayCalRemoteAttachment : public RImplInfoPtrArray |
22 class RImplInfoPtrArrayCalRemoteAttachment : public RImplInfoPtrArray |
23 { |
23 { |
35 // |
35 // |
36 inline CCalRemoteAttachmentApi* CCalRemoteAttachmentApi::NewL( |
36 inline CCalRemoteAttachmentApi* CCalRemoteAttachmentApi::NewL( |
37 const TDesC8& aUri ) |
37 const TDesC8& aUri ) |
38 { |
38 { |
39 TAny* ptr( NULL ); |
39 TAny* ptr( NULL ); |
40 |
40 |
41 RImplInfoPtrArrayCalRemoteAttachment implArray; |
41 RImplInfoPtrArrayCalRemoteAttachment implArray; |
42 CleanupClosePushL( implArray ); |
42 CleanupClosePushL( implArray ); |
43 REComSession::ListImplementationsL( |
43 REComSession::ListImplementationsL( |
44 TUid::Uid( KCalRemoteAttachmentAPIInterface ), |
44 TUid::Uid( KCalRemoteAttachmentAPIInterface ), |
45 implArray ); |
45 implArray ); |
46 |
46 |
47 TInt implCount( implArray.Count() ); |
47 TInt implCount( implArray.Count() ); |
48 if ( !implCount ) |
48 if ( !implCount ) |
49 { |
49 { |
50 User::Leave( KErrNotFound ); |
50 User::Leave( KErrNotFound ); |
51 } |
51 } |
52 |
52 |
53 for ( TInt i(0); i < implCount && !ptr; ++i ) |
53 for ( TInt i(0); i < implCount && !ptr; ++i ) |
54 { |
54 { |
55 TPtrC8 datatype( implArray[i]->DataType() ); |
55 TPtrC8 datatype( implArray[i]->DataType() ); |
56 if ( KErrNotFound != aUri.Find( datatype) ) |
56 if ( KErrNotFound != aUri.Find( datatype) ) |
57 { |
57 { |
58 TInt32 keyOffset = _FOFF( CCalRemoteAttachmentApi, iDtor_ID_Key ); |
58 TInt32 keyOffset = _FOFF( CCalRemoteAttachmentApi, iDtor_ID_Key ); |
59 TUid implUid = implArray[i]->ImplementationUid(); |
59 TUid implUid = implArray[i]->ImplementationUid(); |
60 ptr = REComSession::CreateImplementationL( implUid, |
60 ptr = REComSession::CreateImplementationL( implUid, |
61 keyOffset, |
61 keyOffset, |
62 NULL ); |
62 NULL ); |
63 } |
63 } |
64 } |
64 } |
65 |
65 |
66 User::LeaveIfNull( ptr ); |
66 User::LeaveIfNull( ptr ); |
67 CleanupStack::PopAndDestroy( &implArray ); |
67 CleanupStack::PopAndDestroy( &implArray ); |
68 return reinterpret_cast<CCalRemoteAttachmentApi*>(ptr); |
68 return reinterpret_cast<CCalRemoteAttachmentApi*>(ptr); |
69 } |
69 } |
70 |
70 |