|
1 // Copyright (c) 2008-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 #include <barsc.h> |
|
17 #include <barsread.h> |
|
18 #include "ruidmapper.h" |
|
19 #include <framework.rsg> |
|
20 _LIT(KFrameworkFilename, "\\resource\\mtp\\framework.rsc"); |
|
21 |
|
22 void RUidMapping::ReadFromResourceFileL() |
|
23 { |
|
24 RFs Fs; |
|
25 User::LeaveIfError(Fs.Connect()); |
|
26 CleanupClosePushL(Fs); |
|
27 const TDriveName driveName(TDriveUnit(EDriveZ).Name()); |
|
28 HBufC* filename = HBufC::NewLC(KMaxDriveName + |
|
29 KFrameworkFilename().Length() ); |
|
30 |
|
31 TPtr pFileName = filename->Des(); |
|
32 pFileName.Append(driveName); |
|
33 pFileName.Append(KFrameworkFilename); |
|
34 |
|
35 // Reading from resource file |
|
36 RResourceFile resourceFile; |
|
37 resourceFile.OpenL(Fs, *filename); |
|
38 |
|
39 CleanupClosePushL(resourceFile); |
|
40 TResourceReader resourceReader; |
|
41 MappingStruct st; |
|
42 HBufC8* buffer = resourceFile.AllocReadLC(R_ELEMENTS_INFO); |
|
43 resourceReader.SetBuffer(buffer); |
|
44 const TInt numberOfEntries=resourceReader.ReadInt16(); |
|
45 for(TInt count =0;count<numberOfEntries ; count++) |
|
46 { |
|
47 st.dpUid=resourceReader.ReadInt32(); |
|
48 |
|
49 TInt entries = resourceReader.ReadInt16(); |
|
50 for (TInt n = 0 ; n < entries; ++n) |
|
51 { |
|
52 TUint transportId(resourceReader.ReadInt32()); |
|
53 st.iTransportUidList.Append(transportId); |
|
54 } |
|
55 InsertToMappingStruct(st); |
|
56 } |
|
57 |
|
58 CleanupStack::PopAndDestroy(4, &Fs); |
|
59 } |
|
60 |
|
61 |
|
62 RUidMapping::RUidMapping() |
|
63 { |
|
64 |
|
65 } |
|
66 |
|
67 void RUidMapping::Close() |
|
68 { |
|
69 iMappingStruct.Close(); |
|
70 } |
|
71 |
|
72 void RUidMapping::Open() |
|
73 { |
|
74 iMappingStruct.Reset(); |
|
75 } |
|
76 |
|
77 void RUidMapping::InsertToMappingStruct(MappingStruct& aRef) |
|
78 { |
|
79 iMappingStruct.Append(aRef); |
|
80 } |
|
81 |
|
82 TBool RUidMapping::GetSupportedTransport(const TUint& aDPUid,const TUint& aTransportUid) |
|
83 { |
|
84 TBool found = ETrue; |
|
85 TInt count = iMappingStruct.Count(); |
|
86 for(TInt i=0 ; i<count ; i++) |
|
87 { |
|
88 if(iMappingStruct[i].dpUid == aDPUid) |
|
89 { |
|
90 if(iMappingStruct[i].iTransportUidList.Find(aTransportUid)<0) |
|
91 { |
|
92 found = EFalse; |
|
93 return found; |
|
94 } |
|
95 |
|
96 } |
|
97 } |
|
98 return found; |
|
99 } |
|
100 |