|
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 #include <barsc.h> |
|
17 #include <barsread.h> |
|
18 |
|
19 #include "cmtpfiledpconfigmgr.h" |
|
20 |
|
21 #include <mtp/mmtpdataproviderconfig.h> |
|
22 #include <mtp/mmtpdataproviderframework.h> |
|
23 |
|
24 |
|
25 #define UNUSED_VAR(v) (v = v) |
|
26 |
|
27 CMTPFileDpConfigMgr* CMTPFileDpConfigMgr::NewL(MMTPDataProviderFramework& aFramework) |
|
28 { |
|
29 CMTPFileDpConfigMgr* self = new (ELeave) CMTPFileDpConfigMgr(aFramework); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(self); |
|
33 return self; |
|
34 } |
|
35 |
|
36 CMTPFileDpConfigMgr::CMTPFileDpConfigMgr(MMTPDataProviderFramework& aFramework) : |
|
37 iFramework(aFramework) |
|
38 { |
|
39 } |
|
40 |
|
41 void CMTPFileDpConfigMgr::ConstructL() |
|
42 { |
|
43 iResourceId = iFramework.DataProviderConfig().UintValue(MMTPDataProviderConfig::EOpaqueResource); |
|
44 |
|
45 RResourceFile resFile; |
|
46 CleanupClosePushL(resFile); |
|
47 |
|
48 resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName)); |
|
49 HBufC8* res = resFile.AllocReadLC(iResourceId); |
|
50 |
|
51 TResourceReader reader; |
|
52 reader.SetBuffer(res); |
|
53 |
|
54 // WORD - enumeration_iteration_length |
|
55 iEnumItrLength = reader.ReadInt16(); |
|
56 |
|
57 // Do not read format_exclusion_list and extension_map |
|
58 // to conserve memory - instead read it in dynamically when requested |
|
59 |
|
60 CleanupStack::PopAndDestroy(res); |
|
61 CleanupStack::PopAndDestroy(&resFile); |
|
62 } |
|
63 |
|
64 CMTPFileDpConfigMgr::~CMTPFileDpConfigMgr() |
|
65 { |
|
66 } |
|
67 |
|
68 TUint CMTPFileDpConfigMgr::UintValueL(TParameter aParam) const |
|
69 { |
|
70 __ASSERT_DEBUG(aParam == CMTPFileDpConfigMgr::EEnumerationIterationLength, User::Invariant()); |
|
71 UNUSED_VAR(aParam); |
|
72 return iEnumItrLength; |
|
73 } |
|
74 |
|
75 void CMTPFileDpConfigMgr::GetArrayValueL(TParameter aParam, RArray<TUint>& aArray) const |
|
76 { |
|
77 __ASSERT_DEBUG(aParam == CMTPFileDpConfigMgr::EFormatExclusionList, User::Invariant()); |
|
78 UNUSED_VAR(aParam); |
|
79 ReadFormatExclusionListL(aArray); |
|
80 } |
|
81 |
|
82 void CMTPFileDpConfigMgr::ReadFormatExclusionListL(RArray<TUint>& aArray) const |
|
83 { |
|
84 RResourceFile resFile; |
|
85 CleanupClosePushL(resFile); |
|
86 |
|
87 resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName)); |
|
88 HBufC8* res = resFile.AllocReadLC(iResourceId); |
|
89 |
|
90 TResourceReader reader; |
|
91 reader.SetBuffer(res); |
|
92 |
|
93 // WORD - enumeration_iteration_length, skip it |
|
94 reader.ReadInt16(); |
|
95 |
|
96 // WORD - length of format_exclusion_list |
|
97 TInt16 len = reader.ReadInt16(); |
|
98 |
|
99 TInt err(KErrNone); |
|
100 // WORD[] - of len items |
|
101 while(len--) |
|
102 { |
|
103 err = aArray.InsertInOrder(TUint(reader.ReadUint16())); |
|
104 if( (err != KErrNone) && (err != KErrAlreadyExists) ) |
|
105 { |
|
106 User::Leave(err); |
|
107 } |
|
108 } |
|
109 |
|
110 CleanupStack::PopAndDestroy(res); |
|
111 CleanupStack::PopAndDestroy(&resFile); |
|
112 } |
|
113 |
|
114 TInt CMTPFileDpConfigMgr::FormatCompare(const TUint& aFirst, const TUint& aSecond) |
|
115 { |
|
116 return (aFirst - aSecond); |
|
117 } |