#include <inetop.h>
Inheritance diagram for DownloadOp:
Public Member Functions | |
DownloadOp () | |
DownloadOp constructor. | |
virtual | ~DownloadOp () |
DownloadOp destructor. | |
virtual void | Do (OpDescriptor *) |
virtual BOOL | OnIdleEvent () |
| |
virtual void | DoWithParam (OpDescriptor *pOp, OpParam *pDownloadOpParam) |
Request a download with the parameters passed in pDownloadOpParam. | |
virtual void | End () |
overrides Operation::End() to avoid having an ERROR2 (caused by Document::GetSelectedSpread() returning NULL) go off when Camelot exits while a download is still in progress | |
virtual BOOL | OnDeathMsg () |
virtual void | OnDownloadSuccess () |
| |
virtual void | OnDownloadFail () |
| |
virtual void | OnDownloadAbort () |
| |
virtual void | OnDownloadPending () |
| |
Static Public Member Functions | |
static BOOL | Init () |
Creates an OpDescriptor for a DownloadOp. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Returns the OpState of the DownloadOp operation. | |
Public Attributes | |
DownloadOpParam * | pParam |
Protected Member Functions | |
virtual void | OnDownloadProgress (const INT32 nPercentageCompleted) |
Protected Attributes | |
DOWNLOAD_HANDLE | m_hDownload |
INT32 | m_nPercentageCompleted |
Definition at line 179 of file inetop.h.
|
DownloadOp constructor.
Definition at line 170 of file inetop.cpp. 00171 { 00172 pParam = NULL; 00173 m_hDownload = 0; 00174 m_nPercentageCompleted = 0; 00175 OpFlags.HasOwnTimeIndicator = TRUE; 00176 // GetApplication()->RegisterIdleProcessor(IDLEPRIORITY_LOW, this); // start the polling loop 00177 }
|
|
DownloadOp destructor.
Definition at line 194 of file inetop.cpp. 00195 { 00196 GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_LOW, this); // end polling loop 00197 if (pParam) 00198 delete pParam; 00199 }
|
|
Reimplemented from Operation. Definition at line 263 of file inetop.cpp. 00264 { 00265 ERROR3("This operation does not provide a Do() function - Use DoWithParam"); 00266 End(); 00267 }
|
|
Request a download with the parameters passed in pDownloadOpParam.
Reimplemented from Operation. Definition at line 286 of file inetop.cpp. 00287 { 00288 DownloadOpParam *pInfo = (DownloadOpParam*) pDownloadOpParam; 00289 if (pInfo == NULL) 00290 { 00291 ERROR3("DoWithParam called with invalid pointer"); 00292 goto FAIL; 00293 } 00294 else 00295 { 00296 if (!pInfo->file.IsValid() || pInfo->strURL.IsEmpty()) 00297 { 00298 ERROR3("Invalid file path or URL"); 00299 goto FAIL; 00300 } 00301 // Register the file for download 00302 DOWNLOADINFO downloadInfo; 00303 downloadInfo.strURL = pInfo->strURL; 00304 downloadInfo.strLocalFile = (String_256) pInfo->file.GetPath(); 00305 downloadInfo.nFileType = pInfo->type; 00306 downloadInfo.nPriority = pInfo->priority; 00307 downloadInfo.strDescription = pInfo->strDescription; 00308 downloadInfo.bHasProgressDlg = TRUE; 00309 00310 // NEW! Tell this downloader that we can handle status messages 00311 // (We don't use Idle event polling) 00312 downloadInfo.hwndNotifyWindow = GetMainFrame()->GetSafeHwnd(); 00313 downloadInfo.lNotifyToken = (INT32)this; 00314 00315 m_hDownload = InternetManager::RegisterDownload(&downloadInfo); 00316 if (!m_hDownload || m_hDownload == (DOWNLOAD_HANDLE) INVALID_HANDLE_VALUE) 00317 { 00318 ERROR3("Failed to register download"); 00319 goto FAIL; 00320 } 00321 pParam = pInfo; 00322 if (pInfo->Output) 00323 *(pInfo->Output) = TRUE; 00324 } 00325 return; 00326 00327 FAIL: 00328 if (pInfo->Output) 00329 *(pInfo->Output) = FALSE; 00330 FailAndDiscard(); 00331 End(); 00332 }
|
|
overrides Operation::End() to avoid having an ERROR2 (caused by Document::GetSelectedSpread() returning NULL) go off when Camelot exits while a download is still in progress
Reimplemented from Operation. Definition at line 352 of file inetop.cpp. 00353 { 00354 if (m_hDownload) 00355 InternetManager::UnregisterDownload(m_hDownload); 00356 if (Document::GetSelectedSpread()) 00357 Operation::End(); 00358 else 00359 EndOp(); 00360 }
|
|
Returns the OpState of the DownloadOp operation.
Reimplemented in OpGenericDownload, HelpDownloadOp, and OpBitmapDownload. Definition at line 240 of file inetop.cpp. 00241 { 00242 OpState OpSt; 00243 return(OpSt); 00244 }
|
|
Creates an OpDescriptor for a DownloadOp.
Reimplemented from SimpleCCObject. Reimplemented in OpAsynchFontInstall, OpAsynchBitmapImport, OpGenericDownload, HelpDownloadOp, and OpBitmapDownload. Definition at line 214 of file inetop.cpp. 00215 { 00216 return RegisterOpDescriptor( 00217 0, // Tool ID 00218 _R(IDS_OPDOWNLOAD), // String resource ID 00219 CC_RUNTIME_CLASS(DownloadOp), // Runtime class 00220 OPTOKEN_OPDOWNLOAD, // Token string 00221 DownloadOp::GetState, // GetState function 00222 0, // Help ID 00223 0, // Bubble ID 00224 0, // Resource ID 00225 0 // Control ID 00226 ); 00227 }
|
|
Reimplemented from MessageHandler. Definition at line 195 of file inetop.h.
|
|
Reimplemented in OpGenericDownload, and HelpDownloadOp. Definition at line 480 of file inetop.cpp.
|
|
Reimplemented in OpGenericDownload, HelpDownloadOp, and OpBitmapDownload. Definition at line 456 of file inetop.cpp. 00457 { 00458 String_256 strTemp; 00459 strTemp.MakeMsg(_R(IDS_DOWNLOADFAILED), (TCHAR*) (String_256) GetStringField((UINT32) pParam->type, _R(IDS_GALLERY_DESCRIPTIONS)), (TCHAR*) pParam->strDescription); 00460 Error::SetError(0, strTemp, 0); 00461 InformError(); 00462 }
|
|
Definition at line 502 of file inetop.cpp. 00503 { 00504 // check the percentage downloaded so far 00505 INT32 nPercentageCompleted = 0; 00506 nPercentageCompleted = InternetManager::GetPercentageDownloaded(m_hDownload); 00507 // ERROR3IF(nPercentageCompleted == -1, "Invalid download handle"); 00508 if (nPercentageCompleted != -1) 00509 { 00510 if (nPercentageCompleted != m_nPercentageCompleted) // we made some progress 00511 { 00512 m_nPercentageCompleted = nPercentageCompleted; 00513 OnDownloadProgress(nPercentageCompleted); 00514 } 00515 } 00516 }
|
|
Definition at line 204 of file inetop.h.
|
|
Reimplemented in OpAsynchFontInstall, OpAsynchBitmapImport, OpGenericDownload, HelpDownloadOp, and OpBitmapDownload. Definition at line 437 of file inetop.cpp.
|
|
Reimplemented from Operation. Definition at line 381 of file inetop.cpp. 00382 { 00383 //ERROR2(FALSE, "DownloadOp::OnIdleEvent should no longer be called!!!"); 00384 INT32 nPercentageCompleted = 0; 00385 ERROR2IF(!pParam, FALSE, "Unexpected NULL pointer"); 00386 switch (InternetManager::GetDownloadState(m_hDownload)) 00387 { 00388 case AsynchDownload::STATE_PENDING: 00389 // check the percentage downloaded so far 00390 nPercentageCompleted = InternetManager::GetPercentageDownloaded(m_hDownload); 00391 ERROR3IF(nPercentageCompleted == -1, "Invalid download handle"); 00392 if (nPercentageCompleted != m_nPercentageCompleted) // we made some progress 00393 { 00394 m_nPercentageCompleted = nPercentageCompleted; 00395 OnDownloadProgress(nPercentageCompleted); 00396 } 00397 // download pending, so we continue polling 00398 return TRUE; 00399 case AsynchDownload::STATE_SUCCEEDED: 00400 // file has transferred successfully, we call OnDownloadSuccess() to process it 00401 OnDownloadSuccess(); 00402 SucceedAndDiscard(); 00403 End(); 00404 return FALSE; 00405 case AsynchDownload::STATE_FAILED: 00406 OnDownloadFail(); 00407 break; 00408 case AsynchDownload::STATE_ABORTED: 00409 OnDownloadAbort(); 00410 break; 00411 default: 00412 ERROR3("Error or unrecognized state"); 00413 } 00414 FailAndDiscard(); 00415 End(); 00416 return FALSE; 00417 }
|
|
|
|
|
|
|