|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 #include "cmtpproxydpconfigmgr.h" |
|
20 #include <barsc.h> |
|
21 #include <barsread.h> |
|
22 #include <mtp/mmtpdataproviderconfig.h> |
|
23 #include <mtp/mmtpdataproviderframework.h> |
|
24 __FLOG_STMT(_LIT8(KComponent1,"ProxyDPConfigmanager");) |
|
25 |
|
26 CMTPProxyDpConfigMgr* CMTPProxyDpConfigMgr::NewL(MMTPDataProviderFramework& aFramework) |
|
27 { |
|
28 CMTPProxyDpConfigMgr* self = new (ELeave) CMTPProxyDpConfigMgr(aFramework); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 CMTPProxyDpConfigMgr::CMTPProxyDpConfigMgr(MMTPDataProviderFramework& aFramework) : |
|
36 iFramework(aFramework) |
|
37 { |
|
38 } |
|
39 |
|
40 void CMTPProxyDpConfigMgr::ConstructL() |
|
41 { |
|
42 __FLOG_OPEN(KMTPSubsystem, KComponent1); |
|
43 TUint32 resourceId = iFramework.DataProviderConfig().UintValue(MMTPDataProviderConfig::EOpaqueResource); |
|
44 // Reading from resource file mtpproxydp_config.rss |
|
45 RResourceFile resourceFile; |
|
46 CleanupClosePushL(resourceFile); |
|
47 resourceFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName)); |
|
48 TResourceReader resourceReader; |
|
49 HBufC8* buffer = resourceFile.AllocReadLC(resourceId); |
|
50 resourceReader.SetBuffer(buffer); |
|
51 FileMappingStruct st; |
|
52 const TInt numberOfEntries=resourceReader.ReadInt16(); |
|
53 for(TInt count =0;count<numberOfEntries ; count++) |
|
54 { |
|
55 st.iDpUid=resourceReader.ReadInt32(); |
|
56 st.iFileArray = resourceReader.ReadDesCArrayL(); |
|
57 InsertToMappingStruct(st); |
|
58 } |
|
59 |
|
60 CleanupStack::PopAndDestroy(2, &resourceFile); |
|
61 |
|
62 } |
|
63 |
|
64 CMTPProxyDpConfigMgr::~CMTPProxyDpConfigMgr() |
|
65 { |
|
66 TInt count = iMappingStruct.Count(); |
|
67 for(TInt i=0 ; i<count ; i++) |
|
68 { |
|
69 delete iMappingStruct[i].iFileArray; |
|
70 } |
|
71 iMappingStruct.Reset(); |
|
72 iMappingStruct.Close(); |
|
73 __FLOG_CLOSE; |
|
74 } |
|
75 |
|
76 void CMTPProxyDpConfigMgr::InsertToMappingStruct(FileMappingStruct& aRef) |
|
77 { |
|
78 iMappingStruct.Append(aRef); |
|
79 } |
|
80 |
|
81 TBool CMTPProxyDpConfigMgr::GetFileName(const TDesC& aFileName,TInt& aIndex) |
|
82 { |
|
83 __FLOG(_L8("GetFileName - Entry")); |
|
84 |
|
85 __FLOG_1( _L8("aFileName = %s"), &aFileName ); |
|
86 |
|
87 TInt count = iMappingStruct.Count(); |
|
88 __FLOG_1( _L8("count = %d"), count ); |
|
89 for(TInt i=0 ; i<count ; i++) |
|
90 { |
|
91 TInt err=iMappingStruct[i].iFileArray->Find(aFileName,aIndex); |
|
92 if(err == KErrNone) |
|
93 { |
|
94 aIndex=i; |
|
95 __FLOG_1( _L8("aIndex = %d"), aIndex ); |
|
96 __FLOG(_L8("GetFileName - Exit")); |
|
97 return ETrue; |
|
98 } |
|
99 } |
|
100 |
|
101 __FLOG(_L8("GetFileName - Exit")); |
|
102 return EFalse; |
|
103 } |
|
104 |
|
105 TUint CMTPProxyDpConfigMgr::GetDPId(const TInt& aIndex) |
|
106 { |
|
107 return iMappingStruct[aIndex].iDpUid; |
|
108 } |