#include <inetop.h>
Inheritance diagram for OpThumbDownload:
Public Member Functions | |
OpThumbDownload () | |
~OpThumbDownload () | |
OpThumbDownload destructor. | |
virtual void | Do (OpDescriptor *) |
virtual BOOL | OnIdleEvent () |
| |
virtual void | DoWithParam (OpDescriptor *pOp, OpParam *pThumbDownloadParam) |
| |
virtual void | End () |
Ends the download operation, displaying the thumbnail if successful. | |
void | Abort () |
Aborts the download operation. | |
Static Public Member Functions | |
static BOOL | Init () |
Creates an OpDescriptor for an OpThumbDownload operation. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Returns the OpState of the OpThumbDownload operation. | |
static INT32 | GetLastError (SGLibDisplayItem *pItem) |
| |
static void | ClearErrors () |
| |
static void | Suspend () |
static void | Resume () |
Public Attributes | |
ThumbDownloadParam * | pParam |
Protected Attributes | |
DOWNLOAD_HANDLE | m_hDownload |
INT32 | m_nPercentageCompleted |
LibraryGallery * | pGallery |
Static Protected Attributes | |
static std::list< SGLibDisplayItem * > | m_lstFailedItems |
static INT32 | ThumbsDownloaded [8] |
static INT32 | InstanceCount [8] |
static INT32 | ErrorCount [8] |
static BOOL | m_bIsSuspended = FALSE |
Definition at line 351 of file inetop.h.
|
Definition at line 1696 of file inetop.cpp. 01697 { 01698 pParam = NULL; 01699 m_nPercentageCompleted = 0; 01700 m_hDownload = 0; 01701 pGallery = NULL; 01702 GetApplication()->RegisterIdleProcessor(IDLEPRIORITY_LOW, this); 01703 OpFlags.HasOwnTimeIndicator = TRUE; 01704 }
|
|
OpThumbDownload destructor.
Definition at line 1721 of file inetop.cpp. 01722 { 01723 GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_LOW, this); 01724 if (pParam) 01725 { 01726 InstanceCount[pParam->type]--; 01727 delete pParam; 01728 } 01729 }
|
|
Aborts the download operation.
Definition at line 1932 of file inetop.cpp. 01933 { 01934 if (m_hDownload && InternetManager::GetDownloadState(m_hDownload) == AsynchDownload::STATE_PENDING) 01935 InternetManager::UnregisterDownload(m_hDownload); 01936 LibraryGallery* pGallery = (LibraryGallery*) pParam->pItem->GetParentGallery(); 01937 if (pGallery) 01938 { 01939 pGallery->m_lstPendingThumbs.remove(this); 01940 if (InstanceCount[pParam->type] == 1) 01941 pGallery->SelectionHasChanged(); 01942 } 01943 Operation::End(); 01944 }
|
|
Definition at line 2074 of file inetop.cpp. 02075 { 02076 memset(&ErrorCount, 0x00, sizeof(ErrorCount)); 02077 if (!m_lstFailedItems.empty()) 02078 { 02079 std::list<SGLibDisplayItem*>::iterator itrBegin = m_lstFailedItems.begin(); 02080 std::list<SGLibDisplayItem*>::iterator itrEnd = m_lstFailedItems.end(); 02081 m_lstFailedItems.erase(itrBegin, itrEnd); // zapp the entire list 02082 ERROR3IF(!m_lstFailedItems.empty(), "Warning: failed to empty error list"); 02083 } 02084 }
|
|
Reimplemented from Operation. Definition at line 1793 of file inetop.cpp. 01794 { 01795 ERROR3("OpThumbDownload does not provide a Do() function - Use DoWithParam"); 01796 End(); 01797 }
|
|
Reimplemented from Operation. Definition at line 1816 of file inetop.cpp. 01817 { 01818 ThumbDownloadParam* pInfo = (ThumbDownloadParam*) pThumbDownloadParam; 01819 01820 if (pInfo == NULL || pInfo->pItem == NULL) 01821 { 01822 ERROR3("OpThumbDownload called with NULL info pointer"); 01823 End(); 01824 } 01825 else 01826 { 01827 String_256 thumbPath; 01828 if (!pInfo->pItem->GetThumbFileName(&thumbPath)) 01829 { 01830 ERROR3("Can't get thumbnail file name"); 01831 goto FAIL; 01832 } 01833 String_256 thumbNetPath = thumbPath; 01834 Library* pLibrary = pInfo->pItem->GetParentLibrary(); 01835 if (!pLibrary) 01836 { 01837 ERROR3("Illegal NULL pointer"); 01838 goto FAIL; 01839 } 01840 if (!pLibrary->IsWebLibrary()) 01841 goto FAIL; 01842 pLibrary->LocalPath2URL(&thumbNetPath); 01843 // Register the file for download 01844 DOWNLOADINFO downloadInfo; 01845 downloadInfo.strURL = thumbNetPath; 01846 downloadInfo.strLocalFile = thumbPath; 01847 downloadInfo.nFileType = TYPE_THUMBNAIL; 01848 downloadInfo.nPriority = AsynchDownload::PRIORITY_HIGH; 01849 downloadInfo.bHasProgressDlg = FALSE; 01850 downloadInfo.hwndNotifyWindow = 0; 01851 downloadInfo.lNotifyToken = 0; 01852 m_hDownload = InternetManager::RegisterDownload(&downloadInfo); 01853 if (!m_hDownload || m_hDownload == (DOWNLOAD_HANDLE) INVALID_HANDLE_VALUE) 01854 { 01855 InformWarning(_R(IDS_THUMBDOWNLOADFAILED), _R(IDS_OK)); 01856 if (pGallery = (LibraryGallery*) pInfo->pItem->GetParentGallery()) 01857 pGallery->bThumbDownloading = FALSE; // turn off thumb downloading so we don't flood the user with error messages 01858 goto FAIL; 01859 } 01860 pParam = pInfo; 01861 if (pGallery = (LibraryGallery*) pInfo->pItem->GetParentGallery()) 01862 pGallery->m_lstPendingThumbs.push_back(this); 01863 pInfo->pOp = this; 01864 pInfo->bSuccess = TRUE; 01865 InstanceCount[pParam->type]++; 01866 // thumb downloads occur in "bursts", so when a new burst begins we must reset the error and download counters 01867 // so that we don't get confused by previous errors 01868 if (InstanceCount[pParam->type] == 1) 01869 { 01870 ErrorCount[pParam->type] = 0; 01871 ThumbsDownloaded[pParam->type] = 0; 01872 pGallery->SelectionHasChanged(); 01873 } 01874 return; 01875 } 01876 FAIL: 01877 FailAndExecute(); 01878 End(); 01879 }
|
|
Ends the download operation, displaying the thumbnail if successful.
Reimplemented from Operation. Definition at line 1897 of file inetop.cpp. 01898 { 01899 // Abort the download if still pending - this can only happen if the item is being destroyed 01900 if (m_hDownload && InternetManager::GetDownloadState(m_hDownload) == AsynchDownload::STATE_PENDING) 01901 InternetManager::UnregisterDownload(m_hDownload); 01902 LibraryGallery* pGallery = (LibraryGallery*) pParam->pItem->GetParentGallery(); 01903 if (pGallery) 01904 { 01905 pGallery->m_lstPendingThumbs.remove(this); 01906 if (InstanceCount[pParam->type] == 1) 01907 pGallery->SelectionHasChanged(); 01908 } 01909 if (pParam && pParam->pItem) // tell the item that the thumb download is finished 01910 pParam->pItem->OnThumbDownloadComplete(); 01911 Operation::End(); 01912 }
|
|
Definition at line 2047 of file inetop.cpp. 02048 { 02049 if (m_lstFailedItems.empty()) 02050 return 0; 02051 std::list<SGLibDisplayItem*>::iterator listIterator = m_lstFailedItems.begin(); 02052 INT32 nListSize = m_lstFailedItems.size(); 02053 for (INT32 i = 0; i < nListSize; i++) 02054 if (pItem == *listIterator++) 02055 return DOWNLOAD_ERROR; 02056 return 0; 02057 }
|
|
Returns the OpState of the OpThumbDownload operation.
Definition at line 1769 of file inetop.cpp. 01770 { 01771 OpState OpSt; 01772 return(OpSt); 01773 }
|
|
Creates an OpDescriptor for an OpThumbDownload operation.
Reimplemented from SimpleCCObject. Definition at line 1743 of file inetop.cpp. 01744 { 01745 return RegisterOpDescriptor( 01746 0, // Tool ID 01747 _R(IDS_OPTHUMBDOWNLOAD), // String resource ID 01748 CC_RUNTIME_CLASS(OpThumbDownload), // Runtime class 01749 OPTOKEN_OPTHUMBDOWNLOAD, // Token string 01750 OpThumbDownload::GetState, // GetState function 01751 0, // Help ID 01752 0, // Bubble ID 01753 0, // Resource ID 01754 0 // Control ID 01755 ); 01756 }
|
|
Reimplemented from Operation. Definition at line 1964 of file inetop.cpp. 01965 { 01966 ERROR2IF(!pParam, FALSE, "Unexpected NULL pointer"); 01967 if (m_bIsSuspended) // if the Op is suspended we don't do anything 01968 return FALSE; 01969 switch (InternetManager::GetDownloadState(m_hDownload)) 01970 { 01971 case AsynchDownload::STATE_PENDING: 01972 { 01973 // check the percentage downloaded so far 01974 INT32 nPercentageCompleted = InternetManager::GetPercentageDownloaded(m_hDownload); 01975 ERROR3IF(nPercentageCompleted == -1, "Invalid download handle"); 01976 if (nPercentageCompleted != m_nPercentageCompleted) // we made some progress 01977 { 01978 m_nPercentageCompleted = nPercentageCompleted; 01979 if (pParam && pParam->pItem) // tell the item to update itself 01980 pParam->pItem->OnThumbDownloadProgress(nPercentageCompleted); 01981 } 01982 // the download is still pending, so we continue polling 01983 return TRUE; 01984 } 01985 case AsynchDownload::STATE_SUCCEEDED: 01986 { 01987 // We got lucky 01988 ThumbsDownloaded[pParam->type]++; 01989 SucceedAndDiscard(); 01990 goto END; 01991 } 01992 case AsynchDownload::STATE_FAILED: 01993 { 01994 ErrorCount[pParam->type]++; 01995 m_lstFailedItems.push_back(pParam->pItem); 01996 goto FAIL; 01997 } 01998 case AsynchDownload::STATE_ABORTED: 01999 { 02000 // user cancel 02001 goto FAIL; 02002 } 02003 default: 02004 ERROR3("Error or unrecognized state"); 02005 goto FAIL; 02006 } 02007 02008 FAIL: 02009 FailAndDiscard(); 02010 END: 02011 // Thumb downloads occur in "bursts", so we report errors only once per burst 02012 if (InstanceCount[pParam->type] == 1 && ErrorCount[pParam->type]) 02013 { 02014 String_256 strErrorMsg; 02015 if (ThumbsDownloaded[pParam->type]) // partial failure 02016 strErrorMsg.MakeMsg(_R(IDS_THUMBDOWNLOADPARTIALFAIL), (TCHAR*) (String_256) GetStringField((UINT32) pParam->type, _R(IDS_GETX_CAPTIONS))); 02017 else // complete failure... 02018 strErrorMsg.MakeMsg(_R(IDS_THUMBDOWNLOADFAILED), (TCHAR*) (String_256) GetStringField((UINT32) pParam->type, _R(IDS_GETX_CAPTIONS))); 02019 02020 // As something went wrong (most likely a connection problem) suspend thumb downloading. This means the 02021 // user can scroll this gallery without more such error popups. Fixes,with LibraryGallery change, #10471 02022 pGallery->bThumbDownloading = FALSE; 02023 02024 Error::SetError(0, strErrorMsg, 0); 02025 InformError(); 02026 } 02027 End(); 02028 return FALSE; 02029 }
|
|
Definition at line 372 of file inetop.h. 00372 {m_bIsSuspended = FALSE; InternetManager::Resume();}
|
|
Definition at line 371 of file inetop.h. 00371 {m_bIsSuspended = TRUE; InternetManager::Suspend();}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|