|
1 /* |
|
2 * Copyright (c) 2006-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 the License "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 |
|
19 #include <iostream> |
|
20 |
|
21 #include "filedescription.h" |
|
22 #include "sisfiledescription.h" |
|
23 #include "deserialiser.h" |
|
24 #include "serialiser.h" |
|
25 #include "sisstring.h" |
|
26 #include "sishash.h" |
|
27 |
|
28 FileDescription::~FileDescription () |
|
29 { |
|
30 } |
|
31 |
|
32 FileDescription::FileDescription(const CSISFileDescription& aFile, TInt aSid, const TInt aTargetDrive, const std::wstring& aFileName) |
|
33 : iTarget(aFileName), |
|
34 iMimeType(aFile.MimeType().GetString()), |
|
35 iOperation(aFile.Operation()), |
|
36 iOperationOptions(aFile.OperationOptions()), |
|
37 iUncompressedLength(aFile.UncompressedLength()), |
|
38 iIndex(aFile.FileIndex()), |
|
39 iSid(aSid) |
|
40 { |
|
41 const unsigned char* data = aFile.Hash().Blob().Data(); |
|
42 TUint32 len = aFile.Hash().Blob().Size(); |
|
43 |
|
44 std::string hashData((char*)data, len); |
|
45 |
|
46 iHash.SetData(hashData); |
|
47 iHash.SetHashId(HashContainer::EHashSHA); |
|
48 } |
|
49 |
|
50 void FileDescription::Internalize(Deserialiser& des) |
|
51 { |
|
52 |
|
53 des >> iTarget |
|
54 >> iMimeType |
|
55 >> iOperation |
|
56 >> iOperationOptions |
|
57 >> iHash |
|
58 >> iUncompressedLength |
|
59 >> iIndex |
|
60 >> iSid; |
|
61 } |
|
62 void FileDescription::Externalize(Serialiser& ser) |
|
63 { |
|
64 ser << iTarget |
|
65 << iMimeType |
|
66 << iOperation |
|
67 << iOperationOptions |
|
68 << iHash |
|
69 << iUncompressedLength |
|
70 << iIndex |
|
71 << iSid; |
|
72 } |
|
73 |
|
74 |
|
75 #ifdef _MSC_VER |
|
76 Deserialiser& operator>>(Deserialiser& aInput, std::vector<FileDescription*>& val) |
|
77 { |
|
78 TUint32 size = 0; |
|
79 aInput>> size; |
|
80 val.resize(size); |
|
81 for (TUint32 i = 0; i < size ; ++i) |
|
82 { |
|
83 val[i] = new FileDescription; |
|
84 aInput >> *val[i]; |
|
85 } |
|
86 return aInput; |
|
87 } |
|
88 #endif |