1 /* |
|
2 * Copyright (c) 2006-2007 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: Capsulating store file list item |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <s32mem.h> |
|
26 #include "cmstorelistitem.h" |
|
27 #include "msdebug.h" |
|
28 |
|
29 |
|
30 // ======== LOCAL FUNCTIONS ======== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // NewL |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C CCmStoreListItem* CCmStoreListItem::NewL() |
|
37 { |
|
38 CCmStoreListItem* self = CCmStoreListItem::NewLC(); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // NewLC |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C CCmStoreListItem* CCmStoreListItem::NewLC() |
|
48 { |
|
49 CCmStoreListItem* self = new ( ELeave ) CCmStoreListItem(); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Destructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CCmStoreListItem::~CCmStoreListItem() |
|
60 { |
|
61 iDeviceIds.Reset(); |
|
62 iDeviceIds.Close(); |
|
63 iStatusValues.Reset(); |
|
64 iStatusValues.Close(); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CCmStoreListItem::SetListId |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 EXPORT_C void CCmStoreListItem::SetListId( const TUint aListId ) |
|
72 { |
|
73 iListId = aListId; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CCmStoreListItem::SetDevId |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 EXPORT_C void CCmStoreListItem::SetDevId( const TUint8 aId, |
|
81 TCmListItemStatus aStatus ) |
|
82 { |
|
83 iDeviceIds.Append( aId ); |
|
84 iStatusValues.AppendL( aStatus ); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CCmStoreListItem::ListId |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C TUint CCmStoreListItem::ListId() const |
|
92 { |
|
93 return iListId; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CCmStoreListItem::DevIds |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C RArray<TInt> CCmStoreListItem::DevIds() const |
|
101 { |
|
102 return iDeviceIds; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CCmStoreListItem::StatusValues |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C RArray<TCmListItemStatus> CCmStoreListItem::StatusValues() const |
|
110 { |
|
111 return iStatusValues; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CCmStoreListItem::UpdateFileStatusL |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C void CCmStoreListItem::UpdateFileStatusL( const TUint8 aId, |
|
119 TCmListItemStatus aStatus ) |
|
120 { |
|
121 // Find index of the device |
|
122 TInt index( iDeviceIds.FindL( aId ) ); |
|
123 if( KErrNotFound != index ) |
|
124 { |
|
125 // Use index when updating status value |
|
126 iStatusValues[index] = aStatus; |
|
127 } |
|
128 |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CCmStoreListItem::ExternalizeL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C void CCmStoreListItem::ExternalizeL( RWriteStream& aStream ) const |
|
136 { |
|
137 aStream.WriteUint16L( iListId ); |
|
138 aStream.WriteUint16L( iDeviceIds.Count() ); |
|
139 for( TInt i = 0; i < iDeviceIds.Count(); i++ ) |
|
140 { |
|
141 aStream.WriteInt16L( iDeviceIds[i] ); |
|
142 } |
|
143 aStream.WriteInt16L( iStatusValues.Count() ); |
|
144 for( TInt i = 0; i < iStatusValues.Count(); i++ ) |
|
145 { |
|
146 aStream.WriteInt16L( iStatusValues[i] ); |
|
147 } |
|
148 CCmBaseListItem::ExternalizeL(aStream); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CCmStoreListItem::InternalizeL |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 EXPORT_C void CCmStoreListItem::InternalizeL( RReadStream& aStream ) |
|
156 { |
|
157 iListId = aStream.ReadUint16L(); |
|
158 TUint count( aStream.ReadUint16L() ); |
|
159 iDeviceIds.Reset(); |
|
160 for( TInt i = 0; i < count; i++ ) |
|
161 { |
|
162 iDeviceIds.Append( aStream.ReadInt16L() ); |
|
163 } |
|
164 count = aStream.ReadUint16L(); |
|
165 iStatusValues.Reset(); |
|
166 for( TInt i = 0; i < count; i++ ) |
|
167 { |
|
168 iStatusValues.AppendL( (TCmListItemStatus) aStream.ReadInt16L() ); |
|
169 } |
|
170 CCmBaseListItem::InternalizeL(aStream); |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // Default constructor |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 CCmStoreListItem::CCmStoreListItem() |
|
178 { |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // ConstructL |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 void CCmStoreListItem::ConstructL() |
|
186 { |
|
187 // construct base class |
|
188 CCmBaseListItem::ConstructL(); |
|
189 } |
|
190 |
|
191 // End of file |
|
192 |
|