void CDownloadDetailDlg::SetPartFileInfo(CKnownFile *file) { if(! file) return ; CPartFile *pPartFile = NULL; if ( file->IsKindOf(RUNTIME_CLASS(CPartFile)) ) pPartFile = (CPartFile*) file; SetDlgItemText(IDC_STATIC_FILENAME, file->GetFilePath()); CString strTmp; time_t restTime; if ( NULL != pPartFile ) { if (!thePrefs.UseSimpleTimeRemainingComputation()) restTime = pPartFile->getTimeRemaining(); else restTime = pPartFile->getTimeRemainingSimple(); strTmp.Format(_T("%s (%s)"), CastSecondsToHM(restTime), CastItoXBytes((pPartFile->GetFileSize() - pPartFile->GetCompletedSize()), false, false)); SetDlgItemText(IDC_STATIC_LAST_SEEN_TIME, strTmp); } }
void CDetailInfo::UpdateInfo(CPartFile* pFile, DWORD dwMask) { try { m_ListDetail.DeleteAllItems(); if (NULL == pFile || 0 == dwMask) return; m_pCurFile = pFile; m_dwCurMask = dwMask; int iItem; CString str; CPartFile *lpPartFile = pFile;//DYNAMIC_DOWNCAST(CPartFile, pFile); iItem = 0; if (IM_FILENAME & dwMask) { str = pFile->GetFileName(); m_ListDetail.InsertItem(iItem, GetResString(IDS_DL_FILENAME)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if (IM_FILESIZE & dwMask) { str = CastItoXBytes(pFile->GetFileSize(), false, false); m_ListDetail.InsertItem(iItem, GetResString(IDS_DL_SIZE)); if(!str.IsEmpty()) m_ListDetail.SetItemText(iItem, 1, str); else m_ListDetail.SetItemText(iItem, 1, GetResString(IDS_UNKNOWN)); iItem++; } if (IM_FILETYPE & dwMask) { str = pFile->GetFileTypeDisplayStr(); m_ListDetail.InsertItem(iItem, GetResString(IDS_TYPE)); if(!str.IsEmpty()) m_ListDetail.SetItemText(iItem, 1, str); else m_ListDetail.SetItemText(iItem, 1, GetResString(IDS_UNKNOWN)); iItem++; } if (IM_LINK & dwMask) { str = GetLink(pFile); bool bRefer = false; if(str.Left(7).CompareNoCase(_T("http://")) == 0) { if(str.Find(_T('<'))>0) { bRefer = true; str = str.Left(str.Find(_T('<'))); } if(str.Find(_T('#'))>0) str = str.Left(str.Find(_T('#'))); } if(!str.IsEmpty()) { m_ListDetail.InsertItem(iItem, GetResString(IDS_DOWNLOAD_LINK)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if(bRefer) { CString refer = GetLink(pFile); refer = refer.Right(refer.GetLength() - 1 - refer.Find(_T('='))); if(refer.Find(_T('>')) > 0) refer.Remove(_T('>')); m_ListDetail.InsertItem(iItem,GetResString(IDS_REFER_LINK)); m_ListDetail.SetItemText(iItem,1,refer); iItem++; } } if (IM_SOURCEURL & dwMask) { str = pFile->GetPartFileURL(); bool bRefer = false; if(str.Find(_T('<'))>0) { bRefer = true; str = str.Left(str.Find(_T('<'))); } if(str.Find(_T('#'))>0) str = str.Left(str.Find(_T('#'))); if(!str.IsEmpty()) { m_ListDetail.InsertItem(iItem, GetResString(IDS_URL_LINK)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if(bRefer) { CString strRefer = pFile->GetPartFileURL(); strRefer = strRefer.Right(strRefer.GetLength() -1 - strRefer.Find(_T('=') )); if(strRefer.Find(_T('>'))>0) strRefer.Remove(_T('>')); m_ListDetail.InsertItem(iItem,GetResString(IDS_REFER_LINK)); m_ListDetail.SetItemText(iItem,1,strRefer); iItem++; } } if (IM_PRIORITY & dwMask) { if(dwMask == CDetailInfo::IM_COMBINE_DOWNLOAD) str = PriorityToString(pFile->GetDownPriority(), pFile->IsAutoDownPriority()); if(dwMask == CDetailInfo::IM_COMBINE_SHARE) str = PriorityToString(pFile->GetUpPriority(),pFile->IsAutoUpPriority()); m_ListDetail.InsertItem(iItem, GetResString(IDS_PRIORITY)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if (IM_FILEHASH & dwMask) { if (pFile->HasNullHash()) { str = _T("-"); } else { str = md4str(pFile->GetFileHash()); } m_ListDetail.InsertItem(iItem, GetResString(IDS_FILEID)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if (IM_REQUEST & dwMask) { str.Format(_T("%u (%u)"), pFile->statistic.GetRequests(), pFile->statistic.GetAllTimeRequests()); m_ListDetail.InsertItem(iItem, GetResString(IDS_SF_REQUESTS)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if (IM_TRANSFERED & dwMask) { str.Format(_T("%s (%s)"), CastItoXBytes(pFile->statistic.GetTransferred(), false, false), CastItoXBytes(pFile->statistic.GetAllTimeTransferred(), false, false)); m_ListDetail.InsertItem(iItem, GetResString(IDS_SF_TRANSFERRED)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if (IM_FILEPATH & dwMask) { str = pFile->GetPath(); PathRemoveBackslash(str.GetBuffer()); str.ReleaseBuffer(); m_ListDetail.InsertItem(iItem, GetResString(IDS_FOLDER)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if (IM_ACCEPT & dwMask) { str.Format(_T("%u (%u)"), pFile->statistic.GetAccepts(), pFile->statistic.GetAllTimeAccepts()); m_ListDetail.InsertItem(iItem, GetResString(IDS_SF_ACCEPTS)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if (IM_SOURCE & dwMask) { str.Format(_T("%u - %u"), pFile->m_nCompleteSourcesCountLo, pFile->m_nCompleteSourcesCountHi); m_ListDetail.InsertItem(iItem, GetResString(IDS_COMPLSOURCES)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } if (IM_REMAIN & dwMask) { if (NULL != lpPartFile) { str.Empty(); if (lpPartFile->GetStatus() != PS_COMPLETING && lpPartFile->GetStatus() != PS_COMPLETE ) { // time time_t restTime; if (!thePrefs.UseSimpleTimeRemainingComputation()) restTime = lpPartFile->getTimeRemaining(); else restTime = lpPartFile->getTimeRemainingSimple(); str.Format(_T("%s (%s)"), CastSecondsToHM(restTime), CastItoXBytes((lpPartFile->GetFileSize() - lpPartFile->GetCompletedSize()), false, false)); } else { str.Format(_T("%s (%s)"), _T("0"), CastItoXBytes((lpPartFile->GetFileSize() - lpPartFile->GetCompletedSize()), false, false)); } m_ListDetail.InsertItem(iItem, GetResString(IDS_DL_REMAINS)); if(!str.IsEmpty()) m_ListDetail.SetItemText(iItem, 1, str); else m_ListDetail.SetItemText(iItem,1,GetResString(IDS_UNKNOWN)); iItem++; } } if (IM_LASTCOMPLETE & dwMask) { if (NULL != lpPartFile) { // CString tempbuffer; // if (lpPartFile->m_nCompleteSourcesCountLo == 0) // { // tempbuffer.Format(_T("< %u"), lpPartFile->m_nCompleteSourcesCountHi); // } // else if (lpPartFile->m_nCompleteSourcesCountLo == lpPartFile->m_nCompleteSourcesCountHi) // { // tempbuffer.Format(_T("%u"), lpPartFile->m_nCompleteSourcesCountLo); // } // else // { // tempbuffer.Format(_T("%u - %u"), lpPartFile->m_nCompleteSourcesCountLo, lpPartFile->m_nCompleteSourcesCountHi); // } if (lpPartFile->lastseencomplete==NULL) str.Format(_T("%s" /*(%s)*/),GetResString(IDS_NEVER)/*,tempbuffer*/); else str.Format(_T("%s" /*(%s)*/),lpPartFile->lastseencomplete.Format( thePrefs.GetDateTimeFormat())/*,tempbuffer*/); m_ListDetail.InsertItem(iItem, GetResString(IDS_LASTSEENCOMPL)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } } if (IM_LASTRECV & dwMask) { if (NULL != lpPartFile) { if(lpPartFile->GetFileDate()!=NULL && lpPartFile->GetRealFileSize()/*GetCompletedSize() */> (uint64)0) str = lpPartFile->GetCFileDate().Format( thePrefs.GetDateTimeFormat()); else str.Format(_T("%s"),GetResString(IDS_NEVER)); m_ListDetail.InsertItem(iItem, GetResString(IDS_FD_LASTCHANGE)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } } if (IM_CATEGORY & dwMask) { if (NULL != lpPartFile) { str = (lpPartFile->GetCategory()!=0) ? thePrefs.GetCategory(lpPartFile->GetCategory())->strTitle:_T(""); m_ListDetail.InsertItem(iItem, GetResString(IDS_CAT)); m_ListDetail.SetItemText(iItem, 1, str); iItem++; } } } catch(...) { } }