|
1 /* |
|
2 * Copyright (c) 2006 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: Contains CIptvVodDlDownloadEvent objects* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "CIptvEvents.h" |
|
23 #include "MIptvEvent.h" |
|
24 #include <s32mem.h> |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // LOCAL CONSTANTS AND MACROS |
|
35 |
|
36 // MODULE DATA STRUCTURES |
|
37 |
|
38 // LOCAL FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // ============================= LOCAL FUNCTIONS =============================== |
|
43 |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CIptvEvents::CIptvEvents |
|
49 // C++ default constructor can NOT contain any code, that |
|
50 // might leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CIptvEvents::CIptvEvents(MIptvEvent* aEventProto) |
|
54 : iEventProto(aEventProto) |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CIptvEvents::ConstructL |
|
60 // Symbian 2nd phase constructor can leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CIptvEvents::ConstructL() |
|
64 { |
|
65 iEvents.Reset(); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CIptvEvents::NewL |
|
70 // Two-phased constructor. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C CIptvEvents* CIptvEvents::NewL(MIptvEvent* aEventProto) |
|
74 { |
|
75 CIptvEvents* self = new( ELeave ) CIptvEvents(aEventProto); |
|
76 |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 CleanupStack::Pop(self); |
|
80 |
|
81 return self; |
|
82 } |
|
83 |
|
84 |
|
85 // Destructor |
|
86 EXPORT_C CIptvEvents::~CIptvEvents() |
|
87 { |
|
88 DeleteEvents(); |
|
89 iEventProto->Destruct(); |
|
90 } |
|
91 |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CIptvEvents::InternalizeL |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C void CIptvEvents::InternalizeL(RReadStream& aStream) |
|
98 { |
|
99 TUint16 eventCount = aStream.ReadUint16L(); |
|
100 TInt i; |
|
101 for(i = 0; i < eventCount; i++) |
|
102 { |
|
103 MIptvEvent* event = iEventProto->GetCopyL(); |
|
104 CleanupStack::PushL(event); // 1-> |
|
105 event->InternalizeL(aStream); |
|
106 iEvents.AppendL(event); |
|
107 CleanupStack::Pop(event); // <-1 |
|
108 } |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CIptvEvents::ExternalizeL |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C void CIptvEvents::ExternalizeL(RWriteStream& aStream) |
|
116 { |
|
117 TInt eventCount = iEvents.Count(); |
|
118 aStream.WriteUint16L(eventCount); |
|
119 TInt i; |
|
120 for(i = 0; i < eventCount; i++) |
|
121 { |
|
122 iEvents[i]->ExternalizeL(aStream); |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CIptvEvents::CountExternalizeSize |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 EXPORT_C TUint32 CIptvEvents::CountExternalizeSize() |
|
131 { |
|
132 TUint size = 0; |
|
133 size += 2; |
|
134 TInt i; |
|
135 for(i = 0; i < iEvents.Count(); i++) |
|
136 { |
|
137 size += iEvents[i]->CountExternalizeSize(); |
|
138 } |
|
139 return size; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CIptvEvents::Set |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C void CIptvEvents::SetL(CIptvEvents& aEvents) |
|
147 { |
|
148 DeleteEvents(); |
|
149 |
|
150 //copy new |
|
151 TInt i; |
|
152 for(i = 0; i < aEvents.iEvents.Count(); i++) |
|
153 { |
|
154 MIptvEvent* event = aEvents.iEvents[i]->GetCopyL(); |
|
155 CleanupStack::PushL(event); // 1-> |
|
156 iEvents.AppendL(event); |
|
157 CleanupStack::Pop(event); // <-1 |
|
158 } |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CIptvEvents::DeleteEvents |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C void CIptvEvents::DeleteEvents() |
|
166 { |
|
167 TInt i; |
|
168 for(i = 0; i < iEvents.Count(); i++) |
|
169 { |
|
170 iEvents[i]->Destruct(); //iEvents[i] is MIptvEvent type, MIptvEvent::Destruct() calls derived classes destructor |
|
171 } |
|
172 iEvents.Close(); //delete pointers |
|
173 iEvents.Reset(); |
|
174 } |
|
175 |
|
176 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
177 |
|
178 |
|
179 // End of File |