|
1 /* |
|
2 * Copyright (c) 2002-2005 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 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "AspState.h" |
|
23 #include "AspUtil.h" |
|
24 |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CAspState::NewL |
|
31 // |
|
32 // Two-phased constructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CAspState* CAspState::NewL() |
|
36 { |
|
37 CAspState* self = new (ELeave) CAspState(); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // Destructor |
|
47 // |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CAspState::~CAspState() |
|
51 { |
|
52 delete iSyncContent; |
|
53 } |
|
54 |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CAspState::CAspState |
|
58 // |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CAspState::CAspState() |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CAspState::ConstructL |
|
68 // |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CAspState::ConstructL() |
|
72 { |
|
73 Reset(); |
|
74 |
|
75 iSyncContent = HBufC::NewL(0); |
|
76 } |
|
77 |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CAspState::Reset |
|
81 // |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CAspState::Reset() |
|
85 { |
|
86 iSyncPhase = EPhaseNone; |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CAspState::SetSyncPhase |
|
92 // |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CAspState::SetSyncPhase(TInt aPhase) |
|
96 { |
|
97 if (aPhase != iSyncPhase) |
|
98 { |
|
99 iSyncPhase = aPhase; |
|
100 } |
|
101 } |
|
102 |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CAspState::SyncPhase |
|
106 // |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TInt CAspState::SyncPhase() |
|
110 { |
|
111 return iSyncPhase; |
|
112 } |
|
113 |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CAspState::IncreaseProgress |
|
117 // |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CAspState::IncreaseProgress() |
|
121 { |
|
122 iProgressCount++; |
|
123 iProgressCount2++; |
|
124 } |
|
125 |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CAspState::IncreaseProgress |
|
129 // |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CAspState::IncreaseProgress(TInt aCount) |
|
133 { |
|
134 if (aCount > 0) |
|
135 { |
|
136 iProgressCount = iProgressCount + aCount; |
|
137 iProgressCount2++; |
|
138 } |
|
139 } |
|
140 |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CAspState::Progress |
|
144 // |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CAspState::Progress() |
|
148 { |
|
149 return iProgressCount; |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CAspState::SetProgress |
|
155 // |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 /* |
|
159 void CAspState::SetProgress(TInt aCount) |
|
160 { |
|
161 if (aCount >= 0 && aCount <= KTotalProgress) |
|
162 { |
|
163 iProgressCount = aCount; |
|
164 iProgressCount2++; |
|
165 } |
|
166 } |
|
167 */ |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CAspState::SetTotalProgress |
|
171 // |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CAspState::SetTotalProgress(TInt aCount) |
|
175 { |
|
176 if (aCount < 0) |
|
177 { |
|
178 iTotalProgressCount = KTotalProgressUnknown; |
|
179 return; |
|
180 } |
|
181 |
|
182 iTotalProgressCount = aCount; |
|
183 } |
|
184 |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CAspState::TotalProgress |
|
188 // |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CAspState::TotalProgress() |
|
192 { |
|
193 return iTotalProgressCount; |
|
194 } |
|
195 |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CAspState::FirstProgress |
|
199 // |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 TBool CAspState::FirstProgress() |
|
203 { |
|
204 if (iProgressCount2 == 1) |
|
205 { |
|
206 return ETrue; |
|
207 } |
|
208 |
|
209 return EFalse; |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CAspState::SetContentL |
|
215 // |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 void CAspState::SetContentL(const TDesC& aText) |
|
219 { |
|
220 delete iSyncContent; |
|
221 iSyncContent = NULL; |
|
222 iSyncContent = aText.AllocL(); |
|
223 } |
|
224 |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CAspState::Content |
|
228 // |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 const TDesC& CAspState::Content() |
|
232 { |
|
233 __ASSERT_ALWAYS(iSyncContent, TUtil::Panic(KErrGeneral)); |
|
234 |
|
235 return *iSyncContent; |
|
236 } |
|
237 |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CAspState::ResetProgress |
|
241 // |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CAspState::ResetProgress() |
|
245 { |
|
246 iProgressCount = 0; |
|
247 iProgressCount2 = 0; |
|
248 iTotalProgressCount = 0; |
|
249 |
|
250 TRAP_IGNORE(SetContentL(KNullDesC)); |
|
251 } |
|
252 |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CAspState::ProgressKnown |
|
256 // |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 TBool CAspState::ProgressKnown() |
|
260 { |
|
261 if (iTotalProgressCount == KTotalProgressUnknown) |
|
262 { |
|
263 return EFalse; |
|
264 } |
|
265 |
|
266 return ETrue; |
|
267 } |
|
268 |
|
269 |
|
270 // End of file |
|
271 |