|
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 "launcherdllparser.h" |
|
19 #include "launchertraces.h" |
|
20 |
|
21 // --------------------------------------------------------------------------- |
|
22 |
|
23 CLauncherDLLParser::~CLauncherDLLParser() |
|
24 { |
|
25 LOGSTRING("Launcher: CLauncherDLLParser::~CLauncherDLLParser"); |
|
26 } |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 |
|
30 CLauncherDLLParser::CLauncherDLLParser() |
|
31 { |
|
32 LOGSTRING("Launcher: CLauncherDLLParser::CLauncherDLLParser"); |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 |
|
37 CLauncherDLLParser* CLauncherDLLParser::NewL() |
|
38 { |
|
39 LOGSTRING("Launcher: CLauncherDLLParser::NewL"); |
|
40 CLauncherDLLParser* self = CLauncherDLLParser::NewLC(); |
|
41 CleanupStack::Pop(); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 |
|
47 CLauncherDLLParser* CLauncherDLLParser::NewLC() |
|
48 { |
|
49 LOGSTRING("Launcher: CLauncherDLLParser::NewLC"); |
|
50 CLauncherDLLParser* self = new (ELeave) CLauncherDLLParser; |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 |
|
58 void CLauncherDLLParser::ConstructL() |
|
59 { |
|
60 |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 |
|
65 void CLauncherDLLParser::ParseL( RFs& aFileSession, RFile& aFile, CLauncherDLLElement& aElement ) |
|
66 { |
|
67 TFileName dllName; |
|
68 TFileName fullName; |
|
69 TUid tmpUID; |
|
70 TInt offset = 0; |
|
71 |
|
72 aFile.Name(dllName); |
|
73 aFile.FullName(fullName); |
|
74 aElement.SetNameL(dllName); |
|
75 |
|
76 TBool isFileInRom = aFileSession.IsFileInRom(fullName) != 0; |
|
77 |
|
78 /** |
|
79 * Read UID1 |
|
80 */ |
|
81 offset = UID1_OFFSET; |
|
82 aFile.Seek(ESeekStart, offset); // Set file position |
|
83 tmpUID.iUid = ReadUint32L(aFile); |
|
84 aElement.SetUID1L(tmpUID); |
|
85 |
|
86 /** |
|
87 * Read UID2 |
|
88 */ |
|
89 offset = UID2_OFFSET; |
|
90 aFile.Seek(ESeekStart, offset); // Set file position |
|
91 tmpUID.iUid = ReadUint32L(aFile); |
|
92 aElement.SetUID2L(tmpUID); |
|
93 |
|
94 /** |
|
95 * Read UID3 |
|
96 */ |
|
97 offset = UID3_OFFSET; |
|
98 aFile.Seek(ESeekStart, offset); // Set file position |
|
99 tmpUID.iUid = ReadUint32L(aFile); |
|
100 aElement.SetUID3L(tmpUID); |
|
101 |
|
102 /** |
|
103 * Read SID |
|
104 */ |
|
105 if( isFileInRom ) |
|
106 offset = SID_OFFSET_ROM; |
|
107 else |
|
108 offset = SID_OFFSET_ROFS; |
|
109 aFile.Seek(ESeekStart, offset); // Set file position |
|
110 tmpUID.iUid = ReadUint32L(aFile); |
|
111 aElement.SetSIDL(tmpUID); |
|
112 |
|
113 /** |
|
114 * Read Capability |
|
115 */ |
|
116 if( isFileInRom ) |
|
117 offset = CAPABILITY_OFFSET_ROM; |
|
118 else |
|
119 offset = CAPABILITY_OFFSET_ROFS; |
|
120 aFile.Seek(ESeekStart, offset); // Set file position |
|
121 TUint32 tmpVal = ReadUint32L(aFile); |
|
122 aElement.SetCapabilityL(tmpVal); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 |
|
127 TUint32 CLauncherDLLParser::ReadUint32L( RFile& aFile ) |
|
128 { |
|
129 TBuf8<4> tempBuf; |
|
130 User::LeaveIfError(aFile.Read(tempBuf, 4)); |
|
131 const TUint8* ptr = tempBuf.Ptr(); |
|
132 return TUint32(ptr[0] | (ptr[1]<<8) | (ptr[2]<<16) | (ptr[3]<<24)); |
|
133 } |