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 CHttpDownloadDlg::SetTimeLeft(DWORD dwSecondsLeft, DWORD dwBytesRead, DWORD dwFileSize) { CString strTimeLeft; strTimeLeft.Format( GetResString(IDS_HTTPDOWNLOAD_TIMELEFT), CastSecondsToHM(dwSecondsLeft), CastItoXBytes(dwBytesRead), CastItoXBytes(dwFileSize) ); m_ctrlTimeLeft.SetWindowText(strTimeLeft); }
void CHttpDownloadDlg::SetTimeLeft(DWORD dwSecondsLeft, DWORD dwBytesRead, DWORD dwFileSize) { CString sOf; sOf.Format(GetResString(IDS_HTTPDOWNLOAD_OF), CastItoXBytes((uint64)dwBytesRead, false, false), CastItoXBytes((uint64)dwFileSize, false, false)); CString sTimeLeft; sTimeLeft.Format(GetResString(IDS_HTTPDOWNLOAD_TIMELEFT), CastSecondsToHM(dwSecondsLeft), sOf); m_ctrlTimeLeft.SetWindowText(sTimeLeft); }
void CFileDetailDialog::UpdateData() { wxString bufferS; CastChild(IDC_FNAME,wxStaticText)->SetLabel(MakeStringEscaped( TruncateFilename(m_file->GetFileName(),60))); CastChild(IDC_METFILE,wxStaticText)->SetLabel(MakeStringEscaped( TruncateFilename(m_file->GetFullName(),60,true))); wxString tmp = CastChild(IDC_FILENAME, wxTextCtrl)->GetValue(); if (tmp.Length() < 3) { resetValueForFilenameTextEdit(); } CastChild(IDC_FHASH,wxStaticText)->SetLabel(m_file->GetFileHash().Encode()); bufferS = wxString::Format(wxT("%llu bytes ("), m_file->GetFileSize()) + CastItoXBytes(m_file->GetFileSize()) + wxT(")"); CastChild(IDC_FSIZE,wxControl)->SetLabel(bufferS); CastChild(IDC_PFSTATUS,wxControl)->SetLabel(m_file->getPartfileStatus()); bufferS = wxString::Format(wxT("%i (%i)"),m_file->GetPartCount(),m_file->GetHashCount()); CastChild(IDC_PARTCOUNT,wxControl)->SetLabel(bufferS); CastChild(IDC_TRANSFERRED,wxControl)->SetLabel(CastItoXBytes(m_file->GetTransferred())); CastChild(IDC_FD_STATS1,wxControl)->SetLabel(CastItoXBytes(m_file->GetLostDueToCorruption())); CastChild(IDC_FD_STATS2,wxControl)->SetLabel(CastItoXBytes(m_file->GetGainDueToCompression())); CastChild(IDC_FD_STATS3,wxControl)->SetLabel(CastItoIShort(m_file->TotalPacketsSavedDueToICH())); CastChild(IDC_COMPLSIZE,wxControl)->SetLabel(CastItoXBytes(m_file->GetCompletedSize())); bufferS = wxString::Format(_("%.2f%% done"),m_file->GetPercentCompleted()); CastChild(IDC_PROCCOMPL,wxControl)->SetLabel(bufferS); bufferS = wxString::Format(_("%.2f kB/s"),(float)m_file->GetKBpsDown()); CastChild(IDC_DATARATE,wxControl)->SetLabel(bufferS); bufferS = wxString::Format(wxT("%i"),m_file->GetSourceCount()); CastChild(IDC_SOURCECOUNT,wxControl)->SetLabel(bufferS); bufferS = wxString::Format(wxT("%i"),m_file->GetTransferingSrcCount()); CastChild(IDC_SOURCECOUNT2,wxControl)->SetLabel(bufferS); bufferS = wxString::Format(wxT("%i (%.1f%%)"), m_file->GetAvailablePartCount(), ((m_file->GetAvailablePartCount() * 100.0f)/ m_file->GetPartCount())); CastChild(IDC_PARTAVAILABLE,wxControl)->SetLabel(bufferS); bufferS = CastSecondsToHM(m_file->GetDlActiveTime()); CastChild(IDC_DLACTIVETIME, wxControl)->SetLabel(bufferS); if (m_file->lastseencomplete==0) { bufferS = wxString(_("Unknown")).MakeLower(); } else { wxDateTime last_seen(m_file->lastseencomplete); bufferS = last_seen.FormatISODate() + wxT(" ") + last_seen.FormatISOTime(); } CastChild(IDC_LASTSEENCOMPL,wxControl)->SetLabel(bufferS); setEnableForApplyButton(); // disable "Show all comments" button if there are no comments FileRatingList list; m_file->GetRatingAndComments(list); CastChild(IDC_CMTBT, wxControl)->Enable(!list.empty()); FillSourcenameList(); Layout(); }
void FormatValue(CFormat& format, const CECTag* tag) { wxASSERT(tag->GetTagName() == EC_TAG_STAT_NODE_VALUE); wxString extra; const CECTag *tmp_tag = tag->GetTagByName(EC_TAG_STAT_NODE_VALUE); if (tmp_tag) { wxString tmp_fmt; const CECTag* tmp_vt = tmp_tag->GetTagByName(EC_TAG_STAT_VALUE_TYPE); EC_STATTREE_NODE_VALUE_TYPE tmp_valueType = tmp_vt != NULL ? (EC_STATTREE_NODE_VALUE_TYPE)tmp_vt->GetInt() : EC_VALUE_INTEGER; switch (tmp_valueType) { case EC_VALUE_INTEGER: tmp_fmt = wxT("%llu"); break; case EC_VALUE_DOUBLE: tmp_fmt = wxT("%.2f%%"); // it's used for percentages break; default: tmp_fmt = wxT("%s"); } CFormat tmp_format(wxT(" (") + tmp_fmt + wxT(")")); FormatValue(tmp_format, tmp_tag); extra = tmp_format.GetString(); } const CECTag* vt = tag->GetTagByName(EC_TAG_STAT_VALUE_TYPE); EC_STATTREE_NODE_VALUE_TYPE valueType = vt != NULL ? (EC_STATTREE_NODE_VALUE_TYPE)vt->GetInt() : EC_VALUE_INTEGER; switch (valueType) { case EC_VALUE_INTEGER: format = format % tag->GetInt(); break; case EC_VALUE_ISTRING: format = format % (CFormat(wxT("%u")) % tag->GetInt() + extra); break; case EC_VALUE_BYTES: format = format % (CastItoXBytes(tag->GetInt()) + extra); break; case EC_VALUE_ISHORT: format = format % (CastItoIShort(tag->GetInt()) + extra); break; case EC_VALUE_TIME: format = format % (CastSecondsToHM(tag->GetInt()) + extra); break; case EC_VALUE_SPEED: format = format % (CastItoSpeed(tag->GetInt()) + extra); break; case EC_VALUE_STRING: format = format % (wxGetTranslation(tag->GetStringData()) + extra); break; case EC_VALUE_DOUBLE: format = format % tag->GetDoubleData(); break; default: wxFAIL; } }
CString CStatisticFile::GetEqualChanceValueString(bool detail) const { CString tempString; if(thePrefs.IsEqualChanceEnable()) { if(m_dLastEqualChanceBiasValue != 1){ detail ? tempString.Format(_T("%s : %.2f*%.2f = %s/%s"), CastSecondsToHM(GetSessionShareTime()), m_dLastEqualChanceSemiValue, m_dLastEqualChanceBiasValue, CastItoXBytes(GetTransferred()), CastItoXBytes(fileParent->GetFileSize())) : tempString.Format(_T("%s : %.2f*%.2f"), CastSecondsToHM(GetSessionShareTime()), m_dLastEqualChanceSemiValue, m_dLastEqualChanceBiasValue) ; } else{ detail ? tempString.Format(_T("%s : %.2f = %s/%s"), CastSecondsToHM(GetSessionShareTime()), m_dLastEqualChanceSemiValue, CastItoXBytes(GetTransferred()), CastItoXBytes(fileParent->GetFileSize())) : tempString.Format(_T("%s : %.2f"), CastSecondsToHM(GetSessionShareTime()), m_dLastEqualChanceSemiValue) ; } } else{ tempString.Empty(); } return tempString; }
wxString CStatTreeItemSimple::GetDisplayString() const { switch (m_valuetype) { case vtInteger: switch (m_displaymode) { case dmTime: return CFormat(wxGetTranslation(m_label)) % CastSecondsToHM(m_intvalue); case dmBytes: return CFormat(wxGetTranslation(m_label)) % CastItoXBytes(m_intvalue); default: return CFormat(wxGetTranslation(m_label)) % m_intvalue; } case vtFloat: return CFormat(wxGetTranslation(m_label)) % m_floatvalue; case vtString: return CFormat(wxGetTranslation(m_label)) % m_stringvalue; default: return wxGetTranslation(m_label); } }
wxString CStatTreeItemAverage::GetDisplayString() const { if ((*m_divisor) != 0) { switch (m_displaymode) { case dmBytes: return CFormat(wxGetTranslation(m_label)) % CastItoXBytes((*m_dividend)/(*m_divisor)); case dmTime: return CFormat(wxGetTranslation(m_label)) % CastSecondsToHM((*m_dividend)/(*m_divisor)); default: return CFormat(wxGetTranslation(m_label)) % (CFormat(wxT("%u")) % ((uint64)(*m_dividend)/(*m_divisor))).GetString(); } } else { return CFormat(wxGetTranslation(m_label)) % wxT("-"); } }
wxString CStatTreeItemTimer::GetDisplayString() const { return CFormat(wxGetTranslation(m_label)) % CastSecondsToHM(m_value ? GetTimerSeconds() : 0); }
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if( !theApp.emuledlg->IsRunning() ) return; if (!lpDrawItemStruct->itemData) return; CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC); BOOL bCtrlFocused = ((GetFocus() == this ) || (GetStyle() & LVS_SHOWSELALWAYS)); if (lpDrawItemStruct->itemState & ODS_SELECTED) { if(bCtrlFocused) odc->SetBkColor(m_crHighlight); else odc->SetBkColor(m_crNoHighlight); } else odc->SetBkColor(GetBkColor()); const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; CMemDC dc(odc, &lpDrawItemStruct->rcItem); CFont* pOldFont = dc.SelectObject(GetFont()); CRect cur_rec(lpDrawItemStruct->rcItem); COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText); int iOldBkMode; if (m_crWindowTextBk == CLR_NONE) { DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; CString Sbuffer; for(int iCurrent = 0; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if( !IsColumnHidden(iColumn) ) { cur_rec.right += GetColumnWidth(iColumn); switch(iColumn) { case 0: { uint8 image; if (client->IsFriend()) image = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID) { //==> Xman CreditSystem [shadow2004] if (client->credits->GetScoreRatio(client/*->GetIP()*/) > 1) image = 8; else image = 7; } else if (client->GetClientSoft() == SO_MLDONKEY) { if (client->credits->GetScoreRatio(client/*->GetIP()*/) > 1) image = 6; else image = 5; } else if (client->GetClientSoft() == SO_SHAREAZA) { if(client->credits->GetScoreRatio(client/*->GetIP()*/) > 1) image = 10; else image = 9; } else if (client->GetClientSoft() == SO_AMULE) { if(client->credits->GetScoreRatio(client/*->GetIP()*/) > 1) image = 12; else image = 11; } else if (client->GetClientSoft() == SO_LPHANT) { if(client->credits->GetScoreRatio(client/*->GetIP()*/) > 1) image = 14; else image = 13; } else if (client->ExtProtocolAvailable()) { if(client->credits->GetScoreRatio(client/*->GetIP()*/) > 1) //==>Modversion [shadow2004] #ifdef MODVERSION image = (client->IsNextEMF())?16:3; #else //Modversion image = 3; #endif //Modversion //<==Modversion [shadow2004] else //==>Modversion [shadow2004] #ifdef MODVERSION image = (client->IsNextEMF())?16:1; #else //Modversion image = 1; #endif //Modversion //<==Modversion [shadow2004] } else { if (client->credits->GetScoreRatio(client/*->GetIP()*/) > 1) //==> Xman CreditSystem [shadow2004] image = 2; else image = 0; } POINT point = {cur_rec.left, cur_rec.top+1}; imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0)); Sbuffer = client->GetUserName(); cur_rec.left +=20; dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left -=20; break; } case 1: if(file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); break; case 2: if(file) { switch (file->GetUpPriority()) { case PR_VERYLOW : { Sbuffer = GetResString(IDS_PRIOVERYLOW); break; } case PR_LOW : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOLOW); else Sbuffer = GetResString(IDS_PRIOLOW); break; } case PR_NORMAL : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTONORMAL); else Sbuffer = GetResString(IDS_PRIONORMAL); break; } case PR_HIGH : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOHIGH); else Sbuffer = GetResString(IDS_PRIOHIGH); break; } case PR_VERYHIGH : { Sbuffer = GetResString(IDS_PRIORELEASE); break; } default: Sbuffer.Empty(); } } else Sbuffer = _T("?"); break; case 3: Sbuffer.Format(_T("%i"),client->GetScore(false,false,true)); break; case 4: if (client->HasLowID()) { if (client->m_bAddNextConnect) Sbuffer.Format(_T("%i ****"),client->GetScore(false)); else Sbuffer.Format(_T("%i LowID"),client->GetScore(false)); } else Sbuffer.Format(_T("%i"),client->GetScore(false)); break; case 5: Sbuffer.Format(_T("%i"),client->GetAskedCount()); break; case 6: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetLastUpRequest())/1000); break; case 7: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetWaitStartTime())/1000); break; case 8: if(client->IsBanned()) Sbuffer = GetResString(IDS_YES); else Sbuffer = GetResString(IDS_NO); break; case 9: if( client->GetUpPartCount()) { cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc,&cur_rec,false); cur_rec.bottom++; cur_rec.top--; } break; //==>Modversion [shadow2004] #ifdef MODVERSION case 10: Sbuffer = client->GetClientSoftVer(); break; #endif //Modversion //<==Modversion [shadow2004] }
void CQueueListCtrl::GetItemDisplayText(const CUpDownClient *client, int iSubItem, LPTSTR pszText, int cchTextMax) { if (pszText == NULL || cchTextMax <= 0) { ASSERT(0); return; } pszText[0] = _T('\0'); switch (iSubItem) { case 0: if (client->GetUserName() == NULL) _sntprintf(pszText, cchTextMax, _T("(%s)"), GetResString(IDS_UNKNOWN)); else _tcsncpy(pszText, client->GetUserName(), cchTextMax); break; case 1: { const CKnownFile *file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); _tcsncpy(pszText, file != NULL ? file->GetFileName() : _T(""), cchTextMax); break; } case 2: { const CKnownFile *file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); if (file) { // ==> PowerShare [ZZ/MorphXT] - Stulle /* switch (file->GetUpPriority()) { case PR_VERYLOW: _tcsncpy(pszText, GetResString(IDS_PRIOVERYLOW), cchTextMax); break; case PR_LOW: if (file->IsAutoUpPriority()) _tcsncpy(pszText, GetResString(IDS_PRIOAUTOLOW), cchTextMax); else _tcsncpy(pszText, GetResString(IDS_PRIOLOW), cchTextMax); break; case PR_NORMAL: if (file->IsAutoUpPriority()) _tcsncpy(pszText, GetResString(IDS_PRIOAUTONORMAL), cchTextMax); else _tcsncpy(pszText, GetResString(IDS_PRIONORMAL), cchTextMax); break; case PR_HIGH: if (file->IsAutoUpPriority()) _tcsncpy(pszText, GetResString(IDS_PRIOAUTOHIGH), cchTextMax); else _tcsncpy(pszText, GetResString(IDS_PRIOHIGH), cchTextMax); break; case PR_VERYHIGH: _tcsncpy(pszText, GetResString(IDS_PRIORELEASE), cchTextMax); break; //Xman PowerRelease case PR_POWER: _tcsncpy(pszText, GetResString(IDS_POWERRELEASE), cchTextMax); break; //Xman end } */ CString Sbuffer; switch (file->GetUpPriority()) { case PR_VERYLOW : { Sbuffer = GetResString(IDS_PRIOVERYLOW); break; } case PR_LOW : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOLOW); else Sbuffer = GetResString(IDS_PRIOLOW); break; } case PR_NORMAL : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTONORMAL); else Sbuffer = GetResString(IDS_PRIONORMAL); break; } case PR_HIGH : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOHIGH); else Sbuffer = GetResString(IDS_PRIOHIGH); break; } case PR_VERYHIGH : { Sbuffer = GetResString(IDS_PRIORELEASE); break; } //Xman PowerRelease case PR_POWER: { Sbuffer = GetResString(IDS_POWERRELEASE); break; } //Xman end default: Sbuffer.Empty(); } if(client->GetPowerShared(file)) { CString tempString = GetResString(IDS_POWERSHARE_PREFIX); tempString.Append(_T(",")); tempString.Append(Sbuffer); Sbuffer.Empty(); Sbuffer = tempString; } // ==> Fair Play [AndCycle/Stulle] - Stulle if (!file->IsPartFile() && file->statistic.GetFairPlay()) { Sbuffer.Append(_T(",FairPlay")); } // <== Fair Play [AndCycle/Stulle] - Stulle _tcsncpy(pszText, Sbuffer, cchTextMax); // <== PowerShare [ZZ/MorphXT] - Stulle } break; } case 3: _sntprintf(pszText, cchTextMax, _T("%i"), client->GetScore(false, false, true)); break; case 4: // ==> Display reason for zero score [Stulle] - Stulle /* if (client->HasLowID()) { if (client->m_bAddNextConnect) _sntprintf(pszText, cchTextMax, _T("%i ****"),client->GetScore(false)); else _sntprintf(pszText, cchTextMax, _T("%i (%s)"),client->GetScore(false), GetResString(IDS_IDLOW)); } //Xman uploading problem client else if(client->isupprob && client->m_bAddNextConnect) { if(client->socket && client->socket->IsConnected()) _sntprintf(pszText, cchTextMax, _T("%i #~~"),client->GetScore(false)); else _sntprintf(pszText, cchTextMax, _T("%i ~~~"),client->GetScore(false)); } //Xman end else _sntprintf(pszText, cchTextMax, _T("%i"), client->GetScore(false)); */ { CString Sbuffer; uint32 uScore = client->GetScore(false); if (client->HasLowID()){ if (client->m_bAddNextConnect) Sbuffer.Format(_T("%i ****"),uScore); else Sbuffer.Format(_T("%i (%s)"),uScore, GetResString(IDS_IDLOW)); } //Xman uploading problem client else if(client->isupprob && client->m_bAddNextConnect) { if(client->socket && client->socket->IsConnected()) Sbuffer.Format(_T("%i #~~"),uScore); else Sbuffer.Format(_T("%i ~~~"),uScore); } //Xman end else Sbuffer.Format(_T("%i"),uScore); if(uScore == 0) Sbuffer.AppendFormat(_T(" (%s)"),client->GetZeroScoreString()); // ==> Pay Back First [AndCycle/SiRoB/Stulle] - Stulle if (client->IsPBFClient()) { CString tempStr; if (client->IsSecure()) tempStr.Format(_T("%s %s"), _T("PBF"), Sbuffer); else tempStr.Format(_T("%s %s"), _T("PBF II"), Sbuffer); Sbuffer = tempStr; } // <== Pay Back First [AndCycle/SiRoB/Stulle] - Stulle _tcsncpy(pszText, Sbuffer, cchTextMax); } // <== Display reason for zero score [Stulle] - Stulle break; case 5: _sntprintf(pszText, cchTextMax, _T("%i"), client->GetAskedCount()); break; case 6: _tcsncpy(pszText, CastSecondsToHM((GetTickCount() - client->GetLastUpRequest()) / 1000), cchTextMax); break; case 7: _tcsncpy(pszText, CastSecondsToHM((GetTickCount() - client->GetWaitStartTime()) / 1000), cchTextMax); break; case 8: //Xman Code Improvement /* _tcsncpy(pszText, GetResString(client->IsBanned() ? IDS_YES : IDS_NO), cchTextMax); */ _tcsncpy(pszText, GetResString(client->GetUploadState() == US_BANNED ? IDS_YES : IDS_NO), cchTextMax); //Xman end break; case 9: _tcsncpy(pszText, GetResString(IDS_UPSTATUS), cchTextMax); break; //Xman version see clientversion in every window case 10: _tcsncpy(pszText, client->DbgGetFullClientSoftVer(), cchTextMax); //Xman // Maella -Support for tag ET_MOD_VERSION 0x55 break; //Xman end //Xman show complete up/down in queuelist case 11: if(client->Credits() ) _sntprintf(pszText, cchTextMax, _T("%s/ %s"), CastItoXBytes(client->credits->GetUploadedTotal()), CastItoXBytes(client->credits->GetDownloadedTotal())); break; //Xman end // ==> push small files [sivka] - Stulle case 12: { if (client->GetSmallFilePush()) _tcsncpy(pszText, GetResString(IDS_YES), cchTextMax); else _tcsncpy(pszText, GetResString(IDS_NO), cchTextMax); break; } // <== push small files [sivka] - Stulle // ==> push rare file - Stulle case 13: { _sntprintf(pszText, cchTextMax, _T("%.1f"), client->GetRareFilePushRatio()); break; } // <== push rare file - Stulle } pszText[cchTextMax - 1] = _T('\0'); }
wxMenu* CMuleTrayIcon::CreatePopupMenu() { // Creates dinamically the menu to show the user. wxMenu *traymenu = new wxMenu(); traymenu->SetTitle(_("aMule Tray Menu")); // Build the Top string name wxString label = MOD_VERSION_LONG; traymenu->Append(TRAY_MENU_INFO, label); traymenu->AppendSeparator(); label = wxString(_("Speed limits:")) + wxT(" "); // Check for upload limits unsigned int max_upload = thePrefs::GetMaxUpload(); if ( max_upload == UNLIMITED ) { label += _("UL: None"); } else { label += CFormat(_("UL: %u")) % max_upload; } label += wxT(", "); // Check for download limits unsigned int max_download = thePrefs::GetMaxDownload(); if ( max_download == UNLIMITED ) { label += _("DL: None"); } else { label += CFormat(_("DL: %u")) % max_download; } traymenu->Append(TRAY_MENU_INFO, label); label = CFormat(_("Download speed: %.1f")) % (theStats::GetDownloadRate() / 1024.0); traymenu->Append(TRAY_MENU_INFO, label); label = CFormat(_("Upload speed: %.1f")) % (theStats::GetUploadRate() / 1024.0); traymenu->Append(TRAY_MENU_INFO, label); traymenu->AppendSeparator(); // Client Info wxMenu* ClientInfoMenu = new wxMenu(); ClientInfoMenu->SetTitle(_("Client Information")); // User nick-name { wxString temp = CFormat(_("Nickname: %s")) % ( thePrefs::GetUserNick().IsEmpty() ? wxString(_("No Nickname Selected!")) : thePrefs::GetUserNick() ); ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // Client ID { wxString temp = _("ClientID: "); if (theApp->IsConnectedED2K()) { temp += CFormat(wxT("%u")) % theApp->GetED2KID(); } else { temp += _("Not connected"); } ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // Current Server and Server IP { wxString temp_name = _("ServerName: "); wxString temp_ip = _("ServerIP: "); if ( theApp->serverconnect->GetCurrentServer() ) { temp_name += theApp->serverconnect->GetCurrentServer()->GetListName(); temp_ip += theApp->serverconnect->GetCurrentServer()->GetFullIP(); } else { temp_name += _("Not connected"); temp_ip += _("Not Connected"); } ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp_name); ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp_ip); } // IP Address { wxString temp = CFormat(_("IP: %s")) % ( (theApp->GetPublicIP()) ? Uint32toStringIP(theApp->GetPublicIP()) : wxString(_("Unknown")) ); ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // TCP PORT { wxString temp; if (thePrefs::GetPort()) { temp = CFormat(_("TCP port: %d")) % thePrefs::GetPort(); } else { temp=_("TCP port: Not ready"); } ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // UDP PORT { wxString temp; if (thePrefs::GetEffectiveUDPPort()) { temp = CFormat(_("UDP port: %d")) % thePrefs::GetEffectiveUDPPort(); } else { temp=_("UDP port: Not ready"); } ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // Online Signature { wxString temp; if (thePrefs::IsOnlineSignatureEnabled()) { temp=_("Online Signature: Enabled"); } else { temp=_("Online Signature: Disabled"); } ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // Uptime { wxString temp = CFormat(_("Uptime: %s")) % CastSecondsToHM(theStats::GetUptimeSeconds()); ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // Number of shared files { wxString temp = CFormat(_("Shared files: %d")) % theStats::GetSharedFileCount(); ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // Number of queued clients { wxString temp = CFormat(_("Queued clients: %d")) % theStats::GetWaitingUserCount(); ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // Total Downloaded { wxString temp = CastItoXBytes(theStats::GetTotalReceivedBytes()); temp = CFormat(_("Total DL: %s")) % temp; ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } // Total Uploaded { wxString temp = CastItoXBytes(theStats::GetTotalSentBytes()); temp = CFormat(_("Total UL: %s")) % temp; ClientInfoMenu->Append(TRAY_MENU_CLIENTINFO_ITEM,temp); } traymenu->Append(TRAY_MENU_CLIENTINFO,ClientInfoMenu->GetTitle(),ClientInfoMenu); // Separator traymenu->AppendSeparator(); // Upload Speed sub-menu wxMenu* UploadSpeedMenu = new wxMenu(); UploadSpeedMenu->SetTitle(_("Upload limit")); // Download Speed sub-menu wxMenu* DownloadSpeedMenu = new wxMenu(); DownloadSpeedMenu->SetTitle(_("Download limit")); // Upload Speed sub-menu { UploadSpeedMenu->Append(UPLOAD_ITEM1, _("Unlimited")); uint32 max_ul_speed = thePrefs::GetMaxGraphUploadRate(); if ( max_ul_speed == UNLIMITED ) { max_ul_speed = 100; } else if ( max_ul_speed < 10 ) { max_ul_speed = 10; } for ( int i = 0; i < 5; i++ ) { unsigned int tempspeed = (unsigned int)((double)max_ul_speed / 5) * (5 - i); wxString temp = CFormat(wxT("%u %s")) % tempspeed % _("kB/s"); UploadSpeedMenu->Append((int)UPLOAD_ITEM1+i+1,temp); } } traymenu->Append(0,UploadSpeedMenu->GetTitle(),UploadSpeedMenu); // Download Speed sub-menu { DownloadSpeedMenu->Append(DOWNLOAD_ITEM1, _("Unlimited")); uint32 max_dl_speed = thePrefs::GetMaxGraphDownloadRate(); if ( max_dl_speed == UNLIMITED ) { max_dl_speed = 100; } else if ( max_dl_speed < 10 ) { max_dl_speed = 10; } for ( int i = 0; i < 5; i++ ) { unsigned int tempspeed = (unsigned int)((double)max_dl_speed / 5) * (5 - i); wxString temp = CFormat(wxT("%d %s")) % tempspeed % _("kB/s"); DownloadSpeedMenu->Append((int)DOWNLOAD_ITEM1+i+1,temp); } } traymenu->Append(0,DownloadSpeedMenu->GetTitle(),DownloadSpeedMenu); // Separator traymenu->AppendSeparator(); if (theApp->IsConnected()) { //Disconnection Speed item traymenu->Append(TRAY_MENU_DISCONNECT, _("Disconnect")); } else { //Connect item traymenu->Append(TRAY_MENU_CONNECT, _("Connect")); } // Separator traymenu->AppendSeparator(); if (theApp->amuledlg->IsShown()) { //hide item traymenu->Append(TRAY_MENU_HIDE, _("Hide aMule")); } else { //show item traymenu->Append(TRAY_MENU_SHOW, _("Show aMule")); } // Separator traymenu->AppendSeparator(); // Exit item traymenu->Append(TRAY_MENU_EXIT, _("Exit")); return traymenu; }
void COScopeCtrl::RecreateGrid() { // There is a lot of drawing going on here - particularly in terms of // drawing the grid. Don't panic, this is all being drawn (only once) // to a bitmap. The result is then BitBlt'd to the control whenever needed. bRecreateGrid = false; if (m_rectClient.GetWidth() == 0 || m_rectClient.GetHeight() == 0) { return; } wxMemoryDC dcGrid(m_bmapGrid); wxPen solidPen = *(wxThePenList->FindOrCreatePen(m_gridColour, 1, wxSOLID)); wxString strTemp; // fill the grid background dcGrid.SetBrush(brushBack); dcGrid.SetPen(*wxTRANSPARENT_PEN); dcGrid.DrawRectangle(m_rectClient); // adjust the plot rectangle dimensions // assume 6 pixels per character (this may need to be adjusted) m_rectPlot.x = m_rectClient.GetLeft() + 6*7+4; // draw the plot rectangle dcGrid.SetPen(solidPen); dcGrid.DrawRectangle(m_rectPlot.x - 1, m_rectPlot.y - 1, m_rectPlot.GetWidth() + 2, m_rectPlot.GetHeight() + 2); dcGrid.SetPen(wxNullPen); // create some fonts (horizontal and vertical) wxFont axisFont(10, wxSWISS, wxNORMAL, wxNORMAL, false); dcGrid.SetFont(axisFont); // y max dcGrid.SetTextForeground(m_gridColour); if( strYMax.IsEmpty() ) { strTemp = wxString::Format(wxT("%.*f"), nYDecimals, pdsTrends[ 0 ].fUpperLimit); } else { strTemp = strYMax; } wxCoord sizX,sizY; dcGrid.GetTextExtent(strTemp,&sizX,&sizY); dcGrid.DrawText(strTemp,m_rectPlot.GetLeft()-4-sizX,m_rectPlot.GetTop()-7); // y min if( strYMin.IsEmpty() ) { strTemp = wxString::Format(wxT("%.*f"), nYDecimals, pdsTrends[ 0 ].fLowerLimit) ; } else { strTemp = strYMin; } dcGrid.GetTextExtent(strTemp,&sizX,&sizY); dcGrid.DrawText(strTemp,m_rectPlot.GetLeft()-4-sizX, m_rectPlot.GetBottom()); // x units strTemp = CastSecondsToHM((m_rectPlot.GetWidth()/nShiftPixels) * (int)floor(sLastPeriod+0.5)); // floor(x + 0.5) is a way of doing round(x) that works with gcc < 3 ... if (bStopped) { strXUnits = CFormat( _("Disabled [%s]") ) % strTemp; } else { strXUnits = strTemp; } dcGrid.GetTextExtent(strXUnits,&sizX,&sizY); dcGrid.DrawText(strXUnits,(m_rectPlot.GetLeft() + m_rectPlot.GetRight())/2-sizX/2,m_rectPlot.GetBottom()+4); // y units if (!strYUnits.IsEmpty()) { dcGrid.GetTextExtent(strYUnits,&sizX,&sizY); dcGrid.DrawText(strYUnits, m_rectPlot.GetLeft()-4-sizX, (m_rectPlot.GetTop()+m_rectPlot.GetBottom())/2-sizY/2); } // no more drawing to this bitmap is needed until the setting are changed if (bRecreateGraph) { RecreateGraph(false); } // finally, force the plot area to redraw Refresh(false); }
bool CUploadQueue::CheckForTimeOver(CUpDownClient* client){ //If we have nobody in the queue, do NOT remove the current uploads.. //This will save some bandwidth and some unneeded swapping from upload/queue/upload.. if ( waitinglist.IsEmpty() || client->GetFriendSlot() ) return false; if(client->HasCollectionUploadSlot()){ CKnownFile* pDownloadingFile = theApp.sharedfiles->GetFileByID(client->requpfileid); if(pDownloadingFile == NULL) return true; if (CCollection::HasCollectionExtention(pDownloadingFile->GetFileName()) && pDownloadingFile->GetFileSize() < (uint64)MAXPRIORITYCOLL_SIZE) return false; else{ if (thePrefs.GetLogUlDlEvents()) AddDebugLogLine(DLP_HIGH, false, _T("%s: Upload session ended - client with Collection Slot tried to request blocks from another file"), client->GetUserName()); return true; } } if (!thePrefs.TransferFullChunks()){ if( client->GetUpStartTimeDelay() > SESSIONMAXTIME){ // Try to keep the clients from downloading for ever if (thePrefs.GetLogUlDlEvents()) AddDebugLogLine(DLP_LOW, false, _T("%s: Upload session ended due to max time %s."), client->GetUserName(), CastSecondsToHM(SESSIONMAXTIME/1000)); return true; } // Cache current client score const uint32 score = client->GetScore(true, true); // Check if another client has a bigger score if (score < GetMaxClientScore() && m_dwRemovedClientByScore < GetTickCount()) { if (thePrefs.GetLogUlDlEvents()) AddDebugLogLine(DLP_VERYLOW, false, _T("%s: Upload session ended due to score."), client->GetUserName()); //Set timer to prevent to many uploadslot getting kick do to score. //Upload slots are delayed by a min of 1 sec and the maxscore is reset every 5 sec. //So, I choose 6 secs to make sure the maxscore it updated before doing this again. m_dwRemovedClientByScore = GetTickCount()+SEC2MS(6); return true; } } else{ // Allow the client to download a specified amount per session if( client->GetQueueSessionPayloadUp() > SESSIONMAXTRANS ){ if (thePrefs.GetLogUlDlEvents()) AddDebugLogLine(DLP_DEFAULT, false, _T("%s: Upload session ended due to max transferred amount. %s"), client->GetUserName(), CastItoXBytes(SESSIONMAXTRANS, false, false)); return true; } } return false; }
bool CUploadQueue::RemoveFromUploadQueue(CUpDownClient* client, LPCTSTR pszReason, bool updatewindow, bool earlyabort){ bool result = false; uint32 slotCounter = 1; for (POSITION pos = uploadinglist.GetHeadPosition();pos != 0;){ POSITION curPos = pos; CUpDownClient* curClient = uploadinglist.GetNext(pos); if (client == curClient){ if (updatewindow) theApp.emuledlg->transferwnd->uploadlistctrl.RemoveClient(client); if (thePrefs.GetLogUlDlEvents()) AddDebugLogLine(DLP_DEFAULT, true,_T("Removing client from upload list: %s Client: %s Transferred: %s SessionUp: %s QueueSessionPayload: %s In buffer: %s Req blocks: %i File: %s"), pszReason==NULL ? _T("") : pszReason, client->DbgGetClientInfo(), CastSecondsToHM( client->GetUpStartTimeDelay()/1000), CastItoXBytes(client->GetSessionUp(), false, false), CastItoXBytes(client->GetQueueSessionPayloadUp(), false, false), CastItoXBytes(client->GetPayloadInBuffer()), client->GetNumberOfRequestedBlocksInQueue(), (theApp.sharedfiles->GetFileByID(client->GetUploadFileID())?theApp.sharedfiles->GetFileByID(client->GetUploadFileID())->GetFileName():_T(""))); client->m_bAddNextConnect = false; uploadinglist.RemoveAt(curPos); bool removed = theApp.uploadBandwidthThrottler->RemoveFromStandardList(client->socket); bool pcRemoved = theApp.uploadBandwidthThrottler->RemoveFromStandardList((CClientReqSocket*)client->m_pPCUpSocket); (void)removed; (void)pcRemoved; //if(thePrefs.GetLogUlDlEvents() && !(removed || pcRemoved)) { // AddDebugLogLine(false, _T("UploadQueue: Didn't find socket to delete. Adress: 0x%x"), client->socket); //} if(client->GetSessionUp() > 0) { ++successfullupcount; totaluploadtime += client->GetUpStartTimeDelay()/1000; } else if(earlyabort == false) ++failedupcount; CKnownFile* requestedFile = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); if(requestedFile != NULL) { requestedFile->UpdatePartsInfo(); } theApp.clientlist->AddTrackClient(client); // Keep track of this client client->SetUploadState(US_NONE); client->ClearUploadBlockRequests(); client->SetCollectionUploadSlot(false); m_iHighestNumberOfFullyActivatedSlotsSinceLastCall = 0; result = true; } else { curClient->SetSlotNumber(slotCounter); slotCounter++; } } return result; }
int CIPFilter::AddFromFile(LPCTSTR pszFilePath, bool bShowResponse) { DWORD dwStart = GetTickCount(); FILE* readFile = _tfsopen(pszFilePath, _T("r"), _SH_DENYWR); if (readFile != NULL) { enum EIPFilterFileType { Unknown = 0, FilterDat = 1, // ipfilter.dat/ip.prefix format PeerGuardian = 2, // PeerGuardian text format PeerGuardian2 = 3 // PeerGuardian binary format } eFileType = Unknown; setvbuf(readFile, NULL, _IOFBF, 32768); TCHAR szNam[_MAX_FNAME]; TCHAR szExt[_MAX_EXT]; _tsplitpath(pszFilePath, NULL, NULL, szNam, szExt); if (_tcsicmp(szExt, _T(".p2p")) == 0 || (_tcsicmp(szNam, _T("guarding.p2p")) == 0 && _tcsicmp(szExt, _T(".txt")) == 0)) eFileType = PeerGuardian; else if (_tcsicmp(szExt, _T(".prefix")) == 0) eFileType = FilterDat; else { VERIFY( _setmode(fileno(readFile), _O_BINARY) != -1 ); static const BYTE _aucP2Bheader[] = "\xFF\xFF\xFF\xFFP2B"; BYTE aucHeader[sizeof _aucP2Bheader - 1]; if (fread(aucHeader, sizeof aucHeader, 1, readFile) == 1) { if (memcmp(aucHeader, _aucP2Bheader, sizeof _aucP2Bheader - 1)==0) eFileType = PeerGuardian2; else { (void)fseek(readFile, 0, SEEK_SET); VERIFY( _setmode(fileno(readFile), _O_TEXT) != -1 ); // ugly! } } } int iFoundRanges = 0; int iLine = 0; if (eFileType == PeerGuardian2) { // Version 1: strings are ISO-8859-1 encoded // Version 2: strings are UTF-8 encoded uint8 nVersion; if (fread(&nVersion, sizeof nVersion, 1, readFile)==1 && (nVersion==1 || nVersion==2)) { while (!feof(readFile)) { CHAR szName[256]; int iLen = 0; for (;;) // read until NUL or EOF { int iChar = getc(readFile); if (iChar == EOF) break; if (iLen < sizeof szName - 1) szName[iLen++] = (CHAR)iChar; if (iChar == '\0') break; } szName[iLen] = '\0'; uint32 uStart; if (fread(&uStart, sizeof uStart, 1, readFile) != 1) break; uStart = ntohl(uStart); uint32 uEnd; if (fread(&uEnd, sizeof uEnd, 1, readFile) != 1) break; uEnd = ntohl(uEnd); iLine++; // (nVersion == 2) ? OptUtf8ToStr(szName, iLen) : AddIPRange(uStart, uEnd, DFLT_FILTER_LEVEL, CStringA(szName, iLen)); iFoundRanges++; } } } else { CStringA sbuffer; CHAR szBuffer[1024]; while (fgets(szBuffer, _countof(szBuffer), readFile) != NULL) { iLine++; sbuffer = szBuffer; // ignore comments & too short lines if (sbuffer.GetAt(0) == '#' || sbuffer.GetAt(0) == '/' || sbuffer.GetLength() < 5) { sbuffer.Trim(" \t\r\n"); DEBUG_ONLY( (!sbuffer.IsEmpty()) ? TRACE("IP filter: ignored line %u\n", iLine) : 0 ); continue; } if (eFileType == Unknown) { // looks like html if (sbuffer.Find('>') > -1 && sbuffer.Find('<') > -1) sbuffer.Delete(0, sbuffer.ReverseFind('>') + 1); // check for <IP> - <IP> at start of line UINT u1, u2, u3, u4, u5, u6, u7, u8; if (sscanf(sbuffer, "%u.%u.%u.%u - %u.%u.%u.%u", &u1, &u2, &u3, &u4, &u5, &u6, &u7, &u8) == 8) { eFileType = FilterDat; } else { // check for <description> ':' <IP> '-' <IP> int iColon = sbuffer.Find(':'); if (iColon > -1) { CStringA strIPRange = sbuffer.Mid(iColon + 1); UINT u1, u2, u3, u4, u5, u6, u7, u8; if (sscanf(strIPRange, "%u.%u.%u.%u - %u.%u.%u.%u", &u1, &u2, &u3, &u4, &u5, &u6, &u7, &u8) == 8) { eFileType = PeerGuardian; } } } } bool bValid = false; uint32 start = 0; uint32 end = 0; UINT level = 0; CStringA desc; if (eFileType == FilterDat) bValid = ParseFilterLine1(sbuffer, start, end, level, desc); else if (eFileType == PeerGuardian) bValid = ParseFilterLine2(sbuffer, start, end, level, desc); // add a filter if (bValid) { AddIPRange(start, end, level, desc); iFoundRanges++; } else { sbuffer.Trim(" \t\r\n"); DEBUG_ONLY( (!sbuffer.IsEmpty()) ? TRACE("IP filter: ignored line %u\n", iLine) : 0 ); } } } fclose(readFile); // sort the IP filter list by IP range start addresses qsort(m_iplist.GetData(), m_iplist.GetCount(), sizeof(m_iplist[0]), CmpSIPFilterByStartAddr); // merge overlapping and adjacent filter ranges int iDuplicate = 0; int iMerged = 0; if (m_iplist.GetCount() >= 2) { // On large IP-filter lists there is a noticeable performance problem when merging the list. // The 'CIPFilterArray::RemoveAt' call is way too expensive to get called during the merging, // thus we use temporary helper arrays to copy only the entries into the final list which // are not get deleted. // Reserve a byte array (its used as a boolean array actually) as large as the current // IP-filter list, so we can set a 'to delete' flag for each entry in the current IP-filter list. char* pcToDelete = new char[m_iplist.GetCount()]; memset(pcToDelete, 0, m_iplist.GetCount()); int iNumToDelete = 0; SIPFilter* pPrv = m_iplist[0]; int i = 1; while (i < m_iplist.GetCount()) { SIPFilter* pCur = m_iplist[i]; if ( pCur->start >= pPrv->start && pCur->start <= pPrv->end // overlapping || pCur->start == pPrv->end+1 && pCur->level == pPrv->level) // adjacent { if (pCur->start != pPrv->start || pCur->end != pPrv->end) // don't merge identical entries { //TODO: not yet handled, overlapping entries with different 'level' if (pCur->end > pPrv->end) pPrv->end = pCur->end; //pPrv->desc += _T("; ") + pCur->desc; // this may create a very very long description string... iMerged++; } else { // if we have identical entries, use the lowest 'level' if (pCur->level < pPrv->level) pPrv->level = pCur->level; iDuplicate++; } delete pCur; //m_iplist.RemoveAt(i); // way too expensive (read above) pcToDelete[i] = 1; // mark this entry as 'to delete' iNumToDelete++; i++; continue; } pPrv = pCur; i++; } // Create new IP-filter list which contains only the entries from the original IP-filter list // which are not to be deleted. if (iNumToDelete > 0) { CIPFilterArray newList; newList.SetSize(m_iplist.GetCount() - iNumToDelete); int iNewListIndex = 0; for (int i = 0; i < m_iplist.GetCount(); i++) { if (!pcToDelete[i]) newList[iNewListIndex++] = m_iplist[i]; } ASSERT( iNewListIndex == newList.GetSize() ); // Replace current list with new list. Dump, but still fast enough (only 1 memcpy) m_iplist.RemoveAll(); m_iplist.Append(newList); newList.RemoveAll(); m_bModified = true; } delete[] pcToDelete; } if (thePrefs.GetVerbose()) { DWORD dwEnd = GetTickCount(); AddDebugLogLine(false, _T("Loaded IP filters from \"%s\""), pszFilePath); AddDebugLogLine(false, _T("Parsed lines/entries:%u Found IP ranges:%u Duplicate:%u Merged:%u Time:%s"), iLine, iFoundRanges, iDuplicate, iMerged, CastSecondsToHM((dwEnd-dwStart+500)/1000)); } AddLogLine(bShowResponse, GetResString(IDS_IPFILTERLOADED), m_iplist.GetCount()); } return m_iplist.GetCount(); }
void CUploadListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC); BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); if (lpDrawItemStruct->itemState & ODS_SELECTED) { if (bCtrlFocused) odc->SetBkColor(m_crHighlight); else odc->SetBkColor(m_crNoHighlight); } else odc->SetBkColor(GetBkColor()); const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; CMemDC dc(odc, &lpDrawItemStruct->rcItem); CFont* pOldFont = dc.SelectObject(GetFont()); CRect cur_rec(lpDrawItemStruct->rcItem); COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText); if (client->GetSlotNumber() > theApp.uploadqueue->GetActiveUploadsCount()) { dc.SetTextColor(::GetSysColor(COLOR_GRAYTEXT)); } int iOldBkMode; if (m_crWindowTextBk == CLR_NONE){ DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; CString Sbuffer; for (int iCurrent = 0; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if (!IsColumnHidden(iColumn)) { cur_rec.right += GetColumnWidth(iColumn); switch (iColumn) { case 0:{ uint8 image; if (client->IsFriend()) image = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID){ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 8; else image = 7; } else if (client->GetClientSoft() == SO_MLDONKEY){ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 6; else image = 5; } else if (client->GetClientSoft() == SO_SHAREAZA){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 10; else image = 9; } else if (client->GetClientSoft() == SO_AMULE){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 12; else image = 11; } else if (client->GetClientSoft() == SO_LPHANT){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 14; else image = 13; } else if (client->ExtProtocolAvailable()){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 3; else image = 1; } else{ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 2; else image = 0; } POINT point = {cur_rec.left, cur_rec.top+1}; imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0)); Sbuffer = client->GetUserName(); cur_rec.left += 20; dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left -= 20; break; } case 1: if (file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); break; case 2: Sbuffer = CastItoXBytes(client->GetDatarate(), false, true); break; case 3: // NOTE: If you change (add/remove) anything which is displayed here, update also the sorting part.. if (thePrefs.m_bExtControls) Sbuffer.Format( _T("%s (%s)"), CastItoXBytes(client->GetSessionUp(), false, false), CastItoXBytes(client->GetQueueSessionPayloadUp(), false, false)); else Sbuffer = CastItoXBytes(client->GetSessionUp(), false, false); break; case 4: if (client->HasLowID()) Sbuffer.Format(_T("%s (%s)"), CastSecondsToHM(client->GetWaitTime()/1000), GetResString(IDS_IDLOW)); else Sbuffer = CastSecondsToHM(client->GetWaitTime()/1000); break; case 5: Sbuffer = CastSecondsToHM(client->GetUpStartTimeDelay()/1000); break; case 6: Sbuffer = client->GetUploadStateDisplayString(); break; case 7: cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar()); cur_rec.bottom++; cur_rec.top--; break; } if (iColumn != 7 && iColumn != 0) dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); } } //draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if (bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
void CUploadListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem); BOOL bCtrlFocused; InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused); CRect cur_rec(lpDrawItemStruct->rcItem); CRect rcClient; GetClientRect(&rcClient); const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; COLORREF crOldBackColor = dc->GetBkColor(); //Xman PowerRelease CKnownFile* file = CGlobalVariable::sharedfiles->GetFileByID(client->GetUploadFileID()); CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; CString Sbuffer; for (int iCurrent = 0; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if (!IsColumnHidden(iColumn)) { cur_rec.right += GetColumnWidth(iColumn); switch (iColumn) { case 0: { uint8 image; if (client->IsFriend()) image = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID) { if (client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 8; else image = 7; } else if (client->GetClientSoft() == SO_MLDONKEY) { if (client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 6; else image = 5; } else if (client->GetClientSoft() == SO_SHAREAZA) { if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 10; else image = 9; } else if (client->GetClientSoft() == SO_AMULE) { if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 12; else image = 11; } else if (client->GetClientSoft() == SO_LPHANT) { if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 14; else image = 13; } else if (client->ExtProtocolAvailable()) { if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 3; else image = 1; } else { if (client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 2; else image = 0; } uint32 nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; if (client->IsObfuscatedConnectionEstablished()) nOverlayImage |= 2; POINT point = {cur_rec.left, cur_rec.top+1}; imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0)); Sbuffer = client->GetUserName(); //EastShare Start - added by AndCycle, IP to Country CString tempStr; tempStr.Format(_T("%s%s"), client->GetCountryName(), Sbuffer); Sbuffer = tempStr; if(CGlobalVariable::ip2country->ShowCountryFlag()) { cur_rec.left += 20; POINT point2= {cur_rec.left,cur_rec.top+1}; CGlobalVariable::ip2country->GetFlagImageList()->DrawIndirect(dc, client->GetCountryFlagIndex(), point2, CSize(18,16), CPoint(0,0), ILD_NORMAL); } //EastShare End - added by AndCycle, IP to Country cur_rec.left += 20; dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left -= 20; //EastShare Start - added by AndCycle, IP to Country if(CGlobalVariable::ip2country->ShowCountryFlag()) { cur_rec.left-=20; } //EastShare End - added by AndCycle, IP to Country break; } case 1: if (file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); if(file && file->GetUpPriority()==PR_POWER) ///PowerRelease dc->SetBkColor(RGB(255,225,225)); break; case 2: Sbuffer = CastItoXBytes(client->GetDatarate(), false, true); break; case 3: // NOTE: If you change (add/remove) anything which is displayed here, update also the sorting part.. if (thePrefs.m_bExtControls) Sbuffer.Format( _T("%s (%s)"), CastItoXBytes(client->GetSessionUp(), false, false), CastItoXBytes(client->GetQueueSessionPayloadUp(), false, false)); else Sbuffer = CastItoXBytes(client->GetSessionUp(), false, false); break; case 4: if (client->HasLowID()) Sbuffer.Format(_T("%s (%s)"), CastSecondsToHM(client->GetWaitTime()/1000), GetResString(IDS_IDLOW)); else Sbuffer = CastSecondsToHM(client->GetWaitTime()/1000); break; case 5: Sbuffer = CastSecondsToHM(client->GetUpStartTimeDelay()/1000); break; case 6: Sbuffer = client->GetUploadStateDisplayString(); break; case 7: cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar()); cur_rec.bottom++; cur_rec.top--; break; } if (iColumn != 7 && iColumn != 0) dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); dc->SetBkColor( crOldBackColor ); cur_rec.left += GetColumnWidth(iColumn); } } //draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if (bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } /* if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor);*/ }
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC); BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); if (lpDrawItemStruct->itemState & ODS_SELECTED) { if (bCtrlFocused) odc->SetBkColor(m_crHighlight); else odc->SetBkColor(m_crNoHighlight); } else odc->SetBkColor(GetBkColor()); const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; CMemDC dc(odc, &lpDrawItemStruct->rcItem); CFont* pOldFont = dc.SelectObject(GetFont()); CRect cur_rec(lpDrawItemStruct->rcItem); COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText); int iOldBkMode; if (m_crWindowTextBk == CLR_NONE){ DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; CString Sbuffer; for(int iCurrent = 0; iCurrent < iCount; iCurrent++){ int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if( !IsColumnHidden(iColumn) ){ cur_rec.right += GetColumnWidth(iColumn); switch(iColumn){ case 0:{ uint8 image; if (client->IsFriend()) image = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID){ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 8; else image = 7; } else if (client->GetClientSoft() == SO_MLDONKEY){ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 6; else image = 5; } else if (client->GetClientSoft() == SO_SHAREAZA){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 10; else image = 9; } else if (client->GetClientSoft() == SO_AMULE){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 12; else image = 11; } else if (client->GetClientSoft() == SO_LPHANT){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 14; else image = 13; } else if (client->ExtProtocolAvailable()){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 3; else image = 1; } else{ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 2; else image = 0; } uint32 nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; if (client->IsObfuscatedConnectionEstablished()) nOverlayImage |= 2; int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1; POINT point = {cur_rec.left, cur_rec.top + iIconPosY}; imagelist.Draw(dc,image, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage)); Sbuffer = client->GetUserName(); cur_rec.left += 20; dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left -= 20; break; } case 1: if(file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); break; case 2: if(file){ switch (file->GetUpPriority()) { case PR_VERYLOW : { Sbuffer = GetResString(IDS_PRIOVERYLOW); break; } case PR_LOW : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOLOW); else Sbuffer = GetResString(IDS_PRIOLOW); break; } case PR_NORMAL : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTONORMAL); else Sbuffer = GetResString(IDS_PRIONORMAL); break; } case PR_HIGH : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOHIGH); else Sbuffer = GetResString(IDS_PRIOHIGH); break; } case PR_VERYHIGH : { Sbuffer = GetResString(IDS_PRIORELEASE); break; } default: Sbuffer.Empty(); } } else Sbuffer = _T("?"); break; case 3: Sbuffer.Format(_T("%i"),client->GetScore(false,false,true)); break; case 4: if (client->HasLowID()){ if (client->m_bAddNextConnect) Sbuffer.Format(_T("%i ****"),client->GetScore(false)); else Sbuffer.Format(_T("%i (%s)"),client->GetScore(false), GetResString(IDS_IDLOW)); } else Sbuffer.Format(_T("%i"),client->GetScore(false)); break; case 5: Sbuffer.Format(_T("%i"),client->GetAskedCount()); break; case 6: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetLastUpRequest())/1000); break; case 7: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetWaitStartTime())/1000); break; case 8: if(client->IsBanned()) Sbuffer = GetResString(IDS_YES); else Sbuffer = GetResString(IDS_NO); break; case 9: if( client->GetUpPartCount()){ cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc,&cur_rec,false,thePrefs.UseFlatBar()); cur_rec.bottom++; cur_rec.top--; } break; } if( iColumn != 9 && iColumn != 0) dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); } } // draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if(bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
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(...) { } }
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { #define LIST_CELL_PADDING 6 //should be even number if (!g_App.m_pMDlg->IsRunning() || !lpDrawItemStruct->itemData) return; CDC *odc = CDC::FromHandle(lpDrawItemStruct->hDC); BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); COLORREF crBk, crWinBk; crWinBk = crBk = GetBkColor(); if (lpDrawItemStruct->itemState & ODS_SELECTED) crBk = (bCtrlFocused) ? m_crHighlight : m_crNoHighlight; CUpDownClient *pClient = reinterpret_cast<CUpDownClient*>(lpDrawItemStruct->itemData); CMemDC dc(odc, &lpDrawItemStruct->rcItem, crWinBk, crBk); CFont *pOldFont = dc.SelectObject(GetFont()); COLORREF crOldTextColor = dc->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); int iWidth, iColumn; bool bMeasuring = (m_iMeasuringColumn >= 0); UINT iCalcFlag = bMeasuring ? (DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX|DT_NOCLIP|DT_CALCRECT) : (DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS); if (IsRightToLeftLanguage()) iCalcFlag |= DT_RTLREADING; RECT r = lpDrawItemStruct->rcItem; CString strBuffer; CKnownFile *pKnownFile = g_App.m_pSharedFilesList->GetFileByID(pClient->m_reqFileHash); CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iNumColumns = pHeaderCtrl->GetItemCount(); r.right = r.left - LIST_CELL_PADDING / 2; r.left += LIST_CELL_PADDING / 2; iWidth = LIST_CELL_PADDING; for (int iCurrent = 0; iCurrent < iNumColumns; iCurrent++) { iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if (IsColumnHidden(iColumn) || (bMeasuring && iColumn != m_iMeasuringColumn)) continue; r.right += CListCtrl::GetColumnWidth(iColumn); switch (iColumn) { case QLCOL_USERNAME: { if (!bMeasuring) { POINT point = {r.left, r.top + 1}; int iImgLstIdx = CLIENT_IMGLST_PLAIN; // Select corresponding image list depending on client properties if (pClient->IsBanned()) iImgLstIdx = CLIENT_IMGLST_BANNED; else if (pClient->IsFriend()) iImgLstIdx = CLIENT_IMGLST_FRIEND; else if (pClient->m_pCredits->HasHigherScoreRatio(pClient->GetIP())) iImgLstIdx = CLIENT_IMGLST_CREDITUP; // Display Client icon g_App.m_pMDlg->m_clientImgLists[iImgLstIdx].Draw(dc, pClient->GetClientIconIndex(), point, ILD_NORMAL); r.left += 20; if (g_App.m_pIP2Country->ShowCountryFlag()) { point.x += 20; point.y += 2; g_App.m_pIP2Country->GetFlagImageList()->Draw(dc, pClient->GetCountryIndex(), point, ILD_NORMAL); r.left += 22; } } else { iWidth += 20; if (g_App.m_pIP2Country->ShowCountryFlag()) iWidth += 22; } strBuffer = pClient->GetUserName(); break; } case QLCOL_FILENAME: if (pKnownFile) strBuffer = pKnownFile->GetFileName(); else strBuffer = _T("?"); break; case QLCOL_FILEPRIORITY: { if (pKnownFile) { UINT dwResStrId; switch (pKnownFile->GetULPriority()) { case PR_RELEASE: dwResStrId = IDS_PRIORELEASE; break; case PR_HIGH: dwResStrId = IDS_PRIOHIGH; break; case PR_LOW: dwResStrId = IDS_PRIOLOW; break; case PR_VERYLOW: dwResStrId = IDS_PRIOVERYLOW; break; default: dwResStrId = IDS_PRIONORMAL; break; } GetResString(&strBuffer, dwResStrId); } else strBuffer = _T("?"); break; } case QLCOL_PARTS: if (pClient->GetUpPartCount()) strBuffer.Format(_T("%u/%u"), pClient->GetAvailUpPartCount(), pClient->GetUpPartCount()); else strBuffer = _T(""); break; case QLCOL_PROGRESS: { if (pClient->GetUpPartCount() && g_App.m_pPrefs->IsUploadPartsEnabled()) { if (!bMeasuring) { RECT r2; r2.bottom = r.bottom - 1; r2.top = r.top + 1; r2.right = r.right + LIST_CELL_PADDING / 2; r2.left = r.left - LIST_CELL_PADDING / 2; pClient->DrawUpStatusBar(dc, &r2, g_App.m_pPrefs->UseFlatBar()); } iWidth = 300; } break; } case QLCOL_QLRATING: strBuffer.Format(_T("%u"), pClient->GetScore(true)); break; case QLCOL_SCORE: // Note: actually the client, which is downloading from us should be not in WaitingQueue if (pClient->IsDownloading()) strBuffer = _T("-"); else strBuffer.Format((pClient->IsAddNextConnect()) ? _T("%u*") : _T("%u"), pClient->GetScore()); break; case QLCOL_SFRATIO: if (pKnownFile != NULL) strBuffer.Format(_T("%.2f"), pKnownFile->GetSizeRatio()); else strBuffer = _T("-"); break; case QLCOL_RFRATIO: if (pKnownFile != NULL) strBuffer.Format(_T("%.2f"), pKnownFile->GetPopularityRatio()); else strBuffer = _T("-"); break; case QLCOL_TIMESASKED: strBuffer.Format(_T("%u"), pClient->GetAskedCount()); break; case QLCOL_LASTSEEN: strBuffer = CastSecondsToHM((GetTickCount() - pClient->GetLastUpRequest())/1000); break; case QLCOL_ENTEREDQUEUE: strBuffer = CastSecondsToHM((GetTickCount() - pClient->GetWaitStartTime())/1000); break; case QLCOL_BANNED: strBuffer = YesNoStr(pClient->IsBanned()); break; case QLCOL_COUNTRY: strBuffer = pClient->GetCountryName(); break; } if (iColumn != QLCOL_PROGRESS) { dc->DrawText(strBuffer, &r, iCalcFlag); if (bMeasuring && !strBuffer.IsEmpty()) iWidth += r.right - r.left + 1; } r.left = r.right + LIST_CELL_PADDING; if (bMeasuring) { // Pin the column widths at some reasonable value if (iWidth < 40) iWidth = 40; if (iWidth > m_iColumnMaxWidths[m_iMeasuringColumn]) m_iColumnMaxWidths[m_iMeasuringColumn] = iWidth; } } // Draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT rOutline = lpDrawItemStruct->rcItem; CBrush FrmBrush((bCtrlFocused) ? m_crFocusLine : m_crNoFocusLine); rOutline.left++; rOutline.right--; dc->FrameRect(&rOutline, &FrmBrush); } if (pOldFont) dc.SelectObject(pOldFont); if (crOldTextColor) dc.SetTextColor(crOldTextColor); #undef LIST_CELL_PADDING }
void CUploadListCtrl::GetItemDisplayText(const CUpDownClient *client, int iSubItem, LPTSTR pszText, int cchTextMax) { if (pszText == NULL || cchTextMax <= 0) { ASSERT(0); return; } pszText[0] = _T('\0'); switch (iSubItem) { case 0: if (client->GetUserName() == NULL) _sntprintf(pszText, cchTextMax, _T("(%s)"), GetResString(IDS_UNKNOWN)); else _tcsncpy(pszText, client->GetUserName(), cchTextMax); break; case 1: { // ==> requpfile optimization [SiRoB] - Stulle /* const CKnownFile *file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); */ const CKnownFile *file = client->CheckAndGetReqUpFile(); // <== requpfile optimization [SiRoB] - Stulle _tcsncpy(pszText, file != NULL ? file->GetFileName() : _T(""), cchTextMax); break; } case 2: //Xman count block/success send //Xman // Maella -Accurate measure of bandwidth: eDonkey data + control, network adapter- /* _tcsncpy(pszText, CastItoXBytes(client->GetDatarate(), false, true), cchTextMax); */ if(thePrefs.ShowBlockRatio()) _sntprintf(pszText, cchTextMax, _T("%s, %0.0f%%"),CastItoXBytes(client->GetUploadDatarate(), false, true), client->GetFileUploadSocket()->GetBlockRatio()); else _tcsncpy(pszText, CastItoXBytes(client->GetUploadDatarate(), false, true), cchTextMax); //Xman end break; case 3: // NOTE: If you change (add/remove) anything which is displayed here, update also the sorting part.. //Xman /* if (thePrefs.m_bExtControls) _sntprintf(pszText, cchTextMax, _T("%s (%s)"), CastItoXBytes(client->GetSessionUp(), false, false), CastItoXBytes(client->GetQueueSessionPayloadUp(), false, false)); else _tcsncpy(pszText, CastItoXBytes(client->GetSessionUp(), false, false), cchTextMax); */ //Xman only intern //if(client->GetFileUploadSocket()) // Sbuffer.Format(_T("%s, ready:%u b:%u %u"),CastItoXBytes(client->GetSessionUp(), false, false), client->GetFileUploadSocket()->isready, !client->GetFileUploadSocket()->StandardPacketQueueIsEmpty(),client->GetFileUploadSocket()->blockedsendcount); //else _tcsncpy(pszText, CastItoXBytes(client->GetSessionUp(), false, false), cchTextMax); //Xman end break; case 4: if (client->HasLowID()) _sntprintf(pszText, cchTextMax, _T("%s (%s)"), CastSecondsToHM(client->GetWaitTime() / 1000), GetResString(IDS_IDLOW)); else _tcsncpy(pszText, CastSecondsToHM(client->GetWaitTime() / 1000), cchTextMax); break; case 5: // ==> Display remaining upload time [Stulle] - Stulle /* _tcsncpy(pszText, CastSecondsToHM(client->GetUpStartTimeDelay() / 1000), cchTextMax); */ _sntprintf(pszText, cchTextMax, _T("%s (+%s)"), CastSecondsToHM((client->GetUpStartTimeDelay())/1000), client->GetRemainingUploadTime()); // <== Display remaining upload time [Stulle] - Stulle break; case 6: // ==> PowerShare [ZZ/MorphXT] - Stulle /* _tcsncpy(pszText, client->GetUploadStateDisplayString(), cchTextMax); */ { CString Sbuffer; Sbuffer.Format(client->GetUploadStateDisplayString()); // ==> Display friendslot [Stulle] - Stulle if (client->IsFriend() && client->GetFriendSlot()) Sbuffer.Append(_T(",FS")); // <== Display friendslot [Stulle] - Stulle // ==> Do not display PowerShare or Fair Play for bad clients [Stulle] - Stulle if(client->GetUploadState()==US_BANNED || client->IsGPLEvildoer() || client->IsLeecher()) { _tcsncpy(pszText, Sbuffer, cchTextMax); break; } // <== Do not display PowerShare or Fair Play for bad clients [Stulle] - Stulle if (client->GetPowerShared()) Sbuffer.Append(_T(",PS")); // ==> Fair Play [AndCycle/Stulle] - Stulle // ==> requpfile optimization [SiRoB] - Stulle /* const CKnownFile *file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); */ const CKnownFile *file = client->CheckAndGetReqUpFile(); // <== requpfile optimization [SiRoB] - Stulle if (file && !file->IsPartFile() && file->statistic.GetFairPlay()) { Sbuffer.Append(_T(",FairPlay")); } // <== Fair Play [AndCycle/Stulle] - Stulle // ==> Pay Back First [AndCycle/SiRoB/Stulle] - Stulle if(client->IsPBFClient()) // client->credits != NULL here { if (client->IsSecure()) Sbuffer.Append(_T(",PBF")); else Sbuffer.Append(_T(",PBF II")); Sbuffer.AppendFormat(_T(" (%s)"),CastItoXBytes(client->credits->GetDownloadedTotal()-client->credits->GetUploadedTotal())); } // <== Pay Back First [AndCycle/SiRoB/Stulle] - Stulle _tcsncpy(pszText, Sbuffer, cchTextMax); } // <== PowerShare [ZZ/MorphXT] - Stulle break; case 7: _tcsncpy(pszText, GetResString(IDS_UPSTATUS), cchTextMax); break; //Xman version see clientversion in every window case 8: _tcsncpy(pszText, client->DbgGetFullClientSoftVer(), cchTextMax); break; //Xman end //Xman show complete up/down in uploadlist case 9: if(client->Credits()) _sntprintf(pszText, cchTextMax, _T("%s/ %s"), CastItoXBytes(client->credits->GetUploadedTotal()), CastItoXBytes(client->credits->GetDownloadedTotal())); else _tcsncpy(pszText, _T("?"), cchTextMax); break; //Xman end // ==> Uploading Chunk Detail Display [SiRoB/Fafner] - Stulle case 10: _tcsncpy(pszText, _T("Chunk Details"), cchTextMax); break; // <== Uploading Chunk Detail Display [SiRoB/Fafner] - Stulle } pszText[cchTextMax - 1] = _T('\0'); }