📄 emuledlg.cpp
字号:
if (!theApp.emuledlg->serverwnd.serverlistctrl.AddServer(pSrv,true))
delete pSrv;
else theApp.emuledlg->AddLogLine(true,GetResString(IDS_SERVERADDED)+CString(pSrv->GetListName()));
}
break;
default:
break;
}
delete pLink;
} catch(...) {
OUTPUT_DEBUG_TRACE();
AddLogLine(true, GetResString(IDS_LINKNOTADDED));
}
} else if (data->dwData==OP_CLCOMMAND){
// command line command received
CString clcommand;
clcommand= (char*)data->lpData;
clcommand.MakeLower();
AddLogLine(true,"CLI: %s",clcommand);
if (clcommand=="connect") {StartConnection(); return true;}
if (clcommand=="disconnect") {theApp.serverconnect->Disconnect(); return true;}
if (clcommand=="resume") {theApp.downloadqueue->StartNextFile(); return true;}
if (clcommand=="exit") {OnClose(); return true;}
if (clcommand=="restore") {RestoreWindow();return true;}
if (clcommand.Left(7).MakeLower()=="limits=" && clcommand.GetLength()>8) {
CString down="";
CString up=clcommand.Mid(7);
int pos=up.Find(',');
if (pos>0) {
down=up.Mid(pos+1);
up=up.Left(pos);
}
if (down.GetLength()>0) theApp.glob_prefs->SetMaxDownload(atoi(down) ? atoi(down) : 0xffff);
if (up.GetLength()>0) theApp.glob_prefs->SetMaxUpload(atoi(up) ? atoi(up) : 0xffff);
return true;
}
if (clcommand=="help" || clcommand=="/?") {
// show usage
return true;
}
if (clcommand=="status") {
CString pString;
// todo: output to console
pString.Format("%sstatus.log",theApp.glob_prefs->GetAppDir());
FILE* file = fopen(pString , "w");
if (theApp.serverconnect->IsConnected()) pString=GetResString(IDS_CONNECTED); else
if (theApp.serverconnect->IsConnecting()) pString=GetResString(IDS_CONNECTING); else pString=GetResString(IDS_DISCONNECTED);
fprintf(file, pString);
pString.Format("\n"+GetResString(IDS_UPDOWNSMALL),(float)theApp.uploadqueue->GetDatarate()/1024, (float)theApp.downloadqueue->GetDatarate()/1024);
fprintf(file, pString);
pString="\n"+transferwnd.downloadlistctrl.getTextList();
fprintf(file, pString);
fclose(file);
return true;
}
// show "unknown command";
}
return true;
}
LRESULT CemuleDlg::OnFileHashed(WPARAM wParam,LPARAM lParam){
CKnownFile* result = (CKnownFile*)lParam;
if (wParam){
CPartFile* requester = (CPartFile*)wParam;
requester->PartFileHashFinished(result);
}
else{
theApp.sharedfiles->filelist->SafeAddKFile(result);
theApp.sharedfiles->SafeAddKFile(result);
}
return true;
}
void CemuleDlg::OnClose()
{
if ( m_app_state == APP_STATE_RUNNING )
if (theApp.glob_prefs->IsConfirmExitEnabled() )
if (IDNO==MessageBox(GetResString(IDS_MAIN_EXIT),GetResString(IDS_MAIN_EXITTITLE),MB_YESNO | MB_DEFBUTTON2)) return;
m_app_state = APP_STATE_SHUTINGDOWN;
theApp.OnlineSig(); // Added By Bouc7
// TODO: Add your message handler code here and/or call default
WINDOWPLACEMENT wp;wp.length=sizeof(wp);GetWindowPlacement(&wp);
theApp.glob_prefs->SetWindowLayout(wp);
// saving data & stuff
theApp.knownfiles->Save();
transferwnd.downloadlistctrl.SaveSettings(CPreferences::tableDownload);
transferwnd.uploadlistctrl.SaveSettings(CPreferences::tableUpload);
transferwnd.queuelistctrl.SaveSettings(CPreferences::tableQueue);
transferwnd.clientlistctrl.SaveSettings(CPreferences::tableClientList);
searchwnd.searchlistctrl.SaveSettings(CPreferences::tableSearch);
sharedfileswnd.sharedfilesctrl.SaveSettings(CPreferences::tableShared);
serverwnd.serverlistctrl.SaveSettings(CPreferences::tableServer);
theApp.glob_prefs->Add2TotalDownloaded(theApp.stat_sessionReceivedBytes);
theApp.glob_prefs->Add2TotalUploaded(theApp.stat_sessionSentBytes);
theApp.glob_prefs->Save();
// Barry - Restore old registry if required
if (theApp.glob_prefs->AutoTakeED2KLinks())
RevertReg();
transferwnd.downloadlistctrl.DeleteAllItems();
chatwnd.chatselector.DeleteAllItems();
theApp.clientlist->DeleteAll();
searchwnd.searchlistctrl.DeleteAllItems();
delete theApp.listensocket;
delete theApp.clientudp;
delete theApp.sharedfiles;
delete theApp.serverconnect;
delete theApp.serverlist;
delete theApp.knownfiles;
delete theApp.searchlist;
delete theApp.clientcredits;
delete theApp.downloadqueue;
delete theApp.uploadqueue;
delete theApp.clientlist;
delete theApp.friendlist;
// delete theApp.scheduler;
delete theApp.ipfilter;
delete theApp.webserver;
delete theApp.glob_prefs;
m_app_state = APP_STATE_DONE;
CTrayDialog::OnCancel();
}
void CemuleDlg::OnTrayRButtonDown(CPoint pt){
if (trayPopup) return;
trayPopup.CreatePopupMenu();
UINT flagsC;
UINT flagsD;
// set connect/disconnect to enabled and disabled
if (!theApp.serverconnect->IsConnected()) {
flagsD=MF_STRING || MF_DISABLED; flagsC=MF_STRING;
} else {
flagsC=MF_STRING || MF_DISABLED; flagsD=MF_STRING;
}
trayPopup.AddMenuTitle((CString)"eMule v"+(CString)CURRENT_VERSION_LONG);
trayPopup.AppendMenu( MF_STRING ,MP_RESTORE, GetResString(IDS_MAIN_POPUP_RESTORE) );
trayPopup.SetDefaultItem(MP_RESTORE);
trayPopup.AppendMenu(MF_SEPARATOR);
/*
// Show QuickSpeedOthers
if ((theApp.glob_prefs->GetMaxDownload() == 1) && (theApp.glob_prefs->GetMaxUpload() == 1)) {
trayPopup.AppendMenu(MF_STRING, MP_QS_UA, GetResString(IDS_PW_UA));
} else {
trayPopup.AppendMenu(MF_STRING, MP_QS_PA, GetResString(IDS_PW_PA));
};
trayPopup.AppendMenu(MF_SEPARATOR);
*/
//AddSpeedSelector(&trayPopup);
CTitleMenu trayUploadPopup;
CTitleMenu trayDownloadPopup;
CString text;
// creating UploadPopup Menu
trayUploadPopup.CreateMenu();
trayUploadPopup.AddMenuTitle(GetResString(IDS_PW_TIT_UP));
text.Format("20%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()*0.2),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U20, text);
text.Format("40%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()*0.4),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U40, text);
text.Format("60%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()*0.6),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U60, text);
text.Format("80%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()*0.8),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U80, text);
text.Format("100%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U100, text);
trayUploadPopup.AppendMenu(MF_SEPARATOR);
if (GetRecMaxUpload()>0) {
text.Format(GetResString(IDS_PW_MINREC)+GetResString(IDS_KBYTESEC),GetRecMaxUpload());
trayUploadPopup.AppendMenu(MF_STRING, MP_QS_UP10,text );
}
trayUploadPopup.AppendMenu(MF_STRING, MP_QS_UPC, GetResString(IDS_PW_UNLIMITED));
// creating DownloadPopup Menu
trayDownloadPopup.CreateMenu();
trayDownloadPopup.AddMenuTitle(GetResString(IDS_PW_TIT_DOWN));
text.Format("20%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()*0.2),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D20, text);
text.Format("40%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()*0.4),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D40, text);
text.Format("60%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()*0.6),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D60, text);
text.Format("80%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()*0.8),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D80, text);
text.Format("100%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D100, text);
trayDownloadPopup.AppendMenu(MF_SEPARATOR);
trayDownloadPopup.AppendMenu(MF_STRING, MP_QS_DC, GetResString(IDS_PW_UNLIMITED));
// Show UploadPopup Menu
if(theApp.glob_prefs->GetMaxUpload()==UNLIMITED)
text.Format("%s:\t%s (%i %s)", GetResString(IDS_PW_UPL),GetResString(IDS_PW_UNLIMITED), theApp.glob_prefs->GetMaxGraphUploadRate(),GetResString(IDS_KBYTESEC));
else
text.Format("%s:\t%i %s (%i %s)", GetResString(IDS_PW_UPL), theApp.glob_prefs->GetMaxUpload(),GetResString(IDS_KBYTESEC) ,theApp.glob_prefs->GetMaxGraphUploadRate(),GetResString(IDS_KBYTESEC));
trayPopup.AppendMenu(MF_STRING|MF_POPUP, (UINT_PTR)trayUploadPopup.m_hMenu, text);
// Show DownloadPopup Menu
if(theApp.glob_prefs->GetMaxDownload()==UNLIMITED)
text.Format("%s:\t%s (%i %s)", GetResString(IDS_PW_DOWNL),GetResString(IDS_PW_UNLIMITED), theApp.glob_prefs->GetMaxGraphDownloadRate(),GetResString(IDS_KBYTESEC));
else
text.Format("%s:\t%i %s (%i %s)", GetResString(IDS_PW_DOWNL), theApp.glob_prefs->GetMaxDownload(),GetResString(IDS_KBYTESEC), theApp.glob_prefs->GetMaxGraphDownloadRate(),GetResString(IDS_KBYTESEC));
trayPopup.AppendMenu(MF_STRING|MF_POPUP, (UINT_PTR)trayDownloadPopup.m_hMenu, text);
trayPopup.AppendMenu(MF_SEPARATOR);
trayPopup.AppendMenu(flagsC,MP_CONNECT, GetResString(IDS_CONNECTTOANYSERVER));
trayPopup.AppendMenu(flagsD ,MP_DISCONNECT, GetResString(IDS_MAIN_BTN_DISCONNECT));
trayPopup.AppendMenu(MF_STRING,MP_EXIT, GetResString(IDS_EXIT));
SetForegroundWindow();
trayPopup.TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, pt.x, pt.y, this);
PostMessage(WM_NULL, 0, 0);
trayPopup.DestroyMenu();
}
void CemuleDlg::AddSpeedSelectorSys(CMenu* addToMenu)
{
CMenu trayUploadPopup;
CMenu trayDownloadPopup;
CString text;
// creating UploadPopup Menu
trayUploadPopup.CreateMenu();
//trayUploadPopup.AddMenuTitle(GetResString(IDS_PW_TIT_UP));
text.Format("20%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()*0.2),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U20, text);
text.Format("40%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()*0.4),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U40, text);
text.Format("60%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()*0.6),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U60, text);
text.Format("80%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()*0.8),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U80, text);
text.Format("100%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphUploadRate()),GetResString(IDS_KBYTESEC)); trayUploadPopup.AppendMenu(MF_STRING, MP_QS_U100, text);
trayUploadPopup.AppendMenu(MF_SEPARATOR);
if (GetRecMaxUpload()>0) {
text.Format(GetResString(IDS_PW_MINREC)+GetResString(IDS_KBYTESEC),GetRecMaxUpload());
trayUploadPopup.AppendMenu(MF_STRING, MP_QS_UP10, text );
}
trayUploadPopup.AppendMenu(MF_STRING, MP_QS_UPC, GetResString(IDS_PW_UNLIMITED));
// creating DownloadPopup Menu
trayDownloadPopup.CreateMenu();
//trayDownloadPopup.AddMenuTitle(GetResString(IDS_PW_TIT_DOWN));
text.Format("20%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()*0.2),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D20, text);
text.Format("40%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()*0.4),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D40, text);
text.Format("60%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()*0.6),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D60, text);
text.Format("80%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()*0.8),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D80, text);
text.Format("100%%\t%i %s", (uint16)(theApp.glob_prefs->GetMaxGraphDownloadRate()),GetResString(IDS_KBYTESEC)); trayDownloadPopup.AppendMenu(MF_STRING|MF_POPUP, MP_QS_D100, text);
trayDownloadPopup.AppendMenu(MF_SEPARATOR);
trayDownloadPopup.AppendMenu(MF_STRING, MP_QS_DC, GetResString(IDS_PW_UNLIMITED));
// Show UploadPopup Menu
text.Format("%s:", GetResString(IDS_PW_UPL));
addToMenu->AppendMenu(MF_STRING|MF_POPUP, (UINT_PTR)trayUploadPopup.m_hMenu, text);
// Show DownloadPopup Menu
text.Format("%s:", GetResString(IDS_PW_DOWNL));
addToMenu->AppendMenu(MF_STRING|MF_POPUP, (UINT_PTR)trayDownloadPopup.m_hMenu, text);
addToMenu->AppendMenu(MF_SEPARATOR);
//////////////////////////
}
void CemuleDlg::StartConnection(){
AddLogLine(true, GetResString(IDS_CONNECTING));
if ( serverwnd.serverlistctrl.GetSelectedCount()>1 )
{
serverwnd.serverlistctrl.PostMessage(WM_COMMAND,MP_CONNECTTO,0L);
}
else
{
theApp.serverconnect->ConnectToAnyServer();
}
ShowConnectionState(false);
}
void CemuleDlg::CloseConnection(){
theApp.serverconnect->Disconnect();
theApp.OnlineSig(); // Added By Bouc7
}
void CemuleDlg::RestoreWindow(){
if (TrayIsVisible())
TrayHide();
ShowWindow(SW_SHOW);
}
void CemuleDlg::ShowStatistics() {
statisticswnd.ShowStatistics();
}
void CemuleDlg::UpdateTrayIcon(int procent)
{
//HICON mytrayIcon;
//if (mytrayIcon!=NULL) DestroyIcon(mytrayIcon);
// set the limits of where the bar color changes (low-high)
int pLimits16[1] = {100};
// set the corresponding color for each level
COLORREF pColors16[1] = {theApp.glob_prefs->GetStatsColor(11)};
// start it up
if (theApp.serverconnect->IsConnected())
trayIcon.Init(sourceTrayIcon,100,1,1,16,16,theApp.glob_prefs->GetStatsColor(11));
else trayIcon.Init(sourceTrayIconGrey,100,1,1,16,16,theApp.glob_prefs->GetStatsColor(11));
// load our limit and color info
trayIcon.SetColorLevels(pLimits16,pColors16,1);
// generate the icon (destroy these icon using DestroyIcon())
int pVals16[1] = {procent};
mytrayIcon = trayIcon.Create(pVals16);
ASSERT (mytrayIcon != NULL);
if (mytrayIcon)
TraySetIcon(mytrayIcon,true);
TrayUpdate();
}
int CemuleDlg::OnCreate(LPCREATESTRUCT lpCreateStruct){
CTrayDialog::OnCreate(lpCreateStruct);
/*if (theApp.glob_prefs->UseSplashScreen()){
ModifyStyleEx(0,WS_EX_LAYERED);
SetLayeredWindowAttributes(0, 0, LWA_ALPHA);
}*/
return 0;
}
//START - enkeyDEV(kei-kun) -TaskbarNotifier-
void CemuleDlg::ShowNotifier(CString Text, int MsgType, bool ForceSoundOFF) {
if (!notifierenabled) return;
bool ShowIt = false;
switch(MsgType) {
case TBN_CHAT:
if (theApp.glob_prefs->GetUseChatNotifier()) {
m_wndTaskbarNotifier.Show(Text, MsgType);
ShowIt = true;
}
break;
case TBN_DLOAD:
if (theApp.glob_prefs->GetUseDownloadNotifier()) {
m_wndTaskbarNotifier.Show(Text, MsgType);
ShowIt = true;
}
break;
case TBN_LOG:
if (theApp.glob_prefs->GetUseLogNotifier()) {
m_wndTaskbarNotifier.Show(Text, MsgType);
ShowIt = true;
}
break;
case TBN_IMPORTANTEVENT:
if (theApp.glob_prefs->GetNotifierPopOnImportantError()) {
m_wndTaskbarNotifier.Show(Text, MsgType);
ShowIt = true;
}
break; // added by InterCeptor (bugfix) 27.11.02
case TBN_NEWVERSION:
if (theApp.glob_prefs->GetNotifierPopOnNewVersion()) {
m_wndTaskbarNotifier.Show(Text, MsgType);
ShowIt = true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -