128 default: |
130 default: |
129 return 0; |
131 return 0; |
130 } |
132 } |
131 } |
133 } |
132 |
134 |
133 static const char * downloadPriorityToString(DownloadPriority priority) |
|
134 { |
|
135 switch (priority) { |
|
136 case High: |
|
137 return "High"; |
|
138 case Low: |
|
139 return "Low"; |
|
140 default: |
|
141 return 0; |
|
142 } |
|
143 } |
|
144 |
|
145 static const char * downloadScopeToString(DownloadScope scope) |
|
146 { |
|
147 switch (scope) { |
|
148 case Normal: |
|
149 return "Normal"; |
|
150 case Background: |
|
151 return "Background"; |
|
152 default: |
|
153 return 0; |
|
154 } |
|
155 } |
|
156 |
|
157 static const char * downloadStateToString(DownloadState state) |
|
158 { |
|
159 switch (state) { |
|
160 case DlNone: |
|
161 return "DlNone"; |
|
162 case DlCreated: |
|
163 return "DlCreated"; |
|
164 case DlStarted: |
|
165 return "DlStarted"; |
|
166 case DlInprogress: |
|
167 return "DlInprogress"; |
|
168 case DlPaused: |
|
169 return "DlPaused"; |
|
170 case DlCompleted: |
|
171 return "DlCompleted"; |
|
172 case DlFailed: |
|
173 return "DlFailed"; |
|
174 case DlCancelled: |
|
175 return "DlCancelled"; |
|
176 case DlDescriptorUpdated: |
|
177 return "DlDescriptorUpdated"; |
|
178 default: |
|
179 return 0; |
|
180 } |
|
181 } |
|
182 |
|
183 static const char * downloadTypeToString(DownloadType type) |
|
184 { |
|
185 switch (type) { |
|
186 case Parallel: |
|
187 return "Parallel"; |
|
188 case Sequential: |
|
189 return "Sequential"; |
|
190 default: |
|
191 return 0; |
|
192 } |
|
193 } |
|
194 |
|
195 static void debugDownloadStr( |
|
196 Download * download, |
|
197 DownloadAttribute attribute, |
|
198 const char * name) |
|
199 { |
|
200 QString value = download->getAttribute(attribute).toString(); |
|
201 if (value.length() == 0) { |
|
202 return; |
|
203 } |
|
204 |
|
205 qDebug() << "DL" << download->id() << name << value; |
|
206 } |
|
207 |
|
208 static void debugDownloadInt( |
|
209 Download * download, |
|
210 DownloadAttribute attribute, |
|
211 const char * name) |
|
212 { |
|
213 int value = download->getAttribute(attribute).toInt(); |
|
214 if (value == 0) { |
|
215 return; |
|
216 } |
|
217 |
|
218 qDebug() << "DL" << download->id() << name << value; |
|
219 } |
|
220 |
|
221 static void debugDownloadUInt( |
|
222 Download * download, |
|
223 DownloadAttribute attribute, |
|
224 const char * name) |
|
225 { |
|
226 uint value = download->getAttribute(attribute).toUInt(); |
|
227 if (value == 0) { |
|
228 return; |
|
229 } |
|
230 |
|
231 qDebug() << "DL" << download->id() << name << value; |
|
232 } |
|
233 |
|
234 static void debugDownloadError( |
|
235 Download * download, |
|
236 DownloadAttribute attribute, |
|
237 const char * name) |
|
238 { |
|
239 int num = download->getAttribute(attribute).toInt(); |
|
240 |
|
241 const char * str = downloadErrorToString(static_cast<QNetworkReply::NetworkError>(num)); |
|
242 if (str == 0) { |
|
243 str = "???"; |
|
244 } |
|
245 |
|
246 qDebug() << "DL" << download->id() << name << num << str; |
|
247 } |
|
248 |
|
249 static void debugDownloadPriority( |
|
250 Download * download, |
|
251 DownloadAttribute attribute, |
|
252 const char * name) |
|
253 { |
|
254 int num = download->getAttribute(attribute).toInt(); |
|
255 |
|
256 const char * str = downloadPriorityToString(static_cast<DownloadPriority>(num)); |
|
257 if (str == 0) { |
|
258 str = "???"; |
|
259 } |
|
260 |
|
261 qDebug() << "DL" << download->id() << name << num << str; |
|
262 } |
|
263 |
|
264 static void debugDownloadScope( |
|
265 Download * download, |
|
266 DownloadAttribute attribute, |
|
267 const char * name) |
|
268 { |
|
269 int num = download->getAttribute(attribute).toInt(); |
|
270 |
|
271 const char * str = downloadScopeToString(static_cast<DownloadScope>(num)); |
|
272 if (str == 0) { |
|
273 str = "???"; |
|
274 } |
|
275 |
|
276 qDebug() << "DL" << download->id() << name << num << str; |
|
277 } |
|
278 |
|
279 static void debugDownloadState( |
|
280 Download * download, |
|
281 DownloadAttribute attribute, |
|
282 const char * name) |
|
283 { |
|
284 int num = download->getAttribute(attribute).toInt(); |
|
285 |
|
286 const char * str = downloadStateToString(static_cast<DownloadState>(num)); |
|
287 if (str == 0) { |
|
288 str = "???"; |
|
289 } |
|
290 |
|
291 qDebug() << "DL" << download->id() << name << num << str; |
|
292 } |
|
293 |
|
294 static void debugDownloadType( |
|
295 Download * download, |
|
296 DownloadAttribute attribute, |
|
297 const char * name) |
|
298 { |
|
299 int num = download->getAttribute(attribute).toInt(); |
|
300 |
|
301 const char * str = downloadTypeToString(static_cast<DownloadType>(num)); |
|
302 if (str == 0) { |
|
303 str = "???"; |
|
304 } |
|
305 |
|
306 qDebug() << "DL" << download->id() << name << num << str; |
|
307 } |
|
308 |
|
309 void DownloadController::debugDownload(Download * download) |
|
310 { |
|
311 debugDownloadState(download, |
|
312 DlDownloadState, |
|
313 "DlDownloadState"); |
|
314 |
|
315 debugDownloadError(download, |
|
316 DlLastError, |
|
317 "DlLastError"); |
|
318 |
|
319 debugDownloadStr(download, |
|
320 DlLastErrorString, |
|
321 "DlLastErrorString"); |
|
322 |
|
323 debugDownloadStr(download, |
|
324 DlSourceUrl, |
|
325 "DlSourceUrl"); |
|
326 |
|
327 debugDownloadStr(download, |
|
328 DlContentType, |
|
329 "DlContentType"); |
|
330 |
|
331 debugDownloadStr(download, |
|
332 DlDestPath, |
|
333 "DlDestPath"); |
|
334 |
|
335 debugDownloadStr(download, |
|
336 DlFileName, |
|
337 "DlFileName"); |
|
338 |
|
339 debugDownloadInt(download, |
|
340 DlDownloadedSize, |
|
341 "DlDownloadedSize"); |
|
342 |
|
343 debugDownloadInt(download, |
|
344 DlTotalSize, |
|
345 "DlTotalSize"); |
|
346 |
|
347 debugDownloadInt(download, |
|
348 DlLastPausedSize, |
|
349 "DlLastPausedSize"); |
|
350 |
|
351 debugDownloadInt(download, |
|
352 DlPercentage, |
|
353 "DlPercentage"); |
|
354 |
|
355 debugDownloadStr(download, |
|
356 DlStartTime, |
|
357 "DlStartTime"); |
|
358 |
|
359 debugDownloadStr(download, |
|
360 DlEndTime, |
|
361 "DlEndTime"); |
|
362 |
|
363 debugDownloadUInt(download, |
|
364 DlElapsedTime, |
|
365 "DlElapsedTime"); |
|
366 |
|
367 debugDownloadStr(download, |
|
368 DlRemainingTime, |
|
369 "DlRemainingTime"); |
|
370 |
|
371 debugDownloadStr(download, |
|
372 DlSpeed, |
|
373 "DlSpeed"); |
|
374 |
|
375 debugDownloadScope(download, |
|
376 DlDownloadScope, |
|
377 "DlDownloadScope"); |
|
378 |
|
379 debugDownloadType(download, |
|
380 DlDownloadType, |
|
381 "DlDownloadType"); |
|
382 |
|
383 debugDownloadPriority(download, |
|
384 DlPriority, |
|
385 "DlPriority"); |
|
386 |
|
387 debugDownloadInt(download, |
|
388 DlProgressInterval, |
|
389 "DlProgressInterval"); |
|
390 |
|
391 debugDownloadStr(download, |
|
392 OMADownloadDescriptorName, |
|
393 "OMADownloadDescriptorName"); |
|
394 |
|
395 debugDownloadStr(download, |
|
396 OMADownloadDescriptorVersion, |
|
397 "OMADownloadDescriptorVersion"); |
|
398 |
|
399 debugDownloadStr(download, |
|
400 OMADownloadDescriptorType, |
|
401 "OMADownloadDescriptorType"); |
|
402 |
|
403 debugDownloadStr(download, |
|
404 OMADownloadDescriptorSize, |
|
405 "OMADownloadDescriptorSize"); |
|
406 |
|
407 debugDownloadStr(download, |
|
408 OMADownloadDescriptorVendor, |
|
409 "OMADownloadDescriptorVendor"); |
|
410 |
|
411 debugDownloadStr(download, |
|
412 OMADownloadDescriptorDescription, |
|
413 "OMADownloadDescriptorDescription"); |
|
414 |
|
415 debugDownloadStr(download, |
|
416 OMADownloadDescriptorNextURL, |
|
417 "OMADownloadDescriptorNextURL"); |
|
418 } |
|
419 |
|
420 static void debugDownloadEvent(DEventType type) |
135 static void debugDownloadEvent(DEventType type) |
421 { |
136 { |
422 const char * name = downloadEventToString(type); |
137 const char * name = downloadEventToString(type); |
423 if (name == 0) { |
138 if (name == 0) { |
424 return; |
139 return; |
576 |
297 |
577 QString error; |
298 QString error; |
578 if (errorStr != 0) |
299 if (errorStr != 0) |
579 error = errorStr; |
300 error = errorStr; |
580 |
301 |
|
302 DownloadProxy downloadProxy(new DownloadProxyData(download)); |
|
303 |
581 switch (type) |
304 switch (type) |
582 { |
305 { |
583 case Started: |
306 case Started: |
584 emit m_downloadController->downloadStarted(download); |
307 emit m_downloadController->downloadStarted(downloadProxy); |
585 return true; |
308 return true; |
586 |
309 |
587 case HeaderReceived: |
310 case HeaderReceived: |
588 emit m_downloadController->downloadHeaderReceived(download); |
311 emit m_downloadController->downloadHeaderReceived(downloadProxy); |
589 return true; |
312 return true; |
590 |
313 |
591 case Progress: |
314 case Progress: |
592 emit m_downloadController->downloadProgress(download); |
315 emit m_downloadController->downloadProgress(downloadProxy); |
593 return true; |
316 return true; |
594 |
317 |
595 case Completed: |
318 case Completed: |
596 emit m_downloadController->downloadFinished(download); |
319 emit m_downloadController->downloadFinished(downloadProxy); |
597 return true; |
320 return true; |
598 |
321 |
599 case Paused: |
322 case Paused: |
600 emit m_downloadController->downloadPaused(download, error); |
323 emit m_downloadController->downloadPaused(downloadProxy, error); |
601 return true; |
324 return true; |
602 |
325 |
603 case Cancelled: |
326 case Cancelled: |
604 emit m_downloadController->downloadCancelled(download, error); |
327 emit m_downloadController->downloadCancelled(downloadProxy, error); |
605 return true; |
328 return true; |
606 |
329 |
607 case Failed: |
330 case Failed: |
608 emit m_downloadController->downloadFailed(download, error); |
331 emit m_downloadController->downloadFailed(downloadProxy, error); |
609 return true; |
332 return true; |
610 |
333 |
611 case DescriptorUpdated: |
334 case DescriptorUpdated: |
612 // FIXME ;;; Update to support OMA and DRM. |
335 // FIXME ;;; Update to support OMA and DRM. |
613 return true; |
336 return true; |
614 |
337 |
615 case NetworkLoss: |
338 case NetworkLoss: |
616 emit m_downloadController->downloadNetworkLoss(download, error); |
339 emit m_downloadController->downloadNetworkLoss(downloadProxy, error); |
617 return true; |
340 return true; |
618 |
341 |
619 case Error: |
342 case Error: |
620 emit m_downloadController->downloadError(download, error); |
343 emit m_downloadController->downloadError(downloadProxy, error); |
621 return true; |
344 return true; |
622 |
345 |
623 case OMADownloadDescriptorReady: |
346 case OMADownloadDescriptorReady: |
624 // FIXME ;;; Update to support OMA and DRM. |
347 // FIXME ;;; Update to support OMA and DRM. |
625 return true; |
348 return true; |