void CFileDetailDialogInfo::RefreshData() { CString str; if (m_paFiles->GetSize() == 1) { CPartFile* file = STATIC_DOWNCAST(CPartFile, (*m_paFiles)[0]); // if file is completed, we output the 'file path' and not the 'part.met file path' if (file->GetStatus(true) == PS_COMPLETE) GetDlgItem(IDC_FD_X2)->SetWindowText(GetResString(IDS_DL_FILENAME)); SetDlgItemText(IDC_FNAME, file->GetFileName()); SetDlgItemText(IDC_METFILE, file->GetFullName()); SetDlgItemText(IDC_FHASH, md4str(file->GetFileHash())); if (file->GetTransferringSrcCount() > 0) str.Format(GetResString(IDS_PARTINFOS2), file->GetTransferringSrcCount()); else str = file->getPartfileStatus(); SetDlgItemText(IDC_PFSTATUS, str); str.Format(_T("%u; %s: %u (%.1f%%)"), file->GetPartCount(), GetResString(IDS_AVAILABLE) , file->GetAvailablePartCount(), (float)((file->GetAvailablePartCount()*100)/file->GetPartCount())); SetDlgItemText(IDC_PARTCOUNT, str); // date created if (file->GetCrFileDate() != 0) { str.Format(_T("%s ") + GetResString(IDS_TIMEBEFORE), file->GetCrCFileDate().Format(thePrefs.GetDateTimeFormat()), CastSecondsToLngHM(time(NULL) - file->GetCrFileDate())); } else str = GetResString(IDS_UNKNOWN); SetDlgItemText(IDC_FILECREATED, str); // active download time time_t nDlActiveTime = file->GetDlActiveTime(); //vs2005 if (nDlActiveTime) str = CastSecondsToLngHM(nDlActiveTime); else str = GetResString(IDS_UNKNOWN); SetDlgItemText(IDC_DL_ACTIVE_TIME, str); // last seen complete struct tm tmTemp; struct tm* ptimLastSeenComplete = file->lastseencomplete.GetLocalTm(&tmTemp); if (file->lastseencomplete == NULL || ptimLastSeenComplete == NULL) str.Format(GetResString(IDS_NEVER)); else { str.Format(_T("%s ") + GetResString(IDS_TIMEBEFORE), file->lastseencomplete.Format(thePrefs.GetDateTimeFormat()), CastSecondsToLngHM(time(NULL) - safe_mktime(ptimLastSeenComplete))); } SetDlgItemText(IDC_LASTSEENCOMPL, str); // last receive if (file->GetFileDate() != 0 && file->GetRealFileSize() > (uint64)0) { // 'Last Modified' sometimes is up to 2 seconds greater than the current time ??? // If it's related to the FAT32 seconds time resolution the max. failure should still be only 1 sec. // Happens at least on FAT32 with very high download speed. uint32 tLastModified = file->GetFileDate(); time_t tNow = time(NULL); //vs2005 uint32 tAgo; if (tNow >= tLastModified) tAgo = tNow - tLastModified; else{ TRACE("tNow = %s\n", CTime(tNow).Format("%X")); TRACE("tLMd = %s, +%u\n", CTime(tLastModified).Format("%X"), tLastModified - tNow); TRACE("\n"); tAgo = 0; } str.Format(_T("%s ") + GetResString(IDS_TIMEBEFORE), file->GetCFileDate().Format(thePrefs.GetDateTimeFormat()), CastSecondsToLngHM(tAgo)); } else str = GetResString(IDS_NEVER); SetDlgItemText(IDC_LASTRECEIVED, str); // AICH Hash switch (file->GetAICHRecoveryHashSet()->GetStatus()) { case AICH_TRUSTED: case AICH_VERIFIED: case AICH_HASHSETCOMPLETE: if (file->GetAICHRecoveryHashSet()->HasValidMasterHash()) { SetDlgItemText(IDC_FD_AICHHASH, file->GetAICHRecoveryHashSet()->GetMasterHash().GetString()); break; } default: SetDlgItemText(IDC_FD_AICHHASH, GetResString(IDS_UNKNOWN)); } // file type CString ext; bool showwarning = false; int pos = file->GetFileName().ReverseFind(_T('.')); if (file->GetFileName().ReverseFind(_T('\\')) < pos) { ext = file->GetFileName().Mid(pos + 1); ext.MakeUpper(); } EFileType bycontent = GetFileTypeEx((CKnownFile *)file, false, true); if (bycontent != FILETYPE_UNKNOWN) { str = GetFileTypeName(bycontent) + _T(" ("); str.Append(GetResString(IDS_VERIFIED) + _T(')')); int extLevel = IsExtensionTypeOf(bycontent, ext); if (extLevel == -1) { showwarning = true; str.Append(_T(" - ")); str.Append(GetResString(IDS_INVALIDFILEEXT) + _T(": ")); str.Append(ext); } else if (extLevel == 0) { str.Append(_T(" - ")); str.Append(GetResString(IDS_UNKNOWNFILEEXT) + _T(": ")); str.Append(ext); } } else { // not verified if (pos != -1) { str =file->GetFileName().Mid(pos + 1); str.MakeUpper(); str.Append(_T(" (") ); str.Append( GetResString(IDS_UNVERIFIED) + _T(')')); } else str = GetResString(IDS_UNKNOWN); } m_bShowFileTypeWarning = showwarning; SetDlgItemText(IDC_FD_X11,str); } else { SetDlgItemText(IDC_FNAME, sm_pszNotAvail); SetDlgItemText(IDC_METFILE, sm_pszNotAvail); SetDlgItemText(IDC_FHASH, sm_pszNotAvail); SetDlgItemText(IDC_PFSTATUS, sm_pszNotAvail); SetDlgItemText(IDC_PARTCOUNT, sm_pszNotAvail); SetDlgItemText(IDC_FD_X11, sm_pszNotAvail); SetDlgItemText(IDC_FILECREATED, sm_pszNotAvail); SetDlgItemText(IDC_DL_ACTIVE_TIME, sm_pszNotAvail); SetDlgItemText(IDC_LASTSEENCOMPL, sm_pszNotAvail); SetDlgItemText(IDC_LASTRECEIVED, sm_pszNotAvail); SetDlgItemText(IDC_FD_AICHHASH, sm_pszNotAvail); } uint64 uFileSize = 0; uint64 uRealFileSize = 0; uint64 uTransferred = 0; uint64 uCorrupted = 0; uint32 uRecoveredParts = 0; uint64 uCompression = 0; uint64 uCompleted = 0; int iMD4HashsetAvailable = 0; int iAICHHashsetAvailable = 0; uint32 uDataRate = 0; UINT uSources = 0; UINT uValidSources = 0; UINT uNNPSources = 0; UINT uA4AFSources = 0; for (int i = 0; i < m_paFiles->GetSize(); i++) { CPartFile* file = STATIC_DOWNCAST(CPartFile, (*m_paFiles)[i]); uFileSize += (uint64)file->GetFileSize(); uRealFileSize += (uint64)file->GetRealFileSize(); uTransferred += (uint64)file->GetTransferred(); uCorrupted += file->GetCorruptionLoss(); uRecoveredParts += file->GetRecoveredPartsByICH(); uCompression += file->GetCompressionGain(); uDataRate += file->GetDatarate(); uCompleted += (uint64)file->GetCompletedSize(); iMD4HashsetAvailable += (file->GetFileIdentifier().HasExpectedMD4HashCount()) ? 1 : 0; iAICHHashsetAvailable += (file->GetFileIdentifier().HasExpectedAICHHashCount()) ? 1 : 0; if (file->IsPartFile()) { uSources += file->GetSourceCount(); uValidSources += file->GetValidSourcesCount(); uNNPSources += file->GetSrcStatisticsValue(DS_NONEEDEDPARTS); uA4AFSources += file->GetSrcA4AFCount(); } } str.Format(_T("%s (%s %s); %s %s"), CastItoXBytes(uFileSize, false, false), GetFormatedUInt64(uFileSize), GetResString(IDS_BYTES), GetResString(IDS_ONDISK), CastItoXBytes(uRealFileSize, false, false)); SetDlgItemText(IDC_FSIZE, str); if (m_paFiles->GetSize() == 1) { if (iAICHHashsetAvailable == 0 && iMD4HashsetAvailable == 0) SetDlgItemText(IDC_HASHSET, GetResString(IDS_NO)); else if (iAICHHashsetAvailable == 1 && iMD4HashsetAvailable == 1) SetDlgItemText(IDC_HASHSET, GetResString(IDS_YES) + _T(" (eD2K + AICH)")); else if (iAICHHashsetAvailable == 1) SetDlgItemText(IDC_HASHSET, GetResString(IDS_YES) + _T(" (AICH)")); else if (iMD4HashsetAvailable == 1) SetDlgItemText(IDC_HASHSET, GetResString(IDS_YES) + _T(" (eD2K)")); } else { if (iAICHHashsetAvailable == 0 && iMD4HashsetAvailable == 0) SetDlgItemText(IDC_HASHSET, GetResString(IDS_NO)); else if (iMD4HashsetAvailable == m_paFiles->GetSize() && iAICHHashsetAvailable == m_paFiles->GetSize()) SetDlgItemText(IDC_HASHSET, GetResString(IDS_YES) + + _T(" (eD2K + AICH)")); else SetDlgItemText(IDC_HASHSET, _T("")); } str.Format(GetResString(IDS_SOURCESINFO), uSources, uValidSources, uNNPSources, uA4AFSources); SetDlgItemText(IDC_SOURCECOUNT, str); SetDlgItemText(IDC_DATARATE, CastItoXBytes(uDataRate, false, true)); SetDlgItemText(IDC_TRANSFERRED, CastItoXBytes(uTransferred, false, false)); str.Format(_T("%s (%.1f%%)"), CastItoXBytes(uCompleted, false, false), uFileSize!=0 ? (uCompleted * 100.0 / uFileSize) : 0.0); SetDlgItemText(IDC_COMPLSIZE, str); str.Format(_T("%s (%.1f%%)"), CastItoXBytes(uCorrupted, false, false), uTransferred!=0 ? (uCorrupted * 100.0 / uTransferred) : 0.0); SetDlgItemText(IDC_CORRUPTED, str); str.Format(_T("%s (%.1f%%)"), CastItoXBytes(uFileSize - uCompleted, false, false), uFileSize!=0 ? ((uFileSize - uCompleted) * 100.0 / uFileSize) : 0.0); SetDlgItemText(IDC_REMAINING, str); str.Format(_T("%u %s"), uRecoveredParts, GetResString(IDS_FD_PARTS)); SetDlgItemText(IDC_RECOVERED, str); str.Format(_T("%s (%.1f%%)"), CastItoXBytes(uCompression, false, false), uTransferred!=0 ? (uCompression * 100.0 / uTransferred) : 0.0); SetDlgItemText(IDC_COMPRESSION, str); }
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(...) { } }