Exemplo n.º 1
0
void CPartFileConvertDlg::UpdateJobInfo(ConvertJob* job) {

	if (job==NULL) {
		SetDlgItemText(IDC_CURJOB, GetResString(IDS_FSTAT_WAITING) );
		SetDlgItemText(IDC_CONV_PROZENT, _T(""));
		pb_current.SetPos(0);
		SetDlgItemText(IDC_CONV_PB_LABEL,_T(""));
		return;
	}
	
	CString buffer;

	// search jobitem in listctrl
	LVFINDINFO find;
	find.flags = LVFI_PARAM;
	find.lParam = (LPARAM)job;
	int itemnr = joblist.FindItem(&find);
	if (itemnr != -1) {
		joblist.SetItemText(itemnr,0, job->filename.IsEmpty()?job->folder:job->filename  );
		joblist.SetItemText(itemnr,1, CPartFileConvert::GetReturncodeText(job->state) );
		buffer=_T("");
		if (job->size>0)
			buffer.Format(GetResString(IDS_IMP_SIZE),CastItoXBytes(job->size, false, false),CastItoXBytes(job->spaceneeded, false, false));
		joblist.SetItemText(itemnr,2, buffer );
		joblist.SetItemText(itemnr,3, job->filehash);

	} else {
//		AddJob(job);	why???
	}
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
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();
}
Exemplo n.º 4
0
void DecodeStatisticsDat(const CFileDataIO& file)
{
	uint8_t version = file.ReadUInt8();
	cout << "Version : " << (unsigned)version << '\n';
	if (version == 0) {
		uint64_t tmp = file.ReadUInt64();
		cout << "Total sent bytes     : " << tmp << " (" << CastItoXBytes(tmp) << ")\n";
		tmp = file.ReadUInt64();
		cout << "Total received bytes : " << tmp << " (" << CastItoXBytes(tmp) << ")\n";
	}
}
Exemplo n.º 5
0
// Check all clients that uploaded corrupted data,
// and ban them if they didn't upload enough good data too.
void CCorruptionBlackBox::EvaluateData()
{
	CCBBClientMap::iterator it = m_badClients.begin();
	for (; it != m_badClients.end(); ++it) {
		uint32 ip = it->first;
		uint64 bad = it->second.m_downloaded;
		if (!bad) {
			wxFAIL;		// this should not happen
			continue;
		}
		uint64 good = 0;
		CCBBClientMap::iterator it2 = m_goodClients.find(ip);
		if (it2 != m_goodClients.end()) {
			good = it2->second.m_downloaded;
		}

		int nCorruptPercentage = bad * 100 / (bad + good);

		if (nCorruptPercentage > CBB_BANTHRESHOLD) {
			CUpDownClient* pEvilClient = theApp->clientlist->FindClientByIP(ip);
			wxString clientName;
			if (pEvilClient != NULL) {
				clientName = pEvilClient->GetClientShortInfo();
				AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Banning: Found client which sent %d of %d corrupted data, %s"))
					% m_partNumber % bad % (good + bad) % pEvilClient->GetClientFullInfo());
				theApp->clientlist->AddTrackClient(pEvilClient);
				pEvilClient->Ban();  // Identified as sender of corrupt data
				// Stop download right away
				pEvilClient->SetDownloadState(DS_BANNED);
				if (pEvilClient->Disconnected(wxT("Upload of corrupted data"))) {
					pEvilClient->Safe_Delete();
				}
			} else {
				clientName = Uint32toStringIP(ip);
				theApp->clientlist->AddBannedClient(ip);
			}
			AddLogLineN(CFormat(_("Banned client %s for sending %s corrupt data of %s total for the file '%s'"))
				% clientName % CastItoXBytes(bad) % CastItoXBytes(good + bad) % m_fileName);
		} else {
			CUpDownClient* pSuspectClient = theApp->clientlist->FindClientByIP(ip);
			if (pSuspectClient != NULL) {
				AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Reporting: Found client which probably sent %d of %d corrupted data, but it is within the acceptable limit, %s"))
					% m_partNumber % bad % (good + bad) % pSuspectClient->GetClientFullInfo());
				theApp->clientlist->AddTrackClient(pSuspectClient);
			} else {
				AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Reporting: Found client which probably sent %d of %d corrupted data, but it is within the acceptable limit, %s"))
					% m_partNumber % bad % (good + bad) % Uint32toStringIP(ip));
			}
		}
	}
}
Exemplo n.º 6
0
void CStatisticsInfo::SetTransfer(int range, uint64 pos)
{
	pop_bartrans.SetRange32(0, range/1024);
	pop_bartrans.SetPos((int)pos/1024);
	pop_bartrans.SetShowPercent();
	SetDlgItemText(IDC_STRANSFERRED, CastItoXBytes(pos, false, false));
}
Exemplo n.º 7
0
void CPartFileConvertDlg::UpdateJobInfo(ConvertInfo& info)
{
	if (s_convertgui) {
		// search jobitem in listctrl
		long itemnr = s_convertgui->m_joblist->FindItem(-1, info.id);
		// if it does not exist, add it
		if (itemnr == -1) {
			itemnr = s_convertgui->m_joblist->InsertItem(s_convertgui->m_joblist->GetItemCount(), info.folder.GetPrintable());
			if (itemnr != -1) {
				s_convertgui->m_joblist->SetItemData(itemnr, info.id);
			}
		}
		// update columns
		if (itemnr != -1) {
			s_convertgui->m_joblist->SetItem(itemnr, 0, info.filename.IsOk() ? info.folder.GetPrintable() : info.filename.GetPrintable() );
			s_convertgui->m_joblist->SetItem(itemnr, 1, GetConversionState(info.state) );
			if (info.size > 0) {
				s_convertgui->m_joblist->SetItem(itemnr, 2, CFormat(_("%s (Disk: %s)")) % CastItoXBytes(info.size) % CastItoXBytes(info.spaceneeded));
			} else {
				s_convertgui->m_joblist->SetItem(itemnr, 2, wxEmptyString);
			}
			s_convertgui->m_joblist->SetItem(itemnr, 3, info.filehash);
		}
	}
}
Exemplo n.º 8
0
// 更新ui上的feed大小信息
void CDlgFeedConfig::UpdateFeedSizeInfo()
{
	// 磁盘剩余空间
	CString strSaveDir;
	GetDlgItemText(IDC_EDIT_RW_SAVE_DIR, strSaveDir);
	uint64 uFreeSpace;
	if ( strSaveDir.GetLength() < 3 || strSaveDir.GetAt(1) != _T(':') || strSaveDir.GetAt(2) != _T('\\') )
	{
		uFreeSpace = 0;
	}
	else
	{
		uFreeSpace = GetFreeDiskSpaceX(strSaveDir.Left(3));
	}

	// 订阅大小(磁盘剩余空间)
	CString strText;
	strText.Format(_T("%s (%s%s)"),
				   m_strFeedSize,
				   GetResString(IDS_ADDTASKDLG_FREE_SPACE),
				   CastItoXBytes(uFreeSpace)
				  );
	SetDlgItemText(IDC_EDIT_RW_FEED_SIZE, strText);

}
Exemplo n.º 9
0
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);
	}

}
Exemplo n.º 10
0
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);
}
Exemplo n.º 11
0
void CUploadListCtrl::OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMLVGETINFOTIP>(pNMHDR);

	if (pGetInfoTip->iSubItem == 0)
	{
		LVHITTESTINFO hti = {0};
		::GetCursorPos(&hti.pt);
		ScreenToClient(&hti.pt);
		if (SubItemHitTest(&hti) == -1 || hti.iItem != pGetInfoTip->iItem || hti.iSubItem != 0){
			// don' show the default label tip for the main item, if the mouse is not over the main item
			if ((pGetInfoTip->dwFlags & LVGIT_UNFOLDED) == 0 && pGetInfoTip->cchTextMax > 0 && pGetInfoTip->pszText[0] != '\0')
				pGetInfoTip->pszText[0] = '\0';
			return;
		}

		const CUpDownClient* client = (CUpDownClient*)GetItemData(pGetInfoTip->iItem);
		if (client && pGetInfoTip->pszText && pGetInfoTip->cchTextMax > 0)
		{
			CString info;

			CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID());
			// build info text and display it
			info.Format(GetResString(IDS_USERINFO), client->GetUserName());
			if (file)
			{
				info += GetResString(IDS_SF_REQUESTED) + _T(" ") + CString(file->GetFileName()) + _T("\n");
				CString stat;
				stat.Format(GetResString(IDS_FILESTATS_SESSION)+GetResString(IDS_FILESTATS_TOTAL),
							file->statistic.GetAccepts(), file->statistic.GetRequests(), CastItoXBytes(file->statistic.GetTransferred(), false, false),
							file->statistic.GetAllTimeAccepts(), file->statistic.GetAllTimeRequests(), CastItoXBytes(file->statistic.GetAllTimeTransferred(), false, false) );
				info += stat;
			}
			else
			{
				info += GetResString(IDS_REQ_UNKNOWNFILE);
			}

			_tcsncpy(pGetInfoTip->pszText, info, pGetInfoTip->cchTextMax);
			pGetInfoTip->pszText[pGetInfoTip->cchTextMax-1] = _T('\0');
		}
	}
	*pResult = 0;
}
Exemplo n.º 12
0
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;
	}
}
Exemplo n.º 13
0
void CMiniMule::UpdateContent(UINT uUpDatarate, UINT uDownDatarate)
{
    ASSERT( GetCurrentThreadId() == _uMainThreadId );
    if (m_bResolveImages)
    {
        static const LPCTSTR _apszConnectedImgs[] =
            {
                _T("CONNECTEDNOTNOT.GIF"),
                _T("CONNECTEDNOTLOW.GIF"),
                _T("CONNECTEDNOTHIGH.GIF"),
                _T("CONNECTEDLOWNOT.GIF"),
                _T("CONNECTEDLOWLOW.GIF"),
                _T("CONNECTEDLOWHIGH.GIF"),
                _T("CONNECTEDHIGHNOT.GIF"),
                _T("CONNECTEDHIGHLOW.GIF"),
                _T("CONNECTEDHIGHHIGH.GIF")
            };

        UINT uIconIdx = theApp.emuledlg->GetConnectionStateIconIndex();
        if (uIconIdx >= ARRSIZE(_apszConnectedImgs))
        {
            ASSERT(0);
            uIconIdx = 0;
        }

        TCHAR szModulePath[_MAX_PATH];
        if (GetModuleFileName(AfxGetResourceHandle(), szModulePath, ARRSIZE(szModulePath)))
        {
            CString strFilePathUrl(CreateFilePathUrl(szModulePath, INTERNET_SCHEME_RES));
            CComPtr<IHTMLImgElement> elm;
            GetElementInterface(_T("connectedImg"), &elm);
            if (elm)
            {
                CString strResourceURL;
                strResourceURL.Format(_T("%s/%s"), strFilePathUrl, _apszConnectedImgs[uIconIdx]);
                elm->put_src(CComBSTR(strResourceURL));
            }
        }
    }

    SetElementHtml(_T("connected"), CComBSTR(theApp.IsConnected() ? GetResString(IDS_YES) : GetResString(IDS_NO)));
    SetElementHtml(_T("upRate"), CComBSTR(theApp.emuledlg->GetUpDatarateString(uUpDatarate)));
    SetElementHtml(_T("downRate"), CComBSTR(theApp.emuledlg->GetDownDatarateString(uDownDatarate)));
    UINT uCompleted = 0;
    if (thePrefs.GetRemoveFinishedDownloads())
        uCompleted = thePrefs.GetDownSessionCompletedFiles();
    else if (theApp.emuledlg && theApp.emuledlg->transferwnd && theApp.emuledlg->transferwnd->downloadlistctrl.m_hWnd)
    {
        int iTotal;
        uCompleted = theApp.emuledlg->transferwnd->downloadlistctrl.GetCompleteDownloads(-1, iTotal);	 // [Ded]: -1 to get the count of all completed files in all categories
    }
    SetElementHtml(_T("completed"), CComBSTR(CastItoIShort(uCompleted, false, 0)));
    SetElementHtml(_T("freeSpace"), CComBSTR(CastItoXBytes(GetFreeTempSpace(-1), false, false)));
}
Exemplo n.º 14
0
	void UpdateGauge(int total, int current) {
		CFormat label( wxT("( %s / %s )") );

		label % CastItoXBytes(current);
		if (total > 0) {
			label % CastItoXBytes(total);
		} else {
			label % _("Unknown");
		}

		CastChild(IDC_DOWNLOADSIZE, wxStaticText)->SetLabel(label.GetString());

		if (total && (total != m_progressbar->GetRange())) {
			m_progressbar->SetRange(total);
		}

		if (current && (current <= total)) {
			m_progressbar->SetValue(current);
		}

		Layout();
	}
Exemplo n.º 15
0
wxString CStatTreeItemPacketTotals::GetDisplayString() const
{
    uint32_t tmp_packets = m_packets;
    uint64_t tmp_bytes = m_bytes;
    for (std::vector<CStatTreeItemPackets*>::const_iterator it = m_counters.begin();
            it != m_counters.end(); ++it) {
        tmp_packets += (*it)->m_packets;
        tmp_bytes += (*it)->m_bytes;
    }

    return CFormat(wxGetTranslation(m_label)) %
           a_brackets_b(CastItoXBytes(tmp_bytes), CastItoIShort(tmp_packets));
}
Exemplo n.º 16
0
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);
	}
}
Exemplo n.º 17
0
void CDlgAddTask::UpdateFreeSpaceValue(void)
{
	CString	strText;
	m_cmbLocation.GetWindowText(strText);

	uint64 uFreeSpace;
	if (strText.GetLength()<3 || strText.GetAt(1)!=_T(':') || strText.GetAt(2)!=_T('\\'))
		uFreeSpace = 0;
	else
		uFreeSpace = GetFreeDiskSpaceX(strText.Left(3));

	CString strSize = CastItoXBytes(uFreeSpace);
	GetDlgItem(IDC_STATIC_SPACE_VALUE)->SetWindowText(strSize);
}
Exemplo n.º 18
0
void DecodeClientsMet(const CFileDataIO& file)
{
	uint8_t version = file.ReadUInt8();
	cout << "Version : " << VersionInfo(version, CreditFile) << endl;
	if (version != CREDITFILE_VERSION) {
		cerr << "File seems to be corrupt, invalid version!" << endl;
		return;
	}
	uint32_t count = file.ReadUInt32();
	cout << "Count  : " << count << '\n';
	for (uint32_t i = 0; i < count; i++) {
		cout << wxString::Format(wxT("#%u\tKey          : "), i) << file.ReadHash();
		uint32_t uploaded = file.ReadUInt32();
		uint32_t downloaded = file.ReadUInt32();
		cout << "\n\tUploaded     : " << uploaded;
		cout << "\n\tDownloaded   : " << downloaded;
		cout << "\n\tLast Seen    : " << CTimeT(file.ReadUInt32());
		uint32_t uphi = file.ReadUInt32();
		uint32_t downhi = file.ReadUInt32();
		uint64_t totalup = (static_cast<uint64_t>(uphi) << 32) + uploaded;
		uint64_t totaldown = (static_cast<uint64_t>(downhi) << 32) + downloaded;
		cout << "\n\tUploadedHI   : " << uphi << "   Total : " << totalup << " (" << CastItoXBytes(totalup) << ')';
		cout << "\n\tDownloadedHI : " << downhi << "   Total : " << totaldown << " (" << CastItoXBytes(totaldown) << ')';
		cout << "\n\t(Reserved)   : " << file.ReadUInt16();
		uint8_t keysize = file.ReadUInt8();
		cout << "\n\tKeySize      : " << (unsigned)keysize;
		cout << "\n\tKey Data     : ";
		char buf[MAXPUBKEYSIZE];
		file.Read(buf, MAXPUBKEYSIZE);
		PrintByteArray(buf, MAXPUBKEYSIZE);
		cout << endl;
		if (keysize > MAXPUBKEYSIZE) {
			cerr << "\n*** Corruption found while reading credit file! ***\n" << endl;
			break;
		}
	}
}
Exemplo n.º 19
0
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("-");
    }
}
Exemplo n.º 20
0
void CPPgTweaks::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if (pScrollBar->GetSafeHwnd() == m_ctlFileBuffSize.m_hWnd)
	{
		m_iFileBufferSize = m_ctlFileBuffSize.GetPos() * 1024;
        CString temp;
		temp.Format(_T("%s: %s"), GetResString(IDS_FILEBUFFERSIZE), CastItoXBytes(m_iFileBufferSize, false, false));
		GetDlgItem(IDC_FILEBUFFERSIZE_STATIC)->SetWindowText(temp);
		SetModified(TRUE);
	}
	else if (pScrollBar->GetSafeHwnd() == m_ctlQueueSize.m_hWnd)
	{
		m_iQueueSize = ((CSliderCtrl*)pScrollBar)->GetPos() * 100;
		CString temp;
		temp.Format(_T("%s: %s"), GetResString(IDS_QUEUESIZE), GetFormatedUInt(m_iQueueSize));
		GetDlgItem(IDC_QUEUESIZE_STATIC)->SetWindowText(temp);
		SetModified(TRUE);
	}
}
void CCollectionListCtrl::AddFileToList(CAbstractFile* pAbstractFile)
{
	LVFINDINFO find;
	find.flags = LVFI_PARAM;
	find.lParam = (LPARAM)pAbstractFile;
	int iItem = FindItem(&find);
	if (iItem != -1)
	{
		ASSERT(0);
		return;
	}

	iItem = InsertItem(LVIF_TEXT|LVIF_PARAM,GetItemCount(),NULL,0,0,0,(LPARAM)pAbstractFile);
	if (iItem != -1)
	{
		SetItemText(iItem,colName,pAbstractFile->GetFileName());
		SetItemText(iItem,colSize,CastItoXBytes(pAbstractFile->GetFileSize()));
		SetItemText(iItem,colHash,::md4str(pAbstractFile->GetFileHash()));
	}
}
Exemplo n.º 22
0
CString	CShareableFile::GetInfoSummary() const
{
	CString strFolder = GetPath();
	PathRemoveBackslash(strFolder.GetBuffer());
	strFolder.ReleaseBuffer();

	CString strType = GetFileTypeDisplayStr();
	if (strType.IsEmpty())
		strType = _T("-");

	CString info;
	info.Format(_T("%s\n")
		+ GetResString(IDS_FD_SIZE) + _T(" %s\n<br_head>\n")
		+ GetResString(IDS_TYPE) + _T(": %s\n")
		+ GetResString(IDS_FOLDER) + _T(": %s"),
		GetFileName(),
		CastItoXBytes(GetFileSize(), false, false),
		strType,
		strFolder);
	return info;
}
Exemplo n.º 23
0
wxString CStatTreeItemCounterTmpl<_Tp>::GetDisplayString() const
{
	wxString my_label = wxGetTranslation(m_label);
	// This is needed for client names, for example
	if (my_label == m_label) {
		if (m_label.Right(4) == wxT(": %s")) {
			my_label = wxGetTranslation(
				m_label.Mid(0, m_label.Length() - 4)) +
				wxString(wxT(": %s"));
		}
	}
	CFormat label(my_label);
	if (m_displaymode == dmBytes) {
		return label % CastItoXBytes(m_value);
	} else {
		wxString result = CFormat(wxT("%u")) % m_value;
		if ((m_flags & stShowPercent) && m_parent) {
			result += CFormat(wxT(" (%.2f%%)")) % ((double(m_value) / dynamic_cast<CStatTreeItemCounterTmpl<_Tp>*>(m_parent)->m_value) * 100.0);
		}
		return label % result;
	}
}
Exemplo n.º 24
0
void CPPgTweaks::OnHScroll(UINT /*nSBCode*/, UINT /*nPos*/, CScrollBar* pScrollBar) 
{
	if (pScrollBar->GetSafeHwnd() == m_ctlFileBuffSize.m_hWnd)
	{
#ifdef _SUPPORT_MEMPOOL
		m_iFileBufferSize = m_ctlFileBuffSize.GetPos() * 1024 * 32; // Add * 32 SearchDream@2006/01/10
#else
		m_iFileBufferSize = m_ctlFileBuffSize.GetPos() * 1024; 
#endif
		
        CString temp;
		temp.Format(_T("%s: %s"), GetResString(IDS_FILEBUFFERSIZE), CastItoXBytes(m_iFileBufferSize, false, false));
		GetDlgItem(IDC_FILEBUFFERSIZE_STATIC)->SetWindowText(temp);
		SetModified(TRUE);
	}
	else if (pScrollBar->GetSafeHwnd() == m_ctlQueueSize.m_hWnd)
	{
		m_iQueueSize = ((CSliderCtrl*)pScrollBar)->GetPos() * 100;
		CString temp;
		temp.Format(_T("%s: %s"), GetResString(IDS_QUEUESIZE), GetFormatedUInt(m_iQueueSize));
		GetDlgItem(IDC_QUEUESIZE_STATIC)->SetWindowText(temp);
		SetModified(TRUE);
	}
}
void CDownloadClientsCtrl::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;

	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->credits != NULL){
					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)
							image = 3;
						else
							image = 1;
					}
					else{
						if (client->credits->GetScoreRatio(client/*->GetIP()*/) > 1)
//<== Xman CreditSystem [shadow2004]
							image = 2;
						else
							image = 0;
					}
					}
					else
						image = 0;

					POINT point = {cur_rec.left, cur_rec.top+1};
					m_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:
					Sbuffer.Format(_T("%s"), client->GetClientSoftVer());
					break;
				case 2:
					Sbuffer.Format(_T("%s"), client->GetRequestFile()->GetFileName());
					break;
				case 3:
					Sbuffer=CastItoXBytes( (float)client->GetDownloadDatarate() , false, true);
					dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec, DLC_DT_TEXT | DT_RIGHT);
						break;
				case 4:
						cur_rec.bottom--;
						cur_rec.top++;
						client->DrawStatusBar(dc, &cur_rec, false);
						cur_rec.bottom++;
						cur_rec.top--;
						break;	
				case 5:
					if(client->Credits() && client->GetSessionDown() < client->credits->GetDownloadedTotal())
						Sbuffer.Format(_T("%s (%s)"), CastItoXBytes(client->GetSessionDown()), CastItoXBytes(client->credits->GetDownloadedTotal()));
					else
						Sbuffer.Format(_T("%s"), CastItoXBytes(client->GetSessionDown()));
					break;
				case 6:
					if(client->Credits() && client->GetSessionUp() < client->credits->GetUploadedTotal())
						Sbuffer.Format(_T("%s (%s)"), CastItoXBytes(client->GetSessionUp()), CastItoXBytes(client->credits->GetUploadedTotal()));
					else
						Sbuffer.Format(_T("%s"), CastItoXBytes(client->GetSessionUp()));
					break;
				case 7:
						switch(client->GetSourceFrom()){
						case SF_SERVER:
						Sbuffer = _T("eD2K Server");
							break;
						case SF_KADEMLIA:
							Sbuffer = GetResString(IDS_KADEMLIA);
							break;
						case SF_SOURCE_EXCHANGE:
							Sbuffer = GetResString(IDS_SE);
							break;
						case SF_PASSIVE:
							Sbuffer = GetResString(IDS_PASSIVE);
							break;
						case SF_LINK:
							Sbuffer = GetResString(IDS_SW_LINK);
							break;
						default:
							Sbuffer = GetResString(IDS_UNKNOWN);
							break;
						}
					break;
				}
				if( iColumn != 4 && iColumn != 0 && iColumn != 3 && iColumn != 11)
					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);
}
Exemplo n.º 26
0
void CClientListCtrl::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;

	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 = 2;
					else if (client->GetClientSoft() == SO_EDONKEYHYBRID)
						image = 4;
					else if (client->GetClientSoft() == SO_MLDONKEY)
						image = 3;
					else if (client->GetClientSoft() == SO_SHAREAZA)
						image = 5;
					else if (client->GetClientSoft() == SO_URL)
						image = 6;
					else if (client->GetClientSoft() == SO_AMULE)
						image = 7;
					else if (client->GetClientSoft() == SO_LPHANT)
						image = 8;
					else if (client->ExtProtocolAvailable())
//==>Modversion [shadow2004]
#ifdef MODVERSION
						image = (client->IsNextEMF())?10:1;
#else //Modversion
						image = 1;
#endif //Modversion
//<==Modversion [shadow2004]
					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));
					if (client->GetUserName()==NULL)
						Sbuffer.Format(_T("(%s)"), GetResString(IDS_UNKNOWN));
					else
						Sbuffer = client->GetUserName();
					cur_rec.left +=20;
					dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT);
					cur_rec.left -=20;
					break;
				}
				case 1:{
					Sbuffer = client->GetUploadStateDisplayString();
					break;
				}
				case 2:{
					if(client->credits)
						Sbuffer = CastItoXBytes(client->credits->GetUploadedTotal(), false, false);
					else
						Sbuffer.Empty();
					break;
				}
				case 3:{
					Sbuffer = client->GetDownloadStateDisplayString();
					break;
				}
				case 4:{
					if(client->credits)
						Sbuffer = CastItoXBytes(client->credits->GetDownloadedTotal(), false, false);
					else
						Sbuffer.Empty();
					break;
				}
				case 5:{
					Sbuffer = client->GetClientSoftVer();
					if (Sbuffer.IsEmpty())
						Sbuffer = GetResString(IDS_UNKNOWN);
					break;
				}
				case 6:{
					if(client->socket){
						if(client->socket->IsConnected()){
							Sbuffer = GetResString(IDS_YES);
							break;
						}
					}
					Sbuffer = GetResString(IDS_NO);
					break;
				}
				case 7:
					Sbuffer = md4str(client->GetUserHash());
					break;
			}
			if( iColumn != 0)
				dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT);
			cur_rec.left += GetColumnWidth(iColumn);
		}
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');
}
Exemplo n.º 28
0
BOOL CCollectionViewDialog::OnInitDialog(void)
{
	CDialog::OnInitDialog();
	InitWindowStyles(this);

	if (!m_pCollection) {
		ASSERT(0);
		return TRUE;
	}

	m_CollectionViewList.Init(_T("CollectionView"));
	SetIcon(m_icoWnd = theApp.LoadIcon(_T("Collection_View")), FALSE);

	m_AddNewCatagory.SetCheck(false);

	SetWindowText(GetResString(IDS_VIEWCOLLECTION) + _T(": ") + m_pCollection->m_sCollectionName);

	m_CollectionViewListIcon.SetIcon(m_icoColl = theApp.LoadIcon(_T("AABCollectionFileType")));
	m_CollectionDownload.SetWindowText(GetResString(IDS_DOWNLOAD));
	m_CollectionExit.SetWindowText(GetResString(IDS_CW_CLOSE));
	SetDlgItemText(IDC_COLLECTIONVIEWAUTHORLABEL, GetResString(IDS_AUTHOR) + _T(":"));
	SetDlgItemText(IDC_COLLECTIONVIEWAUTHORKEYLABEL, GetResString(IDS_AUTHORKEY) + _T(":"));
	SetDlgItemText(IDC_COLLECTIONVIEWCATEGORYCHECK, GetResString(IDS_COLL_ADDINCAT));
	SetDlgItemText(IDC_VCOLL_DETAILS, GetResString(IDS_DETAILS));
	SetDlgItemText(IDC_VCOLL_OPTIONS, GetResString(IDS_OPTIONS));

	m_CollectionViewAuthor.SetWindowText(m_pCollection->m_sCollectionAuthorName);
	m_CollectionViewAuthorKey.SetWindowText(m_pCollection->GetAuthorKeyHashString());

	AddAnchor(IDC_COLLECTIONVEWLIST, TOP_LEFT, BOTTOM_RIGHT);
	AddAnchor(IDC_VCOLL_DETAILS, BOTTOM_LEFT, BOTTOM_RIGHT);
	AddAnchor(IDC_VCOLL_OPTIONS, BOTTOM_LEFT, BOTTOM_RIGHT);
	AddAnchor(IDC_COLLECTIONVIEWAUTHORLABEL, BOTTOM_LEFT);
	AddAnchor(IDC_COLLECTIONVIEWAUTHORKEYLABEL, BOTTOM_LEFT);
	AddAnchor(IDC_COLLECTIONVIEWCATEGORYCHECK, BOTTOM_LEFT);
	AddAnchor(IDC_COLLECTIONVIEWAUTHOR, BOTTOM_LEFT, BOTTOM_RIGHT);
	AddAnchor(IDC_COLLECTIONVIEWAUTHORKEY, BOTTOM_LEFT, BOTTOM_RIGHT);
	AddAnchor(IDC_VCOLL_CLOSE, BOTTOM_RIGHT);
	AddAnchor(IDC_VIEWCOLLECTIONDL, BOTTOM_RIGHT);
	EnableSaveRestore(PREF_INI_SECTION);

	POSITION pos = m_pCollection->m_CollectionFilesMap.GetStartPosition();
	while (pos != NULL)
	{
		CCollectionFile* pCollectionFile;
		CSKey key;
		m_pCollection->m_CollectionFilesMap.GetNextAssoc(pos, key, pCollectionFile);

		int iImage = theApp.GetFileTypeSystemImageIdx(pCollectionFile->GetFileName());
		int iItem = m_CollectionViewList.InsertItem(LVIF_TEXT | LVIF_PARAM | (iImage > 0 ? LVIF_IMAGE : 0), m_CollectionViewList.GetItemCount(), NULL, 0, 0, iImage, (LPARAM)pCollectionFile);
		if (iItem != -1)
		{
			m_CollectionViewList.SetItemText(iItem, colName, pCollectionFile->GetFileName());
			m_CollectionViewList.SetItemText(iItem, colSize, CastItoXBytes(pCollectionFile->GetFileSize()));
			m_CollectionViewList.SetItemText(iItem, colHash, md4str(pCollectionFile->GetFileHash()));
		}
	}

	int iItem = m_CollectionViewList.GetItemCount();
	while (iItem)
		m_CollectionViewList.SetItemState(--iItem, LVIS_SELECTED, LVIS_SELECTED);

	CString strTitle;
	strTitle.Format(GetResString(IDS_COLLECTIONLIST) + _T(" (%u)"), m_CollectionViewList.GetItemCount());
	m_CollectionViewListLabel.SetWindowText(strTitle);

	return TRUE;
}
Exemplo n.º 29
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;
}		
Exemplo n.º 30
0
void CHttpDownloadDlg::SetTransferRate(double KbPerSecond)
{
	CString sRate;
	sRate.Format( _T("%s"), CastItoXBytes(KbPerSecond, true, true));
	m_ctrlTransferRate.SetWindowText(sRate);
}