|
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 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 #include <s32strm.h> |
|
18 #include "BrowserBookmarksOrder.h" |
|
19 #include "Commonconstants.h" |
|
20 |
|
21 _LIT( KBrowserBMOrderDataBegin, "BMOrderDataBegin" ); |
|
22 _LIT( KBrowserBMOrderDataEnd, "BMOrderDataEnd" ); |
|
23 |
|
24 |
|
25 // --------------------------------------------------------- |
|
26 // CBrowserBookmarksOrder::NewLC() |
|
27 // --------------------------------------------------------- |
|
28 // |
|
29 |
|
30 CBrowserBookmarksOrder* CBrowserBookmarksOrder::NewLC() |
|
31 { |
|
32 CBrowserBookmarksOrder* order = |
|
33 new (ELeave) CBrowserBookmarksOrder(); |
|
34 CleanupStack::PushL(order); |
|
35 order->ConstructL(); |
|
36 return order; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // CBrowserBookmarksOrder::ConstructL() |
|
41 // --------------------------------------------------------- |
|
42 // |
|
43 |
|
44 void CBrowserBookmarksOrder::ConstructL() |
|
45 { |
|
46 iBMOrderArray = new (ELeave) CArrayFixFlat<TInt>(KGranularityHigh); |
|
47 } |
|
48 |
|
49 CBrowserBookmarksOrder::~CBrowserBookmarksOrder() |
|
50 { |
|
51 delete iBMOrderArray; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------- |
|
55 // CBrowserBookmarksOrder::InternalizeL |
|
56 // --------------------------------------------------------- |
|
57 // |
|
58 |
|
59 void CBrowserBookmarksOrder::InternalizeL( RReadStream& aStream ) |
|
60 { |
|
61 iBMOrderArray->Reset(); |
|
62 HBufC* tag = HBufC::NewLC(sizeof (KBrowserBMOrderDataBegin)); |
|
63 TInt err = 0; |
|
64 TPtr des = tag->Des(); |
|
65 |
|
66 TRAP(err, aStream>>des ); |
|
67 if ( (err == KErrNone) && (tag->Des() == KBrowserBMOrderDataBegin ) ) |
|
68 { |
|
69 TInt count = aStream.ReadInt16L(); |
|
70 for (TInt i=0; i<count; i++) |
|
71 { |
|
72 TInt value; |
|
73 TRAP(err, value = aStream.ReadInt16L()); |
|
74 if (err == KErrNone) |
|
75 { |
|
76 iBMOrderArray->AppendL(value); |
|
77 } |
|
78 else |
|
79 if (err != KErrEof) |
|
80 { |
|
81 User::Leave(err); |
|
82 } |
|
83 } |
|
84 |
|
85 TRAP(err, aStream>>des ); |
|
86 if (tag->Des() != KBrowserBMOrderDataEnd) |
|
87 { |
|
88 iBMOrderArray->Reset(); |
|
89 } |
|
90 } |
|
91 CleanupStack::PopAndDestroy(tag); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CBrowserBookmarksOrder::ExternalizeL |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 |
|
99 void CBrowserBookmarksOrder::ExternalizeL( RWriteStream& aStream ) const |
|
100 { |
|
101 aStream<<KBrowserBMOrderDataBegin; |
|
102 aStream.WriteInt16L(iBMOrderArray->Count()); |
|
103 for (TInt i=0; i<iBMOrderArray->Count(); i++) |
|
104 { |
|
105 aStream.WriteInt16L((*iBMOrderArray)[i]); |
|
106 } |
|
107 aStream<<KBrowserBMOrderDataEnd; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // CBrowserBookmarksOrder::GetBookMarksOrder() |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 |
|
115 const CArrayFixFlat<TInt>& CBrowserBookmarksOrder::GetBookMarksOrder() |
|
116 { |
|
117 return *iBMOrderArray; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------- |
|
121 // CBrowserBookmarksOrder::SetBookMarksOrderL |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 |
|
125 void CBrowserBookmarksOrder::SetBookMarksOrderL(const CArrayFixFlat<TInt>& aBookMarksOrder) |
|
126 { |
|
127 |
|
128 iBMOrderArray->Reset(); |
|
129 if ( aBookMarksOrder.Count() ) |
|
130 { |
|
131 iBMOrderArray->AppendL(&(aBookMarksOrder[0]), aBookMarksOrder.Count()); |
|
132 } |
|
133 } |