From 13983526945d58b0bc1123619a795cf1e6b80aba Mon Sep 17 00:00:00 2001 From: irwir Date: Fri, 16 Aug 2024 13:51:41 +0300 Subject: [PATCH] Added TLS 1.3 support PeerCache removed Redesigned Options->Directories and UNC shares handling A few minor changes and fixed regressions. --- srchybrid/AICHSyncThread.cpp | 112 +- srchybrid/AICHSyncThread.h | 5 +- srchybrid/AbstractFile.cpp | 4 +- srchybrid/AbstractFile.h | 4 +- srchybrid/AddFriend.cpp | 2 +- srchybrid/AddFriend.h | 3 +- srchybrid/AddSourceDlg.cpp | 2 +- srchybrid/AddSourceDlg.h | 3 +- srchybrid/ArchivePreviewDlg.cpp | 2 +- srchybrid/ArchivePreviewDlg.h | 3 +- srchybrid/ArchiveRecovery.cpp | 48 +- srchybrid/ArchiveRecovery.h | 2 +- srchybrid/AsyncProxySocketLayer.cpp | 8 +- srchybrid/AsyncProxySocketLayer.h | 4 +- srchybrid/AsyncSocketEx.cpp | 39 +- srchybrid/AsyncSocketEx.h | 33 +- srchybrid/AsyncSocketExLayer.cpp | 11 +- srchybrid/AsyncSocketExLayer.h | 8 +- srchybrid/BarShader.cpp | 4 +- srchybrid/BarShader.h | 2 +- srchybrid/BaseClient.cpp | 126 +- srchybrid/BuddyButton.cpp | 9 +- srchybrid/ButtonsTabCtrl.cpp | 3 +- srchybrid/CaptchaGenerator.cpp | 3 +- srchybrid/CaptchaGenerator.h | 3 +- srchybrid/CatDialog.cpp | 2 +- srchybrid/ChatSelector.cpp | 159 ++- srchybrid/ChatSelector.h | 2 +- srchybrid/ChatWnd.cpp | 14 +- srchybrid/ChatWnd.h | 2 +- srchybrid/ClientCredits.cpp | 61 +- srchybrid/ClientCredits.h | 2 +- srchybrid/ClientDetailDialog.cpp | 6 +- srchybrid/ClientDetailDialog.h | 2 +- srchybrid/ClientList.cpp | 4 +- srchybrid/ClientList.h | 2 +- srchybrid/ClientListCtrl.cpp | 2 +- srchybrid/ClientListCtrl.h | 2 +- srchybrid/ClientStateDefs.h | 17 +- srchybrid/ClientUDPSocket.cpp | 32 +- srchybrid/ClientUDPSocket.h | 2 +- srchybrid/ClientVersionInfo.h | 153 --- srchybrid/ClosableTabCtrl.cpp | 3 +- srchybrid/Collection.cpp | 21 +- srchybrid/Collection.h | 4 +- srchybrid/CollectionCreateDialog.cpp | 2 +- srchybrid/CollectionCreateDialog.h | 2 +- srchybrid/CollectionFile.cpp | 7 +- srchybrid/CollectionFile.h | 3 +- srchybrid/CollectionListCtrl.cpp | 2 +- srchybrid/CollectionListCtrl.h | 3 +- srchybrid/CollectionViewDialog.cpp | 2 +- srchybrid/CollectionViewDialog.h | 2 +- srchybrid/ColorButton.h | 2 +- srchybrid/ColourPopup.cpp | 24 +- srchybrid/ColourPopup.h | 2 +- srchybrid/ComboBoxEx2.cpp | 4 +- srchybrid/CommentDialog.cpp | 2 +- srchybrid/CommentDialogLst.cpp | 2 +- srchybrid/CommentListCtrl.cpp | 2 +- srchybrid/CommentListCtrl.h | 2 +- srchybrid/CorruptionBlackBox.cpp | 2 +- srchybrid/CorruptionBlackBox.h | 3 +- srchybrid/CreditsThread.cpp | 4 +- srchybrid/CustomAutoComplete.cpp | 2 +- srchybrid/DeadSourceList.cpp | 2 +- srchybrid/DeadSourceList.h | 3 +- srchybrid/Debug_FileSize.h | 2 +- srchybrid/DirectDownloadDlg.cpp | 2 +- srchybrid/DirectDownloadDlg.h | 2 +- srchybrid/DirectoryTreeCtrl.cpp | 204 ++-- srchybrid/DirectoryTreeCtrl.h | 12 +- srchybrid/DownloadClient.cpp | 113 +- srchybrid/DownloadClientsCtrl.cpp | 2 +- srchybrid/DownloadClientsCtrl.h | 2 +- srchybrid/DownloadListCtrl.cpp | 13 +- srchybrid/DownloadListCtrl.h | 2 +- srchybrid/DownloadQueue.cpp | 48 +- srchybrid/DownloadQueue.h | 2 +- srchybrid/DropDownButton.cpp | 4 +- srchybrid/DropDownButton.h | 4 +- srchybrid/DropTarget.cpp | 2 +- srchybrid/ED2KLink.cpp | 4 +- srchybrid/ED2KLink.h | 2 +- srchybrid/ED2kLinkDlg.cpp | 28 +- srchybrid/ED2kLinkDlg.h | 3 +- srchybrid/EMSocket.cpp | 128 +- srchybrid/EMSocket.h | 38 +- srchybrid/EditDelayed.cpp | 26 +- srchybrid/EditDelayed.h | 3 +- srchybrid/EditX.cpp | 2 +- srchybrid/Emule.cpp | 70 +- srchybrid/Emule.h | 11 +- srchybrid/EmuleDlg.cpp | 216 ++-- srchybrid/EmuleDlg.h | 45 +- srchybrid/EnBitmap.cpp | 6 +- srchybrid/EncryptedDatagramSocket.cpp | 11 +- srchybrid/EncryptedDatagramSocket.h | 2 +- srchybrid/EncryptedStreamSocket.cpp | 15 +- srchybrid/EncryptedStreamSocket.h | 25 +- srchybrid/Exceptions.h | 4 +- srchybrid/ExitBox.cpp | 2 +- srchybrid/ExitBox.h | 2 +- srchybrid/FileDetailDialog.cpp | 2 +- srchybrid/FileDetailDialog.h | 2 +- srchybrid/FileDetailDialogInfo.cpp | 2 +- srchybrid/FileDetailDialogName.cpp | 2 +- srchybrid/FileDetailDlgStatistics.cpp | 2 +- srchybrid/FileDetailDlgStatistics.h | 2 +- srchybrid/FileIdentifier.cpp | 4 +- srchybrid/FileIdentifier.h | 2 +- srchybrid/FileInfoDialog.cpp | 24 +- srchybrid/FirewallOpener.cpp | 2 +- srchybrid/FirewallOpener.h | 2 +- srchybrid/FrameGrabThread.cpp | 2 +- srchybrid/FrameGrabThread.h | 2 +- srchybrid/Friend.cpp | 2 +- srchybrid/Friend.h | 2 +- srchybrid/FriendList.cpp | 59 +- srchybrid/FriendList.h | 2 +- srchybrid/FriendListCtrl.cpp | 2 +- srchybrid/FriendListCtrl.h | 2 +- srchybrid/GDIThread.cpp | 2 +- srchybrid/GZipFile.cpp | 2 +- srchybrid/GZipFile.h | 2 +- srchybrid/HTRichEditCtrl.cpp | 10 +- srchybrid/HighColorTab.hpp | 5 +- srchybrid/HttpClientReqSocket.cpp | 8 +- srchybrid/HttpClientReqSocket.h | 2 +- srchybrid/HttpDownloadDlg.cpp | 6 +- srchybrid/HttpDownloadDlg.h | 2 +- srchybrid/I18n.cpp | 4 +- srchybrid/IESecurity.cpp | 14 +- srchybrid/IPFilter.cpp | 6 +- srchybrid/IPFilter.h | 2 +- srchybrid/IPFilterDlg.cpp | 6 +- srchybrid/IPFilterDlg.h | 2 +- srchybrid/IconStatic.cpp | 6 +- srchybrid/Ini2.h | 12 +- srchybrid/InputBox.cpp | 2 +- srchybrid/InputBox.h | 2 +- srchybrid/IrcChannelListCtrl.cpp | 3 +- srchybrid/IrcChannelListCtrl.h | 2 +- srchybrid/IrcChannelTabCtrl.cpp | 143 ++- srchybrid/IrcChannelTabCtrl.h | 4 +- srchybrid/IrcMain.cpp | 4 +- srchybrid/IrcMain.h | 1 - srchybrid/IrcNickListCtrl.cpp | 26 +- srchybrid/IrcNickListCtrl.h | 3 +- srchybrid/IrcSocket.cpp | 2 +- srchybrid/IrcSocket.h | 1 - srchybrid/IrcWnd.cpp | 30 +- srchybrid/IrcWnd.h | 13 +- srchybrid/KadContactHistogramCtrl.cpp | 2 +- srchybrid/KadContactListCtrl.cpp | 2 +- srchybrid/KadContactListCtrl.h | 2 +- srchybrid/KadLookupGraph.cpp | 99 +- srchybrid/KadLookupGraph.h | 5 +- srchybrid/KadSearchListCtrl.cpp | 2 +- srchybrid/KadSearchListCtrl.h | 2 +- srchybrid/KademliaWnd.cpp | 2 +- srchybrid/KnownFile.cpp | 42 +- srchybrid/KnownFile.h | 2 +- srchybrid/KnownFileList.cpp | 152 +-- srchybrid/KnownFileList.h | 4 +- srchybrid/LastCommonRouteFinder.cpp | 2 +- srchybrid/LastCommonRouteFinder.h | 2 +- srchybrid/LayeredWindowHelperST.cpp | 5 +- srchybrid/ListBoxST.cpp | 2 +- srchybrid/ListCtrlX.cpp | 56 +- srchybrid/ListViewSearchDlg.cpp | 3 +- srchybrid/ListViewWalkerPropertySheet.cpp | 2 +- srchybrid/ListenSocket.cpp | 119 +- srchybrid/ListenSocket.h | 5 +- srchybrid/Log.cpp | 2 +- srchybrid/MapKey.h | 3 +- srchybrid/Mdump.cpp | 82 +- srchybrid/MediaInfo.cpp | 27 +- srchybrid/MediaInfo.h | 2 +- srchybrid/MenuCmds.h | 4 +- srchybrid/MetaDataDlg.cpp | 2 +- srchybrid/MeterIcon.cpp | 2 +- srchybrid/MeterIcon.h | 2 +- srchybrid/MiniMule.cpp | 2 +- srchybrid/MiniMule.h | 2 +- srchybrid/MuleListCtrl.cpp | 45 +- srchybrid/MuleListCtrl.h | 49 +- srchybrid/MuleStatusBarCtrl.cpp | 2 +- srchybrid/MuleToolBarCtrl.cpp | 12 +- srchybrid/MuleToolBarCtrl.h | 2 +- srchybrid/NetworkInfoDlg.cpp | 4 +- srchybrid/OScopeCtrl.cpp | 4 +- srchybrid/OScopeCtrl.h | 2 +- srchybrid/Opcodes.h | 37 +- srchybrid/OtherFunctions.cpp | 94 +- srchybrid/OtherFunctions.h | 11 +- srchybrid/PPgConnection.cpp | 2 +- srchybrid/PPgDebug.cpp | 2 +- srchybrid/PPgDirectories.cpp | 37 +- srchybrid/PPgDirectories.h | 3 - srchybrid/PPgDisplay.cpp | 2 +- srchybrid/PPgFiles.cpp | 2 +- srchybrid/PPgGeneral.cpp | 4 +- srchybrid/PPgIRC.cpp | 2 +- srchybrid/PPgMessages.cpp | 2 +- srchybrid/PPgMessages.h | 3 +- srchybrid/PPgNotify.cpp | 10 +- srchybrid/PPgNotify.h | 2 +- srchybrid/PPgProxy.cpp | 6 +- srchybrid/PPgScheduler.cpp | 2 +- srchybrid/PPgSecurity.cpp | 49 +- srchybrid/PPgServer.cpp | 2 +- srchybrid/PPgStats.cpp | 2 +- srchybrid/PPgTweaks.cpp | 9 +- srchybrid/PPgWebServer.cpp | 109 +- srchybrid/PShtWiz1.cpp | 4 +- srchybrid/Packets.cpp | 3 +- srchybrid/Packets.h | 2 +- srchybrid/PartFile.cpp | 310 ++--- srchybrid/PartFile.h | 26 +- srchybrid/PartFileConvert.cpp | 12 +- srchybrid/PartFileConvert.h | 2 +- srchybrid/PartFileWriteThread.cpp | 60 +- srchybrid/PartFileWriteThread.h | 8 +- srchybrid/PeerCacheClient.cpp | 1025 ----------------- srchybrid/PeerCacheFinder.cpp | 691 ----------- srchybrid/PeerCacheFinder.h | 140 --- srchybrid/PeerCacheSocket.h | 95 -- srchybrid/PerfLog.cpp | 2 +- srchybrid/Pinger.cpp | 2 +- srchybrid/Pinger.h | 2 +- srchybrid/Preferences.cpp | 113 +- srchybrid/Preferences.h | 58 +- srchybrid/PreferencesDlg.cpp | 2 +- srchybrid/Preview.cpp | 11 +- srchybrid/Preview.h | 2 +- srchybrid/PreviewDlg.cpp | 6 +- srchybrid/PreviewDlg.h | 2 +- srchybrid/Quantize.cpp | 2 +- srchybrid/Quantize.h | 4 +- srchybrid/QueueListCtrl.cpp | 2 +- srchybrid/QueueListCtrl.h | 2 +- srchybrid/RARFile.cpp | 13 +- srchybrid/RARFile.h | 50 +- srchybrid/Resource.h | 12 +- srchybrid/RichEditCtrlX.cpp | 4 +- srchybrid/RichEditStream.cpp | 2 +- srchybrid/SHAHashSet.cpp | 68 +- srchybrid/SHAHashSet.h | 4 +- srchybrid/SMTPdialog.cpp | 2 +- srchybrid/SafeFile.cpp | 2 +- srchybrid/SafeFile.h | 4 +- srchybrid/Scanner.cpp | 13 +- srchybrid/Scanner.l | 2 +- srchybrid/Scheduler.cpp | 36 +- srchybrid/Scheduler.h | 4 +- srchybrid/SearchDlg.cpp | 45 +- srchybrid/SearchDlg.h | 19 +- srchybrid/SearchFile.cpp | 39 +- srchybrid/SearchFile.h | 12 +- srchybrid/SearchList.cpp | 153 ++- srchybrid/SearchList.h | 28 +- srchybrid/SearchListCtrl.cpp | 94 +- srchybrid/SearchListCtrl.h | 3 +- srchybrid/SearchParamsWnd.cpp | 15 +- srchybrid/SearchResultsWnd.cpp | 220 ++-- srchybrid/SearchResultsWnd.h | 8 +- srchybrid/SecRunAsUser.cpp | 2 +- srchybrid/SecRunAsUser.h | 3 +- srchybrid/SendMail.cpp | 116 +- srchybrid/Server.cpp | 2 +- srchybrid/Server.h | 4 +- srchybrid/ServerConnect.cpp | 26 +- srchybrid/ServerConnect.h | 8 +- srchybrid/ServerList.cpp | 210 ++-- srchybrid/ServerList.h | 17 +- srchybrid/ServerListCtrl.cpp | 8 +- srchybrid/ServerSocket.cpp | 62 +- srchybrid/ServerSocket.h | 2 +- srchybrid/ServerWnd.cpp | 63 +- srchybrid/ServerWnd.h | 2 +- srchybrid/ShareableFile.cpp | 2 +- srchybrid/ShareableFile.h | 3 +- srchybrid/SharedDirsTreeCtrl.cpp | 26 +- srchybrid/SharedDirsTreeCtrl.h | 5 +- srchybrid/SharedFileList.cpp | 48 +- srchybrid/SharedFileList.h | 4 +- srchybrid/SharedFilesCtrl.cpp | 5 +- srchybrid/SharedFilesCtrl.h | 2 +- srchybrid/SharedFilesWnd.cpp | 10 +- srchybrid/SharedFilesWnd.h | 2 +- srchybrid/SmileySelector.cpp | 8 +- srchybrid/SmileySelector.h | 4 +- srchybrid/SplashScreen.cpp | 4 +- srchybrid/SplitterControl.cpp | 4 +- srchybrid/SplitterControl.h | 2 +- srchybrid/StatisticFile.cpp | 2 +- srchybrid/StatisticFile.h | 2 +- srchybrid/Statistics.cpp | 2 +- srchybrid/Statistics.h | 4 +- srchybrid/StatisticsDlg.cpp | 66 +- srchybrid/StatisticsDlg.h | 14 +- srchybrid/StringConversion.cpp | 2 +- srchybrid/StringConversion.h | 2 +- srchybrid/TabCtrl.cpp | 16 +- srchybrid/TaskbarNotifier.cpp | 2 +- srchybrid/TaskbarNotifier.h | 2 +- srchybrid/TextToSpeech.cpp | 2 +- srchybrid/TextToSpeech.h | 2 +- srchybrid/TitleMenu.cpp | 10 +- srchybrid/ToolBarCtrlX.cpp | 2 +- srchybrid/ToolBarCtrlX.h | 2 +- srchybrid/ToolTipCtrlX.cpp | 2 +- srchybrid/ToolTipCtrlX.h | 2 +- srchybrid/ToolbarWnd.cpp | 5 +- srchybrid/ToolbarWnd.h | 3 +- srchybrid/TransferDlg.cpp | 24 +- srchybrid/TransferDlg.h | 5 +- srchybrid/TransferWnd.cpp | 19 +- srchybrid/TransferWnd.h | 2 +- srchybrid/TrayDialog.cpp | 4 +- srchybrid/TreeOptionsCtrl.h | 26 +- srchybrid/TreeOptionsCtrlEx.cpp | 2 +- srchybrid/TreePropSheet.cpp | 1 - srchybrid/TreePropSheet.h | 2 +- srchybrid/UDPSocket.cpp | 41 +- srchybrid/UDPSocket.h | 2 +- srchybrid/UPnPImpl.cpp | 9 +- srchybrid/UPnPImpl.h | 63 +- srchybrid/UPnPImplMiniLib.cpp | 33 +- srchybrid/UPnPImplMiniLib.h | 10 +- srchybrid/UPnPImplWinServ.cpp | 3 +- srchybrid/UPnPImplWinServ.h | 3 +- srchybrid/UPnPImplWrapper.cpp | 3 +- srchybrid/UPnPImplWrapper.h | 3 +- srchybrid/URLClient.cpp | 26 +- srchybrid/URLClient.h | 2 +- srchybrid/UpdownClient.h | 113 +- srchybrid/UploadBandwidthThrottler.cpp | 18 +- srchybrid/UploadBandwidthThrottler.h | 4 +- srchybrid/UploadClient.cpp | 36 +- srchybrid/UploadDiskIOThread.cpp | 131 +-- srchybrid/UploadDiskIOThread.h | 11 +- srchybrid/UploadListCtrl.cpp | 2 +- srchybrid/UploadListCtrl.h | 2 +- srchybrid/UploadQueue.cpp | 90 +- srchybrid/UploadQueue.h | 3 +- srchybrid/UserMsgs.h | 2 +- srchybrid/Version.cpp | 2 +- srchybrid/Version.h | 4 +- srchybrid/VisualStylesXP.h | 2 +- srchybrid/WebServer.cpp | 10 +- srchybrid/WebSocket.cpp | 74 +- srchybrid/WebSocket.h | 1 - srchybrid/Wizard.cpp | 2 +- srchybrid/emule.rc | 31 +- srchybrid/emule.sln | 2 +- srchybrid/emule.vcxproj | 31 +- srchybrid/emule_site_config.h | 8 +- srchybrid/kademlia/io/DataIO.cpp | 4 +- srchybrid/kademlia/io/IOException.cpp | 3 +- srchybrid/kademlia/io/IOException.h | 4 +- srchybrid/kademlia/kademlia/Entry.cpp | 22 +- srchybrid/kademlia/kademlia/Entry.h | 1 - srchybrid/kademlia/kademlia/Indexed.cpp | 12 +- srchybrid/kademlia/kademlia/Kademlia.cpp | 10 +- srchybrid/kademlia/kademlia/Kademlia.h | 2 +- srchybrid/kademlia/kademlia/Prefs.cpp | 32 +- srchybrid/kademlia/kademlia/Search.cpp | 18 +- srchybrid/kademlia/kademlia/Search.h | 20 +- srchybrid/kademlia/kademlia/SearchManager.cpp | 23 +- srchybrid/kademlia/kademlia/Tag.h | 2 +- .../kademlia/kademlia/UDPFirewallTester.cpp | 3 +- .../kademlia/kademlia/UDPFirewallTester.h | 3 +- .../kademlia/net/KademliaUDPListener.cpp | 14 +- srchybrid/kademlia/net/PacketTracking.cpp | 3 +- srchybrid/kademlia/net/PacketTracking.h | 3 +- srchybrid/kademlia/routing/Contact.cpp | 169 +-- srchybrid/kademlia/routing/Contact.h | 60 +- srchybrid/kademlia/routing/RoutingBin.cpp | 13 +- srchybrid/kademlia/routing/RoutingZone.cpp | 367 +++--- srchybrid/kademlia/routing/RoutingZone.h | 4 +- srchybrid/kademlia/utils/KadClientSearcher.h | 3 +- srchybrid/kademlia/utils/KadUDPKey.h | 3 +- srchybrid/kademlia/utils/LookupHistory.cpp | 3 +- srchybrid/kademlia/utils/LookupHistory.h | 3 +- srchybrid/lang/ar_AE.rc | 8 +- srchybrid/lang/ar_AE.vcxproj | 2 +- srchybrid/lang/ba_BA.rc | 8 +- srchybrid/lang/ba_BA.vcxproj | 2 +- srchybrid/lang/bg_BG.rc | 8 +- srchybrid/lang/bg_BG.vcxproj | 2 +- srchybrid/lang/ca_ES.rc | 8 +- srchybrid/lang/ca_ES.vcxproj | 2 +- srchybrid/lang/cz_CZ.rc | 8 +- srchybrid/lang/cz_CZ.vcxproj | 2 +- srchybrid/lang/da_DK.rc | 8 +- srchybrid/lang/da_DK.vcxproj | 2 +- srchybrid/lang/de_DE.rc | 8 +- srchybrid/lang/de_DE.vcxproj | 2 +- srchybrid/lang/el_GR.rc | 8 +- srchybrid/lang/el_GR.vcxproj | 2 +- srchybrid/lang/es_AS.rc | 8 +- srchybrid/lang/es_AS.vcxproj | 2 +- srchybrid/lang/es_ES_T.rc | 8 +- srchybrid/lang/es_ES_T.vcxproj | 2 +- srchybrid/lang/et_EE.rc | 8 +- srchybrid/lang/et_EE.vcxproj | 2 +- srchybrid/lang/fa_IR.rc | 8 +- srchybrid/lang/fa_IR.vcxproj | 2 +- srchybrid/lang/fi_FI.rc | 8 +- srchybrid/lang/fi_FI.vcxproj | 2 +- srchybrid/lang/fr_BR.rc | 8 +- srchybrid/lang/fr_BR.vcxproj | 2 +- srchybrid/lang/fr_FR.rc | 8 +- srchybrid/lang/fr_FR.vcxproj | 2 +- srchybrid/lang/gl_ES.rc | 8 +- srchybrid/lang/gl_ES.vcxproj | 2 +- srchybrid/lang/he_IL.rc | 8 +- srchybrid/lang/he_IL.vcxproj | 2 +- srchybrid/lang/hu_HU.rc | 8 +- srchybrid/lang/hu_HU.vcxproj | 2 +- srchybrid/lang/it_IT.rc | 8 +- srchybrid/lang/it_IT.vcxproj | 2 +- srchybrid/lang/jp_JP.rc | 8 +- srchybrid/lang/jp_JP.vcxproj | 2 +- srchybrid/lang/ko_KR.rc | 8 +- srchybrid/lang/ko_KR.vcxproj | 2 +- srchybrid/lang/lang.rc2 | 2 +- srchybrid/lang/lt_LT.rc | 8 +- srchybrid/lang/lt_LT.vcxproj | 2 +- srchybrid/lang/lv_LV.rc | 8 +- srchybrid/lang/lv_LV.vcxproj | 2 +- srchybrid/lang/mt_MT.rc | 8 +- srchybrid/lang/mt_MT.vcxproj | 2 +- srchybrid/lang/nb_NO.rc | 8 +- srchybrid/lang/nb_NO.vcxproj | 2 +- srchybrid/lang/nl_NL.rc | 8 +- srchybrid/lang/nl_NL.vcxproj | 2 +- srchybrid/lang/nn_NO.rc | 8 +- srchybrid/lang/nn_NO.vcxproj | 2 +- srchybrid/lang/pl_PL.rc | 8 +- srchybrid/lang/pl_PL.vcxproj | 2 +- srchybrid/lang/pt_BR.rc | 8 +- srchybrid/lang/pt_BR.vcxproj | 2 +- srchybrid/lang/pt_PT.rc | 8 +- srchybrid/lang/pt_PT.vcxproj | 2 +- srchybrid/lang/ro_RO.rc | 8 +- srchybrid/lang/ro_RO.vcxproj | 2 +- srchybrid/lang/ru_RU.rc | 8 +- srchybrid/lang/ru_RU.vcxproj | 2 +- srchybrid/lang/sl_SI.rc | 8 +- srchybrid/lang/sl_SI.vcxproj | 2 +- srchybrid/lang/sq_AL.rc | 8 +- srchybrid/lang/sq_AL.vcxproj | 2 +- srchybrid/lang/sv_SE.rc | 8 +- srchybrid/lang/sv_SE.vcxproj | 2 +- srchybrid/lang/tr_TR.rc | 8 +- srchybrid/lang/tr_TR.vcxproj | 2 +- srchybrid/lang/ua_UA.rc | 8 +- srchybrid/lang/ua_UA.vcxproj | 2 +- srchybrid/lang/ug_CN.rc | 8 +- srchybrid/lang/ug_CN.vcxproj | 2 +- srchybrid/lang/va_ES.rc | 8 +- srchybrid/lang/va_ES.vcxproj | 2 +- srchybrid/lang/va_ES_RACV.rc | 8 +- srchybrid/lang/va_ES_RACV.vcxproj | 2 +- srchybrid/lang/vi_VN.rc | 8 +- srchybrid/lang/vi_VN.vcxproj | 2 +- srchybrid/lang/zh_CN.rc | 8 +- srchybrid/lang/zh_CN.vcxproj | 2 +- srchybrid/lang/zh_TW.rc | 8 +- srchybrid/lang/zh_TW.vcxproj | 2 +- srchybrid/res/emule.rc2 | 2 +- srchybrid/res/emuleWin32.manifest | 2 +- srchybrid/res/emulex64.manifest | 2 +- 476 files changed, 3383 insertions(+), 6630 deletions(-) delete mode 100644 srchybrid/ClientVersionInfo.h delete mode 100644 srchybrid/PeerCacheClient.cpp delete mode 100644 srchybrid/PeerCacheFinder.cpp delete mode 100644 srchybrid/PeerCacheFinder.h delete mode 100644 srchybrid/PeerCacheSocket.h diff --git a/srchybrid/AICHSyncThread.cpp b/srchybrid/AICHSyncThread.cpp index 774bb145..12f0524c 100644 --- a/srchybrid/AICHSyncThread.cpp +++ b/srchybrid/AICHSyncThread.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -53,24 +53,19 @@ int CAICHSyncThread::Run() // we collect all masterhashes which we find in the known2.met and store them in a list CArray aKnown2Hashes; CArray aKnown2HashesFilePos; - const CString &fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + KNOWN2_MET_FILENAME); CSafeFile file; - // we need to keep a lock on this file while the thread is running CSingleLock lockKnown2Met(&CAICHRecoveryHashSet::m_mutKnown2File, TRUE); - bool bJustCreated = ConvertToKnown2ToKnown264(&file); - - CFileException fexp; - if (!bJustCreated && !file.Open(fullpath, CFile::modeCreate | CFile::modeReadWrite | CFile::modeNoTruncate | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + bool bJustCreated = ConvertKnown2ToKnown264(file); + if (!bJustCreated) { + if (!CFileOpen(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + KNOWN2_MET_FILENAME + , CFile::modeReadWrite | CFile::modeCreate | CFile::modeNoTruncate | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone + , _T("Failed to load ") KNOWN2_MET_FILENAME _T(" file"))) + { + return 0; } - return 0; } uint32 nLastVerifiedPos = 0; try { @@ -94,25 +89,23 @@ int CAICHSyncThread::Run() } } else file.WriteUInt8(KNOWN2_MET_VERSION); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) { + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) { LogError(LOG_STATUSBAR, GetResString(IDS_ERR_MET_BAD), KNOWN2_MET_FILENAME); - // truncate the file to the size to the last verified valid pos + // truncate the file to the last verified valid position try { file.SetLength(nLastVerifiedPos); if (file.GetLength() == 0) { file.SeekToBegin(); file.WriteUInt8(KNOWN2_MET_VERSION); } - } catch (CFileException *error2) { - error2->Delete(); + } catch (CFileException *ex2) { + ex2->Delete(); } - } else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN), buffer); - } - error->Delete(); + } else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN), (LPCTSTR)CExceptionStr(*ex)); + + ex->Delete(); return 0; } @@ -237,16 +230,14 @@ int CAICHSyncThread::Run() , nPurgeCount - nPurgeBecauseOld, nPurgeBecauseOld, (LPCTSTR)CastItoXBytes(posReadPos - posWritePos)); if (nPurgeDups) theApp.QueueDebugLogLine(false, _T("Marked %u duplicate hashsets for purging"), nPurgeDups); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) { + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) { // we just parsed this file some ms ago, should never happen here ASSERT(0); - } else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN), buffer); - } - error->Delete(); + } else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN), (LPCTSTR)CExceptionStr(*ex)); + + ex->Delete(); return 0; } } else { @@ -313,7 +304,7 @@ int CAICHSyncThread::Run() return 0; } -bool CAICHSyncThread::ConvertToKnown2ToKnown264(CSafeFile *pTargetFile) +bool CAICHSyncThread::ConvertKnown2ToKnown264(CSafeFile &TargetFile) { // converting known2.met to known2_64.met to support large files // changing hashcount from uint16 to uint32 @@ -328,34 +319,24 @@ bool CAICHSyncThread::ConvertToKnown2ToKnown264(CSafeFile *pTargetFile) return false; CSafeFile oldfile; - CFileException fexp; - if (!oldfile.Open(oldfullpath, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") OLD_KNOWN2_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } + if (!CFileOpen(oldfile, oldfullpath + , CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone + , _T("Failed to load ") OLD_KNOWN2_MET_FILENAME _T(" file"))) + { // known2.met also doesn't exist, so nothing to convert return false; } - - if (!pTargetFile->Open(newfullpath, CFile::modeCreate | CFile::modeReadWrite | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } + if (!CFileOpen(TargetFile, newfullpath + , CFile::modeReadWrite | CFile::modeCreate | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone + , _T("Failed to load ") KNOWN2_MET_FILENAME _T(" file"))) + { return false; } theApp.QueueLogLine(false, GetResString(IDS_CONVERTINGKNOWN2MET), OLD_KNOWN2_MET_FILENAME, KNOWN2_MET_FILENAME); try { - pTargetFile->WriteUInt8(KNOWN2_MET_VERSION); + TargetFile.WriteUInt8(KNOWN2_MET_VERSION); while (oldfile.GetPosition() < oldfile.GetLength()) { CAICHHash aichHash(oldfile); uint32 nHashCount = oldfile.ReadUInt16(); @@ -364,31 +345,28 @@ bool CAICHSyncThread::ConvertToKnown2ToKnown264(CSafeFile *pTargetFile) BYTE *buffer = new BYTE[nHashCount * (size_t)CAICHHash::GetHashSize()]; oldfile.Read(buffer, nHashCount * CAICHHash::GetHashSize()); - pTargetFile->Write(aichHash.GetRawHash(), CAICHHash::GetHashSize()); - pTargetFile->WriteUInt32(nHashCount); - pTargetFile->Write(buffer, nHashCount * CAICHHash::GetHashSize()); + TargetFile.Write(aichHash.GetRawHash(), CAICHHash::GetHashSize()); + TargetFile.WriteUInt32(nHashCount); + TargetFile.Write(buffer, nHashCount * CAICHHash::GetHashSize()); delete[] buffer; } - pTargetFile->Flush(); + TargetFile.Flush(); oldfile.Close(); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) { + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) { LogError(LOG_STATUSBAR, GetResString(IDS_ERR_MET_BAD), OLD_KNOWN2_MET_FILENAME); ASSERT(0); - } else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN), buffer); - } - error->Delete(); + } else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); theApp.QueueLogLine(false, GetResString(IDS_CONVERTINGKNOWN2FAILED)); - pTargetFile->Close(); + TargetFile.Close(); return false; } theApp.QueueLogLine(false, GetResString(IDS_CONVERTINGKNOWN2DONE)); // FIXME LARGE FILES (uncomment) //::DeleteFile(oldfullpath); - pTargetFile->SeekToBegin(); + TargetFile.SeekToBegin(); return true; } \ No newline at end of file diff --git a/srchybrid/AICHSyncThread.h b/srchybrid/AICHSyncThread.h index b4317886..f2b47969 100644 --- a/srchybrid/AICHSyncThread.h +++ b/srchybrid/AICHSyncThread.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once class CKnownFile; @@ -32,7 +31,7 @@ class CAICHSyncThread : public CWinThread virtual int Run(); protected: - bool ConvertToKnown2ToKnown264(CSafeFile *pTargetFile); + bool ConvertKnown2ToKnown264(CSafeFile &TargetFile); private: CTypedPtrList m_liToHash; diff --git a/srchybrid/AbstractFile.cpp b/srchybrid/AbstractFile.cpp index 043eb57e..7891baf5 100644 --- a/srchybrid/AbstractFile.cpp +++ b/srchybrid/AbstractFile.cpp @@ -1,6 +1,6 @@ // parts of this file are based on work from pan One (http://home-3.tiscali.nl/~meost/pms/) //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -161,7 +161,7 @@ void CAbstractFile::AddTagUnique(CTag *pTag) m_taglist.Add(pTag); } -void CAbstractFile::SetFileName(LPCTSTR pszFileName, bool bReplaceInvalidFileSystemChars, bool bAutoSetFileType, bool bRemoveControlChars) +void CAbstractFile::SetAFileName(LPCTSTR pszFileName, bool bReplaceInvalidFileSystemChars, bool bAutoSetFileType, bool bRemoveControlChars) { m_strFileName = pszFileName; if (bReplaceInvalidFileSystemChars) diff --git a/srchybrid/AbstractFile.h b/srchybrid/AbstractFile.h index 4f7f9aa6..38e733c4 100644 --- a/srchybrid/AbstractFile.h +++ b/srchybrid/AbstractFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -54,7 +54,7 @@ class CAbstractFile: public CObject const CString& GetFileName() const { return m_strFileName; } // 'bReplaceInvalidFileSystemChars' is set to 'false' for backward compatibility! - virtual void SetFileName(LPCTSTR pszFileName, bool bReplaceInvalidFileSystemChars = false, bool bAutoSetFileType = true, bool bRemoveControlChars = false); + virtual void SetAFileName(LPCTSTR pszFileName, bool bReplaceInvalidFileSystemChars = false, bool bAutoSetFileType = true, bool bRemoveControlChars = false); // returns the ED2K file type (an ASCII string) const CString& GetFileType() const { return m_strFileType; } diff --git a/srchybrid/AddFriend.cpp b/srchybrid/AddFriend.cpp index 22ed5528..aff7bb75 100644 --- a/srchybrid/AddFriend.cpp +++ b/srchybrid/AddFriend.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/AddFriend.h b/srchybrid/AddFriend.h index eb88c4e1..f70f8454 100644 --- a/srchybrid/AddFriend.h +++ b/srchybrid/AddFriend.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "Friend.h" diff --git a/srchybrid/AddSourceDlg.cpp b/srchybrid/AddSourceDlg.cpp index cfecc29a..f1437f10 100644 --- a/srchybrid/AddSourceDlg.cpp +++ b/srchybrid/AddSourceDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/AddSourceDlg.h b/srchybrid/AddSourceDlg.h index 3f88f8f3..65e5d4dc 100644 --- a/srchybrid/AddSourceDlg.h +++ b/srchybrid/AddSourceDlg.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "ResizableLib/ResizableDialog.h" diff --git a/srchybrid/ArchivePreviewDlg.cpp b/srchybrid/ArchivePreviewDlg.cpp index b3a00fe2..679acc8c 100644 --- a/srchybrid/ArchivePreviewDlg.cpp +++ b/srchybrid/ArchivePreviewDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ArchivePreviewDlg.h b/srchybrid/ArchivePreviewDlg.h index d4a6f618..f8d84591 100644 --- a/srchybrid/ArchivePreviewDlg.h +++ b/srchybrid/ArchivePreviewDlg.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "ResizableLib/ResizablePage.h" #include "ListCtrlX.h" diff --git a/srchybrid/ArchiveRecovery.cpp b/srchybrid/ArchiveRecovery.cpp index e07cc4f7..00c8b60d 100644 --- a/srchybrid/ArchiveRecovery.cpp +++ b/srchybrid/ArchiveRecovery.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -198,8 +198,8 @@ bool CArchiveRecovery::performRecovery(CPartFile *partFile, CArray * } } else CFile::Remove(outputFileName); - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -339,8 +339,8 @@ bool CArchiveRecovery::recoverZip(CFile *zipInput, CFile *zipOutput, archiveScan centralDirectoryEntries->RemoveAll(); } retVal = true; - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -410,8 +410,8 @@ bool CArchiveRecovery::readZipCentralDirectory(CFile *zipInput, CTypedPtrListDelete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -547,8 +547,8 @@ bool CArchiveRecovery::processZipEntry(CFile *zipInput, CFile *zipOutput, uint32 zipInput->Seek(entry.lenCompressed, CFile::current); } return true; - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -674,8 +674,8 @@ bool CArchiveRecovery::recoverRar(CFile *rarInput, CFile *rarOutput, archiveScan } } retVal = true; - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -744,8 +744,8 @@ bool CArchiveRecovery::scanForZipMarker(CFile *input, archiveScannerThreadParams } } } - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -917,8 +917,8 @@ RAR_BlockFile* CArchiveRecovery::scanForRarFileHeader(CFile *input, archiveScann retVal = NULL; } } - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -1014,8 +1014,8 @@ void CArchiveRecovery::writeRarBlock(CFile *input, CFile *output, RAR_BlockFile } output->Flush(); return; - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -1161,8 +1161,8 @@ bool CArchiveRecovery::recoverAce(CFile *aceInput, CFile *aceOutput, archiveScan } } return true; - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -1278,8 +1278,8 @@ ACE_BlockFile* CArchiveRecovery::scanForAceFileHeader(CFile *input, archiveScann } // while foundpos } // while available>0 - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -1347,7 +1347,7 @@ void CArchiveRecovery::writeAceBlock(CFile *input, CFile *output, ACE_BlockFile output->Write(block->COMMENT, block->COMM_SIZE); } - // skip unknown data between header and compressed data - if any exists... + // skip unknown data between header and compressed data - if exists any // Now copy compressed data from input file uint32 lenToCopy = block->PACK_SIZE; @@ -1364,8 +1364,8 @@ void CArchiveRecovery::writeAceBlock(CFile *input, CFile *output, ACE_BlockFile } output->Flush(); return; - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } diff --git a/srchybrid/ArchiveRecovery.h b/srchybrid/ArchiveRecovery.h index 52927e74..9586d056 100644 --- a/srchybrid/ArchiveRecovery.h +++ b/srchybrid/ArchiveRecovery.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/AsyncProxySocketLayer.cpp b/srchybrid/AsyncProxySocketLayer.cpp index 80713ef8..ae2416c1 100644 --- a/srchybrid/AsyncProxySocketLayer.cpp +++ b/srchybrid/AsyncProxySocketLayer.cpp @@ -9,10 +9,10 @@ This class is layer class for CAsyncSocketEx. With this class you can connect through SOCKS4/5 and HTTP 1.1 proxies. This class works as semi-transparent layer between CAsyncSocketEx and the actual socket. This class is used in FileZilla, a powerful open-source FTP client. -It can be found under http://sourceforge.net/projects/filezilla +It can be found under https://sourceforge.net/projects/filezilla For more information about SOCKS4/5 goto http://www.socks.nec.com/socksprot.html -For more information about HTTP 1.1 goto http://www.rfc-editor.org +For more information about HTTP 1.1 goto https://www.rfc-editor.org and search for RFC2616 How to use? @@ -433,7 +433,7 @@ void CAsyncProxySocketLayer::OnReceive(int nErrorCode) int nBufLen = 3 + nLenUser + nLenPass; int res = SendNext(buffer, nBufLen); delete[] buffer; - if (res == SOCKET_ERROR || res < nBufLen) { + if (res < nBufLen || res == SOCKET_ERROR) { if ((WSAGetLastError() != WSAEWOULDBLOCK) || res < nBufLen) { DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, PROXYERROR_REQUESTFAILED, 0); TriggerEvent((m_nProxyOpID == PROXYOP_CONNECT) ? FD_CONNECT : FD_ACCEPT, WSAGetLastError(), TRUE); @@ -468,7 +468,7 @@ void CAsyncProxySocketLayer::OnReceive(int nErrorCode) nBufLen += 2; int res = SendNext(command, nBufLen); delete[] command; - if (res == SOCKET_ERROR || res < nBufLen) { + if (res < nBufLen || res == SOCKET_ERROR) { if ((WSAGetLastError() != WSAEWOULDBLOCK) || res < nBufLen) { DoLayerCallback(LAYERCALLBACK_LAYERSPECIFIC, PROXYERROR_REQUESTFAILED, 0); TriggerEvent((m_nProxyOpID == PROXYOP_CONNECT) ? FD_CONNECT : FD_ACCEPT, WSAGetLastError(), TRUE); diff --git a/srchybrid/AsyncProxySocketLayer.h b/srchybrid/AsyncProxySocketLayer.h index 2c8f3396..361c3548 100644 --- a/srchybrid/AsyncProxySocketLayer.h +++ b/srchybrid/AsyncProxySocketLayer.h @@ -9,10 +9,10 @@ This class is layer class for CAsyncSocketEx. With this class you can connect through SOCKS4/5 and HTTP 1.1 proxies. This class works as semi-transparent layer between CAsyncSocketEx and the actual socket. This class is used in FileZilla, a powerful open-source FTP client. -It can be found under http://sourceforge.net/projects/filezilla +It can be found under https://sourceforge.net/projects/filezilla For more information about SOCKS4/5 goto http://www.socks.nec.com/socksprot.html -For more information about HTTP 1.1 goto http://www.rfc-editor.org +For more information about HTTP 1.1 goto https://www.rfc-editor.org and search for RFC2616 How to use? diff --git a/srchybrid/AsyncSocketEx.cpp b/srchybrid/AsyncSocketEx.cpp index e1cefca8..a5e4bdc0 100644 --- a/srchybrid/AsyncSocketEx.cpp +++ b/srchybrid/AsyncSocketEx.cpp @@ -210,7 +210,7 @@ class CAsyncSocketExHelperWindow if (msg.wParam >= static_cast(m_nWindowDataSize)) //Index is within socket storage continue; - CAsyncSocketEx *pSocket = m_pAsyncSocketExWindowData[msg.wParam].m_pSocket; + const CAsyncSocketEx *pSocket = m_pAsyncSocketExWindowData[msg.wParam].m_pSocket; CAsyncSocketExLayer::t_LayerNotifyMsg *pMsg = reinterpret_cast(msg.lParam); if (!pMsg || !pSocket || pSocket->m_SocketData.hSocket == INVALID_SOCKET || pSocket == pOrigSocket || pSocket->m_SocketData.hSocket != pMsg->hSocket) delete pMsg; @@ -489,7 +489,7 @@ class CAsyncSocketExHelperWindow return 0; } - CAsyncSocketEx *socket = pWnd->m_pThreadData->layerCloseNotify.front(); + const CAsyncSocketEx *socket = pWnd->m_pThreadData->layerCloseNotify.front(); pWnd->m_pThreadData->layerCloseNotify.pop_front(); if (pWnd->m_pThreadData->layerCloseNotify.empty()) ::KillTimer(hWnd, 1); @@ -587,18 +587,18 @@ class CAsyncSocketExHelperWindow IMPLEMENT_DYNAMIC(CAsyncSocketEx, CObject) CAsyncSocketEx::CAsyncSocketEx() - : m_lEvent() + : m_pLocalAsyncSocketExThreadData() , m_pAsyncGetHostByNameBuffer() , m_hAsyncGetHostByNameHandle() , m_nAsyncGetHostByNamePort() - , m_pLocalAsyncSocketExThreadData() #ifndef NOSOCKETSTATES - , m_nPendingEvents() , m_nState(notsock) + , m_nPendingEvents() #endif //NOSOCKETSTATES , m_pFirstLayer() , m_pLastLayer() , m_nSocketPort() + , m_lEvent() { m_SocketData.addrInfo = NULL; m_SocketData.nextAddr = NULL; @@ -1119,11 +1119,6 @@ BOOL CAsyncSocketEx::IOCtl(long lCommand, DWORD *lpArgument) return !ioctlsocket(m_SocketData.hSocket, lCommand, lpArgument); } -int CAsyncSocketEx::GetLastError() -{ - return WSAGetLastError(); -} - BOOL CAsyncSocketEx::TriggerEvent(long lEvent) { if (m_SocketData.hSocket == INVALID_SOCKET) @@ -1146,11 +1141,6 @@ BOOL CAsyncSocketEx::TriggerEvent(long lEvent) return ::PostMessage(GetHelperWindowHandle(), WM_SOCKETEX_NOTIFY + m_SocketData.nSocketIndex, m_SocketData.hSocket, WSAGETSELECTEVENT(lEvent)); } -SOCKET CAsyncSocketEx::GetSocketHandle() -{ - return m_SocketData.hSocket; -} - HWND CAsyncSocketEx::GetHelperWindowHandle() { if (!m_pLocalAsyncSocketExThreadData || !m_pLocalAsyncSocketExThreadData->m_pHelperWindow) @@ -1211,25 +1201,6 @@ BOOL CAsyncSocketEx::SetSockOpt(int nOptionName, const void *lpOptionValue, int return !setsockopt(m_SocketData.hSocket, nLevel, nOptionName, (LPSTR)lpOptionValue, nOptionLen); } -#ifndef NOSOCKETSTATES - -int CAsyncSocketEx::GetState() const -{ - return m_nState; -} - -void CAsyncSocketEx::SetState(int nState) -{ - m_nState = nState; -} - -#endif //NOSOCKETSTATES - -ADDRESS_FAMILY CAsyncSocketEx::GetFamily() const -{ - return m_SocketData.nFamily; -} - bool CAsyncSocketEx::SetFamily(ADDRESS_FAMILY nFamily) { if (m_SocketData.nFamily != AF_UNSPEC) diff --git a/srchybrid/AsyncSocketEx.h b/srchybrid/AsyncSocketEx.h index 2511db8d..4b7593ab 100644 --- a/srchybrid/AsyncSocketEx.h +++ b/srchybrid/AsyncSocketEx.h @@ -96,7 +96,7 @@ struct t_callbackMsg int nType; }; -enum AsyncSocketExState +enum AsyncSocketExState : uint8 { notsock, unconnected, @@ -144,7 +144,7 @@ class CAsyncSocketEx : public CObject SOCKET Detach(); //Gets the error status for the last operation that failed. - static int GetLastError(); + static int GetLastError() { return WSAGetLastError(); } //Gets the address of the peer socket to which the socket is connected. bool GetPeerName(CString &rPeerAddress, UINT &rPeerPort); @@ -161,7 +161,7 @@ class CAsyncSocketEx : public CObject BOOL SetSockOpt(int nOptionName, const void *lpOptionValue, int nOptionLen, int nLevel = SOL_SOCKET); //Gets the socket family - ADDRESS_FAMILY GetFamily() const; + ADDRESS_FAMILY GetFamily() const { return m_SocketData.nFamily; } //Sets the socket family bool SetFamily(ADDRESS_FAMILY nFamily); @@ -235,7 +235,7 @@ class CAsyncSocketEx : public CObject bool IsLayerAttached() const; //Returns the handle of the socket. - SOCKET GetSocketHandle(); + SOCKET GetSocketHandle() const { return m_SocketData.hSocket; } //Triggers an event on the socket // Any combination of FD_READ, FD_WRITE, FD_CLOSE, FD_ACCEPT, FD_CONNECT and FD_FORCEREAD is valid for lEvent. @@ -258,14 +258,6 @@ class CAsyncSocketEx : public CObject bool bIsClosing; // Set to true on first received FD_CLOSE event } m_SocketData; - //If using layers, only the events specified with m_lEvent will send to the event handlers. - long m_lEvent; - - //AsyncGetHostByName - char *m_pAsyncGetHostByNameBuffer; //Buffer for hostend structure - HANDLE m_hAsyncGetHostByNameHandle; //TaskHandle - USHORT m_nAsyncGetHostByNamePort; //Port to connect to - //Returns the handle of the helper window HWND GetHelperWindowHandle(); @@ -300,13 +292,17 @@ class CAsyncSocketEx : public CObject // Add a new notification to the list of pending callbacks void AddCallbackNotification(const t_callbackMsg &msg); + //AsyncGetHostByName + char* m_pAsyncGetHostByNameBuffer; //Buffer for hostend structure + HANDLE m_hAsyncGetHostByNameHandle; //TaskHandle + USHORT m_nAsyncGetHostByNamePort; //Port to connect to + #ifndef NOSOCKETSTATES + AsyncSocketExState m_nState; int m_nPendingEvents; - int GetState() const; - void SetState(int nState); - - int m_nState; + AsyncSocketExState GetState() const { return m_nState; } + void SetState(AsyncSocketExState nState) { m_nState = nState; } #endif //NOSOCKETSTATES //Layer chain @@ -317,8 +313,11 @@ class CAsyncSocketEx : public CObject virtual int OnLayerCallback(std::vector &callbacks); // Used by Bind with AF_UNSPEC sockets - UINT m_nSocketPort; CString m_sSocketAddress; + UINT m_nSocketPort; + + //If using layers, only the events specified with m_lEvent will send to the event handlers. + long m_lEvent; // Pending callbacks std::vector m_pendingCallbacks; diff --git a/srchybrid/AsyncSocketExLayer.cpp b/srchybrid/AsyncSocketExLayer.cpp index 2cc6fafa..53521d23 100644 --- a/srchybrid/AsyncSocketExLayer.cpp +++ b/srchybrid/AsyncSocketExLayer.cpp @@ -80,8 +80,8 @@ CAsyncSocketExLayer::CAsyncSocketExLayer() : m_pOwnerSocket() , m_nLayerState(notsock) , m_nFamily(AF_UNSPEC) - , m_lEvent() , m_nSocketPort() + , m_lEvent() , m_addrInfo() , m_nextAddr() , m_nPendingEvents() @@ -477,15 +477,10 @@ void CAsyncSocketExLayer::Init(CAsyncSocketExLayer *pPrevLayer, CAsyncSocketEx * #endif //NOSOCKETSTATES } -int CAsyncSocketExLayer::GetLayerState() const -{ - return m_nLayerState; -} - -void CAsyncSocketExLayer::SetLayerState(int nLayerState) +void CAsyncSocketExLayer::SetLayerState(AsyncSocketExState nLayerState) { ASSERT(m_pOwnerSocket); - int nOldLayerState = GetLayerState(); + AsyncSocketExState nOldLayerState = GetLayerState(); m_nLayerState = nLayerState; if (nOldLayerState != nLayerState) DoLayerCallback(LAYERCALLBACK_STATECHANGE, GetLayerState(), nOldLayerState); diff --git a/srchybrid/AsyncSocketExLayer.h b/srchybrid/AsyncSocketExLayer.h index 6c45433b..2fd5aa95 100644 --- a/srchybrid/AsyncSocketExLayer.h +++ b/srchybrid/AsyncSocketExLayer.h @@ -123,7 +123,7 @@ class CAsyncSocketExLayer //Calls OnLayerCallback on owner socket int DoLayerCallback(int nType, WPARAM wParam, LPARAM lParam, const char* const str = NULL); - int GetLayerState() const; + AsyncSocketExState GetLayerState() const { return m_nLayerState; } BOOL TriggerEvent(long lEvent, int nErrorCode, BOOL bPassThrough = FALSE); //Gets the socket family @@ -137,13 +137,13 @@ class CAsyncSocketExLayer private: //Layer state can't be set directly from derived classes - void SetLayerState(int nLayerState); - int m_nLayerState; + void SetLayerState(AsyncSocketExState nLayerState); + AsyncSocketExState m_nLayerState; ADDRESS_FAMILY m_nFamily; - int m_lEvent; CString m_sSocketAddress; UINT m_nSocketPort; + long m_lEvent; addrinfo *m_addrInfo, *m_nextAddr; diff --git a/srchybrid/BarShader.cpp b/srchybrid/BarShader.cpp index f1409f07..f0fefaa0 100644 --- a/srchybrid/BarShader.cpp +++ b/srchybrid/BarShader.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -35,8 +35,8 @@ CBarShader::CBarShader(uint32 height, uint32 width) , m_iWidth(width) , m_iHeight(height) , m_bIsPreview() - , m_Modifiers() , m_used3dlevel() + , m_Modifiers() { m_Spans.SetAt(0, 0); // SLUGFILLER: speedBarShader } diff --git a/srchybrid/BarShader.h b/srchybrid/BarShader.h index 2d7c409c..45915b6c 100644 --- a/srchybrid/BarShader.h +++ b/srchybrid/BarShader.h @@ -50,7 +50,7 @@ class CBarShader bool m_bIsPreview; private: + UINT m_used3dlevel; CRBMap m_Spans; // SLUGFILLER: speedBarShader float *m_Modifiers; - UINT m_used3dlevel; }; \ No newline at end of file diff --git a/srchybrid/BaseClient.cpp b/srchybrid/BaseClient.cpp index 0912a9e0..4bd4cb57 100644 --- a/srchybrid/BaseClient.cpp +++ b/srchybrid/BaseClient.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -24,7 +24,6 @@ #include "Clientlist.h" #include "PartFile.h" #include "ListenSocket.h" -#include "PeerCacheSocket.h" #include "Packets.h" #include "Opcodes.h" #include "SafeFile.h" @@ -54,7 +53,6 @@ #include "ChatWnd.h" #include "PreviewDlg.h" #include "Exceptions.h" -#include "Peercachefinder.h" #include "ClientUDPSocket.h" #include "shahashset.h" #include "Log.h" @@ -107,17 +105,6 @@ void CUpDownClient::Init() m_abyUpPartStatus = NULL; m_lastPartAsked = _UI16_MAX; m_bAddNextConnect = false; - m_pPCDownSocket = NULL; - m_pPCUpSocket = NULL; - - m_iHttpSendState = 0; - m_uPeerCacheDownloadPushId = 0; - m_uPeerCacheUploadPushId = 0; - m_uPeerCacheRemoteIP = 0; - m_bPeerCacheDownHit = false; - m_bPeerCacheUpHit = false; - m_ePeerCacheDownState = PCDS_NONE; - m_ePeerCacheUpState = PCUS_NONE; if (socket) { SOCKADDR_IN sockAddr = {}; @@ -291,14 +278,6 @@ CUpDownClient::~CUpDownClient() socket->client = NULL; socket->Safe_Delete(); } - if (m_pPCDownSocket) { - m_pPCDownSocket->client = NULL; - m_pPCDownSocket->Safe_Delete(); - } - if (m_pPCUpSocket) { - m_pPCUpSocket->client = NULL; - m_pPCUpSocket->Safe_Delete(); - } free(m_pszUsername); m_pszUsername = NULL; @@ -345,8 +324,6 @@ void CUpDownClient::ClearHelloProperties() m_fSharedDirectories = 0; m_bMultiPacket = 0; m_fPeerCache = 0; - m_uPeerCacheDownloadPushId = 0; - m_uPeerCacheUploadPushId = 0; m_byKadVersion = 0; m_fSupportsLargeFiles = 0; m_fExtMultiPacket = 0; @@ -672,8 +649,9 @@ bool CUpDownClient::ProcessHelloTypePacket(CSafeMemFile &data) CString strBuffer(m_pszUsername); strBuffer.Remove(_T(' ')); strBuffer.MakeUpper(); - if (strBuffer.Find(_T("EMULE-CLIENT")) >= 0 || strBuffer.Find(_T("POWERMULE")) >= 0) - m_bGPLEvildoer = true; +// obsolete mods +// if (strBuffer.Find(_T("EMULE-CLIENT")) >= 0 || strBuffer.Find(_T("POWERMULE")) >= 0) +// m_bGPLEvildoer = true; m_byInfopacketsReceived |= IP_EDONKEYPROTPACK; // check if at least CT_EMULEVERSION was received, all other tags are optional @@ -993,7 +971,7 @@ void CUpDownClient::SendHelloTypePacket(CSafeMemFile &data) const UINT uNoViewSharedFiles = static_cast(thePrefs.CanSeeShares() == vsfaNobody); // for backward compatibility this has to be a 'negative' flag const UINT uMultiPacket = 1; const UINT uSupportPreview = static_cast(thePrefs.CanSeeShares() != vsfaNobody); // set 'Preview supported' only if 'View Shared Files' allowed - const UINT uPeerCache = 1; + const UINT uPeerCache = 0; const UINT uUnicodeSupport = 1; const UINT nAICHVer = 1; CTag tagMisOptions1(CT_EMULE_MISCOPTIONS1, @@ -1017,9 +995,9 @@ void CUpDownClient::SendHelloTypePacket(CSafeMemFile &data) const UINT uSupportLargeFiles = 1; const UINT uExtMultiPacket = 1; const UINT uReserved = 0; // mod bit - const UINT uSupportsCryptLayer = static_cast(thePrefs.IsClientCryptLayerSupported()); - const UINT uRequestsCryptLayer = static_cast(thePrefs.IsClientCryptLayerRequested()); - const UINT uRequiresCryptLayer = static_cast(thePrefs.IsClientCryptLayerRequired()); + const UINT uSupportsCryptLayer = static_cast(thePrefs.IsCryptLayerEnabled()); + const UINT uRequestsCryptLayer = static_cast(thePrefs.IsCryptLayerPreferred()); + const UINT uRequiresCryptLayer = static_cast(thePrefs.IsCryptLayerRequired()); const UINT uSupportsSourceEx2 = 1; const UINT uSupportsCaptcha = 1; // direct callback is only possible if connected to kad, TCP firewalled and verified UDP open (for example on a full cone NAT) @@ -1143,8 +1121,6 @@ bool CUpDownClient::Disconnected(LPCTSTR pszReason, bool bFromSocket) if (GetDownloadState() == DS_DOWNLOADING) { ASSERT(m_eConnectingState == CCS_NONE); - if (m_ePeerCacheDownState == PCDS_WAIT_CACHE_REPLY || m_ePeerCacheDownState == PCDS_DOWNLOADING) - theApp.m_pPeerCache->DownloadAttemptFailed(); SetDownloadState(DS_ONQUEUE, CString(_T("Disconnected: ")) + pszReason); } else { // ensure that all possible block requests are removed from the partfile @@ -1252,19 +1228,6 @@ bool CUpDownClient::Disconnected(LPCTSTR pszReason, bool bFromSocket) m_fQueueRankPending = 0; m_fFailedFileIdReqs = 0; m_fUnaskQueueRankRecv = 0; - m_uPeerCacheDownloadPushId = 0; - m_uPeerCacheUploadPushId = 0; - m_uPeerCacheRemoteIP = 0; - SetPeerCacheDownState(PCDS_NONE); - SetPeerCacheUpState(PCUS_NONE); - if (m_pPCDownSocket) { - m_pPCDownSocket->client = NULL; - m_pPCDownSocket->Safe_Delete(); - } - if (m_pPCUpSocket) { - m_pPCUpSocket->client = NULL; - m_pPCUpSocket->Safe_Delete(); - } m_fSentOutOfPartReqs = 0; return false; } @@ -1335,7 +1298,7 @@ bool CUpDownClient::TryToConnect(bool bIgnoreMaxCon, bool bNoCallbacks, CRuntime return true; } // do not try to connect to source which are incompatible with our encryption setting (one requires it, and the other one doesn't support it) - if ((RequiresCryptLayer() && !thePrefs.IsClientCryptLayerSupported()) || (thePrefs.IsClientCryptLayerRequired() && !SupportsCryptLayer())) { + if ((RequiresCryptLayer() && !thePrefs.IsCryptLayerEnabled()) || (thePrefs.IsCryptLayerRequired() && !SupportsCryptLayer())) { DEBUG_ONLY(AddDebugLogLine(DLP_DEFAULT, false, _T("Rejected outgoing connection because CryptLayer-Setting (Obfuscation) was incompatible %s"), (LPCTSTR)DbgGetClientInfo())); if (Disconnected(_T("CryptLayer-Settings (Obfuscation) incompatible"))) { delete this; @@ -1517,7 +1480,7 @@ bool CUpDownClient::TryToConnect(bool bIgnoreMaxCon, bool bNoCallbacks, CRuntime void CUpDownClient::Connect() { // enable or disable encryption based on our and the remote clients preference - if (HasValidHash() && SupportsCryptLayer() && thePrefs.IsClientCryptLayerSupported() && (RequestsCryptLayer() || thePrefs.IsClientCryptLayerRequested())) { + if (HasValidHash() && SupportsCryptLayer() && thePrefs.IsCryptLayerEnabled() && (RequestsCryptLayer() || thePrefs.IsCryptLayerPreferred())) { //DebugLog(_T("Enabling CryptLayer on outgoing connection to client %s"), (LPCTSTR)DbgGetClientInfo()); // to be removed later socket->SetConnectionEncryption(true, GetUserHash(), false); } else @@ -1536,21 +1499,22 @@ void CUpDownClient::Connect() void CUpDownClient::ConnectionEstablished() { // OK we have a connection, lets see if we want anything from this client - - /*// was this a direct callback? +/* + // was this a direct callback? if (m_nConnectingState == CCS_DIRECTCALLBACK) // TODO LOGREMOVE DebugLog(_T("Direct Callback succeeded, connection established - %s"), (LPCTSTR)DbgGetClientInfo()); // remove the connecting timer and state if (m_nConnectingState == CCS_NONE) // TODO LOGREMOVE - DEBUG_ONLY( DebugLog(_T("ConnectionEstablished with CCS_NONE (incoming, that's fine)")) );*/ + DEBUG_ONLY( DebugLog(_T("ConnectionEstablished with CCS_NONE (incoming, that's fine)")) ); +*/ m_eConnectingState = CCS_NONE; theApp.clientlist->RemoveConnectingClient(this); - // check if we should use this client to retrieve our public IP +/* // check if we should use this client to retrieve our public IP if (theApp.GetPublicIP() == 0 && theApp.IsConnected() && m_fPeerCache) SendPublicIPRequest(); - +*/ switch (GetKadState()) { case KS_CONNECTING_FWCHECK: SetKadState(KS_CONNECTED_FWCHECK); @@ -2508,33 +2472,9 @@ CString CUpDownClient::GetDownloadStateDisplayString() const uid = IDS_KAD_TOOMANDYKADLKPS; break; default: - uid = 0; - } - CString strState; - if (uid) - strState = GetResString(uid); - - if (thePrefs.GetPeerCacheShow()) { - switch (m_ePeerCacheDownState) { - case PCDS_WAIT_CLIENT_REPLY: - uid = IDS_PCDS_CLIENTWAIT; - break; - case PCDS_WAIT_CACHE_REPLY: - uid = IDS_PCDS_CACHEWAIT; - break; - case PCDS_DOWNLOADING: - uid = IDS_CACHE; - break; - default: - uid = 0; - } - if (uid) - strState.AppendFormat(_T(" %s"), (LPCTSTR)GetResString(uid)); - if (m_ePeerCacheDownState != PCDS_NONE && m_bPeerCacheDownHit) - strState += _T(" Hit"); + return CString(); } - - return strState; + return GetResString(uid); } CString CUpDownClient::GetUploadStateDisplayString() const @@ -2566,25 +2506,9 @@ CString CUpDownClient::GetUploadStateDisplayString() const uid = IDS_TRICKLING; break; default: - uid = 0; + return CString(); } - CString strState; - if (uid) - strState = GetResString(uid); - - if (thePrefs.GetPeerCacheShow()) { - switch (m_ePeerCacheUpState) { - case PCUS_WAIT_CACHE_REPLY: - strState += _T(" CacheWait"); - break; - case PCUS_UPLOADING: - strState += _T(" Cache"); - } - if (m_ePeerCacheUpState != PCUS_NONE && m_bPeerCacheUpHit) - strState += _T(" Hit"); - } - - return strState; + return GetResString(uid); } void CUpDownClient::SendPublicIPRequest() @@ -2617,7 +2541,7 @@ void CUpDownClient::CheckFailedFileIdReqs(const uchar *aucFileHash) return; //if (GetDownloadState() != DS_DOWNLOADING) // filereq floods are never allowed! { - if (m_fFailedFileIdReqs < 6)// NOTE: Do not increase this counter without increasing the bits for 'm_fFailedFileIdReqs' + if (m_fFailedFileIdReqs < 6) // NOTE: Do not increase this counter without increasing the bits for 'm_fFailedFileIdReqs' ++m_fFailedFileIdReqs; if (m_fFailedFileIdReqs == 6) { if (theApp.clientlist->GetBadRequests(this) < 2) @@ -2657,8 +2581,8 @@ bool CUpDownClient::IsObfuscatedConnectionEstablished() const bool CUpDownClient::ShouldReceiveCryptUDPPackets() const { - return thePrefs.IsClientCryptLayerSupported() && SupportsCryptLayer() && theApp.GetPublicIP() != 0 - && HasValidHash() && (thePrefs.IsClientCryptLayerRequested() || RequestsCryptLayer()); + return thePrefs.IsCryptLayerEnabled() && SupportsCryptLayer() && theApp.GetPublicIP() != 0 + && HasValidHash() && (thePrefs.IsCryptLayerPreferred() || RequestsCryptLayer()); } void CUpDownClient::GetDisplayImage(int &iImage, UINT &uOverlayImage) const @@ -2959,7 +2883,7 @@ void CUpDownClient::ProcessFirewallCheckUDPRequest(CSafeMemFile &data) if (thePrefs.GetDebugClientKadUDPLevel() > 0) DebugSend("KADEMLIA2_FIREWALLUDP", ntohl(GetConnectIP()), nRemoteInternPort); Kademlia::CKademlia::GetUDPListener()->SendPacket(fileTestPacket1, KADEMLIA2_FIREWALLUDP, ntohl(GetConnectIP()) - , nRemoteInternPort, Kademlia::CKadUDPKey(dwSenderKey, theApp.GetPublicIP(false)), NULL); + , nRemoteInternPort, Kademlia::CKadUDPKey(dwSenderKey, theApp.GetPublicIP()), NULL); // if the client has a router with PAT (and therefore a different extern port than intern), test this port too if (nRemoteExternPort != 0 && nRemoteExternPort != nRemoteInternPort) { @@ -2969,7 +2893,7 @@ void CUpDownClient::ProcessFirewallCheckUDPRequest(CSafeMemFile &data) if (thePrefs.GetDebugClientKadUDPLevel() > 0) DebugSend("KADEMLIA2_FIREWALLUDP", ntohl(GetConnectIP()), nRemoteExternPort); Kademlia::CKademlia::GetUDPListener()->SendPacket(fileTestPacket2, KADEMLIA2_FIREWALLUDP, ntohl(GetConnectIP()) - , nRemoteExternPort, Kademlia::CKadUDPKey(dwSenderKey, theApp.GetPublicIP(false)), NULL); + , nRemoteExternPort, Kademlia::CKadUDPKey(dwSenderKey, theApp.GetPublicIP()), NULL); } DebugLog(_T("Answered UDP Firewall check request (%s)"), (LPCTSTR)DbgGetClientInfo()); } diff --git a/srchybrid/BuddyButton.cpp b/srchybrid/BuddyButton.cpp index 2f4a1810..62dcab18 100644 --- a/srchybrid/BuddyButton.cpp +++ b/srchybrid/BuddyButton.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -96,6 +96,13 @@ void AddBuddyButton(HWND hwndEdit, HWND hwndButton) ::SetWindowPos(hwndEdit, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); } +void DestroyIconsArr(HICON *pIcon, size_t cnt) +{ + while (cnt-- > 0) + if (pIcon[cnt]) + VERIFY(::DestroyIcon(pIcon[cnt])); +} + bool InitAttachedBrowseButton(HWND hwndButton, HICON &ricoBrowse) { // Showing an icon button works for all Windows versions *except* Windows XP w/ active styles diff --git a/srchybrid/ButtonsTabCtrl.cpp b/srchybrid/ButtonsTabCtrl.cpp index 1bc6f015..110d3f89 100644 --- a/srchybrid/ButtonsTabCtrl.cpp +++ b/srchybrid/ButtonsTabCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -59,7 +59,6 @@ void CButtonsTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS) tci.cchTextMax = _countof(szLabel); if (!GetItem(nTabIndex, &tci)) return; - szLabel[_countof(szLabel) - 1] = _T('\0'); CDC *pDC = CDC::FromHandle(lpDIS->hDC); if (!pDC) diff --git a/srchybrid/CaptchaGenerator.cpp b/srchybrid/CaptchaGenerator.cpp index 4e06c08e..b44b5791 100644 --- a/srchybrid/CaptchaGenerator.cpp +++ b/srchybrid/CaptchaGenerator.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "CaptchaGenerator.h" #include "CxImage/xImage.h" diff --git a/srchybrid/CaptchaGenerator.h b/srchybrid/CaptchaGenerator.h index 5762df7a..4367412c 100644 --- a/srchybrid/CaptchaGenerator.h +++ b/srchybrid/CaptchaGenerator.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "SafeFile.h" diff --git a/srchybrid/CatDialog.cpp b/srchybrid/CatDialog.cpp index 5b1a51a9..10e0dfa3 100644 --- a/srchybrid/CatDialog.cpp +++ b/srchybrid/CatDialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ChatSelector.cpp b/srchybrid/ChatSelector.cpp index eb2d5a0e..3670438f 100644 --- a/srchybrid/ChatSelector.cpp +++ b/srchybrid/ChatSelector.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -90,7 +90,7 @@ void CChatSelector::Init(CChatWnd *pParent) ModifyStyle(0, WS_CLIPCHILDREN); SetAllIcons(); - VERIFY((m_Timer = SetTimer(IDT_CHATITEMS, 1500, NULL)) != 0); + VERIFY((m_Timer = SetTimer(IDT_CHATITEMS, SEC2MS(3) / 2, NULL)) != 0); } void CChatSelector::OnSysColorChange() @@ -114,12 +114,13 @@ void CChatSelector::SetAllIcons() void CChatSelector::UpdateFonts(CFont *pFont) { - TCITEM item; - item.mask = TCIF_PARAM; - for (int i = 0; GetItem(i++, &item);) { - CChatItem *ci = reinterpret_cast(item.lParam); - ci->log->SetFont(pFont); - } + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = GetItemCount(); --i >= 0;) + if (GetItem(i, &ti)) { + CChatItem *ci = reinterpret_cast(ti.lParam); + ci->log->SetFont(pFont); + } } CChatItem* CChatSelector::StartSession(CUpDownClient *client, bool show) @@ -171,13 +172,13 @@ CChatItem* CChatSelector::StartSession(CUpDownClient *client, bool show) name.Format(_T("(%s)"), (LPCTSTR)GetResString(IDS_UNKNOWN)); chatitem->log->SetTitle(name); - TCITEM newitem; - newitem.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; - newitem.lParam = (LPARAM)chatitem; + TCITEM ti; + ti.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; + ti.lParam = (LPARAM)chatitem; DupAmpersand(name); - newitem.pszText = const_cast((LPCTSTR)name); - newitem.iImage = 0; - int iItemNr = InsertItem(GetItemCount(), &newitem); + ti.pszText = const_cast((LPCTSTR)name); + ti.iImage = 0; + int iItemNr = InsertItem(GetItemCount(), &ti); if (show || IsWindowVisible()) { SetCurSel(iItemNr); ShowChat(); @@ -187,33 +188,33 @@ CChatItem* CChatSelector::StartSession(CUpDownClient *client, bool show) int CChatSelector::GetTabByClient(CUpDownClient *client) { - for (int i = GetItemCount(); --i >= 0;) { - TCITEM cur_item; - cur_item.mask = TCIF_PARAM; - if (GetItem(i, &cur_item) && reinterpret_cast(cur_item.lParam)->client == client) + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = GetItemCount(); --i >= 0;) + if (GetItem(i, &ti) && reinterpret_cast(ti.lParam)->client == client) return i; - } + return -1; } CChatItem* CChatSelector::GetItemByIndex(int index) { - TCITEM item; - item.mask = TCIF_PARAM; - if (!GetItem(index, &item)) + TCITEM ti; + ti.mask = TCIF_PARAM; + if (!GetItem(index, &ti)) return NULL; - return reinterpret_cast(item.lParam); + return reinterpret_cast(ti.lParam); } CChatItem* CChatSelector::GetItemByClient(CUpDownClient *client) { - for (int i = GetItemCount(); --i >= 0;) { - TCITEM cur_item; - cur_item.mask = TCIF_PARAM; - if (GetItem(i, &cur_item) && reinterpret_cast(cur_item.lParam)->client == client) - return reinterpret_cast(cur_item.lParam); - } + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = GetItemCount(); --i >= 0;) + if (GetItem(i, &ti) && reinterpret_cast(ti.lParam)->client == client) + return reinterpret_cast(ti.lParam); + return NULL; } @@ -361,36 +362,33 @@ void CChatSelector::ConnectingResult(CUpDownClient *sender, bool success) void CChatSelector::DeleteAllItems() { - for (int i = GetItemCount(); --i >= 0;) { - TCITEM cur_item; - cur_item.mask = TCIF_PARAM; - if (GetItem(i, &cur_item)) - delete reinterpret_cast(cur_item.lParam); - } + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = GetItemCount(); --i >= 0;) + if (GetItem(i, &ti)) + delete reinterpret_cast(ti.lParam); } void CChatSelector::OnTimer(UINT_PTR /*nIDEvent*/) { m_blinkstate = !m_blinkstate; bool globalnotify = false; - for (int i = GetItemCount(); --i >= 0;) { - TCITEM cur_item; - cur_item.mask = TCIF_PARAM | TCIF_IMAGE; - if (!GetItem(i, &cur_item)) - break; - - cur_item.mask = TCIF_IMAGE; - if (reinterpret_cast(cur_item.lParam)->notify) { - cur_item.iImage = (m_blinkstate) ? 1 : 2; - SetItem(i, &cur_item); - HighlightItem(i, TRUE); - globalnotify = true; - } else if (cur_item.iImage != 0) { - cur_item.iImage = 0; - SetItem(i, &cur_item); - HighlightItem(i, FALSE); + TCITEM ti; + ti.mask = TCIF_PARAM | TCIF_IMAGE; + for (int i = GetItemCount(); --i >= 0;) + if (GetItem(i, &ti)) { + ti.mask = TCIF_IMAGE; + if (reinterpret_cast(ti.lParam)->notify) { + ti.iImage = (m_blinkstate) ? 1 : 2; + SetItem(i, &ti); + HighlightItem(i, TRUE); + globalnotify = true; + } else if (ti.iImage != 0) { + ti.iImage = 0; + SetItem(i, &ti); + HighlightItem(i, FALSE); + } } - } if (globalnotify) { theApp.emuledlg->ShowMessageState(m_blinkstate ? 1 : 2); @@ -407,12 +405,12 @@ CChatItem* CChatSelector::GetCurrentChatItem() if (iCurSel == -1) return NULL; - TCITEM cur_item; - cur_item.mask = TCIF_PARAM; - if (!GetItem(iCurSel, &cur_item)) + TCITEM ti; + ti.mask = TCIF_PARAM; + if (!GetItem(iCurSel, &ti)) return NULL; - return reinterpret_cast(cur_item.lParam); + return reinterpret_cast(ti.lParam); } void CChatSelector::ShowChat() @@ -425,17 +423,17 @@ void CChatSelector::ShowChat() ci->log->ShowWindow(SW_SHOW); m_pParent->m_wndMessage.SetFocus(); - TCITEM item; - item.mask = TCIF_IMAGE; - item.iImage = 0; - SetItem(GetCurSel(), &item); + TCITEM ti; + ti.mask = TCIF_IMAGE; + ti.iImage = 0; + SetItem(GetCurSel(), &ti); HighlightItem(GetCurSel(), FALSE); // hide all other chat windows - item.mask = TCIF_PARAM; + ti.mask = TCIF_PARAM; int i = 0; - while (GetItem(i++, &item)) { - CChatItem *ci2 = reinterpret_cast(item.lParam); + while (GetItem(i++, &ti)) { + CChatItem *ci2 = reinterpret_cast(ti.lParam); if (ci2 != ci) ci2->log->ShowWindow(SW_HIDE); } @@ -469,11 +467,11 @@ void CChatSelector::EndSession(CUpDownClient *client) if (iCurSel == -1) return; - TCITEM item; - item.mask = TCIF_PARAM; - if (!GetItem(iCurSel, &item) || item.lParam == 0) + TCITEM ti; + ti.mask = TCIF_PARAM; + if (!GetItem(iCurSel, &ti) || ti.lParam == 0) return; - CChatItem *ci = reinterpret_cast(item.lParam); + CChatItem *ci = reinterpret_cast(ti.lParam); ci->client->SetChatState(MS_NONE); ci->client->SetChatCaptchaState(CA_NONE); @@ -506,10 +504,10 @@ void CChatSelector::OnSize(UINT nType, int cx, int cy) CRect rcChat; GetChatSize(rcChat); - TCITEM item; - item.mask = TCIF_PARAM; - for (int i = 0; GetItem(i, &item); ++i) { - CChatItem *ci = reinterpret_cast(item.lParam); + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = 0; GetItem(i, &ti); ++i) { + CChatItem *ci = reinterpret_cast(ti.lParam); ci->log->SetWindowPos(NULL, rcChat.left, rcChat.top, rcChat.Width(), rcChat.Height(), SWP_NOZORDER); } } @@ -582,11 +580,11 @@ void CChatSelector::OnContextMenu(CWnd*, CPoint point) if (m_iContextIndex == -1) return; - TCITEM item; - item.mask = TCIF_PARAM; - GetItem(m_iContextIndex, &item); + TCITEM ti; + ti.mask = TCIF_PARAM; + GetItem(m_iContextIndex, &ti); - const CChatItem *ci = reinterpret_cast(item.lParam); + const CChatItem *ci = reinterpret_cast(ti.lParam); if (ci == NULL) return; @@ -613,12 +611,11 @@ void CChatSelector::OnContextMenu(CWnd*, CPoint point) void CChatSelector::EnableSmileys(bool bEnable) { - for (int i = GetItemCount(); --i >= 0;) { - TCITEM cur_item; - cur_item.mask = TCIF_PARAM; - if (GetItem(i, &cur_item) && reinterpret_cast(cur_item.lParam)->log) - reinterpret_cast(cur_item.lParam)->log->EnableSmileys(bEnable); - } + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = GetItemCount(); --i >= 0;) + if (GetItem(i, &ti) && reinterpret_cast(ti.lParam)->log) + reinterpret_cast(ti.lParam)->log->EnableSmileys(bEnable); } void CChatSelector::ReportConnectionProgress(CUpDownClient *pClient, const CString &strProgressDesc, bool bNoTimeStamp) diff --git a/srchybrid/ChatSelector.h b/srchybrid/ChatSelector.h index 554c4932..cf025099 100644 --- a/srchybrid/ChatSelector.h +++ b/srchybrid/ChatSelector.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ChatWnd.cpp b/srchybrid/ChatWnd.cpp index 4196b612..c76eee30 100644 --- a/srchybrid/ChatWnd.cpp +++ b/srchybrid/ChatWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -183,7 +183,7 @@ BOOL CChatWnd::OnInitDialog() ScreenToClient(&rcSpl); rcSpl.left = rcSpl.right + SPLITTER_HORZ_MARGIN; rcSpl.right = rcSpl.left + SPLITTER_HORZ_WIDTH; - m_wndSplitterHorz.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_FRIEND); + m_wndSplitterHorz.CreateWnd(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_FRIEND); // Vista: Remove the TBSTYLE_TRANSPARENT to avoid flickering (can be done only after the toolbar was initially created with TBSTYLE_TRANSPARENT !?) m_wndFormat.ModifyStyle((theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6, 16, 0, 0)) ? TBSTYLE_TRANSPARENT : 0, TBSTYLE_TOOLTIPS); @@ -436,10 +436,10 @@ void CChatWnd::Localize() LRESULT CChatWnd::OnCloseTab(WPARAM wParam, LPARAM) { - TCITEM item = {}; - item.mask = TCIF_PARAM; - if (chatselector.GetItem((int)wParam, &item)) - chatselector.EndSession(reinterpret_cast(item.lParam)->client); + TCITEM ti; + ti.mask = TCIF_PARAM; + if (chatselector.GetItem((int)wParam, &ti)) + chatselector.EndSession(reinterpret_cast(ti.lParam)->client); EnableClose(); return TRUE; } @@ -514,7 +514,7 @@ void CChatWnd::OnBnClickedSmiley() m_wndFormat.GetWindowRect(&rcBtn); rcBtn.top -= 2; - if (!m_pwndSmileySel->Create(this, &rcBtn, &m_wndMessage)) { + if (!m_pwndSmileySel->CreateWnd(this, &rcBtn, &m_wndMessage)) { delete m_pwndSmileySel; m_pwndSmileySel = NULL; } diff --git a/srchybrid/ChatWnd.h b/srchybrid/ChatWnd.h index 2f8c77c2..9fd57c6d 100644 --- a/srchybrid/ChatWnd.h +++ b/srchybrid/ChatWnd.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ClientCredits.cpp b/srchybrid/ClientCredits.cpp index 2a1b7264..ef72296e 100644 --- a/srchybrid/ClientCredits.cpp +++ b/srchybrid/ClientCredits.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -160,19 +160,10 @@ void CClientCreditsList::LoadList() const CString &strFileName(sConfDir + CLIENTS_MET_FILENAME); const int iOpenFlags = CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite; CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(strFileName, iOpenFlags, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(GetResString(IDS_ERR_LOADCREDITFILE)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } + if (!CFileOpen(file, strFileName, iOpenFlags, GetResString(IDS_ERR_LOADCREDITFILE))) return; - } - ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { uint8 version = file.ReadUInt8(); if (version != CREDITFILE_VERSION && version != CREDITFILE_VERSION_29) { @@ -207,14 +198,9 @@ void CClientCreditsList::LoadList() LogError(GetResString(IDS_ERR_MAKEBAKCREDITFILE)); // reopen file - if (!file.Open(strFileName, iOpenFlags, &fexp)) { - CString strError(GetResString(IDS_ERR_LOADCREDITFILE)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + if (!CFileOpen(file, strFileName, iOpenFlags, GetResString(IDS_ERR_LOADCREDITFILE))) return; - } + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); file.Seek(1, CFile::begin); //set file pointer behind file version byte } @@ -241,15 +227,12 @@ void CClientCreditsList::LoadList() AddLogLine(false, GetResString(IDS_CREDITFILELOADED) + GetResString(IDS_CREDITSEXPIRED), count - cDeleted, cDeleted); else AddLogLine(false, GetResString(IDS_CREDITFILELOADED), count); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) LogError(LOG_STATUSBAR, GetResString(IDS_CREDITFILECORRUPT)); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_CREDITFILEREAD), buffer); - } - error->Delete(); + else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_CREDITFILEREAD), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); } } @@ -259,18 +242,14 @@ void CClientCreditsList::SaveList() AddDebugLogLine(false, _T("Saving clients credit list file \"%s\""), CLIENTS_MET_FILENAME); m_nLastSaved = ::GetTickCount(); - const CString &metname(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + CLIENTS_MET_FILENAME); CFile file;// no buffering needed here since we swap out the entire array - CFileException fexp; - if (!file.Open(metname, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - CString strError(GetResString(IDS_ERR_FAILED_CREDITSAVE)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + if (!CFileOpen(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + CLIENTS_MET_FILENAME + , CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite + , GetResString(IDS_ERR_FAILED_CREDITSAVE))) + { return; } - byte *pBuffer = new byte[m_mapClients.GetCount() * sizeof(CreditStruct)]; //not CreditStruct[] because of alignment uint32 count = 0; for (const CClientCreditsMap::CPair *pair = m_mapClients.PGetFirstAssoc(); pair != NULL; pair = m_mapClients.PGetNextAssoc(pair)) { @@ -285,13 +264,9 @@ void CClientCreditsList::SaveList() file.Write(&count, 4); file.Write(pBuffer, (UINT)(count * sizeof(CreditStruct))); file.Close(); - } catch (CFileException *error) { - CString strError(GetResString(IDS_ERR_FAILED_CREDITSAVE)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*error, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - error->Delete(); + } catch (CFileException *ex) { + LogError(LOG_STATUSBAR, _T("%s%s"), (LPCTSTR)GetResString(IDS_ERR_FAILED_CREDITSAVE), (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } delete[] pBuffer; diff --git a/srchybrid/ClientCredits.h b/srchybrid/ClientCredits.h index dde3adc9..59865a4d 100644 --- a/srchybrid/ClientCredits.h +++ b/srchybrid/ClientCredits.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ClientDetailDialog.cpp b/srchybrid/ClientDetailDialog.cpp index 22fb6600..4eeabea8 100644 --- a/srchybrid/ClientDetailDialog.cpp +++ b/srchybrid/ClientDetailDialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -94,8 +94,8 @@ BOOL CClientDetailPage::OnSetActive() if (!client->SupportsCryptLayer()) uid = IDS_IDENTNOSUPPORT; else - uid = ( thePrefs.IsClientCryptLayerSupported() - && (client->RequestsCryptLayer() || thePrefs.IsClientCryptLayerRequested()) + uid = ( thePrefs.IsCryptLayerEnabled() + && (client->RequestsCryptLayer() || thePrefs.IsCryptLayerPreferred()) && (client->IsObfuscatedConnectionEstablished() || client->socket == NULL || !client->socket->IsConnected()) ) ? IDS_ENABLED : IDS_SUPPORTED; diff --git a/srchybrid/ClientDetailDialog.h b/srchybrid/ClientDetailDialog.h index e3718b06..70f71ea4 100644 --- a/srchybrid/ClientDetailDialog.h +++ b/srchybrid/ClientDetailDialog.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ClientList.cpp b/srchybrid/ClientList.cpp index f244a12d..0aa7fbb4 100644 --- a/srchybrid/ClientList.cpp +++ b/srchybrid/ClientList.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -596,7 +596,7 @@ void CClientList::Process() //be fixed in later version // Update: Buddy connections itself support obfuscation properly since 0.49a (this makes it work fine if our buddy uses require crypt), // however callback requests don't support it yet so we wouldn't be able to answer callback requests with RequireCrypt, protocol change intended for the next version - if (m_nBuddyStatus == Disconnected && Kademlia::CKademlia::GetPrefs()->GetFindBuddy() && !thePrefs.IsClientCryptLayerRequired()) { + if (m_nBuddyStatus == Disconnected && Kademlia::CKademlia::GetPrefs()->GetFindBuddy() && !thePrefs.IsCryptLayerRequired()) { DEBUG_ONLY(DebugLog(_T("Starting Buddy search"))); //We are a firewalled client with no buddy. We have also waited a set time //to try to avoid a false firewalled status. So lets look for a buddy. diff --git a/srchybrid/ClientList.h b/srchybrid/ClientList.h index 2816b195..de2b9e9f 100644 --- a/srchybrid/ClientList.h +++ b/srchybrid/ClientList.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ClientListCtrl.cpp b/srchybrid/ClientListCtrl.cpp index 59c6d7dd..0167c2af 100644 --- a/srchybrid/ClientListCtrl.cpp +++ b/srchybrid/ClientListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ClientListCtrl.h b/srchybrid/ClientListCtrl.h index ff95b76c..6c885320 100644 --- a/srchybrid/ClientListCtrl.h +++ b/srchybrid/ClientListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ClientStateDefs.h b/srchybrid/ClientStateDefs.h index 985949c1..9622fe4b 100644 --- a/srchybrid/ClientStateDefs.h +++ b/srchybrid/ClientStateDefs.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -44,21 +44,6 @@ enum EDownloadState : uint8 DS_REMOTEQUEUEFULL // not used yet, except in statistics }; -enum EPeerCacheDownState : uint8 -{ - PCDS_NONE = 0, - PCDS_WAIT_CLIENT_REPLY, - PCDS_WAIT_CACHE_REPLY, - PCDS_DOWNLOADING -}; - -enum EPeerCacheUpState : uint8 -{ - PCUS_NONE = 0, - PCUS_WAIT_CACHE_REPLY, - PCUS_UPLOADING -}; - enum EChatState : uint8 { MS_NONE, diff --git a/srchybrid/ClientUDPSocket.cpp b/srchybrid/ClientUDPSocket.cpp index 5e52b454..e0e95dbd 100644 --- a/srchybrid/ClientUDPSocket.cpp +++ b/srchybrid/ClientUDPSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -97,7 +97,7 @@ void CClientUDPSocket::OnReceive(int nErrorCode) if (nPacketLen < 2) strError = _T("Kad packet (compressed) too short"); else { - BYTE* unpack = NULL; + BYTE *unpack = NULL; uLongf unpackedsize = 0; uint32 nNewSize = nPacketLen * 10 + 300; int iZLibResult = Z_OK; @@ -119,7 +119,7 @@ void CClientUDPSocket::OnReceive(int nErrorCode) Kademlia::CKademlia::ProcessPacket(unpack, unpackedsize + 2 , ntohl(sockAddr.sin_addr.s_addr), ntohs(sockAddr.sin_port) , (Kademlia::CPrefs::GetUDPVerifyKey(sockAddr.sin_addr.s_addr) == nReceiverVerifyKey) - , Kademlia::CKadUDPKey(nSenderVerifyKey, theApp.GetPublicIP(false))); + , Kademlia::CKadUDPKey(nSenderVerifyKey, theApp.GetPublicIP())); } catch (...) { delete[] unpack; throw; @@ -135,25 +135,25 @@ void CClientUDPSocket::OnReceive(int nErrorCode) else Kademlia::CKademlia::ProcessPacket(pBuffer, nPacketLen, ntohl(sockAddr.sin_addr.s_addr), ntohs(sockAddr.sin_port) , (Kademlia::CPrefs::GetUDPVerifyKey(sockAddr.sin_addr.s_addr) == nReceiverVerifyKey) - , Kademlia::CKadUDPKey(nSenderVerifyKey, theApp.GetPublicIP(false))); + , Kademlia::CKadUDPKey(nSenderVerifyKey, theApp.GetPublicIP())); break; default: strError.Format(_T("Unknown protocol 0x%02x"), pBuffer[0]); } //code above does not need to throw strError - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); strError = _T("Invalid packet received"); - } catch (CMemoryException *error) { - error->Delete(); + } catch (CMemoryException *ex) { + ex->Delete(); strError = _T("Memory exception"); - } catch (const CString &error) { - strError = error; - } catch (Kademlia::CIOException *error) { - error->Delete(); + } catch (const CString &ex) { + strError = ex; + } catch (Kademlia::CIOException *ex) { + ex->Delete(); strError = _T("Invalid packet received"); - } catch (CException *error) { - error->Delete(); + } catch (CException *ex) { + ex->Delete(); strError = _T("General packet error"); #ifndef _DEBUG } catch (...) { @@ -262,7 +262,7 @@ bool CClientUDPSocket::ProcessPacket(const BYTE *packet, UINT size, uint8 opcode //something in the extended info data as this will be taken care of in ProcessExtendedInfo() //Update extended info. if (sender->GetUDPVersion() > 3) - sender->ProcessExtendedInfo(&data_in, reqfile); + sender->ProcessExtendedInfo(data_in, reqfile); //Update our complete source counts. else if (sender->GetUDPVersion() > 2) { @@ -330,7 +330,7 @@ bool CClientUDPSocket::ProcessPacket(const BYTE *packet, UINT size, uint8 opcode if (sender && sender->UDPPacketPending()) { CSafeMemFile data_in(packet, size); if (sender->GetUDPVersion() > 3) - sender->ProcessFileStatus(true, &data_in, sender->GetRequestFile()); + sender->ProcessFileStatus(true, data_in, sender->GetRequestFile()); uint16 nRank = data_in.ReadUInt16(); sender->SetRemoteQueueFull(false); diff --git a/srchybrid/ClientUDPSocket.h b/srchybrid/ClientUDPSocket.h index 6188be20..c892f060 100644 --- a/srchybrid/ClientUDPSocket.h +++ b/srchybrid/ClientUDPSocket.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ClientVersionInfo.h b/srchybrid/ClientVersionInfo.h deleted file mode 100644 index 11359d1f..00000000 --- a/srchybrid/ClientVersionInfo.h +++ /dev/null @@ -1,153 +0,0 @@ -//this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) -// -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU General Public License -//as published by the Free Software Foundation; either -//version 2 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. -// -//You should have received a copy of the GNU General Public License -//along with this program; if not, write to the Free Software - -#pragma once -#include "emule.h" -#include "updownclient.h" -// class to convert peercache Client versions to comparable values. - -#define CVI_IGNORED (UINT_MAX) -// Version comparison rules -// == means same client type, same or ignored version (for example, eMule/0.4.* == eMule/0.4.2) -// != means different client or different defined version (for example, eMule/0.4.2 != SomeClient/0.4.2) -// > mean _same client type_ and higher version, which therefore cannot be completely undefined (for example, eMule/1.* > eMule/0.4.2) -// >= same as > but here the version can be undefined (for example, eMule/* >= eMule/0.4.2) -class CClientVersionInfo -{ - void init(UINT nVerMajor, UINT nVerMinor, UINT nVerUpdate, UINT nVerBuild, UINT ClientTypeMajor, UINT ClientTypeMinor) - { - m_nVerMajor = nVerMajor; - m_nVerMinor = nVerMinor; - m_nVerUpdate = nVerUpdate; - m_nVerBuild = nVerBuild; - m_ClientTypeMajor = ClientTypeMajor; - m_ClientTypeMinor = ClientTypeMinor; - } - -public: - explicit CClientVersionInfo(const CString &strPCEncodedVersion) - { - init(CVI_IGNORED, CVI_IGNORED, CVI_IGNORED, CVI_IGNORED, SO_UNKNOWN, SO_UNKNOWN); - - int posSeparator = strPCEncodedVersion.Find('/', 1); - if (posSeparator < 0 || strPCEncodedVersion.GetLength() - posSeparator < 2) { - theApp.QueueDebugLogLine(false, _T("PeerCache Error: Bad Version info in PeerCache Descriptor found: %s"), (LPCTSTR)strPCEncodedVersion); - return; - } - const CString strClientType(strPCEncodedVersion.Left(posSeparator).Trim()); - const CString strVersionNumber(strPCEncodedVersion.Mid(posSeparator + 1).Trim()); - - if (strClientType.CompareNoCase(_T("eMule")) == 0) - m_ClientTypeMajor = SO_EMULE; - else if (strClientType.CompareNoCase(_T("eDonkey")) == 0) - m_ClientTypeMajor = SO_EDONKEYHYBRID; - // can add more types here - else { - theApp.QueueDebugLogLine(false, _T("PeerCache Warning: Unknown Clienttype in descriptor file found")); - m_ClientTypeMajor = SO_UNKNOWN; - } - - int iPos = 0; - CString strNumber = strVersionNumber.Tokenize(_T("."), iPos); - if (strNumber.IsEmpty()) - return; - m_nVerMajor = (strNumber == _T("*")) ? CVI_IGNORED : _tstoi(strNumber); - - strNumber = strVersionNumber.Tokenize(_T("."), iPos); - if (strNumber.IsEmpty()) - return; - m_nVerMinor = (strNumber == _T("*")) ? CVI_IGNORED : _tstoi(strNumber); - - strNumber = strVersionNumber.Tokenize(_T("."), iPos); - if (strNumber.IsEmpty()) - return; - m_nVerUpdate = (strNumber == _T("*")) ? CVI_IGNORED : _tstoi(strNumber); - - strNumber = strVersionNumber.Tokenize(_T("."), iPos); - if (strNumber.IsEmpty()) - return; - m_nVerBuild = (strNumber == _T("*")) ? CVI_IGNORED : _tstoi(strNumber); - } - - CClientVersionInfo(uint32 dwTagVersionInfo, UINT nClientMajor) - { - UINT nClientMajVersion = (dwTagVersionInfo >> 17) & 0x7f; - UINT nClientMinVersion = (dwTagVersionInfo >> 10) & 0x7f; - UINT nClientUpVersion = (dwTagVersionInfo >> 7) & 0x07; - init(nClientMajVersion, nClientMinVersion, nClientUpVersion, CVI_IGNORED, nClientMajor, SO_UNKNOWN); - } - - CClientVersionInfo(UINT nVerMajor, UINT nVerMinor, UINT nVerUpdate, UINT nVerBuild, UINT ClientTypeMajor, UINT ClientTypeMinor = SO_UNKNOWN) - { - init(nVerMajor, nVerMinor, nVerUpdate, nVerBuild, ClientTypeMajor, ClientTypeMinor); - } - - CClientVersionInfo() - { - init(CVI_IGNORED, CVI_IGNORED, CVI_IGNORED, CVI_IGNORED, SO_UNKNOWN, SO_UNKNOWN); - } - - friend bool operator==(const CClientVersionInfo &c1, const CClientVersionInfo &c2) - { - return (c1.m_nVerMajor == CVI_IGNORED || c2.m_nVerMajor == CVI_IGNORED || c1.m_nVerMajor == c2.m_nVerMajor) - && (c1.m_nVerMinor == CVI_IGNORED || c2.m_nVerMinor == CVI_IGNORED || c1.m_nVerMinor == c2.m_nVerMinor) - && (c1.m_nVerUpdate == CVI_IGNORED || c2.m_nVerUpdate == CVI_IGNORED || c1.m_nVerUpdate == c2.m_nVerUpdate) - && (c1.m_nVerBuild == CVI_IGNORED || c2.m_nVerBuild == CVI_IGNORED || c1.m_nVerBuild == c2.m_nVerBuild) - && (c1.m_ClientTypeMajor == CVI_IGNORED || c2.m_ClientTypeMajor == CVI_IGNORED || c1.m_ClientTypeMajor == c2.m_ClientTypeMajor) - && (c1.m_ClientTypeMinor == CVI_IGNORED || c2.m_ClientTypeMinor == CVI_IGNORED || c1.m_ClientTypeMinor == c2.m_ClientTypeMinor); - } - - friend bool operator !=(const CClientVersionInfo &c1, const CClientVersionInfo &c2) - { - return !(c1 == c2); - } - - friend bool operator >(const CClientVersionInfo &c1, const CClientVersionInfo &c2) - { - if (c1.m_ClientTypeMajor == CVI_IGNORED || c2.m_ClientTypeMajor == CVI_IGNORED - || c1.m_ClientTypeMajor != c2.m_ClientTypeMajor || c1.m_ClientTypeMinor != c2.m_ClientTypeMinor) - { - return false; - } - return (c1.m_nVerMajor != CVI_IGNORED && c2.m_nVerMajor != CVI_IGNORED && c1.m_nVerMajor > c2.m_nVerMajor) - || (c1.m_nVerMinor != CVI_IGNORED && c2.m_nVerMinor != CVI_IGNORED && c1.m_nVerMinor > c2.m_nVerMinor) - || (c1.m_nVerUpdate != CVI_IGNORED && c2.m_nVerUpdate != CVI_IGNORED && c1.m_nVerUpdate > c2.m_nVerUpdate) - || (c1.m_nVerBuild != CVI_IGNORED && c2.m_nVerBuild != CVI_IGNORED && c1.m_nVerBuild > c2.m_nVerBuild); - - } - - friend bool operator <(const CClientVersionInfo &c1, const CClientVersionInfo &c2) - { - return c2 > c1; - } - - friend bool operator <=(const CClientVersionInfo &c1, const CClientVersionInfo &c2) - { - return c2 > c1 || c1 == c2; - } - - friend bool operator >=(const CClientVersionInfo &c1, const CClientVersionInfo &c2) - { - return c1 > c2 || c1 == c2; - } - - UINT m_nVerMajor; - UINT m_nVerMinor; - UINT m_nVerUpdate; - UINT m_nVerBuild; - UINT m_ClientTypeMajor; - UINT m_ClientTypeMinor; //unused atm -}; \ No newline at end of file diff --git a/srchybrid/ClosableTabCtrl.cpp b/srchybrid/ClosableTabCtrl.cpp index ea360ef0..1429b9b9 100644 --- a/srchybrid/ClosableTabCtrl.cpp +++ b/srchybrid/ClosableTabCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -201,7 +201,6 @@ void CClosableTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS) tci.dwStateMask = TCIS_HIGHLIGHTED; if (!GetItem(nTabIndex, &tci)) return; - szLabel[_countof(szLabel) - 1] = _T('\0'); //TRACE("CClosableTabCtrl::DrawItem: item=%u, state=%08x, color=%08x, rc=%3d,%3d,%3dx%3d\n", nTabIndex, tci.dwState, GetTextColor(lpDIS->hDC), lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right - lpDIS->rcItem.left, lpDIS->rcItem.bottom - lpDIS->rcItem.top); CDC *pDC = CDC::FromHandle(lpDIS->hDC); diff --git a/srchybrid/Collection.cpp b/srchybrid/Collection.cpp index 8b748601..18aba730 100644 --- a/srchybrid/Collection.cpp +++ b/srchybrid/Collection.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "collection.h" #include "KnownFile.h" @@ -38,8 +37,8 @@ static char THIS_FILE[] = __FILE__; CCollection::CCollection() : m_bTextFormat() - , m_pabyCollectionAuthorKey() , m_nKeySize() + , m_pabyCollectionAuthorKey() { m_CollectionFilesMap.InitHashTable(1031); m_sCollectionName.Format(_T("New Collection-%u"), ::GetTickCount()); @@ -189,8 +188,8 @@ bool CCollection::InitCollectionFromFile(const CString &sFilePath, const CString } else m_sCollectionAuthorName.Empty(); data.Close(); - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); return false; } catch (...) { ASSERT(0); @@ -226,8 +225,8 @@ bool CCollection::InitCollectionFromFile(const CString &sFilePath, const CString m_sCollectionName = sFileName.Left(iLen); m_bTextFormat = true; return true; - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -252,8 +251,8 @@ void CCollection::WriteToFileAddShared(CryptoPP::RSASSA_PKCS1v15_SHA_Signer *pSi data.WriteString(pair->value->GetED2kLink() + _T('\n')); data.Close(); - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); return; } catch (...) { ASSERT(0); @@ -311,8 +310,8 @@ void CCollection::WriteToFileAddShared(CryptoPP::RSASSA_PKCS1v15_SHA_Signer *pSi delete[] pBuffer; } data.Close(); - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); return; } catch (...) { ASSERT(0); diff --git a/srchybrid/Collection.h b/srchybrid/Collection.h index 8c861f24..d650053b 100644 --- a/srchybrid/Collection.h +++ b/srchybrid/Collection.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( merkur-@users.sourceforge.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( merkur-@users.sourceforge.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -53,7 +53,7 @@ class CCollection bool m_bTextFormat; private: + uint32 m_nKeySize; CCollectionFilesMap m_CollectionFilesMap; byte *m_pabyCollectionAuthorKey; - uint32 m_nKeySize; }; \ No newline at end of file diff --git a/srchybrid/CollectionCreateDialog.cpp b/srchybrid/CollectionCreateDialog.cpp index fac9dca0..0345855f 100644 --- a/srchybrid/CollectionCreateDialog.cpp +++ b/srchybrid/CollectionCreateDialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CollectionCreateDialog.h b/srchybrid/CollectionCreateDialog.h index f8d55c21..ef61b89d 100644 --- a/srchybrid/CollectionCreateDialog.h +++ b/srchybrid/CollectionCreateDialog.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CollectionFile.cpp b/srchybrid/CollectionFile.cpp index 2891beac..43b4cee0 100644 --- a/srchybrid/CollectionFile.cpp +++ b/srchybrid/CollectionFile.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "collectionfile.h" #include "Packets.h" @@ -67,7 +66,7 @@ CCollectionFile::CCollectionFile(CFileDataIO &in_data) // to avoid using 'wrong' file types for part files when adding a search result to the download queue, // in no case we will use the received file type (this has to be handled when creating the part files) const CString &rstrFileType(GetStrTagValue(FT_FILETYPE)); - CCollectionFile::SetFileName(GetStrTagValue(FT_FILENAME), false, rstrFileType.IsEmpty()); + CCollectionFile::SetAFileName(GetStrTagValue(FT_FILENAME), false, rstrFileType.IsEmpty()); CCollectionFile::SetFileSize(GetInt64TagValue(FT_FILESIZE)); if (!rstrFileType.IsEmpty()) if (rstrFileType == _T(ED2KFTSTR_PROGRAM)) { @@ -125,7 +124,7 @@ bool CCollectionFile::InitFromLink(const CString &sLink) SetFileSize(pFileLink->GetSize()); m_taglist.Add(new CTag(FT_FILENAME, pFileLink->GetName())); - SetFileName(pFileLink->GetName()); + SetAFileName(pFileLink->GetName()); if (pFileLink->HasValidAICHHash()) { m_taglist.Add(new CTag(FT_AICH_HASH, pFileLink->GetAICHHash().GetString())); diff --git a/srchybrid/CollectionFile.h b/srchybrid/CollectionFile.h index af587377..6f223a1e 100644 --- a/srchybrid/CollectionFile.h +++ b/srchybrid/CollectionFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "abstractfile.h" diff --git a/srchybrid/CollectionListCtrl.cpp b/srchybrid/CollectionListCtrl.cpp index 5469a007..cd0a3ca5 100644 --- a/srchybrid/CollectionListCtrl.cpp +++ b/srchybrid/CollectionListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( merkur-@users.sourceforge.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( merkur-@users.sourceforge.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CollectionListCtrl.h b/srchybrid/CollectionListCtrl.h index 3a02902c..8bd75afe 100644 --- a/srchybrid/CollectionListCtrl.h +++ b/srchybrid/CollectionListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( merkur-@users.sourceforge.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( merkur-@users.sourceforge.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "MuleListCtrl.h" #include "ListCtrlItemWalk.h" diff --git a/srchybrid/CollectionViewDialog.cpp b/srchybrid/CollectionViewDialog.cpp index 2fc08893..5800e6b2 100644 --- a/srchybrid/CollectionViewDialog.cpp +++ b/srchybrid/CollectionViewDialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CollectionViewDialog.h b/srchybrid/CollectionViewDialog.h index 478d6c6a..7b9f66cb 100644 --- a/srchybrid/CollectionViewDialog.h +++ b/srchybrid/CollectionViewDialog.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ColorButton.h b/srchybrid/ColorButton.h index eb1d1a81..d649e289 100644 --- a/srchybrid/ColorButton.h +++ b/srchybrid/ColorButton.h @@ -8,7 +8,7 @@ // in CColourPopup. I was hoping for (cough... gag...) a more Microsoft look // and I think this is pretty close. Hope you like it. // -// ORIGINAL: http://www.codeproject.com/miscctrl/colour_picker.asp +// ORIGINAL: https://www.codeproject.com/miscctrl/colour_picker.asp // //*************************************************************************** #pragma once diff --git a/srchybrid/ColourPopup.cpp b/srchybrid/ColourPopup.cpp index e0a0eff5..545138f8 100644 --- a/srchybrid/ColourPopup.cpp +++ b/srchybrid/ColourPopup.cpp @@ -121,10 +121,16 @@ CColourPopup::CColourPopup(CPoint p, COLORREF crColour, CWnd *pParentWnd m_crColour = m_crInitialColour = crColour; m_pParent = pParentWnd; - m_strDefaultText = szDefaultText ? szDefaultText : _T(""); - m_strCustomText = szCustomText ? szCustomText : _T(""); + if (szDefaultText) + m_strDefaultText = szDefaultText; + else + m_strDefaultText.Empty(); + if (szCustomText) + m_strCustomText = szCustomText; + else + m_strCustomText.Empty(); - CColourPopup::Create(p, crColour, pParentWnd, szDefaultText, szCustomText); + CColourPopup::CreateWnd(p, crColour, pParentWnd, szDefaultText, szCustomText); } void CColourPopup::Initialise() @@ -154,8 +160,8 @@ void CColourPopup::Initialise() // Create the font NONCLIENTMETRICS ncm; - ncm.cbSize = (UINT)sizeof(NONCLIENTMETRICS); - VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)); + ncm.cbSize = (UINT)sizeof NONCLIENTMETRICS; + VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof NONCLIENTMETRICS, &ncm, 0)); m_Font.CreateFontIndirect(&(ncm.lfMessageFont)); // Create the palette @@ -165,19 +171,19 @@ void CColourPopup::Initialise() PALETTEENTRY PalEntry[MAX_COLOURS]; } pal; - LOGPALETTE *pLogPalette = (LOGPALETTE*)&pal; + LOGPALETTE *pLogPalette = &pal.LogPalette; pLogPalette->palVersion = 0x300; pLogPalette->palNumEntries = (WORD)m_nNumColours; if (colourArrayPassed == NULL) //use default array - for (int i = 0; i < m_nNumColours; ++i) { + for (int i = m_nNumColours; --i >= 0 ;) { pLogPalette->palPalEntry[i].peRed = GetRValue(m_crColours[i].crColour); pLogPalette->palPalEntry[i].peGreen = GetGValue(m_crColours[i].crColour); pLogPalette->palPalEntry[i].peBlue = GetBValue(m_crColours[i].crColour); pLogPalette->palPalEntry[i].peFlags = 0; } else //if an array has been passed use it - for(int i = 0; i < m_nNumColours; ++i) { + for (int i = m_nNumColours; --i >= 0;) { pLogPalette->palPalEntry[i].peRed = GetRValue(colourArrayPassed[i]); pLogPalette->palPalEntry[i].peGreen = GetGValue(colourArrayPassed[i]); pLogPalette->palPalEntry[i].peBlue = GetBValue(colourArrayPassed[i]); @@ -193,7 +199,7 @@ CColourPopup::~CColourPopup() m_Palette.DeleteObject(); } -BOOL CColourPopup::Create(CPoint p, COLORREF crColour, CWnd *pParentWnd +BOOL CColourPopup::CreateWnd(CPoint p, COLORREF crColour, CWnd *pParentWnd , LPCTSTR szDefaultText /* = NULL */ , LPCTSTR szCustomText /* = NULL */) { diff --git a/srchybrid/ColourPopup.h b/srchybrid/ColourPopup.h index c6a4794b..e10dbe6f 100644 --- a/srchybrid/ColourPopup.h +++ b/srchybrid/ColourPopup.h @@ -48,7 +48,7 @@ class CColourPopup : public CWnd // Operations public: - BOOL Create(CPoint p, COLORREF crColour, CWnd *pParentWnd, LPCTSTR szDefaultText = NULL + BOOL CreateWnd(CPoint p, COLORREF crColour, CWnd *pParentWnd, LPCTSTR szDefaultText = NULL , LPCTSTR szCustomText = NULL); // Overrides diff --git a/srchybrid/ComboBoxEx2.cpp b/srchybrid/ComboBoxEx2.cpp index 28a50624..fac1a9f9 100644 --- a/srchybrid/ComboBoxEx2.cpp +++ b/srchybrid/ComboBoxEx2.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -36,7 +36,7 @@ int CComboBoxEx2::AddItem(LPCTSTR pszText, int iImage) COMBOBOXEXITEM cbi = {}; cbi.mask = CBEIF_TEXT; cbi.iItem = -1; - cbi.pszText = (LPTSTR)pszText; + cbi.pszText = const_cast(pszText); if (iImage >= 0) { cbi.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE; cbi.iImage = iImage; diff --git a/srchybrid/CommentDialog.cpp b/srchybrid/CommentDialog.cpp index 66953e75..f09ff827 100644 --- a/srchybrid/CommentDialog.cpp +++ b/srchybrid/CommentDialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CommentDialogLst.cpp b/srchybrid/CommentDialogLst.cpp index 1416d977..ae06db53 100644 --- a/srchybrid/CommentDialogLst.cpp +++ b/srchybrid/CommentDialogLst.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CommentListCtrl.cpp b/srchybrid/CommentListCtrl.cpp index 16163308..435b0c69 100644 --- a/srchybrid/CommentListCtrl.cpp +++ b/srchybrid/CommentListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( merkur-@users.sourceforge.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( merkur-@users.sourceforge.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CommentListCtrl.h b/srchybrid/CommentListCtrl.h index 9497663c..78801aea 100644 --- a/srchybrid/CommentListCtrl.h +++ b/srchybrid/CommentListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CorruptionBlackBox.cpp b/srchybrid/CorruptionBlackBox.cpp index 31e3da11..4430b8a2 100644 --- a/srchybrid/CorruptionBlackBox.cpp +++ b/srchybrid/CorruptionBlackBox.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/CorruptionBlackBox.h b/srchybrid/CorruptionBlackBox.h index 39cd7bad..e5aa8231 100644 --- a/srchybrid/CorruptionBlackBox.h +++ b/srchybrid/CorruptionBlackBox.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once class CUpDownClient; diff --git a/srchybrid/CreditsThread.cpp b/srchybrid/CreditsThread.cpp index 622d5c69..b03becb9 100644 --- a/srchybrid/CreditsThread.cpp +++ b/srchybrid/CreditsThread.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -390,7 +390,7 @@ void CCreditsThread::InitText() m_arCredits.Add(_T("03:00:eMule")); m_arCredits.Add(_T("02:01:Version ") + theApp.m_strCurVersionLong); - m_arCredits.Add(_T("01:06:Copyright (C) 2002-2023 Merkur")); + m_arCredits.Add(_T("01:06:Copyright (C) 2002-2024 Merkur")); m_arCredits.Add(_T("S:50")); m_arCredits.Add(_T("02:04:Developers")); m_arCredits.Add(_T("S:5")); diff --git a/srchybrid/CustomAutoComplete.cpp b/srchybrid/CustomAutoComplete.cpp index 51891ec6..84b02084 100644 --- a/srchybrid/CustomAutoComplete.cpp +++ b/srchybrid/CustomAutoComplete.cpp @@ -323,7 +323,7 @@ bool CCustomAutoComplete::SaveList(LPCTSTR pszFileName) if (fp == NULL) return false; bool ret = (fputwc(u'\xFEFF', fp) != WEOF); // write Unicode byte order mark 0xFEFF - for (int i = 0; ret && i < m_asList.GetCount(); ++i) + for (INT_PTR i = 0; ret && i < m_asList.GetCount(); ++i) ret = (_ftprintf(fp, _T("%s\r\n"), (LPCTSTR)m_asList[i]) > 0); return fclose(fp) ? false : ret; } diff --git a/srchybrid/DeadSourceList.cpp b/srchybrid/DeadSourceList.cpp index 685bc527..a65caa28 100644 --- a/srchybrid/DeadSourceList.cpp +++ b/srchybrid/DeadSourceList.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/DeadSourceList.h b/srchybrid/DeadSourceList.h index f87b9e12..1f211654 100644 --- a/srchybrid/DeadSourceList.h +++ b/srchybrid/DeadSourceList.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "otherfunctions.h" diff --git a/srchybrid/Debug_FileSize.h b/srchybrid/Debug_FileSize.h index e84854aa..ebacebd1 100644 --- a/srchybrid/Debug_FileSize.h +++ b/srchybrid/Debug_FileSize.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/DirectDownloadDlg.cpp b/srchybrid/DirectDownloadDlg.cpp index dc70104b..33896a1f 100644 --- a/srchybrid/DirectDownloadDlg.cpp +++ b/srchybrid/DirectDownloadDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/DirectDownloadDlg.h b/srchybrid/DirectDownloadDlg.h index 405a8c2d..c143dcdf 100644 --- a/srchybrid/DirectDownloadDlg.h +++ b/srchybrid/DirectDownloadDlg.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/DirectoryTreeCtrl.cpp b/srchybrid/DirectoryTreeCtrl.cpp index 5e143f61..a19f9b6e 100644 --- a/srchybrid/DirectoryTreeCtrl.cpp +++ b/srchybrid/DirectoryTreeCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -17,6 +17,7 @@ #include "stdafx.h" #include "emule.h" #include "DirectoryTreeCtrl.h" +#include "MenuCmds.h" #include "otherfunctions.h" #include "Preferences.h" #include "TitleMenu.h" @@ -112,6 +113,26 @@ void CDirectoryTreeCtrl::ShareSubDirTree(HTREEITEM hItem, BOOL bRecurse) Invalidate(); } +void CDirectoryTreeCtrl::AddDirectory(const CString &strDir) +{ + m_lstShared.AddTail(strDir); + if (::PathIsUNC(strDir)) { + const CString &sShare(GetShareName(strDir)); + INT_PTR i = m_aUNCshares.GetCount(); + if (!i) + m_aUNCshares.Add(sShare); + else + while (--i >= 0) { + int cmp = sShare.CompareNoCase(m_aUNCshares[i]); + if (cmp >= 0) { + if (cmp) + m_aUNCshares.InsertAt(i + 1, sShare); + break; + } + } + } +} + void CDirectoryTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point) { //VQB adjustments to provide for sharing or unsharing of subdirectories when control key is Down @@ -129,7 +150,7 @@ void CDirectoryTreeCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) if (hItem) { ShareSubDirTree(hItem, GetKeyState(VK_CONTROL) < 0); - // if Ctrl+Space is passed to the tree control, it just beeps and does not check/uncheck the item! + // if Ctrl+Space is passed to the tree control, it just beeps and does not check/uncheck the hItem! SetCheck(hItem, !GetCheck(hItem)); return; } @@ -187,9 +208,7 @@ void CDirectoryTreeCtrl::Init() TCHAR drivebuffer[500]; DWORD dwRet = GetLogicalDriveStrings(_countof(drivebuffer) - 1, drivebuffer); - if (dwRet > 0 && dwRet < _countof(drivebuffer)) { - drivebuffer[_countof(drivebuffer) - 1] = _T('\0'); - + if (dwRet > 0 && dwRet < _countof(drivebuffer)) for (LPCTSTR pos = drivebuffer; *pos != _T('\0');) { // Copy drive name TCHAR drive[4]; @@ -200,9 +219,9 @@ void CDirectoryTreeCtrl::Init() // Point to the next drive pos += _tcslen(pos) + 1; } - } - for (INT_PTR i = 0; i < m_lstUNC.GetCount(); ++i) { - const CString &sUNC(m_lstUNC[i]); + + for (INT_PTR i = 0; i < m_aUNCshares.GetCount(); ++i) { + const CString &sUNC(m_aUNCshares[i]); AddChildItem(NULL, sUNC.Left(sUNC.GetLength() - 1)); } @@ -227,7 +246,7 @@ HTREEITEM CDirectoryTreeCtrl::AddChildItem(HTREEITEM hRoot, const CString &strTe // END: changed by FoRcHa /////// itInsert.item.state = HasSharedSubdirectory(strDir) ? TVIS_BOLD : 0; - // used to display the + symbol next to each item + // used to display [+] and [-] buttons next to items itInsert.item.cChildren = HasSubdirectories(strDir) ? I_CHILDRENCALLBACK : 0; // START: added by FoRcHa //////////////// @@ -237,27 +256,19 @@ HTREEITEM CDirectoryTreeCtrl::AddChildItem(HTREEITEM hRoot, const CString &strTe SHFILEINFO shFinfo; shFinfo.szDisplayName[0] = _T('\0'); - if (!::SHGetFileInfo(strDir, 0, &shFinfo, sizeof(shFinfo), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME)) { - TRACE(_T("Error getting SystemFileInfo!")); - itInsert.itemex.iImage = 0; // :( - } else { + if (::SHGetFileInfo(strDir, 0, &shFinfo, sizeof(shFinfo), SHGFI_SMALLICON | SHGFI_ICON | SHGFI_OPENICON | SHGFI_DISPLAYNAME)) { itInsert.itemex.iImage = shFinfo.iIcon; ::DestroyIcon(shFinfo.hIcon); if (hRoot == NULL && shFinfo.szDisplayName[0] != _T('\0')) { STreeItem *pti = new STreeItem; pti->strPath = strText; - itInsert.item.pszText = const_cast((LPCTSTR)pti->strPath); + itInsert.item.pszText = shFinfo.szDisplayName; itInsert.item.mask |= TVIF_PARAM; itInsert.item.lParam = (LPARAM)pti; } - } - - if (!::SHGetFileInfo(strDir, 0, &shFinfo, sizeof(shFinfo), SHGFI_ICON | SHGFI_OPENICON | SHGFI_SMALLICON)) { - TRACE(_T("Error Getting SystemFileInfo!")); - itInsert.itemex.iImage = 0; } else { - itInsert.itemex.iSelectedImage = shFinfo.iIcon; - ::DestroyIcon(shFinfo.hIcon); + TRACE(_T("Error getting SystemFileInfo!")); + itInsert.itemex.iImage = 0; // :( } // END: added by FoRcHa ////////////// @@ -309,29 +320,22 @@ void CDirectoryTreeCtrl::SetSharedDirectories(CStringList &list) { m_lstShared.RemoveAll(); - for (POSITION pos = list.GetHeadPosition(); pos != NULL;) { - const CString &sDir(list.GetNext(pos)); - m_lstShared.AddTail(sDir); - if (::PathIsUNC(sDir)) { - const CString &sShare(GetShareName(sDir)); - INT_PTR i = m_lstUNC.GetCount(); - if (!i) { - m_lstUNC.Add(sShare); - continue; - } - while (--i >= 0) { - int cmp = sShare.CompareNoCase(m_lstUNC[i]); - if (cmp >= 0) { - if (cmp) - m_lstUNC.InsertAt(i + 1, sShare); - break; - } - } - } - } + for (POSITION pos = list.GetHeadPosition(); pos != NULL;) + AddDirectory(list.GetNext(pos)); Init(); } +bool CDirectoryTreeCtrl::AddUNCShare(const CString &strDir) +{ + ASSERT(strDir.Right(1) == _T('\\')); + if (IsShared(strDir) || !thePrefs.IsShareableDirectory(strDir)) + return false; + + AddDirectory(strDir); + Init(); + return true; +} + bool CDirectoryTreeCtrl::HasSharedSubdirectory(const CString &strDir) { int iLen = strDir.GetLength(); @@ -351,7 +355,7 @@ void CDirectoryTreeCtrl::CheckChanged(HTREEITEM hItem, bool bChecked) if (bChecked) AddShare(strDir); else - DelShare(strDir); + RemShare(strDir); UpdateParentItems(hItem); GetParent()->SendMessage(WM_COMMAND, UM_ITEMSTATECHANGED, reinterpret_cast(m_hWnd)); @@ -373,7 +377,7 @@ void CDirectoryTreeCtrl::AddShare(const CString &strDir) m_lstShared.AddTail(strDir); } -void CDirectoryTreeCtrl::DelShare(const CString &strDir) +void CDirectoryTreeCtrl::RemShare(const CString &strDir) { ASSERT(strDir.Right(1) == _T('\\')); for (POSITION pos = m_lstShared.GetHeadPosition(); pos != NULL;) { @@ -399,74 +403,88 @@ void CDirectoryTreeCtrl::OnContextMenu(CWnd*, CPoint point) return; } - CPoint ptMenu(-1, -1); - if (ptMenu != point) { - ptMenu = point; - ScreenToClient(&point); - } else { - HTREEITEM hSel = GetNextItem(TVI_ROOT, TVGN_CARET); - if (hSel) { - CRect rcItem; - if (GetItemRect(hSel, &rcItem, TRUE)) { - ptMenu = rcItem.TopLeft(); - ClientToScreen(&ptMenu); - } - } else { - ptMenu.SetPoint(0, 0); - ClientToScreen(&ptMenu); - } - } - - HTREEITEM hItem = HitTest(point); + const HTREEITEM hItem = GetSelectedItem(); + if (!hItem) + return; + const CString &sItem(GetFullPath(hItem)); //trailing backslash // create the menu CTitleMenu SharedMenu; SharedMenu.CreatePopupMenu(); SharedMenu.AddMenuTitle(GetResString(IDS_SHAREDFOLDERS)); - bool bMenuIsEmpty = true; - - // add all shared directories - UINT_PTR iCnt = 0; - const CString &sView1(GetResString(IDS_VIEW1)); - CString sViewPath; - for (POSITION pos = m_lstShared.GetHeadPosition(); pos != NULL; ++iCnt) { - sViewPath.Format(_T("%s%s"), (LPCTSTR)sView1, (LPCTSTR)m_lstShared.GetNext(pos)); - SharedMenu.AppendMenu(MF_STRING, MP_SHAREDFOLDERS_FIRST + iCnt, sViewPath); - bMenuIsEmpty = false; - } - // add right clicked folder, if any - if (hItem) { - m_strLastRightClicked = GetFullPath(hItem); //trailing backslash - if (!IsShared(m_strLastRightClicked)) { - sViewPath.Format(_T("%s%s%s"), (LPCTSTR)sView1, (LPCTSTR)m_strLastRightClicked, (LPCTSTR)GetResString(IDS_VIEW2)); - if (!bMenuIsEmpty) - SharedMenu.AppendMenu(MF_SEPARATOR); - SharedMenu.AppendMenu(MF_STRING, MP_SHAREDFOLDERS_FIRST - 1, sViewPath); - bMenuIsEmpty = false; + SharedMenu.AppendMenu(MF_STRING, MP_OPENFOLDER, GetResString(IDS_OPENFOLDER)); + SharedMenu.AppendMenu(MF_STRING | MF_SEPARATOR); + if (IsShared(sItem)) { + SharedMenu.AppendMenu(MF_STRING, MP_UNSHAREDIR, GetResString(IDS_UNSHAREDIR)); + SharedMenu.AppendMenu(MF_STRING, MP_UNSHAREDIRSUB, GetResString(IDS_UNSHAREDIRSUB)); + if (PathIsUNC(sItem) && !GetParentItem(hItem)) { + CString sViewPath; + sViewPath.Format(_T("%s %s"), (LPCTSTR)GetResString(IDS_REMOVETHIS), (LPCTSTR)sItem); + SharedMenu.AppendMenu(MF_STRING | MF_SEPARATOR); + SharedMenu.AppendMenu(MF_STRING, MP_REMOVESHARE, sViewPath); } + } else { + SharedMenu.AppendMenu(MF_STRING, MP_SHAREDIR, GetResString(IDS_SHAREDIR)); + SharedMenu.AppendMenu(MF_STRING, MP_SHAREDIRSUB, GetResString(IDS_SHAREDIRSUB)); } // display menu - if (!bMenuIsEmpty) - SharedMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, ptMenu.x, ptMenu.y, this); + GetPopupMenuPos(*this, point); + SharedMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); + VERIFY(SharedMenu.DestroyMenu()); } -void CDirectoryTreeCtrl::OnRButtonDown(UINT, CPoint) +void CDirectoryTreeCtrl::OnRButtonDown(UINT, CPoint point) { - // catch WM_RBUTTONDOWN and do not route it the default way... otherwise we won't get a WM_CONTEXTMENU. - //CTreeCtrl::OnRButtonDown(nFlags, point); + UINT uHitFlags; + HTREEITEM hItem = HitTest(point, &uHitFlags); + if (hItem != NULL && (uHitFlags & TVHT_ONITEM)) { + Select(hItem, TVGN_CARET); + SetItemState(hItem, TVIS_SELECTED, TVIS_SELECTED); + } } BOOL CDirectoryTreeCtrl::OnCommand(WPARAM wParam, LPARAM) { - if (wParam < MP_SHAREDFOLDERS_FIRST) - ShellOpenFile(m_strLastRightClicked); - else { - POSITION pos = m_lstShared.FindIndex(wParam - MP_SHAREDFOLDERS_FIRST); - if (pos) - ShellOpenFile(m_lstShared.GetAt(pos)); + const HTREEITEM hItem = GetSelectedItem(); + if (!hItem) + return TRUE; + + const CString &sItem(GetFullPath(hItem)); + switch (wParam) { + case MP_OPENFOLDER: + ShellOpenFile(sItem); + break; + case MP_SHAREDIR: + case MP_UNSHAREDIR: + CheckChanged(hItem, wParam == MP_SHAREDIR); + SetCheck(hItem, wParam == MP_SHAREDIR); + break; + case MP_SHAREDIRSUB: + case MP_UNSHAREDIRSUB: + ShareSubDirTree(hItem, TRUE); + SetCheck(hItem, wParam == MP_SHAREDIRSUB); + break; + case MP_REMOVESHARE: + { + DeleteItem(hItem); + int iLen = sItem.GetLength(); + for (POSITION pos = m_lstShared.GetHeadPosition(); pos != NULL;) { + POSITION pos2 = pos; + const CString &sDir(m_lstShared.GetNext(pos)); + if (_tcsnicmp(sDir, sItem, iLen) == 0) + m_lstShared.RemoveAt(pos2); + } + for (INT_PTR i = m_aUNCshares.GetCount(); --i >= 0;) + if (_tcsnicmp(m_aUNCshares[i], sItem, iLen) == 0) { + m_aUNCshares.RemoveAt(i); + break; + } + + static_cast(GetParent())->SetModified(); + } } return TRUE; diff --git a/srchybrid/DirectoryTreeCtrl.h b/srchybrid/DirectoryTreeCtrl.h index 22b8fbf1..b2cd4c5e 100644 --- a/srchybrid/DirectoryTreeCtrl.h +++ b/srchybrid/DirectoryTreeCtrl.h @@ -3,7 +3,7 @@ // written by robert rostek - tecxx@rrs.at // ///////////////////////////////////////////// -#define MP_SHAREDFOLDERS_FIRST 46901 +#define MP_REMOVESHARE 46900 class CDirectoryTreeCtrl : public CTreeCtrl { @@ -21,6 +21,7 @@ class CDirectoryTreeCtrl : public CTreeCtrl void GetSharedDirectories(CStringList &list); // set shared directories void SetSharedDirectories(CStringList &list); + bool AddUNCShare(const CString &strDir); private: // add a new item @@ -39,17 +40,18 @@ class CDirectoryTreeCtrl : public CTreeCtrl void UpdateParentItems(HTREEITEM hChild); void ShareSubDirTree(HTREEITEM hItem, BOOL bRecurse); + void AddDirectory(const CString &strDir); + // share list access bool IsShared(const CString &strDir); void AddShare(const CString &strDir); - void DelShare(const CString &strDir); + void RemShare(const CString &strDir); void MarkChildren(HTREEITEM hChild, bool mark); CImageList m_images; CStringList m_lstShared; - CStringArray m_lstUNC; + CStringArray m_aUNCshares; //UNC "drives" (ordered array) CString m_strLastRightClicked; -// bool m_bSelectSubDirs; protected: DECLARE_MESSAGE_MAP() @@ -58,7 +60,7 @@ class CDirectoryTreeCtrl : public CTreeCtrl afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnTvnDeleteItem(LPNMHDR pNMHDR, LRESULT *pResult); afx_msg void OnContextMenu(CWnd*, CPoint point); - afx_msg void OnRButtonDown(UINT, CPoint); + afx_msg void OnRButtonDown(UINT, CPoint point); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnDestroy(); diff --git a/srchybrid/DownloadClient.cpp b/srchybrid/DownloadClient.cpp index 7572d226..d9b21795 100644 --- a/srchybrid/DownloadClient.cpp +++ b/srchybrid/DownloadClient.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -17,9 +17,9 @@ #include "stdafx.h" #include "emule.h" #include "UpDownClient.h" +#include "URLClient.h" #include "PartFile.h" #include "ListenSocket.h" -#include "PeerCacheSocket.h" #include "Preferences.h" #include "SafeFile.h" #include "Packets.h" @@ -29,7 +29,6 @@ #include "ClientUDPSocket.h" #include "emuledlg.h" #include "TransferDlg.h" -#include "PeerCacheFinder.h" #include "Exceptions.h" #include "clientlist.h" #include "Kademlia/Kademlia/Kademlia.h" @@ -215,11 +214,6 @@ bool CUpDownClient::AskForDownload() return TryToConnect(); } -bool CUpDownClient::IsSourceRequestAllowed() const -{ - return IsSourceRequestAllowed(m_reqfile); -} - bool CUpDownClient::IsSourceRequestAllowed(CPartFile *partfile, bool sourceExchangeCheck) const { DWORD dwTicks = ::GetTickCount() + CONNECTION_LATENCY; @@ -449,7 +443,7 @@ void CUpDownClient::SendStartupLoadReq() SendPacket(packet); } -void CUpDownClient::ProcessFileInfo(CSafeMemFile *data, CPartFile *file) +void CUpDownClient::ProcessFileInfo(CSafeMemFile &data, CPartFile *file) { LPCTSTR p; if (file == NULL) @@ -463,7 +457,7 @@ void CUpDownClient::ProcessFileInfo(CSafeMemFile *data, CPartFile *file) if (p) throw GetResString(IDS_ERR_WRONGFILEID) + p; - m_strClientFilename = data->ReadString(GetUnicodeSupport() != UTF8strNone); + m_strClientFilename = data.ReadString(GetUnicodeSupport() != UTF8strNone); if (thePrefs.GetDebugClientTCPLevel() > 0) Debug(_T(" Filename=\"%s\"\n"), (LPCTSTR)m_strClientFilename); // 26-Jul-2003: removed requesting the file status for files <= PARTSIZE for better compatibility with @@ -502,7 +496,7 @@ void CUpDownClient::ProcessFileInfo(CSafeMemFile *data, CPartFile *file) } } -void CUpDownClient::ProcessFileStatus(bool bUdpPacket, CSafeMemFile *data, CPartFile *file) +void CUpDownClient::ProcessFileStatus(bool bUdpPacket, CSafeMemFile &data, CPartFile *file) { if (!m_reqfile || file != m_reqfile) { CString str; @@ -518,7 +512,7 @@ void CUpDownClient::ProcessFileStatus(bool bUdpPacket, CSafeMemFile *data, CPart delete[] m_abyPartStatus; m_abyPartStatus = NULL; - uint16 nED2KPartCount = data->ReadUInt16(); + uint16 nED2KPartCount = data.ReadUInt16(); bool bPartsNeeded = m_bCompleteSource = !nED2KPartCount; int iNeeded = 0; if (bPartsNeeded) { @@ -545,7 +539,7 @@ void CUpDownClient::ProcessFileStatus(bool bUdpPacket, CSafeMemFile *data, CPart m_nPartCount = m_reqfile->GetPartCount(); m_abyPartStatus = new uint8[m_nPartCount]; for (UINT done = 0; done < m_nPartCount;) { - uint8 toread = data->ReadUInt8(); + uint8 toread = data.ReadUInt8(); for (UINT i = 0; i < 8 && done < m_nPartCount; ++i) { m_abyPartStatus[done] = (toread >> i) & 1; iNeeded += static_cast(m_abyPartStatus[done] && !m_reqfile->IsComplete(done)); @@ -746,7 +740,7 @@ void CUpDownClient::ProcessHashSet(const uchar *packet, uint32 size, bool bFileI } if (m_fHashsetRequestingMD4) if (bMD4) - DebugLog(_T("Received valid MD4 Hashset (FileIdentifiers) form %s, file: %s"), (LPCTSTR)DbgGetClientInfo(), (LPCTSTR)m_reqfile->GetFileName()); + DebugLog(_T("Received valid MD4 Hashset (FileIdentifiers) from %s, file: %s"), (LPCTSTR)DbgGetClientInfo(), (LPCTSTR)m_reqfile->GetFileName()); else { DebugLogWarning(_T("Client was unable to deliver requested MD4 hashset (shouldn't happen) - %s, file: %s"), (LPCTSTR)DbgGetClientInfo(), (LPCTSTR)m_reqfile->GetFileName()); m_reqfile->m_bMD4HashsetNeeded = true; @@ -754,7 +748,7 @@ void CUpDownClient::ProcessHashSet(const uchar *packet, uint32 size, bool bFileI if (m_fHashsetRequestingAICH) if (bAICH) - DebugLog(_T("Received valid AICH Part Hashset form %s, file: %s"), (LPCTSTR)DbgGetClientInfo(), (LPCTSTR)m_reqfile->GetFileName()); + DebugLog(_T("Received valid AICH Part Hashset from %s, file: %s"), (LPCTSTR)DbgGetClientInfo(), (LPCTSTR)m_reqfile->GetFileName()); else { DebugLogWarning(_T("Client was unable to deliver requested AICH part hashset, asking other clients - %s, file: %s"), (LPCTSTR)DbgGetClientInfo(), (LPCTSTR)m_reqfile->GetFileName()); m_reqfile->SetAICHHashSetNeeded(true); @@ -918,19 +912,19 @@ void CUpDownClient::SendBlockRequests() if (thePrefs.GetDebugClientTCPLevel() > 0) DebugSend("OP_RequestParts", this, m_reqfile->GetFileHash()); SendPacket(packet, true); - // on high-speed downloads, we want this packet to get out ASAP, so wake up - // the throttler if it is sleeping because there was nothing to send yet + // we want this packet to get out ASAP, especially for high-speed downloads + // so wake up the throttler if it was idle and fell asleep theApp.uploadBandwidthThrottler->NewUploadDataAvailable(); } -/* Barry - Originally, this wrote to disk only when a full 180k block +/* Barry - Originally, this method wrote to disk only when a full 180k block had been received from a client, and asked for data only by 180k blocks. - This means that on average 90k was lost for every connection + It means that on average 90k was lost for every connection to a client data source. That is a lot of wasted data. - To reduce data loss, packets are now written to a buffer + To reduce data loss, packets are now written to buffers and flushed to disk regularly regardless of size downloaded. This includes compressed packets. @@ -1115,7 +1109,7 @@ void CUpDownClient::ProcessBlockPacket(const uchar *packet, uint32 size, bool pa } // These checks only need to be done if any data was written - // Additionally, asynchronous writing allows tricks such as disconnecting from client while + // Also, asynchronous writing allows tricks such as disconnecting from client while // file data is being in buffers. // Hence additional checks. if (lenWritten > 0 && !m_PendingBlocks_list.IsEmpty() && cur_block->block) { @@ -1136,7 +1130,7 @@ void CUpDownClient::ProcessBlockPacket(const uchar *packet, uint32 size, bool pa } } - // Stop looping and exit method + // Stop looping and exit return; } @@ -1165,8 +1159,8 @@ int CUpDownClient::unzip(Pending_Block_Struct *block, const BYTE *zipped, uint32 zS->opaque = (voidpf)NULL; // Set output data streams, do this here to avoid overwriting on recursive calls - zS->next_out = (*unzipped); - zS->avail_out = (*lenUnzipped); + zS->next_out = *unzipped; + zS->avail_out = *lenUnzipped; // Initialise the z_stream err = inflateInit(zS); @@ -1184,8 +1178,8 @@ int CUpDownClient::unzip(Pending_Block_Struct *block, const BYTE *zipped, uint32 // Only set the output if not being called recursively if (iRecursion == 0) { - zS->next_out = (*unzipped); - zS->avail_out = (*lenUnzipped); + zS->next_out = *unzipped; + zS->avail_out = *lenUnzipped; } // Try to unzip the data @@ -1203,28 +1197,29 @@ int CUpDownClient::unzip(Pending_Block_Struct *block, const BYTE *zipped, uint32 TRACE_UNZIP("; Z_STREAM_END\n"); // Got a good result, set the size to the amount unzipped in this call (including all recursive calls) - (*lenUnzipped) = (zS->total_out - block->totalUnzipped); + *lenUnzipped = zS->total_out - block->totalUnzipped; block->totalUnzipped = zS->total_out; } else if ((err == Z_OK) && (zS->avail_out == 0) && (zS->avail_in != 0)) { // Output array was not big enough, call recursively until there is enough space TRACE_UNZIP("; output array not big enough (ain=%u)\n", zS->avail_in); // What size should we try next - uint32 newLength = (*lenUnzipped) *= 2; + *lenUnzipped *= 2; + uint32 newLength = *lenUnzipped; if (newLength == 0) newLength = lenZipped * 2; // Copy any data that was successfully unzipped to new array BYTE *temp = new BYTE[newLength]; ASSERT(zS->total_out - block->totalUnzipped <= newLength); - memcpy(temp, (*unzipped), (zS->total_out - block->totalUnzipped)); - delete[](*unzipped); - (*unzipped) = temp; - (*lenUnzipped) = newLength; + memcpy(temp, *unzipped, zS->total_out - block->totalUnzipped); + delete[] *unzipped; + *unzipped = temp; + *lenUnzipped = newLength; // Position stream output to correct place in new array - zS->next_out = (*unzipped) + (zS->total_out - block->totalUnzipped); - zS->avail_out = (*lenUnzipped) - (zS->total_out - block->totalUnzipped); + zS->next_out = *unzipped + (zS->total_out - block->totalUnzipped); + zS->avail_out = *lenUnzipped - (zS->total_out - block->totalUnzipped); // Try again err = unzip(block, zS->next_in, zS->avail_in, unzipped, lenUnzipped, iRecursion + 1); @@ -1232,7 +1227,7 @@ int CUpDownClient::unzip(Pending_Block_Struct *block, const BYTE *zipped, uint32 TRACE_UNZIP("; all input processed\n"); // All available input has been processed, everything OK. // Set the size to the amount unzipped in this call (including all recursive calls) - (*lenUnzipped) = (zS->total_out - block->totalUnzipped); + *lenUnzipped = zS->total_out - block->totalUnzipped; block->totalUnzipped = zS->total_out; } else { // Should not get here unless input data is corrupt @@ -1246,7 +1241,7 @@ int CUpDownClient::unzip(Pending_Block_Struct *block, const BYTE *zipped, uint32 } if (err != Z_OK) - (*lenUnzipped) = 0; + *lenUnzipped = 0; } catch (...) { if (thePrefs.GetVerbose()) DebugLogError(_T("Unknown exception in %hs: file \"%s\""), __FUNCTION__, m_reqfile ? (LPCTSTR)m_reqfile->GetFileName() : _T("")); @@ -1284,17 +1279,13 @@ uint32 CUpDownClient::CalculateDownloadRate() void CUpDownClient::CheckDownloadTimeout() { - if (::GetTickCount() >= m_dwLastBlockReceived + DOWNLOADTIMEOUT) - if (IsDownloadingFromPeerCache() && m_pPCDownSocket && m_pPCDownSocket->IsConnected()) { - ASSERT(DOWNLOADTIMEOUT < m_pPCDownSocket->GetTimeOut()); - OnPeerCacheDownSocketTimeout(); - } else { - if (socket != NULL && !socket->IsRawDataMode()) - SendCancelTransfer(); - else - ASSERT(0); - SetDownloadState(DS_ONQUEUE, _T("Timeout. More than 100 seconds since last complete block was received.")); - } + if (::GetTickCount() >= m_dwLastBlockReceived + DOWNLOADTIMEOUT) { + if (socket != NULL && !socket->IsRawDataMode()) + SendCancelTransfer(); + else + ASSERT(0); + SetDownloadState(DS_ONQUEUE, _T("Timeout. More than 100 seconds since last complete block was received.")); + } } uint16 CUpDownClient::GetAvailablePartCount() const @@ -1504,8 +1495,8 @@ bool CUpDownClient::SwapToRightFile(CPartFile *SwapTo, CPartFile *cur_file, bool else AddDebugLogLine(DLP_VERYLOW, false, _T("oooo Debug: Higher prio for unknown reason!")); - if (IsSourceRequestAllowed(cur_file) && (cur_file->AllowSwapForSourceExchange() || (cur_file == m_reqfile && RecentlySwappedForSourceExchange())) - || !(IsSourceRequestAllowed(SwapTo) && (SwapTo->AllowSwapForSourceExchange() || (SwapTo == m_reqfile && RecentlySwappedForSourceExchange()))) + if (IsSourceRequestAllowed(cur_file) && (cur_file->AllowSwapForSourceExchange(curTick) || (cur_file == m_reqfile && RecentlySwappedForSourceExchange())) + || !(IsSourceRequestAllowed(SwapTo) && (SwapTo->AllowSwapForSourceExchange(curTick) || (SwapTo == m_reqfile && RecentlySwappedForSourceExchange()))) || (GetDownloadState() == DS_ONQUEUE && GetRemoteQueueRank() <= 50)) { if (printDebug) @@ -1518,8 +1509,8 @@ bool CUpDownClient::SwapToRightFile(CPartFile *SwapTo, CPartFile *cur_file, bool wasSkippedDueToSourceExchange = true; } - if (IsSourceRequestAllowed(cur_file, true) && (cur_file->AllowSwapForSourceExchange() || (cur_file == m_reqfile && RecentlySwappedForSourceExchange())) - && !(IsSourceRequestAllowed(SwapTo, true) && (SwapTo->AllowSwapForSourceExchange() || (SwapTo == m_reqfile && RecentlySwappedForSourceExchange()))) + if (IsSourceRequestAllowed(cur_file, true) && (cur_file->AllowSwapForSourceExchange(curTick) || (cur_file == m_reqfile && RecentlySwappedForSourceExchange())) + && !(IsSourceRequestAllowed(SwapTo, true) && (SwapTo->AllowSwapForSourceExchange(curTick) || (SwapTo == m_reqfile && RecentlySwappedForSourceExchange()))) && (GetDownloadState() != DS_ONQUEUE || GetRemoteQueueRank() > 50)) { wasSkippedDueToSourceExchange = true; @@ -1959,12 +1950,6 @@ void CUpDownClient::SendCancelTransfer() socket->SendPacket(pCancelTransferPacket); SetSentCancelTransfer(true); } - - if (m_pPCDownSocket) { - m_pPCDownSocket->Safe_Delete(); - m_pPCDownSocket = NULL; - SetPeerCacheDownState(PCDS_NONE); - } } void CUpDownClient::SetRequestFile(CPartFile *pReqFile) @@ -1979,18 +1964,8 @@ void CUpDownClient::ProcessAcceptUpload() m_fQueueRankPending = 1; if (m_reqfile && !m_reqfile->IsStopped() && (m_reqfile->GetStatus() == PS_READY || m_reqfile->GetStatus() == PS_EMPTY)) { SetSentCancelTransfer(0); - if (GetDownloadState() == DS_ONQUEUE) { - // PC-TODO: If remote client does not answer the PeerCache query within a timeout, - // automatically fall back to ed2k download. - if (!SupportPeerCache() // client knows peercache protocol - || !thePrefs.IsPeerCacheDownloadEnabled() // user has enabled peercache downloads - || !theApp.m_pPeerCache->IsCacheAvailable() // we have found our cache and its usable - || !theApp.m_pPeerCache->IsClientPCCompatible(GetVersion(), GetClientSoft()) // the client version is accepted by the cache - || !SendPeerCacheFileRequest()) // request made - { - StartDownload(); - } - } + if (GetDownloadState() == DS_ONQUEUE) + StartDownload(); } else { SendCancelTransfer(); SetDownloadState((m_reqfile == NULL || m_reqfile->IsStopped()) ? DS_NONE : DS_ONQUEUE); diff --git a/srchybrid/DownloadClientsCtrl.cpp b/srchybrid/DownloadClientsCtrl.cpp index 2b687422..81add60c 100644 --- a/srchybrid/DownloadClientsCtrl.cpp +++ b/srchybrid/DownloadClientsCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/DownloadClientsCtrl.h b/srchybrid/DownloadClientsCtrl.h index 64d20e37..7c270146 100644 --- a/srchybrid/DownloadClientsCtrl.h +++ b/srchybrid/DownloadClientsCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/DownloadListCtrl.cpp b/srchybrid/DownloadListCtrl.cpp index c56a588e..569d8cff 100644 --- a/srchybrid/DownloadListCtrl.cpp +++ b/srchybrid/DownloadListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -803,6 +803,8 @@ void CDownloadListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) void CDownloadListCtrl::HideSources(CPartFile *toCollapse) { + if (!toCollapse->srcarevisible) + return; SetRedraw(false); for (int i = GetItemCount(); --i >= 0;) { CtrlItem_Struct *item = reinterpret_cast(GetItemData(i)); @@ -822,7 +824,7 @@ void CDownloadListCtrl::ExpandCollapseItem(int iItem, int iAction, bool bCollaps return; CtrlItem_Struct *content = reinterpret_cast(GetItemData(iItem)); - // to collapse/expand files when one of its source is selected + // to collapse/expand files when one of its sources is selected if (content != NULL && bCollapseSource && content->parent != NULL) { content = content->parent; @@ -980,10 +982,10 @@ void CDownloadListCtrl::OnContextMenu(CWnd*, CPoint point) m_FileMenu.EnableMenuItem((UINT)m_PreviewMenu.m_hMenu, m_PreviewMenu.HasEnabledItems() ? MF_ENABLED : MF_GRAYED); if (iPreviewMenuEntries > 0) - if (!thePrefs.GetExtraPreviewWithMenu()) - m_PreviewMenu.InsertMenu(1, MF_POPUP | MF_BYPOSITION | (iSelectedItems == 1 ? MF_ENABLED : MF_GRAYED), (UINT_PTR)PreviewWithMenu.m_hMenu, GetResString(IDS_PREVIEWWITH)); - else + if (thePrefs.GetExtraPreviewWithMenu()) m_FileMenu.InsertMenu(MP_METINFO, MF_POPUP | MF_BYCOMMAND | (iSelectedItems == 1 ? MF_ENABLED : MF_GRAYED), (UINT_PTR)PreviewWithMenu.m_hMenu, GetResString(IDS_PREVIEWWITH)); + else + m_PreviewMenu.InsertMenu(1, MF_POPUP | MF_BYPOSITION | (iSelectedItems == 1 ? MF_ENABLED : MF_GRAYED), (UINT_PTR)PreviewWithMenu.m_hMenu, GetResString(IDS_PREVIEWWITH)); } else { m_FileMenu.EnableMenuItem(MP_PREVIEW, (iSelectedItems == 1 && iFilesToPreview == 1) ? MF_ENABLED : MF_GRAYED); if (iPreviewMenuEntries > 0) @@ -2594,7 +2596,6 @@ bool CDownloadListCtrl::ReportAvailableCommands(CList &liAvailableCommands) iFilesToPreview += static_cast(pFile->IsReadyForPreview()); } - // enable commands if there is at least one item which can be used for the action if (iFilesToCancel > 0) liAvailableCommands.AddTail(MP_CANCEL); diff --git a/srchybrid/DownloadListCtrl.h b/srchybrid/DownloadListCtrl.h index 081988ca..9098f587 100644 --- a/srchybrid/DownloadListCtrl.h +++ b/srchybrid/DownloadListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/DownloadQueue.cpp b/srchybrid/DownloadQueue.cpp index fd6bd869..b348c186 100644 --- a/srchybrid/DownloadQueue.cpp +++ b/srchybrid/DownloadQueue.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -181,9 +181,9 @@ void CDownloadQueue::AddSearchToDownload(CSearchFile *toadd, uint8 paused, int c sources.WriteUInt16(toadd->GetClientPort()); sources.SeekToBegin(); newfile->AddSources(&sources, toadd->GetClientServerIP(), toadd->GetClientServerPort(), false); - } catch (CFileException *error) { + } catch (CFileException *ex) { ASSERT(0); - error->Delete(); + ex->Delete(); } } @@ -197,9 +197,9 @@ void CDownloadQueue::AddSearchToDownload(CSearchFile *toadd, uint8 paused, int c sources.WriteUInt16(aClients[i].m_nPort); sources.SeekToBegin(); newfile->AddSources(&sources, aClients[i].m_nServerIP, aClients[i].m_nServerPort, false); - } catch (CFileException *error) { + } catch (CFileException *ex) { ASSERT(0); - error->Delete(); + ex->Delete(); break; } } @@ -475,7 +475,7 @@ bool CDownloadQueue::CheckAndAddSource(CPartFile *sender, CUpDownClient *source) } // filter sources which are incompatible with our encryption setting (one requires it, and the other one doesn't support it) - if ((source->RequiresCryptLayer() && (!thePrefs.IsClientCryptLayerSupported() || !source->HasValidHash())) || (thePrefs.IsClientCryptLayerRequired() && (!source->SupportsCryptLayer() || !source->HasValidHash()))) { + if ((source->RequiresCryptLayer() && (!thePrefs.IsCryptLayerEnabled() || !source->HasValidHash())) || (thePrefs.IsCryptLayerRequired() && (!source->SupportsCryptLayer() || !source->HasValidHash()))) { #if defined(_DEBUG) || defined(_BETA) || defined(_DEVBUILD) //if (thePrefs.GetDebugSourceExchange()) // TODO: Uncomment after testing AddDebugLogLine(DLP_DEFAULT, false, _T("Rejected source because CryptLayer-Setting (Obfuscation) was incompatible for file %s : %s"), (LPCTSTR)sender->GetFileName(), (LPCTSTR)source->DbgGetClientInfo()); @@ -551,7 +551,7 @@ bool CDownloadQueue::CheckAndAddKnownSource(CPartFile *sender, CUpDownClient *so } // filter sources which are incompatible with our encryption setting (one requires it, and the other one doesn't support it) - if ((source->RequiresCryptLayer() && (!thePrefs.IsClientCryptLayerSupported() || !source->HasValidHash())) || (thePrefs.IsClientCryptLayerRequired() && (!source->SupportsCryptLayer() || !source->HasValidHash()))) { + if ((source->RequiresCryptLayer() && (!thePrefs.IsCryptLayerEnabled() || !source->HasValidHash())) || (thePrefs.IsCryptLayerRequired() && (!source->SupportsCryptLayer() || !source->HasValidHash()))) { #if defined(_DEBUG) || defined(_BETA) || defined(_DEVBUILD) //if (thePrefs.GetDebugSourceExchange()) // TODO: Uncomment after testing AddDebugLogLine(DLP_DEFAULT, false, _T("Rejected source because CryptLayer-Setting (Obfuscation) was incompatible for file %s : %s"), (LPCTSTR)sender->GetFileName(), (LPCTSTR)source->DbgGetClientInfo()); @@ -759,7 +759,7 @@ bool CDownloadQueue::SendNextUDPPacket() if (filelist.IsEmpty() || !theApp.serverconnect->IsUDPSocketAvailable() || !theApp.serverconnect->IsConnected() - || thePrefs.IsClientCryptLayerRequired()) // we cannot use sources received without user hash, so don't ask + || thePrefs.IsCryptLayerRequired()) // we cannot use sources received without user hash, so don't ask { return false; } @@ -990,7 +990,7 @@ void CDownloadQueue::CheckDiskspace(bool bNotEnoughSpaceLeft) uint64 nTotalAvailableSpaceMain = bNotEnoughSpaceLeft ? 0 : GetFreeDiskSpaceX(thePrefs.GetTempDir()); for (POSITION pos = filelist.GetHeadPosition(); pos != NULL;) { - CPartFile* cur_file = filelist.GetNext(pos); + CPartFile *cur_file = filelist.GetNext(pos); switch (cur_file->GetStatus()) { case PS_PAUSED: @@ -1357,7 +1357,7 @@ void CDownloadQueue::ProcessLocalRequests() } uint8 byOpcode; - if (thePrefs.IsClientCryptLayerSupported() && theApp.serverconnect->GetCurrentServer() != NULL && theApp.serverconnect->GetCurrentServer()->SupportsGetSourcesObfuscation()) + if (thePrefs.IsCryptLayerEnabled() && theApp.serverconnect->GetCurrentServer() != NULL && theApp.serverconnect->GetCurrentServer()->SupportsGetSourcesObfuscation()) byOpcode = OP_GETSOURCES_OBFU; else byOpcode = OP_GETSOURCES; @@ -1616,13 +1616,9 @@ void CDownloadQueue::ExportPartMetFilesOverview() const strTmpFileListPath.ReleaseBuffer(); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(strTmpFileListPath, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - CString strError; - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.Format(_T(" - %s"), szError); - LogError(_T("Failed to create part.met file list%s"), (LPCTSTR)strError); + CFileException fex; + if (!file.Open(strTmpFileListPath, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyWrite, &fex)) { + LogError(_T("Failed to create part.met file list%s"), (LPCTSTR)CExceptionStrDash(fex)); return; } @@ -1649,13 +1645,7 @@ void CDownloadQueue::ExportPartMetFilesOverview() const file.printf(_T("%s\t%s\r\n"), (LPCTSTR)pPartFile->GetFullName(), (LPCTSTR)pPartFile->GetED2kLink()); } } - - if (thePrefs.GetCommitFiles() >= 2 || (thePrefs.GetCommitFiles() >= 1 && theApp.IsClosing())) { - file.Flush(); // flush file stream buffers to disk buffers - if (_commit(_fileno(file.m_pStream)) != 0) // commit disk buffers to disk - AfxThrowFileException(CFileException::hardIO, ::GetLastError(), file.GetFileName()); - } - file.Close(); + CommitAndClose(file); CString strBakFileListPath(strFileListPath); PathRenameExtension(strBakFileListPath.GetBuffer(MAX_PATH), _T(".bak")); @@ -1666,13 +1656,9 @@ void CDownloadQueue::ExportPartMetFilesOverview() const if (_taccess(strFileListPath, 0) == 0) CFile::Rename(strFileListPath, strBakFileListPath); CFile::Rename(strTmpFileListPath, strFileListPath); - } catch (CFileException *e) { - CString strError; - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*e, szError, _countof(szError))) - strError.Format(_T(" - %s"), szError); - LogError(_T("Failed to write part.met file list%s"), (LPCTSTR)strError); - e->Delete(); + } catch (CFileException *ex) { + LogError(_T("Failed to write part.met file list%s"), (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); file.Abort(); (void)_tremove(file.GetFilePath()); } diff --git a/srchybrid/DownloadQueue.h b/srchybrid/DownloadQueue.h index a16f2578..143c7355 100644 --- a/srchybrid/DownloadQueue.h +++ b/srchybrid/DownloadQueue.h @@ -1,4 +1,4 @@ -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/DropDownButton.cpp b/srchybrid/DropDownButton.cpp index 86d81fc6..d4694898 100644 --- a/srchybrid/DropDownButton.cpp +++ b/srchybrid/DropDownButton.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -37,7 +37,7 @@ CDropDownButton::CDropDownButton() m_bSingleDropDownBtn = true; } -BOOL CDropDownButton::Create(DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, bool bSingleDropDownBtn) +BOOL CDropDownButton::CreateBar(DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, bool bSingleDropDownBtn) { m_bSingleDropDownBtn = bSingleDropDownBtn; dwStyle |= CCS_NOMOVEY diff --git a/srchybrid/DropDownButton.h b/srchybrid/DropDownButton.h index 22497002..6184d7a5 100644 --- a/srchybrid/DropDownButton.h +++ b/srchybrid/DropDownButton.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -23,7 +23,7 @@ class CDropDownButton : public CToolBarCtrlX public: CDropDownButton(); - BOOL Create(DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, bool bSingleDropDownBtn = true); + BOOL CreateBar(DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID, bool bSingleDropDownBtn = true); BOOL Init(bool bSingleDropDownBtn = true, bool bWholeDropDown = false); void SetWindowText(LPCTSTR pszString); diff --git a/srchybrid/DropTarget.cpp b/srchybrid/DropTarget.cpp index 5d789e77..047d70ea 100644 --- a/srchybrid/DropTarget.cpp +++ b/srchybrid/DropTarget.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ED2KLink.cpp b/srchybrid/ED2KLink.cpp index b2ebbb0e..97fb66dc 100644 --- a/srchybrid/ED2KLink.cpp +++ b/srchybrid/ED2KLink.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -128,7 +128,7 @@ CED2KFileLink::CED2KFileLink(LPCTSTR pszName, LPCTSTR pszSize, LPCTSTR pszHash throw GetResString(uid); bool bError = false; - for (int i = 0; !bError && i < astrParams.GetCount(); ++i) { + for (INT_PTR i = 0; !bError && i < astrParams.GetCount(); ++i) { const CString &strParam(astrParams[i]); ASSERT(!strParam.IsEmpty()); diff --git a/srchybrid/ED2KLink.h b/srchybrid/ED2KLink.h index a5501a87..e849ff47 100644 --- a/srchybrid/ED2KLink.h +++ b/srchybrid/ED2KLink.h @@ -75,7 +75,7 @@ class CED2KFileLink : public CED2KLink CED2KFileLink(LPCTSTR pszName, LPCTSTR pszSize, LPCTSTR pszHash, const CStringArray &astrParams, LPCTSTR pszSources); ~CED2KFileLink(); - LinkType GetKind() const { return kFile; }; + LinkType GetKind() const { return kFile; } void GetLink(CString &lnk) const; CED2KFileLink* GetFileLink() { return this; } diff --git a/srchybrid/ED2kLinkDlg.cpp b/srchybrid/ED2kLinkDlg.cpp index 85992355..e032997c 100644 --- a/srchybrid/ED2kLinkDlg.cpp +++ b/srchybrid/ED2kLinkDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -43,7 +43,6 @@ END_MESSAGE_MAP() CED2kLinkDlg::CED2kLinkDlg() : CResizablePage(CED2kLinkDlg::IDD) - , m_strLinks(_T(" ")) , m_paFiles() , m_bDataChanged() , m_bReducedDlg() @@ -72,19 +71,16 @@ BOOL CED2kLinkDlg::OnInitDialog() AddAnchor(IDC_LD_HASHSETCHE, BOTTOM_LEFT, BOTTOM_LEFT); AddAnchor(IDC_LD_HOSTNAMECHE, BOTTOM_LEFT, BOTTOM_LEFT); - // enabled/disable checkbox depending on situation - if (theApp.IsConnected() && !theApp.IsFirewalled()) - GetDlgItem(IDC_LD_SOURCECHE)->EnableWindow(TRUE); - else { - GetDlgItem(IDC_LD_SOURCECHE)->EnableWindow(FALSE); + // enabled/disable checkboxes depending on situation + bool b = theApp.IsConnected() && !theApp.IsFirewalled(); + GetDlgItem(IDC_LD_SOURCECHE)->EnableWindow(b); + if (!b) CheckDlgButton(IDC_LD_SOURCECHE, BST_UNCHECKED); - } - if (theApp.IsConnected() && !theApp.IsFirewalled() && thePrefs.GetYourHostname().Find(_T('.')) >= 0) - GetDlgItem(IDC_LD_HOSTNAMECHE)->EnableWindow(TRUE); - else { - GetDlgItem(IDC_LD_HOSTNAMECHE)->EnableWindow(FALSE); + else + b = thePrefs.GetYourHostname().Find(_T('.')) >= 0; + GetDlgItem(IDC_LD_HOSTNAMECHE)->EnableWindow(b); + if (!b) CheckDlgButton(IDC_LD_HOSTNAMECHE, BST_UNCHECKED); - } } else { CRect rcDefault; GetDlgItem(IDC_LD_LINKGROUP)->GetWindowRect(rcDefault); @@ -190,16 +186,14 @@ void CED2kLinkDlg::UpdateLink() //skip update if nothing has changed if (m_strLinks != strLinks) { - m_ctrlLinkEdit.SetWindowText(strLinks); m_strLinks = strLinks; + m_ctrlLinkEdit.SetWindowText(m_strLinks); } } void CED2kLinkDlg::OnBnClickedClipboard() { - CString strBuffer; - m_ctrlLinkEdit.GetWindowText(strBuffer); - theApp.CopyTextToClipboard(strBuffer); + theApp.CopyTextToClipboard(m_strLinks); } void CED2kLinkDlg::OnSettingsChange() diff --git a/srchybrid/ED2kLinkDlg.h b/srchybrid/ED2kLinkDlg.h index 5ba41dd8..73389f87 100644 --- a/srchybrid/ED2kLinkDlg.h +++ b/srchybrid/ED2kLinkDlg.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "ResizableLib/ResizablePage.h" diff --git a/srchybrid/EMSocket.cpp b/srchybrid/EMSocket.cpp index 152e71e1..d7e16a01 100644 --- a/srchybrid/EMSocket.cpp +++ b/srchybrid/EMSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -44,27 +44,27 @@ namespace va_list argptr; char bufferline[512]; va_start(argptr, fmt); - _vsnprintf(bufferline, 512, fmt, argptr); + vsnprintf(bufferline, _countof(bufferline), fmt, argptr); va_end(argptr); //(Ornis+) char osDate[30], osTime[30]; char temp[1024]; _strtime(osTime); _strdate(osDate); - int len = _snprintf(temp, 1021, "%s %s: %s\r\n", osDate, osTime, bufferline); + int len = snprintf(temp, _countof(temp), "%s %s: %s\r\n", osDate, osTime, bufferline); if (len > 0) { - HANDLE hFile = ::CreateFile(_T("c:\\EMSocket.log") // open MYFILE.TXT - , GENERIC_WRITE // open for reading + HANDLE hFile = ::CreateFile(_T("c:\\tmp\\EMSocket.log") // ensure valid path to a writable location + , GENERIC_WRITE // open for writing , FILE_SHARE_READ // share for reading , NULL // no security - , OPEN_ALWAYS // existing file only + , OPEN_ALWAYS // open existing or create new , FILE_ATTRIBUTE_NORMAL // normal file - , NULL); // no attr. template + , NULL); // no template file if (hFile != INVALID_HANDLE_VALUE) { - DWORD nbBytesWritten = 0; + DWORD nbBytesWritten; SetFilePointer(hFile, 0, NULL, FILE_END); - BOOL b = ::WriteFile(hFile // handle to file + ::WriteFile(hFile // handle to file , temp // data buffer , len // number of bytes to write , &nbBytesWritten // number of bytes written @@ -85,17 +85,17 @@ namespace IMPLEMENT_DYNAMIC(CEMSocket, CEncryptedStreamSocket) CEMSocket::CEMSocket() - : byConnected(ES_NOTCONNECTED) + : m_pProxyLayer() , m_uTimeOut(CONNECTION_TIMEOUT) // default timeout for ed2k sockets + , byConnected(EMS_NOTCONNECTED) , m_bProxyConnectFailed() - , m_pProxyLayer() - , downloadLimit() , downloadLimitEnable() , pendingOnReceive() - , pendingHeader() - , pendingHeaderSize() - , pendingPacket() + , downloadLimit() , pendingPacketSize() + , pendingPacket() + , pendingHeaderSize() + , pendingHeader() , sendbuffer() , sendblen() , sent() @@ -125,7 +125,7 @@ CEMSocket::~CEMSocket() // need to be locked here to know that the other methods // won't be in the middle of things sendLocker.Lock(); - byConnected = ES_DISCONNECTED; + byConnected = EMS_DISCONNECTED; CleanUpOverlappedSendOperation(true); sendLocker.Unlock(); @@ -228,7 +228,7 @@ void CEMSocket::OnClose(int nErrorCode) { // need to be locked here to know that the other methods // won't be in the middle of things - SetConState(ES_DISCONNECTED); + SetConState(EMS_DISCONNECTED); // now that we know no other method will keep adding to the queue // we can remove ourself from the queue @@ -265,10 +265,10 @@ void CEMSocket::OnReceive(int nErrorCode) } // Check current connection state - if (byConnected == ES_DISCONNECTED) + if (byConnected == EMS_DISCONNECTED) return; - byConnected = ES_CONNECTED; // ES_DISCONNECTED, ES_NOTCONNECTED, ES_CONNECTED + byConnected = EMS_CONNECTED; // EMS_DISCONNECTED, EMS_NOTCONNECTED, EMS_CONNECTED // CPU load improvement if (downloadLimitEnable && downloadLimit == 0 && nErrorCode != WSAESHUTDOWN) { @@ -284,7 +284,7 @@ void CEMSocket::OnReceive(int nErrorCode) // We attempt to read up to 2 megs at a time (minus whatever is in our internal read buffer) int ret = Receive(GlobalReadBuffer + pendingHeaderSize, (int)readMax); - if (ret == SOCKET_ERROR || byConnected == ES_DISCONNECTED) + if (ret == SOCKET_ERROR || byConnected == EMS_DISCONNECTED) return; // Bandwidth control @@ -337,7 +337,7 @@ void CEMSocket::OnReceive(int nErrorCode) if (pendingPacket == NULL) { // Bugfix We still need to check for a valid protocol - // Remark: the default eMule v0.26b had removed this test...... + // Remark: the default eMule v0.26b had removed this test... switch (reinterpret_cast(rptr)->eDonkeyID) { case OP_EDONKEYPROT: case OP_PACKEDPROT: @@ -374,8 +374,8 @@ void CEMSocket::OnReceive(int nErrorCode) ASSERT(pendingPacket->size >= pendingPacketSize); if (pendingPacket->size == pendingPacketSize) { #ifdef EMSOCKET_DEBUG - EMTrace("CEMSocket::PacketReceived on %d, opcode=%X, realSize=%d", - (SOCKET)this, pendingPacket->opcode, pendingPacket->GetRealPacketSize()); + EMTrace("CEMSocket::PacketReceived on %u, opcode=%X, realSize=%d" + , (SOCKET)this, pendingPacket->opcode, pendingPacket->GetRealPacketSize()); #endif // Process packet bool bPacketResult = PacketReceived(pendingPacket); @@ -438,7 +438,7 @@ void CEMSocket::SendPacket(Packet *packet, bool controlpacket, uint32 actualPayl { //EMTrace("CEMSocket::OnSenPacked1 controlcount %i, standardcount %i, isbusy: %i", controlpacket_queue.GetCount(), standardpacket_queue.GetCount(), IsBusy()); - if (byConnected == ES_DISCONNECTED) { + if (byConnected == EMS_DISCONNECTED) { delete packet; return; } @@ -466,7 +466,7 @@ void CEMSocket::SendPacket(Packet *packet, bool controlpacket, uint32 actualPayl if (bForceImmediateSend) { ASSERT(controlpacket_queue.GetCount() == 1); - Send(1024, 0, true); + SendEM(1024, 0, true); } } @@ -507,10 +507,10 @@ void CEMSocket::OnSend(int nErrorCode) // stopped sending here. //StoppedSendSoUpdateStats(); - if (byConnected == ES_DISCONNECTED) + if (byConnected == EMS_DISCONNECTED) return; - byConnected = ES_CONNECTED; + byConnected = EMS_CONNECTED; if (m_currentPacket_is_controlpacket) { // queue up for control packet @@ -521,9 +521,9 @@ void CEMSocket::OnSend(int nErrorCode) theApp.uploadBandwidthThrottler->SocketAvailable(); } -SocketSentBytes CEMSocket::Send(uint32 maxNumberOfBytesToSend, uint32 minFragSize, bool onlyAllowedToSendControlPacket) +SocketSentBytes CEMSocket::SendEM(uint32 maxNumberOfBytesToSend, uint32 minFragSize, bool onlyAllowedToSendControlPacket) { - if (byConnected == ES_DISCONNECTED) + if (byConnected == EMS_DISCONNECTED) return SocketSentBytes{}; if (m_bUseOverlappedSend) return SendOv(maxNumberOfBytesToSend, minFragSize, onlyAllowedToSendControlPacket); @@ -556,7 +556,7 @@ SocketSentBytes CEMSocket::SendStd(uint32 maxNumberOfBytesToSend, uint32 minFrag SocketSentBytes ret = { 0, 0, true }; sendLocker.Lock(); - if (byConnected == ES_CONNECTED && IsEncryptionLayerReady()) { + if (byConnected == EMS_CONNECTED && IsEncryptionLayerReady()) { if (minFragSize < 1) minFragSize = 1; @@ -732,7 +732,7 @@ SocketSentBytes CEMSocket::SendOv(uint32 maxNumberOfBytesToSend, uint32 minFragS SocketSentBytes ret = {0, 0, true}; sendLocker.Lock(); - if (byConnected == ES_CONNECTED && IsEncryptionLayerReady() && !IsBusyExtensiveCheck() && maxNumberOfBytesToSend > 0) { + if (byConnected == EMS_CONNECTED && IsEncryptionLayerReady() && !IsBusyExtensiveCheck() && maxNumberOfBytesToSend > 0) { if (minFragSize < 1) minFragSize = 1; @@ -798,7 +798,7 @@ SocketSentBytes CEMSocket::SendOv(uint32 maxNumberOfBytesToSend, uint32 minFragS // yay pCurBuf.len = curPacket->GetRealPacketSize(); pCurBuf.buf = curPacket->DetachPacket(); - CryptPrepareSendData((uchar*)pCurBuf.buf, pCurBuf.len);// encrypting which cannot be done transparent by base class + CryptPrepareSendData((uchar*)pCurBuf.buf, pCurBuf.len);// encryption cannot be done transparently in the base class ::InterlockedAdd((LONG*)&m_actualPayloadSizeSent, queueEntry.actualPayloadSize); lastFinishedStandard = timeGetTime(); m_bAccelerateUpload = false; @@ -808,7 +808,7 @@ SocketSentBytes CEMSocket::SendOv(uint32 maxNumberOfBytesToSend, uint32 minFragS sendblen = curPacket->GetRealPacketSize(); sendbuffer = curPacket->DetachPacket(); sent = 0; - CryptPrepareSendData((uchar*)sendbuffer, sendblen); // encrypting which cannot be done transparent by base class + CryptPrepareSendData((uchar*)sendbuffer, sendblen); // encryption cannot be done transparently in the base class pCurBuf.len = min(sendblen - sent, (uint32)nBytesLeft); pCurBuf.buf = new CHAR[pCurBuf.len]; memcpy(pCurBuf.buf, sendbuffer, pCurBuf.len); @@ -870,7 +870,7 @@ uint32 CEMSocket::GetNextFragSize(uint32 current, uint32 minFragSize) uint32 CEMSocket::GetNeededBytes() { sendLocker.Lock(); - if (byConnected == ES_DISCONNECTED) { + if (byConnected == EMS_DISCONNECTED) { sendLocker.Unlock(); return 0; } @@ -915,15 +915,15 @@ uint32 CEMSocket::GetNeededBytes() // pach2: // written this overriden Receive to handle transparently FIN notifications coming from calls to recv() // This was maybe(??) the cause of a lot of socket error, notably after a brutal close from peer -// also added trace so that we can debug after the fact... +// also added trace so that we can debug after the fact. int CEMSocket::Receive(void *lpBuf, int nBufLen, int nFlags) { - //EMTrace("CEMSocket::Receive on %lu, maxSize=%d", (SOCKET)this, nBufLen); + //EMTrace("CEMSocket::Receive on %u, maxSize=%d", (SOCKET)this, nBufLen); int recvRetCode = CEncryptedStreamSocket::Receive(lpBuf, nBufLen, nFlags); // deadlake PROXYSUPPORT - changed to AsyncSocketEx switch (recvRetCode) { case 0: if (GetRealReceivedBytes() <= 0) { // we received data but it was for the underlying encryption layer - all fine - //EMTrace("CEMSocket::##Received FIN on %d, maxSize=%d",(SOCKET)this,nBufLen); + //EMTrace("CEMSocket::##Received FIN on %u, maxSize=%d", (SOCKET)this, nBufLen); // FIN received on socket // Connection is being closed by peer //ASSERT (false); if (!AsyncSelect(FD_CLOSE | FD_WRITE)) { // no more READ notifications... @@ -937,45 +937,45 @@ int CEMSocket::Receive(void *lpBuf, int nBufLen, int nFlags) switch (CAsyncSocket::GetLastError()) { case WSANOTINITIALISED: ASSERT(0); - EMTrace("CEMSocket::OnReceive: A successful AfxSocketInit must occur before using this API."); + EMTrace("%sA successful AfxSocketInit must occur before using this API."); break; case WSAENETDOWN: ASSERT(true); - p = "CEMSocket::OnReceive: The socket %u received a net down error"; + p = "%sThe socket %u received a net down error"; break; - case WSAENOTCONN: // The socket is not connected. - p = "CEMSocket::OnReceive: The socket %u is not connected"; + case WSAENOTCONN: + p = "%sThe socket %u is not connected"; break; - case WSAEINPROGRESS: // A blocking Windows Sockets operation is in progress. - p = "CEMSocket::OnReceive: The socket %u is blocked"; + case WSAEINPROGRESS: // A blocking Windows Sockets operation is in progress. + p = "%sThe socket %u is blocked"; break; - case WSAEWOULDBLOCK: // The socket is marked as nonblocking and the Receive operation would block. - p = "CEMSocket::OnReceive: The socket %u would block"; + case WSAEWOULDBLOCK: // The socket is marked as nonblocking and the Receive operation would block. + p = "%sThe socket %u would block"; break; - case WSAENOTSOCK: // The descriptor is not a socket. - p = "CEMSocket::OnReceive: The descriptor %u is not a socket (may have been closed or never created)"; + case WSAENOTSOCK: // The descriptor is not a socket. + p = "%sThe descriptor %u is not a socket (may have been closed or never created)"; break; - case WSAEOPNOTSUPP: // MSG_OOB was specified, but the socket is not of type SOCK_STREAM. + case WSAEOPNOTSUPP: // MSG_OOB was specified, but the socket is not of type SOCK_STREAM. break; - case WSAESHUTDOWN: // The socket has been shut down; it is not possible to call Receive on a socket after ShutDown(0) or ShutDown(2) has been invoked. - p = "CEMSocket::OnReceive: The socket %u has been shut down"; + case WSAESHUTDOWN: // The socket has been shut down; it is impossible to call Receive on a socket after ShutDown(0) or ShutDown(2) has been invoked. + p = "%sThe socket %u has been shut down"; break; - case WSAEMSGSIZE: // The datagram was too large to fit into the specified buffer and was truncated. - p = "CEMSocket::OnReceive: The datagram was too large to fit and was truncated (socket %u)"; + case WSAEMSGSIZE: // The datagram was too large to fit into the specified buffer and was truncated. + p = "%sThe datagram was too large to fit and was truncated (socket %u)"; break; - case WSAEINVAL: // The socket has not been bound with Bind. - case WSAECONNABORTED: // The virtual circuit was aborted due to timeout or other failure. - case WSAECONNRESET: // The virtual circuit was reset by the remote side. - p = "CEMSocket::OnReceive: The socket %u has not been bound"; + case WSAEINVAL: // The socket has not been bound with Bind. + case WSAECONNABORTED: // The virtual circuit was aborted due to timeout or other failure. + case WSAECONNRESET: // The virtual circuit was reset by the remote side. + p = "%sThe socket %u has not been bound"; break; default: EMTrace("CEMSocket::OnReceive: Unexpected socket error %x on socket %u", CAsyncSocket::GetLastError(), (SOCKET)this); } if (p) - EMTrace(p, (SOCKET)this); + EMTrace(p, "CEMSocket::OnReceive: ", (SOCKET)this); // break; // default: -// EMTrace("CEMSocket::OnReceive on %u, receivedSize=%d",(SOCKET)this,recvRetCode); +// EMTrace("CEMSocket::OnReceive on %u, receivedSize=%d", (SOCKET)this, recvRetCode); } return recvRetCode; } @@ -1038,7 +1038,7 @@ void CEMSocket::AssertValid() const const_cast(this)->sendLocker.Lock(); - ASSERT(byConnected == ES_DISCONNECTED || byConnected == ES_NOTCONNECTED || byConnected == ES_CONNECTED); + ASSERT(byConnected == EMS_DISCONNECTED || byConnected == EMS_NOTCONNECTED || byConnected == EMS_CONNECTED); CHECK_BOOL(m_bProxyConnectFailed); CHECK_PTR(m_pProxyLayer); (void)downloadLimit; @@ -1078,16 +1078,6 @@ void CEMSocket::DataReceived(const BYTE*, UINT) ASSERT(0); } -DWORD CEMSocket::GetTimeOut() const -{ - return m_uTimeOut; -} - -void CEMSocket::SetTimeOut(DWORD uTimeOut) -{ - m_uTimeOut = uTimeOut; -} - CString CEMSocket::GetFullErrorMessage(DWORD dwError) { CString strError; diff --git a/srchybrid/EMSocket.h b/srchybrid/EMSocket.h index 7c9f10a6..5eded59d 100644 --- a/srchybrid/EMSocket.h +++ b/srchybrid/EMSocket.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -21,9 +21,9 @@ class CAsyncProxySocketLayer; -#define ES_DISCONNECTED 0xFF -#define ES_NOTCONNECTED 0x00 -#define ES_CONNECTED 0x01 +#define EMS_DISCONNECTED 0xFF +#define EMS_NOTCONNECTED 0x00 +#define EMS_CONNECTED 0x01 struct StandardPacketQueueEntry { @@ -39,7 +39,7 @@ class CEMSocket : public CEncryptedStreamSocket, public ThrottledFileSocket // Z ~CEMSocket(); virtual void SendPacket(Packet *packet, bool controlpacket = true, uint32 actualPayloadSize = 0, bool bForceImmediateSend = false); - bool IsConnected() const { return byConnected == ES_CONNECTED; } + bool IsConnected() const { return byConnected == EMS_CONNECTED; } uint8 GetConState() const { return byConnected; } void SetConState(uint8 val) { sendLocker.Lock(); byConnected = val; sendLocker.Unlock(); } virtual bool IsRawDataMode() const { return false; } @@ -53,8 +53,8 @@ class CEMSocket : public CEncryptedStreamSocket, public ThrottledFileSocket // Z virtual bool UseBigSendBuffer(); INT_PTR DbgGetStdQueueCount() const { return standardpacket_queue.GetCount(); } - virtual DWORD GetTimeOut() const; - virtual void SetTimeOut(DWORD uTimeOut); + virtual DWORD GetTimeOut() const { return m_uTimeOut; } + virtual void SetTimeOut(DWORD uTimeOut) { m_uTimeOut = uTimeOut; } virtual bool Connect(const CString &sHostAddress, UINT nHostPort); virtual BOOL Connect(const LPSOCKADDR pSockAddr, int iSockAddrLen); @@ -78,8 +78,8 @@ class CEMSocket : public CEncryptedStreamSocket, public ThrottledFileSocket // Z uint32 GetSentPayloadSinceLastCall(bool bReset); void TruncateQueues(); - virtual SocketSentBytes SendControlData(uint32 maxNumberOfBytesToSend, uint32 minFragSize) { return Send(maxNumberOfBytesToSend, minFragSize, true); }; - virtual SocketSentBytes SendFileAndControlData(uint32 maxNumberOfBytesToSend, uint32 minFragSize) { return Send(maxNumberOfBytesToSend, minFragSize, false); }; + virtual SocketSentBytes SendControlData(uint32 maxNumberOfBytesToSend, uint32 minFragSize) { return SendEM(maxNumberOfBytesToSend, minFragSize, true); } + virtual SocketSentBytes SendFileAndControlData(uint32 maxNumberOfBytesToSend, uint32 minFragSize) { return SendEM(maxNumberOfBytesToSend, minFragSize, false); } uint32 GetNeededBytes(); #ifdef _DEBUG @@ -94,14 +94,14 @@ class CEMSocket : public CEncryptedStreamSocket, public ThrottledFileSocket // Z virtual void DataReceived(const BYTE *pcData, UINT uSize); virtual bool PacketReceived(Packet *packet) = 0; virtual void OnError(int nErrorCode) = 0; - uint8 byConnected; - UINT m_uTimeOut; - bool m_bProxyConnectFailed; CAsyncProxySocketLayer *m_pProxyLayer; CString m_strLastProxyError; + UINT m_uTimeOut; + uint8 byConnected; + bool m_bProxyConnectFailed; private: - virtual SocketSentBytes Send(uint32 maxNumberOfBytesToSend, uint32 minFragSize, bool onlyAllowedToSendControlPacket); + virtual SocketSentBytes SendEM(uint32 maxNumberOfBytesToSend, uint32 minFragSize, bool onlyAllowedToSendControlPacket); SocketSentBytes SendStd(uint32 maxNumberOfBytesToSend, uint32 minFragSize, bool onlyAllowedToSendControlPacket); SocketSentBytes SendOv(uint32 maxNumberOfBytesToSend, uint32 minFragSize, bool onlyAllowedToSendControlPacket); void ClearQueues(); @@ -110,17 +110,17 @@ class CEMSocket : public CEncryptedStreamSocket, public ThrottledFileSocket // Z static uint32 GetNextFragSize(uint32 current, uint32 minFragSize); // Download (pseudo) rate control - uint32 downloadLimit; bool downloadLimitEnable; bool pendingOnReceive; - - // Download partial header - char pendingHeader[PACKET_HEADER_SIZE]; // actually, this holds only 'PACKET_HEADER_SIZE-1' bytes. - size_t pendingHeaderSize; + uint32 downloadLimit; // Download partial packet - Packet *pendingPacket; uint32 pendingPacketSize; + Packet *pendingPacket; + + // Download partial header + size_t pendingHeaderSize; + char pendingHeader[PACKET_HEADER_SIZE]; // actually, this holds only 'PACKET_HEADER_SIZE-1' bytes. // Upload control char *sendbuffer; diff --git a/srchybrid/EditDelayed.cpp b/srchybrid/EditDelayed.cpp index adb3383b..f421428e 100644 --- a/srchybrid/EditDelayed.cpp +++ b/srchybrid/EditDelayed.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -222,16 +222,16 @@ void CEditDelayed::OnLButtonDown(UINT nFlags, CPoint point) int nCount = m_pctrlColumnHeader->GetItemCount(); for (int i = 0; i < nCount; ++i) { int nIdx = m_pctrlColumnHeader->OrderToIndex(i); - m_pctrlColumnHeader->GetItem(nIdx, &hdi); - szBuffer[_countof(szBuffer) - 1] = _T('\0'); - bool bVisible = true; - for (INT_PTR j = m_aIgnoredColumns.GetCount(); --j >= 0;) - if (m_aIgnoredColumns[j] == nIdx) { - bVisible = false; - break; - } - if (hdi.cxy > 0 && bVisible) // ignore hidden columns - menu.AppendMenu(MF_STRING | ((m_nCurrentColumnIdx == nIdx) ? MF_CHECKED : MF_UNCHECKED), MP_FILTERCOLUMNS + nIdx, hdi.pszText); + if (m_pctrlColumnHeader->GetItem(nIdx, &hdi)) { + bool bVisible = true; + for (INT_PTR j = m_aIgnoredColumns.GetCount(); --j >= 0;) + if (m_aIgnoredColumns[j] == nIdx) { + bVisible = false; + break; + } + if (hdi.cxy > 0 && bVisible) // ignore hidden columns + menu.AppendMenu(MF_STRING | ((m_nCurrentColumnIdx == nIdx) ? MF_CHECKED : MF_UNCHECKED), MP_FILTERCOLUMNS + nIdx, hdi.pszText); + } } // draw the menu on a fixed position so it doesn't hide the input text @@ -310,10 +310,8 @@ void CEditDelayed::ShowColumnText(bool bShow) hdi.mask = HDI_TEXT | HDI_WIDTH; hdi.pszText = szBuffer; hdi.cchTextMax = _countof(szBuffer); - if (m_pctrlColumnHeader->GetItem(m_nCurrentColumnIdx, &hdi)) { - szBuffer[_countof(szBuffer) - 1] = _T('\0'); + if (m_pctrlColumnHeader->GetItem(m_nCurrentColumnIdx, &hdi)) SetWindowText(szBuffer); - } } else SetWindowText(m_strAlternateText); } else if (m_bShowsColumnText) { diff --git a/srchybrid/EditDelayed.h b/srchybrid/EditDelayed.h index 5cdcce43..d3f96904 100644 --- a/srchybrid/EditDelayed.h +++ b/srchybrid/EditDelayed.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once ////////////////////////////////////////////////////////////////////////////// diff --git a/srchybrid/EditX.cpp b/srchybrid/EditX.cpp index 954eb17c..d27cc24c 100644 --- a/srchybrid/EditX.cpp +++ b/srchybrid/EditX.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Emule.cpp b/srchybrid/Emule.cpp index 7581e794..50cb978f 100644 --- a/srchybrid/Emule.cpp +++ b/srchybrid/Emule.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -57,7 +57,6 @@ #include "Preferences.h" #include "secrunasuser.h" #include "SafeFile.h" -#include "PeerCacheFinder.h" #include "emuleDlg.h" #include "SearchDlg.h" #include "enbitmap.h" @@ -292,6 +291,7 @@ CemuleApp::CemuleApp(LPCTSTR lpszAppName) , m_dwPublicIP() , m_bGuardClipboardPrompt() , m_bAutoStart() + , m_bStandbyOff() { // Initialize Windows security features. #if !defined(_DEBUG) && !defined(_WIN64) @@ -336,12 +336,12 @@ CemuleApp::CemuleApp(LPCTSTR lpszAppName) // create the protocol version number CString strTmp; - strTmp.Format(_T("0x%u"), m_dwProductVersionMS); + strTmp.Format(_T("0x%lu"), m_dwProductVersionMS); VERIFY(_stscanf(strTmp, _T("0x%x"), &m_uCurVersionShort) == 1); ASSERT(m_uCurVersionShort < 0x99); // create the version check number - strTmp.Format(_T("0x%u%c"), m_dwProductVersionMS, _T('A') + CemuleApp::m_nVersionUpd); + strTmp.Format(_T("0x%lu%c"), m_dwProductVersionMS, _T('A') + CemuleApp::m_nVersionUpd); VERIFY(_stscanf(strTmp, _T("0x%x"), &m_uCurVersionCheck) == 1); ASSERT(m_uCurVersionCheck < 0x999); // MOD Note: end @@ -614,7 +614,6 @@ BOOL CemuleApp::InitInstance() ipfilter = new CIPFilter(); webserver = new CWebServer(); // Web Server [kuchin] scheduler = new CScheduler(); - m_pPeerCache = new CPeerCacheFinder(); // ZZ:UploadSpeedSense --> lastCommonRouteFinder = new LastCommonRouteFinder(); @@ -949,14 +948,9 @@ void CemuleApp::OnlineSig() // Added By Bouc7 // - Although this file is a text file, we set the file mode to 'binary' because of backward // compatibility with older eMule versions. CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(strSigPath, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite | CFile::typeBinary, &fexp)) { - CString strError; - strError.Format(_T("%s %s"), (LPCTSTR)GetResString(IDS_ERROR_SAVEFILE), _szFileName); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(fexp, szError, _countof(szError)); - strError.Format(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + CFileException fex; + if (!file.Open(strSigPath, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite | CFile::typeBinary, &fex)) { + LogError(LOG_STATUSBAR, _T("%s %s%s"), (LPCTSTR)GetResString(IDS_ERROR_SAVEFILE), _szFileName, (LPCTSTR)CExceptionStrDash(fex)); return; } @@ -988,13 +982,11 @@ void CemuleApp::OnlineSig() // Added By Bouc7 file.Write("0", 1); file.Write("\n", 1); - _snprintf(buffer, _countof(buffer), "%.1f", (float)downloadqueue->GetDatarate() / 1024); - buffer[_countof(buffer) - 1] = '\0'; + snprintf(buffer, _countof(buffer), "%.1f", (float)downloadqueue->GetDatarate() / 1024); file.Write(buffer, (UINT)strlen(buffer)); file.Write("|", 1); - _snprintf(buffer, _countof(buffer), "%.1f", (float)uploadqueue->GetDatarate() / 1024); - buffer[_countof(buffer) - 1] = '\0'; + snprintf(buffer, _countof(buffer), "%.1f", (float)uploadqueue->GetDatarate() / 1024); file.Write(buffer, (UINT)strlen(buffer)); file.Write("|", 1); @@ -1003,11 +995,7 @@ void CemuleApp::OnlineSig() // Added By Bouc7 file.Close(); } catch (CFileException *ex) { - TCHAR szError[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*ex, szError, _countof(szError)); - CString strError; - strError.Format(_T("%s %s - %s"), (LPCTSTR)GetResString(IDS_ERROR_SAVEFILE), _szFileName, szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + LogError(LOG_STATUSBAR, _T("%s %s%s"), (LPCTSTR)GetResString(IDS_ERROR_SAVEFILE), _szFileName, (LPCTSTR)CExceptionStrDash(*ex)); ex->Delete(); } } //End Added By Bouc7 @@ -1150,9 +1138,14 @@ uint32 CemuleApp::GetID() return static_cast(Kademlia::CKademlia::IsConnected() && Kademlia::CKademlia::IsFirewalled()); } -uint32 CemuleApp::GetPublicIP(bool bIgnoreKadIP) const +uint32 CemuleApp::GetED2KPublicIP() const { - if (!bIgnoreKadIP && m_dwPublicIP == 0 && Kademlia::CKademlia::IsConnected()) { + return m_dwPublicIP; +} + +uint32 CemuleApp::GetPublicIP() const +{ + if (m_dwPublicIP == 0 && Kademlia::CKademlia::IsConnected()) { uint32 uIP = Kademlia::CKademlia::GetIPAddress(); if (uIP) return ntohl(uIP); @@ -1164,14 +1157,12 @@ void CemuleApp::SetPublicIP(const uint32 dwIP) { if (dwIP != 0) { ASSERT(!::IsLowID(dwIP)); - ASSERT(m_pPeerCache); if (GetPublicIP() == 0) AddDebugLogLine(DLP_VERYLOW, false, _T("My public IP Address is: %s"), (LPCTSTR)ipstr(dwIP)); else if (Kademlia::CKademlia::IsConnected() && Kademlia::CKademlia::GetPrefs()->GetIPAddress()) if (htonl(Kademlia::CKademlia::GetIPAddress()) != dwIP) AddDebugLogLine(DLP_DEFAULT, false, _T("Public IP Address reported by Kademlia (%s) differs from new-found (%s)"), (LPCTSTR)ipstr(htonl(Kademlia::CKademlia::GetIPAddress())), (LPCTSTR)ipstr(dwIP)); - m_pPeerCache->FoundMyPublicIPAddress(dwIP); } else AddDebugLogLine(DLP_VERYLOW, false, _T("Deleted public IP")); @@ -1237,7 +1228,7 @@ HICON CemuleApp::LoadIcon(LPCTSTR lpszResourceName, int cx, int cy, UINT uFlags) if (szSkinResource[0] != _T('\0')) { // expand any optional available environment strings TCHAR szExpSkinRes[MAX_PATH]; - if (ExpandEnvironmentStrings(szSkinResource, szExpSkinRes, _countof(szExpSkinRes)) != 0) { + if (::ExpandEnvironmentStrings(szSkinResource, szExpSkinRes, _countof(szExpSkinRes)) != 0) { _tcsncpy(szSkinResource, szExpSkinRes, _countof(szSkinResource)); szSkinResource[_countof(szSkinResource) - 1] = _T('\0'); } @@ -1292,12 +1283,8 @@ HICON CemuleApp::LoadIcon(LPCTSTR lpszResourceName, int cx, int cy, UINT uFlags) } } - for (unsigned i = 0; i < _countof(aIconsLarge); ++i) { - if (aIconsLarge[i] != NULL) - VERIFY(::DestroyIcon(aIconsLarge[i])); - if (aIconsSmall[i] != NULL) - VERIFY(::DestroyIcon(aIconsSmall[i])); - } + DestroyIconsArr(aIconsLarge, _countof(aIconsLarge)); + DestroyIconsArr(aIconsSmall, _countof(aIconsSmall)); } } } else { @@ -1346,7 +1333,7 @@ HBITMAP CemuleApp::LoadImage(LPCTSTR lpszResourceName, LPCTSTR pszResourceType) if (szSkinResource[0] != _T('\0')) { // expand any optional available environment strings TCHAR szExpSkinRes[MAX_PATH]; - if (ExpandEnvironmentStrings(szSkinResource, szExpSkinRes, _countof(szExpSkinRes)) != 0) { + if (::ExpandEnvironmentStrings(szSkinResource, szExpSkinRes, _countof(szExpSkinRes)) != 0) { _tcsncpy(szSkinResource, szExpSkinRes, _countof(szSkinResource)); szSkinResource[_countof(szSkinResource) - 1] = _T('\0'); } @@ -1386,7 +1373,7 @@ CString CemuleApp::GetSkinFileItem(LPCTSTR lpszResourceName, LPCTSTR pszResource if (szSkinResource[0] != _T('\0')) { // expand any optional available environment strings TCHAR szExpSkinRes[MAX_PATH]; - if (ExpandEnvironmentStrings(szSkinResource, szExpSkinRes, _countof(szExpSkinRes)) != 0) { + if (::ExpandEnvironmentStrings(szSkinResource, szExpSkinRes, _countof(szExpSkinRes)) != 0) { _tcsncpy(szSkinResource, szExpSkinRes, _countof(szSkinResource)); szSkinResource[_countof(szSkinResource) - 1] = _T('\0'); } @@ -1527,7 +1514,7 @@ bool CemuleApp::IsEd2kLinkInClipboard(LPCSTR pszLinkType, int iLinkTypeLen) HGLOBAL hText = GetClipboardData(CF_TEXT); if (hText != NULL) { // Use the ANSI string - LPCSTR pszText = (LPCSTR)::GlobalLock(hText); + LPCSTR pszText = static_cast(::GlobalLock(hText)); if (pszText != NULL) { while (isspace(*pszText)) ++pszText; @@ -1951,13 +1938,16 @@ void CemuleApp::UpdateLargeIconSize() void CemuleApp::ResetStandByIdleTimer() { - // check if anything is going on (ongoing upload, download or connected) and reset the idle timer if so + // Prevent system from falling asleep if connected or there are ongoing data transfers (upload or download) + // Since Windows 11 there is no option to reset the idle timer if (IsConnected() || (uploadqueue != NULL && uploadqueue->GetUploadQueueLength() > 0) || (downloadqueue != NULL && downloadqueue->GetDatarate() > 0)) { - VERIFY(::SetThreadExecutionState(ES_SYSTEM_REQUIRED)); - } + if (!m_bStandbyOff && ::SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_CONTINUOUS)) + m_bStandbyOff = true; + } else if (m_bStandbyOff && ::SetThreadExecutionState(ES_CONTINUOUS)) + m_bStandbyOff = false; } bool CemuleApp::IsXPThemeActive() const @@ -1968,6 +1958,6 @@ bool CemuleApp::IsXPThemeActive() const bool CemuleApp::IsVistaThemeActive() const { - // TRUE: If a Vista (or better) style is active + // Return true if Vista (or better) style is active return theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6, 16, 0, 0) && g_xpStyle.IsThemeActive() && g_xpStyle.IsAppThemed(); } \ No newline at end of file diff --git a/srchybrid/Emule.h b/srchybrid/Emule.h index 1eec582c..770cb9d5 100644 --- a/srchybrid/Emule.h +++ b/srchybrid/Emule.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -20,7 +20,7 @@ #endif #include "resource.h" -#define DEFAULT_NICK thePrefs.GetHomepageBaseURL() +#define DEFAULT_NICK thePrefs.GetHomepageBaseURL() #define DEFAULT_TCP_PORT_OLD 4662 #define DEFAULT_UDP_PORT_OLD (DEFAULT_TCP_PORT_OLD+10) @@ -46,7 +46,6 @@ class CIPFilter; class CWebServer; class CAbstractFile; class CUpDownClient; -class CPeerCacheFinder; class CFirewallOpener; class CUPnPImplWrapper; class CUploadDiskIOThread; @@ -90,7 +89,6 @@ class CemuleApp : public CWinApp CIPFilter *ipfilter; CWebServer *webserver; CScheduler *scheduler; - CPeerCacheFinder *m_pPeerCache; CFirewallOpener *m_pFirewallOpener; CUPnPImplWrapper *m_pUPnPFinder; CUploadDiskIOThread *m_pUploadDiskIOThread; @@ -160,7 +158,8 @@ class CemuleApp : public CWinApp bool IsFirewalled(); bool CanDoCallback(CUpDownClient *client); uint32 GetID(); - uint32 GetPublicIP(bool bIgnoreKadIP = false) const; // return current (valid) public IP or 0 if unknown + uint32 GetED2KPublicIP() const; // return current (valid) public IP or 0 if unknown (ignore KAD connection) + uint32 GetPublicIP() const; // return current (valid) public IP or 0 if unknown void SetPublicIP(const uint32 dwIP); void ResetStandByIdleTimer(); @@ -199,6 +198,7 @@ class CemuleApp : public CWinApp // Elandal:ThreadSafeLogging <-- bool DidWeAutoStart() { return m_bAutoStart; } + void ResetStandbyOff() { m_bStandbyOff = false; } protected: bool ProcessCommandline(); @@ -233,6 +233,7 @@ class CemuleApp : public CWinApp private: UINT m_wTimerRes; + bool m_bStandbyOff; }; extern CemuleApp theApp; diff --git a/srchybrid/EmuleDlg.cpp b/srchybrid/EmuleDlg.cpp index 06ff8af5..7787bf39 100644 --- a/srchybrid/EmuleDlg.cpp +++ b/srchybrid/EmuleDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -91,7 +91,6 @@ #include "IPFilterDlg.h" #include "WebServices.h" #include "DirectDownloadDlg.h" -#include "PeerCacheFinder.h" #include "Statistics.h" #include "FirewallOpener.h" #include "StringConversion.h" @@ -193,9 +192,6 @@ BEGIN_MESSAGE_MAP(CemuleDlg, CTrayDialog) // Version Check DNS ON_MESSAGE(UM_VERSIONCHECK_RESPONSE, OnVersionCheckResponse) - // PeerCache DNS - ON_MESSAGE(UM_PEERCACHE_RESPONSE, OnPeerCacheResponse) - // UPnP ON_MESSAGE(UM_UPNP_RESULT, OnUPnPResult) @@ -222,33 +218,26 @@ CemuleDlg::CemuleDlg(CWnd *pParent /*=NULL*/) , m_pSplashWnd() , activewnd() , status() - , m_hIcon() - , ready() - , m_bStartMinimizedChecked() - , m_bStartMinimized() , m_wpFirstRestore() + , m_hIcon() , m_connicons() , transicons() , imicons() , m_icoSysTrayCurrent() , usericon() - , m_TrayIcon() , m_icoSysTrayConnected() , m_icoSysTrayDisconnected() , m_icoSysTrayLowID() + , m_pSystrayDlg() + , m_pDropTarget() , m_iMsgIcon() , m_uLastSysTrayIconCookie(SYS_TRAY_ICON_COOKIE_FORCE_UPDATE) , m_uUpDatarate() , m_uDownDatarate() - , imagelist() - , trayPopup() - , m_pSystrayDlg() - , m_pDropTarget() - , m_SysMenuOptions() - , m_menuUploadCtrl() - , m_menuDownloadCtrl() , m_acVCDNSBuffer() - , m_iMsgBlinkState() + , m_bStartMinimizedChecked() + , m_bStartMinimized() + , m_bMsgBlinkState() , m_bConnectRequestDelayedForUPnP() , m_bKadSuspendDisconnect() , m_bEd2kSuspendDisconnect() @@ -276,7 +265,6 @@ CemuleDlg::CemuleDlg(CWnd *pParent /*=NULL*/) statisticswnd = new CStatisticsDlg; toolbar = new CMuleToolbarCtrl; statusbar = new CMuleStatusBarCtrl; - m_wndTaskbarNotifier = new CTaskbarNotifier; m_pDropTarget = new CMainFrameDropTarget; } @@ -309,13 +297,6 @@ CImageList& CemuleDlg::GetClientIconList() return m_IconList; } -void DestroyIconsArr(HICON *pIcon, size_t cnt) -{ - while (cnt-- > 0) - if (pIcon[cnt]) - VERIFY(::DestroyIcon(pIcon[cnt])); -} - CemuleDlg::~CemuleDlg() { CloseTTS(); @@ -346,21 +327,20 @@ CemuleDlg::~CemuleDlg() #endif // already destroyed by windows? - //VERIFY( m_menuUploadCtrl.DestroyMenu() ); - //VERIFY( m_menuDownloadCtrl.DestroyMenu() ); - //VERIFY( m_SysMenuOptions.DestroyMenu() ); + //VERIFY(m_menuUploadCtrl.DestroyMenu()); + //VERIFY(m_menuDownloadCtrl.DestroyMenu()); + //VERIFY(m_SysMenuOptions.DestroyMenu()); - delete preferenceswnd; - delete serverwnd; - delete kademliawnd; - delete sharedfileswnd; - delete chatwnd; - delete ircwnd; - delete statisticswnd; - delete toolbar; - delete statusbar; - delete m_wndTaskbarNotifier; delete m_pDropTarget; + delete statusbar; + delete toolbar; + delete statisticswnd; + delete ircwnd; + delete chatwnd; + delete sharedfileswnd; + delete kademliawnd; + delete serverwnd; + delete preferenceswnd; } void CemuleDlg::DoDataExchange(CDataExchange *pDX) @@ -421,7 +401,7 @@ BOOL CemuleDlg::OnInitDialog() // Create global GUI objects theApp.CreateAllFonts(); theApp.CreateBackwardDiagonalBrush(); - m_wndTaskbarNotifier->SetTextDefaultFont(); + m_wndTaskbarNotifier.SetTextDefaultFont(); CTrayDialog::OnInitDialog(); InitWindowStyles(this); CreateToolbarCmdIconMap(); @@ -472,7 +452,7 @@ BOOL CemuleDlg::OnInitDialog() SetWindowText(_T("eMule v") + theApp.m_strCurVersionLong); // Init taskbar notifier - m_wndTaskbarNotifier->Create(this); + m_wndTaskbarNotifier.CreateWnd(this); LoadNotifier(thePrefs.GetNotifierConfiguration()); // set statusbar @@ -485,9 +465,9 @@ BOOL CemuleDlg::OnInitDialog() // create main window dialog pages DialogCreateIndirect(serverwnd, IDD_SERVER); DialogCreateIndirect(sharedfileswnd, IDD_FILES); - searchwnd->Create(this); // can not use 'DialogCreateIndirect' for the SearchWnd, grrr... + searchwnd->CreateWnd(this); // can not use 'DialogCreateIndirect' for the SearchWnd, grrr... DialogCreateIndirect(chatwnd, IDD_CHAT); - transferwnd->Create(this); + transferwnd->CreateWnd(this); DialogCreateIndirect(statisticswnd, IDD_STATISTICS); DialogCreateIndirect(kademliawnd, IDD_KADEMLIAWND); DialogCreateIndirect(ircwnd, IDD_IRC); @@ -551,7 +531,7 @@ BOOL CemuleDlg::OnInitDialog() rcClient.top += rcToolbar.Height(); rcClient.bottom -= rcStatusbar.Height(); - CWnd* const apWnds[] = + CWnd *const apWnds[] = { serverwnd, kademliawnd, @@ -640,7 +620,7 @@ BOOL CemuleDlg::OnInitDialog() if (thePrefs.GetWSIsEnabled()) theApp.webserver->StartServer(); - VERIFY((m_hTimer = ::SetTimer(NULL, 0, 300, StartupTimer)) != 0); + VERIFY((m_hTimer = ::SetTimer(NULL, 0, SEC2MS(3)/10, StartupTimer)) != 0); if (thePrefs.GetVerbose() && !m_hTimer) AddDebugLogLine(true, _T("Failed to create 'startup' timer - %s"), (LPCTSTR)GetErrorMessage(::GetLastError())); @@ -657,9 +637,6 @@ BOOL CemuleDlg::OnInitDialog() VERIFY(m_pDropTarget->Register(this)); - // initialize PeerCache - theApp.m_pPeerCache->Init(thePrefs.GetPeerCacheLastSearch(), thePrefs.WasPeerCacheFound(), thePrefs.IsPeerCacheDownloadEnabled(), thePrefs.GetPeerCachePort()); - // start aichsyncthread AfxBeginThread(RUNTIME_CLASS(CAICHSyncThread), THREAD_PRIORITY_IDLE, 0); @@ -708,7 +685,6 @@ void CALLBACK CemuleDlg::StartupTimer(HWND /*hwnd*/, UINT /*uiMsg*/, UINT_PTR /* switch (theApp.emuledlg->status) { case 0: ++theApp.emuledlg->status; - theApp.emuledlg->ready = true; theApp.sharedfiles->SetOutputCtrl(&theApp.emuledlg->sharedfileswnd->sharedfilesctrl); ++theApp.emuledlg->status; case 1: @@ -814,7 +790,7 @@ void CemuleDlg::OnSysCommand(UINT nID, LPARAM lParam) return; } - switch (nID /*& 0xFFF0*/) { + switch (nID) { case MP_ABOUTBOX: { CCreditsDlg dlgAbout; @@ -940,7 +916,7 @@ void CemuleDlg::AddLogText(UINT uFlags, LPCTSTR pszText) serverwnd->logbox->AddTyped(temp, iLen, uFlags & LOGMSGTYPEMASK); if (::IsWindow(serverwnd->StatusSelector) && serverwnd->StatusSelector.GetCurSel() != CServerWnd::PaneLog) serverwnd->StatusSelector.HighlightItem(CServerWnd::PaneLog, TRUE); - if (!(uFlags & LOG_DONTNOTIFY) && ready) + if (!(uFlags & LOG_DONTNOTIFY) && status) //status!=0 means this dialog has been created ShowNotifier(pszText, TBN_LOG); if (thePrefs.GetLog2Disk()) theLog.Log(temp, iLen); @@ -1153,9 +1129,7 @@ void CemuleDlg::ShowTransferRate(bool bForceAll) if (TrayIconVisible() || bForceAll) { // set tray icon int iDownRatePercent = (int)ceil((m_uDownDatarate / 10.24) / thePrefs.GetMaxGraphDownloadRate()); - if (iDownRatePercent > 100) - iDownRatePercent = 100; - UpdateTrayIcon(iDownRatePercent); + UpdateTrayIcon(min(iDownRatePercent, 100)); CString buffer; buffer.Format(_T("eMule v%s (%s)\r\n%s") @@ -1665,6 +1639,10 @@ void CemuleDlg::OnClose() return; } theApp.m_app_state = APP_STATE_SHUTTINGDOWN; + notifierenabled = false; + //flush queued messages + theApp.HandleDebugLogQueue(); + theApp.HandleLogQueue(); Log(_T("Closing eMule")); CloseTTS(); @@ -1719,13 +1697,12 @@ void CemuleDlg::OnClose() // saving data & stuff theApp.emuledlg->preferenceswnd->m_wndSecurity.DeleteDDB(); - theApp.knownfiles->Save(); // CKnownFileList::Save + theApp.knownfiles->Save(); theApp.sharedfiles->Save(); searchwnd->SaveAllSettings(); serverwnd->SaveAllSettings(); kademliawnd->SaveAllSettings(); - theApp.m_pPeerCache->Save(); theApp.scheduler->RestoreOriginals(); theApp.searchlist->SaveSpamFilter(); if (thePrefs.IsStoringSearchesEnabled()) @@ -1782,7 +1759,6 @@ void CemuleDlg::OnClose() delete theApp.scheduler; theApp.scheduler = NULL; delete theApp.ipfilter; theApp.ipfilter = NULL; // CIPFilter::SaveToDefaultFile delete theApp.webserver; theApp.webserver = NULL; - delete theApp.m_pPeerCache; theApp.m_pPeerCache = NULL; delete theApp.m_pFirewallOpener; theApp.m_pFirewallOpener = NULL; delete theApp.uploadBandwidthThrottler; theApp.uploadBandwidthThrottler = NULL; delete theApp.lastCommonRouteFinder; theApp.lastCommonRouteFinder = NULL; @@ -1793,6 +1769,9 @@ void CemuleDlg::OnClose() thePrefs.Uninit(); theApp.m_app_state = APP_STATE_DONE; CTrayDialog::OnCancel(); + //flush queued messages + theApp.HandleDebugLogQueue(); + theApp.HandleLogQueue(); AddDebugLogLine(DLP_VERYLOW, _T("Closed eMule")); } @@ -1843,7 +1822,7 @@ void CemuleDlg::OnTrayLButtonUp() return; } - if (thePrefs.GetEnableMiniMule()) { + if (thePrefs.GetEnableMiniMule()) try { TRACE("%s - m_pMiniMule = new CMiniMule(this);\n", __FUNCTION__); ASSERT(m_pMiniMule == NULL); @@ -1860,7 +1839,6 @@ void CemuleDlg::OnTrayLButtonUp() ASSERT(0); m_pMiniMule = NULL; } - } } void CemuleDlg::OnTrayRButtonUp(CPoint pt) @@ -1943,8 +1921,8 @@ void CemuleDlg::AddSpeedSelectorMenus(CMenu *addToMenu) m_menuUploadCtrl.AppendMenu(MF_STRING, MP_QS_U60, text); text.Format(_T("80%%\t%i %s"), max(rate * 4 / 5, 1), (LPCTSTR)kbyps); m_menuUploadCtrl.AppendMenu(MF_STRING, MP_QS_U80, text); - //text.Format(_T("100%%\t%i %s"), rate, (LPCTSTR)kbyps); - //m_menuUploadCtrl.AppendMenu(MF_STRING, MP_QS_U100, text); + text.Format(_T("100%%\t%i %s"), rate, (LPCTSTR)kbyps); + m_menuUploadCtrl.AppendMenu(MF_STRING, MP_QS_U100, text); m_menuUploadCtrl.AppendMenu(MF_SEPARATOR); if (GetRecMaxUpload() > 0) { @@ -2059,14 +2037,14 @@ void CemuleDlg::UpdateTrayIcon(int iPercent) // prepare it up if (m_iMsgIcon != 0 && thePrefs.DoFlashOnNewMessage()) { - m_iMsgBlinkState = !m_iMsgBlinkState; + m_bMsgBlinkState = !m_bMsgBlinkState; - if (m_iMsgBlinkState) + if (m_bMsgBlinkState) m_TrayIcon.Init(imicons[1], 100, 1, 1, 16, 16, thePrefs.GetStatsColor(11)); } else - m_iMsgBlinkState = false; + m_bMsgBlinkState = false; - if (!m_iMsgBlinkState) { + if (!m_bMsgBlinkState) { HICON trayicon; if (theApp.IsConnected()) trayicon = theApp.IsFirewalled() ? m_icoSysTrayLowID : m_icoSysTrayConnected; @@ -2116,7 +2094,7 @@ void CemuleDlg::ShowNotifier(LPCTSTR pszText, TbnMsg nMsgType, LPCTSTR pszLink, switch (nMsgType) { case TBN_CHAT: if (thePrefs.GetNotifierOnChat()) { - m_wndTaskbarNotifier->Show(pszText, nMsgType, pszLink); + m_wndTaskbarNotifier.Show(pszText, nMsgType, pszLink); bShowIt = true; pszSoundEvent = _T("eMule_Chat"); iSoundPrio = 1; @@ -2124,7 +2102,7 @@ void CemuleDlg::ShowNotifier(LPCTSTR pszText, TbnMsg nMsgType, LPCTSTR pszLink, break; case TBN_DOWNLOADFINISHED: if (thePrefs.GetNotifierOnDownloadFinished()) { - m_wndTaskbarNotifier->Show(pszText, nMsgType, pszLink); + m_wndTaskbarNotifier.Show(pszText, nMsgType, pszLink); bShowIt = true; pszSoundEvent = _T("eMule_DownloadFinished"); iSoundPrio = 1; @@ -2133,7 +2111,7 @@ void CemuleDlg::ShowNotifier(LPCTSTR pszText, TbnMsg nMsgType, LPCTSTR pszLink, break; case TBN_DOWNLOADADDED: if (thePrefs.GetNotifierOnNewDownload()) { - m_wndTaskbarNotifier->Show(pszText, nMsgType, pszLink); + m_wndTaskbarNotifier.Show(pszText, nMsgType, pszLink); bShowIt = true; pszSoundEvent = _T("eMule_DownloadAdded"); iSoundPrio = 1; @@ -2141,14 +2119,14 @@ void CemuleDlg::ShowNotifier(LPCTSTR pszText, TbnMsg nMsgType, LPCTSTR pszLink, break; case TBN_LOG: if (thePrefs.GetNotifierOnLog()) { - m_wndTaskbarNotifier->Show(pszText, nMsgType, pszLink); + m_wndTaskbarNotifier.Show(pszText, nMsgType, pszLink); bShowIt = true; pszSoundEvent = _T("eMule_LogEntryAdded"); } break; case TBN_IMPORTANTEVENT: if (thePrefs.GetNotifierOnImportantError()) { - m_wndTaskbarNotifier->Show(pszText, nMsgType, pszLink); + m_wndTaskbarNotifier.Show(pszText, nMsgType, pszLink); bShowIt = true; pszSoundEvent = _T("eMule_Urgent"); iSoundPrio = 1; @@ -2157,14 +2135,14 @@ void CemuleDlg::ShowNotifier(LPCTSTR pszText, TbnMsg nMsgType, LPCTSTR pszLink, break; case TBN_NEWVERSION: if (thePrefs.GetNotifierOnNewVersion()) { - m_wndTaskbarNotifier->Show(pszText, nMsgType, pszLink); + m_wndTaskbarNotifier.Show(pszText, nMsgType, pszLink); bShowIt = true; pszSoundEvent = _T("eMule_NewVersion"); iSoundPrio = 1; } break; case TBN_NULL: - m_wndTaskbarNotifier->Show(pszText, nMsgType, pszLink); + m_wndTaskbarNotifier.Show(pszText, nMsgType, pszLink); bShowIt = true; } @@ -2187,7 +2165,7 @@ void CemuleDlg::ShowNotifier(LPCTSTR pszText, TbnMsg nMsgType, LPCTSTR pszLink, void CemuleDlg::LoadNotifier(const CString &configuration) { - notifierenabled = m_wndTaskbarNotifier->LoadConfiguration(configuration); + notifierenabled = m_wndTaskbarNotifier.LoadConfiguration(configuration); } LRESULT CemuleDlg::OnTaskbarNotifierClicked(WPARAM, LPARAM lParam) @@ -2197,7 +2175,7 @@ LRESULT CemuleDlg::OnTaskbarNotifierClicked(WPARAM, LPARAM lParam) free((void*)lParam); } - switch (m_wndTaskbarNotifier->GetMessageType()) { + switch (m_wndTaskbarNotifier.GetMessageType()) { case TBN_CHAT: RestoreWindow(); SetActiveDialog(chatwnd); @@ -2275,10 +2253,7 @@ void CemuleDlg::SetAllIcons() //SetIcon(m_hIcon, FALSE); // connection state - for (unsigned i = 0; i < _countof(m_connicons); ++i) - if (m_connicons[i]) - VERIFY(::DestroyIcon(m_connicons[i])); - + DestroyIconsArr(m_connicons, _countof(m_connicons)); m_connicons[0] = theApp.LoadIcon(_T("ConnectedNotNot"), 16, 16); m_connicons[1] = theApp.LoadIcon(_T("ConnectedNotLow"), 16, 16); m_connicons[2] = theApp.LoadIcon(_T("ConnectedNotHigh"), 16, 16); @@ -2291,10 +2266,7 @@ void CemuleDlg::SetAllIcons() ShowConnectionStateIcon(); // transfer state - for (int i = 0; i < 4; ++i) - if (transicons[i]) - VERIFY(::DestroyIcon(transicons[i])); - + DestroyIconsArr(transicons, _countof(transicons)); transicons[0] = theApp.LoadIcon(_T("UP0DOWN0"), 16, 16); transicons[1] = theApp.LoadIcon(_T("UP0DOWN1"), 16, 16); transicons[2] = theApp.LoadIcon(_T("UP1DOWN0"), 16, 16); @@ -2319,10 +2291,7 @@ void CemuleDlg::SetAllIcons() m_icoSysTrayLowID = theApp.LoadIcon(_T("TrayLowID"), 16, 16); ShowTransferRate(true); - for (int i = 0; i < 3; ++i) - if (imicons[i]) - VERIFY(::DestroyIcon(imicons[i])); - + DestroyIconsArr(imicons, _countof(imicons)); imicons[0] = NULL; imicons[1] = theApp.LoadIcon(_T("Message"), 16, 16); imicons[2] = theApp.LoadIcon(_T("MessagePending"), 16, 16); @@ -2336,40 +2305,28 @@ void CemuleDlg::Localize() VERIFY(pSysMenu->ModifyMenu(MP_ABOUTBOX, MF_BYCOMMAND | MF_STRING, MP_ABOUTBOX, GetResString(IDS_ABOUTBOX))); VERIFY(pSysMenu->ModifyMenu(MP_VERSIONCHECK, MF_BYCOMMAND | MF_STRING, MP_VERSIONCHECK, GetResString(IDS_VERSIONCHECK))); - switch (thePrefs.GetWindowsVersion()) { - case _WINVER_98_: - case _WINVER_95_: - case _WINVER_ME_: - // NOTE: I think the reason why the old version of the following code crashed under Win9X was because - // of the menus were destroyed right after they were added to the system menu. New code should work - // under Win9X too but I can't test it. - break; - default: - { // localize the 'speed control' sub menus by deleting the current menus and creating a new ones. // remove any already available 'speed control' menus from system menu - UINT uOptMenuPos = pSysMenu->GetMenuItemCount() - 1; - CMenu *pAccelMenu = pSysMenu->GetSubMenu(uOptMenuPos); - if (pAccelMenu) { - ASSERT(pAccelMenu->m_hMenu == m_SysMenuOptions.m_hMenu); - VERIFY(pSysMenu->RemoveMenu(uOptMenuPos, MF_BYPOSITION)); - } + UINT uOptMenuPos = pSysMenu->GetMenuItemCount() - 1; + CMenu *pAccelMenu = pSysMenu->GetSubMenu(uOptMenuPos); + if (pAccelMenu) { + ASSERT(pAccelMenu->m_hMenu == m_SysMenuOptions.m_hMenu); + VERIFY(pSysMenu->RemoveMenu(uOptMenuPos, MF_BYPOSITION)); + } - // destroy all 'speed control' menus - if (m_menuUploadCtrl) - VERIFY(m_menuUploadCtrl.DestroyMenu()); - if (m_menuDownloadCtrl) - VERIFY(m_menuDownloadCtrl.DestroyMenu()); - if (m_SysMenuOptions) - VERIFY(m_SysMenuOptions.DestroyMenu()); - - // create new 'speed control' menus - if (m_SysMenuOptions.CreateMenu()) { - AddSpeedSelectorMenus(&m_SysMenuOptions); - pSysMenu->AppendMenu(MF_STRING | MF_POPUP, (UINT_PTR)m_SysMenuOptions.m_hMenu, GetResString(IDS_EM_PREFS)); - } - } + // destroy all 'speed control' menus + if (m_menuUploadCtrl) + VERIFY(m_menuUploadCtrl.DestroyMenu()); + if (m_menuDownloadCtrl) + VERIFY(m_menuDownloadCtrl.DestroyMenu()); + if (m_SysMenuOptions) + VERIFY(m_SysMenuOptions.DestroyMenu()); + + // create new 'speed control' menus + if (m_SysMenuOptions.CreateMenu()) { + AddSpeedSelectorMenus(&m_SysMenuOptions); + pSysMenu->AppendMenu(MF_STRING | MF_POPUP, (UINT_PTR)m_SysMenuOptions.m_hMenu, GetResString(IDS_EM_PREFS)); } } @@ -3144,11 +3101,6 @@ void CemuleDlg::HtmlHelp(DWORD_PTR dwData, UINT nCmd) } } -LRESULT CemuleDlg::OnPeerCacheResponse(WPARAM wParam, LPARAM lParam) -{ - return theApp.m_pPeerCache->OnPeerCacheCheckResponse(wParam, lParam); -} - void CemuleDlg::CreateToolbarCmdIconMap() { m_mapTbarCmdToIcon[TBBTN_CONNECT] = _T("Connect"); @@ -3206,16 +3158,15 @@ BOOL CemuleDlg::OnChevronPushed(UINT id, LPNMHDR pNMHDR, LRESULT *plResult) menu.CreatePopupMenu(); menu.AddMenuTitle(_T("eMule"), true); + TCHAR szString[256]; TBBUTTONINFO tbbi; tbbi.cbSize = (UINT)sizeof tbbi; tbbi.dwMask = TBIF_BYINDEX | TBIF_COMMAND | TBIF_STYLE | TBIF_STATE | TBIF_TEXT; + tbbi.cchText = _countof(szString); + tbbi.pszText = szString; - for (; i < iButtons; ++i) { - TCHAR szString[256]; - tbbi.cchText = _countof(szString); - tbbi.pszText = szString; - if (toolbar->GetButtonInfo(i, &tbbi) >= 0) { - szString[_countof(szString) - 1] = _T('\0'); + for (; i < iButtons; ++i) + if (toolbar->GetButtonInfo(i, &tbbi) >= 0) if (tbbi.fsStyle & TBSTYLE_SEP) { if (!bLastMenuItemIsSep) bLastMenuItemIsSep = menu.AppendMenu(MF_SEPARATOR, 0, (LPCTSTR)NULL); @@ -3226,8 +3177,6 @@ BOOL CemuleDlg::OnChevronPushed(UINT id, LPNMHDR pNMHDR, LRESULT *plResult) if ((tbbi.fsState & TBSTATE_ENABLED) == 0) menu.EnableMenuItem(tbbi.idCommand, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } - } - } CPoint ptMenu(pnmrc->rc.left, pnmrc->rc.top); ClientToScreen(&ptMenu); @@ -3486,6 +3435,7 @@ LRESULT CemuleDlg::OnPowerBroadcast(WPARAM wParam, LPARAM lParam) //DebugLog(_T("DEBUG:Power state change. wParam=%d lPararm=%ld"),wParam,lParam); switch (wParam) { case PBT_APMRESUMEAUTOMATIC: + theApp.ResetStandbyOff(); if (m_bEd2kSuspendDisconnect || m_bKadSuspendDisconnect) { DebugLog(_T("Reconnect after Power state change. wParam=%d lPararm=%ld"), wParam, lParam); RefreshUPnP(true); @@ -3522,8 +3472,8 @@ void CemuleDlg::StartUPnP(bool bReset, uint16 nForceTCPPort, uint16 nForceUDPPor /*theApp.emuledlg->*/PostMessage(UM_UPNP_RESULT, (WPARAM)CUPnPImpl::UPNP_FAILED, 0); } catch (const CUPnPImpl::UPnPError&) { //ignore - } catch (CException *e) { - e->Delete(); + } catch (CException *ex) { + ex->Delete(); } } else ASSERT(0); @@ -3547,8 +3497,8 @@ void CemuleDlg::RefreshUPnP(bool bRequestAnswer) DebugLogWarning(_T("RefreshUPnP, implementation not ready")); } catch (const CUPnPImpl::UPnPError&) { //ignore - } catch (CException *e) { - e->Delete(); + } catch (CException *ex) { + ex->Delete(); } } else ASSERT(0); diff --git a/srchybrid/EmuleDlg.h b/srchybrid/EmuleDlg.h index 9a243099..d954e258 100644 --- a/srchybrid/EmuleDlg.h +++ b/srchybrid/EmuleDlg.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -43,7 +43,6 @@ class CServerWnd; class CSharedFilesWnd; class CSplashScreen; class CStatisticsDlg; -class CTaskbarNotifier; class CTransferDlg; struct Status; @@ -67,6 +66,8 @@ class CemuleDlg : public CTrayDialog //Client icons for all windows CImageList m_IconList; + CReBarCtrl m_ctlMainTopReBar; + CTaskbarNotifier m_wndTaskbarNotifier; void SetClientIconList(); public: explicit CemuleDlg(CWnd *pParent = NULL); @@ -149,8 +150,6 @@ class CemuleDlg : public CTrayDialog CMuleStatusBarCtrl *statusbar; CStatisticsDlg *statisticswnd; CIrcWnd *ircwnd; - CTaskbarNotifier *m_wndTaskbarNotifier; - CReBarCtrl m_ctlMainTopReBar; CMuleToolbarCtrl *toolbar; CKademliaWnd *kademliawnd; CSplashScreen *m_pSplashWnd; @@ -158,33 +157,32 @@ class CemuleDlg : public CTrayDialog uint8 status; protected: - HICON m_hIcon; - bool ready; - bool m_bStartMinimizedChecked; - bool m_bStartMinimized; WINDOWPLACEMENT m_wpFirstRestore; + HICON m_hIcon; HICON m_connicons[9]; HICON transicons[4]; HICON imicons[3]; HICON m_icoSysTrayCurrent; HICON usericon; CMeterIcon m_TrayIcon; - HICON m_icoSysTrayConnected; // do not use this icon for anything else than the system tray!!! - HICON m_icoSysTrayDisconnected; // do not use this icon for anything else than the system tray!!! - HICON m_icoSysTrayLowID; // do not use this icon for anything else than the system tray!!! - int m_iMsgIcon; - UINT m_uLastSysTrayIconCookie; - uint32 m_uUpDatarate; - uint32 m_uDownDatarate; + HICON m_icoSysTrayConnected; // do not use this icon for anything but the system tray!!! + HICON m_icoSysTrayDisconnected; // do not use this icon for anything but the system tray!!! + HICON m_icoSysTrayLowID; // do not use this icon for anything but the system tray!!! CImageList imagelist; CTitleMenu trayPopup; CMuleSystrayDlg *m_pSystrayDlg; - CMainFrameDropTarget *m_pDropTarget; + CMainFrameDropTarget *m_pDropTarget; CMenu m_SysMenuOptions; CMenu m_menuUploadCtrl; CMenu m_menuDownloadCtrl; + int m_iMsgIcon; + UINT m_uLastSysTrayIconCookie; + uint32 m_uUpDatarate; + uint32 m_uDownDatarate; char m_acVCDNSBuffer[MAXGETHOSTSTRUCT]; - bool m_iMsgBlinkState; + bool m_bStartMinimizedChecked; + bool m_bStartMinimized; + bool m_bMsgBlinkState; bool m_bConnectRequestDelayedForUPnP; bool m_bKadSuspendDisconnect; bool m_bEd2kSuspendDisconnect; @@ -304,8 +302,6 @@ class CemuleDlg : public CTrayDialog afx_msg LRESULT OnAddRemoveFriend(WPARAM wParam, LPARAM lParam); // VersionCheck DNS afx_msg LRESULT OnVersionCheckResponse(WPARAM, LPARAM lParam); - // Peercache DNS - afx_msg LRESULT OnPeerCacheResponse(WPARAM wParam, LPARAM lParam); // MiniMule afx_msg LRESULT OnCloseMiniMule(WPARAM wParam, LPARAM); // Terminal Services @@ -314,6 +310,17 @@ class CemuleDlg : public CTrayDialog afx_msg LRESULT OnUPnPResult(WPARAM wParam, LPARAM lParam); }; +#ifdef _DEBUG +/////////////////////////////////////////////////////////////////////////////// +// Suppress null document warning in Output (CFrameWnd::Create) +// +class CFrameDoc : public CDocument +{ +public: + CFrameDoc() = default; + BOOL OnNewDocument() { return CDocument::OnNewDocument(); } +}; +#endif enum EEMuleAppMsgs { diff --git a/srchybrid/EnBitmap.cpp b/srchybrid/EnBitmap.cpp index 60c053e5..3eee1c5f 100644 --- a/srchybrid/EnBitmap.cpp +++ b/srchybrid/EnBitmap.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -79,9 +79,9 @@ BOOL CEnBitmap::LoadImage(LPCTSTR szImagePath, COLORREF crBack) return CBitmap::Attach(img.Detach()); BOOL bResult = FALSE; - CFileException e; + CFileException ex; CFile cFile; - if (cFile.Open(szImagePath, CFile::modeRead | CFile::typeBinary | CFile::shareDenyWrite, &e)) { + if (cFile.Open(szImagePath, CFile::modeRead | CFile::typeBinary | CFile::shareDenyWrite, &ex)) { int nSize = (int)cFile.GetLength(); BYTE *pBuff = new BYTE[nSize]; if (cFile.Read(pBuff, nSize) > 0) { diff --git a/srchybrid/EncryptedDatagramSocket.cpp b/srchybrid/EncryptedDatagramSocket.cpp index fa477957..e0d2ed04 100644 --- a/srchybrid/EncryptedDatagramSocket.cpp +++ b/srchybrid/EncryptedDatagramSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -98,7 +98,6 @@ - Packets which use the senderkey are prone to BruteForce attacks, which take only a few minutes (2^32) which is while not acceptable for encryption fair enough for obfuscation */ - #include "stdafx.h" #include "EncryptedDatagramSocket.h" #include "emule.h" @@ -158,7 +157,7 @@ int CEncryptedDatagramSocket::DecryptReceivedClient(BYTE *pbyBufIn, int nBufLen, *nReceiverVerifyKey = 0; *nSenderVerifyKey = 0; - if (nResult <= CRYPT_HEADER_SIZE /*|| !thePrefs.IsClientCryptLayerSupported()*/) + if (nResult <= CRYPT_HEADER_SIZE /*|| !thePrefs.IsCryptLayerEnabled()*/) return nResult; Crypt_Header_Struct &crypt = *reinterpret_cast(pbyBufIn); @@ -290,7 +289,7 @@ int CEncryptedDatagramSocket::DecryptReceivedClient(BYTE *pbyBufIn, int nBufLen, uint32 CEncryptedDatagramSocket::EncryptSendClient(uchar *pbyBuf, uint32 nBufLen, const uchar *pachClientHashOrKadID, bool bKad, uint32 nReceiverVerifyKey, uint32 nSenderVerifyKey) { ASSERT(theApp.GetPublicIP() != 0 || bKad); - ASSERT(thePrefs.IsClientCryptLayerSupported()); + ASSERT(thePrefs.IsCryptLayerEnabled()); ASSERT(pachClientHashOrKadID != NULL || nReceiverVerifyKey); ASSERT((nReceiverVerifyKey == 0 && nSenderVerifyKey == 0) || bKad); @@ -381,7 +380,7 @@ int CEncryptedDatagramSocket::DecryptReceivedServer(BYTE *pbyBufIn, int nBufLen, int nResult = nBufLen; *ppbyBufOut = pbyBufIn; - if (nResult <= CRYPT_HEADER_SIZE || !thePrefs.IsServerCryptLayerUDPEnabled() || dwBaseKey == 0) + if (nResult <= CRYPT_HEADER_SIZE || !thePrefs.IsCryptLayerEnabled() || dwBaseKey == 0) return nResult; Crypt_Header_Struct &crypt = *reinterpret_cast(pbyBufIn); @@ -426,7 +425,7 @@ int CEncryptedDatagramSocket::DecryptReceivedServer(BYTE *pbyBufIn, int nBufLen, uint32 CEncryptedDatagramSocket::EncryptSendServer(uchar *pbyBuf, uint32 nBufLen, uint32 dwBaseKey) { - ASSERT(thePrefs.IsServerCryptLayerUDPEnabled()); + ASSERT(thePrefs.IsCryptLayerEnabled()); ASSERT(dwBaseKey); const uint16 nRandomKeyPart = (uint16)cryptRandomGen.GenerateWord32(0, _UI16_MAX); diff --git a/srchybrid/EncryptedDatagramSocket.h b/srchybrid/EncryptedDatagramSocket.h index f92b6f97..38a2d771 100644 --- a/srchybrid/EncryptedDatagramSocket.h +++ b/srchybrid/EncryptedDatagramSocket.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/EncryptedStreamSocket.cpp b/srchybrid/EncryptedStreamSocket.cpp index 598c751a..e7328b50 100644 --- a/srchybrid/EncryptedStreamSocket.cpp +++ b/srchybrid/EncryptedStreamSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -72,7 +72,6 @@ Basic Obfuscated Handshake Protocol Client <-> Server: - DH Agreement Specifics: sizeof(a) and sizeof(b) = 128 Bits, g = 2, p = dh768_p (see below), sizeof p, s, etc. = 768 bits */ - #include "stdafx.h" #include "EncryptedStreamSocket.h" #include "emule.h" @@ -118,7 +117,7 @@ CEncryptedStreamSocket::CEncryptedStreamSocket() : m_dbgbyEncryptionSupported(0xff) , m_dbgbyEncryptionRequested(0xff) , m_dbgbyEncryptionMethodSet(0xff) - , m_StreamCryptState(thePrefs.IsClientCryptLayerSupported() ? ECS_UNKNOWN : ECS_NONE) + , m_StreamCryptState(thePrefs.IsCryptLayerEnabled() ? ECS_UNKNOWN : ECS_NONE) , m_EncryptionMethod(ENM_OBFUSCATION) , m_bFullReceive(true) , m_bServerCrypt() @@ -231,7 +230,7 @@ int CEncryptedStreamSocket::Receive(void *lpBuf, int nBufLen, int nFlags) m_nObfuscatedBytesReceived = CAsyncSocketEx::Receive(lpBuf, nBufLen, nFlags); m_bFullReceive = (m_nObfuscatedBytesReceived == nBufLen); - if (m_nObfuscatedBytesReceived == SOCKET_ERROR || m_nObfuscatedBytesReceived <= 0) + if (m_nObfuscatedBytesReceived <= 0 || m_nObfuscatedBytesReceived == SOCKET_ERROR) return m_nObfuscatedBytesReceived; switch (m_StreamCryptState) { @@ -268,7 +267,7 @@ int CEncryptedStreamSocket::Receive(void *lpBuf, int nBufLen, int nFlags) // if we require an encrypted connection, cut the connection here. // This shouldn't happen that often at least with other up-to-date eMule clients // because they check for incompatibility before connecting if possible - if (thePrefs.IsClientCryptLayerRequired()) { + if (thePrefs.IsCryptLayerRequired()) { // TODO: Remove me when i have been solved // Even if the Require option is enabled, we currently have to accept unencrypted connection // which are made for lowid/firewall checks from servers and other selected client from us. @@ -282,7 +281,7 @@ int CEncryptedStreamSocket::Receive(void *lpBuf, int nBufLen, int nFlags) SOCKADDR_IN sockAddr = {}; int nSockAddrLen = sizeof sockAddr; GetPeerName((LPSOCKADDR)&sockAddr, &nSockAddrLen); - if (thePrefs.IsClientCryptLayerRequiredStrict() || (!theApp.serverconnect->AwaitingTestFromIP(sockAddr.sin_addr.s_addr) + if (thePrefs.IsCryptLayerRequiredStrict() || (!theApp.serverconnect->AwaitingTestFromIP(sockAddr.sin_addr.s_addr) && !theApp.clientlist->IsKadFirewallCheckIP(sockAddr.sin_addr.s_addr))) { #if defined(_DEBUG) || defined(_BETA) || defined(_DEVBUILD) @@ -649,9 +648,9 @@ int CEncryptedStreamSocket::Negotiate(const uchar *pBuffer, int nLen) m_pfiReceiveBuffer = NULL; } return nRead; - } catch (CFileException *error) { + } catch (CFileException *ex) { // can only be caused by a bug in negotiation handling, not by the data stream - error->Delete(); + ex->Delete(); ASSERT(0); OnError(ERR_ENCRYPTION); if (m_pfiReceiveBuffer != NULL) { diff --git a/srchybrid/EncryptedStreamSocket.h b/srchybrid/EncryptedStreamSocket.h index 6217af3b..6f1e3858 100644 --- a/srchybrid/EncryptedStreamSocket.h +++ b/srchybrid/EncryptedStreamSocket.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -15,14 +15,15 @@ //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -/* This class supports obfuscation and encryption for an eMule TCP connection. - Right now only basic obfuscation is supported, but this can be expanded, as their is a - dedicated handshake to negotiate the encryption method used. - - Please note, even if obfuscation uses encryption methods, it does not fulfill cryptographic standards since it - doesn't use secret (and for rc4 important: unique) keys -*/ - +/* + * This class supports obfuscation and encryption for an eMule TCP connection. + * + * Right now only basic obfuscation is supported, but this can be expanded, + * as their is a dedicated handshake to negotiate the encryption method used. + * + * Please note, obfuscation uses encryption, but not up to cryptographic standards + * since it doesn't use secret (and important for rc4: unique) keys + */ #pragma once #include "AsyncSocketEx.h" #include "cryptopp/integer.h" @@ -32,7 +33,7 @@ #define ERR_ENCRYPTION 0x03 #define ERR_ENCRYPTION_NOTALLOWED 0x04 -enum EStreamCryptState +enum EStreamCryptState : uint8 { ECS_NONE = 0, // Disabled or not available ECS_UNKNOWN, // Incoming connection, will test the first incoming data for encrypted protocol @@ -42,7 +43,7 @@ enum EStreamCryptState ECS_ENCRYPTING // Encryption enabled }; -enum ENegotiatingState +enum ENegotiatingState : uint8 { ONS_NONE, @@ -64,7 +65,7 @@ enum ENegotiatingState ONS_COMPLETE }; -enum EEncryptionMethods +enum EEncryptionMethods : uint8 { ENM_OBFUSCATION = 0x00 }; diff --git a/srchybrid/Exceptions.h b/srchybrid/Exceptions.h index a1c7ca82..3eaf9248 100644 --- a/srchybrid/Exceptions.h +++ b/srchybrid/Exceptions.h @@ -29,9 +29,9 @@ } #define CATCH_STR_EXCEPTION(fname) \ - catch (const CString &strError){ \ + catch (const CString &sError){ \ if (thePrefs.GetVerbose()) \ - DebugLogError(LOG_STATUSBAR, _T("Unknown CString exception in ") fname _T(" - %s"), (LPCTSTR)strError); \ + DebugLogError(LOG_STATUSBAR, _T("Unknown CString exception in ") fname _T(" - %s"), (LPCTSTR)sError); \ } #define CATCH_DFLT_EXCEPTIONS(fname) \ diff --git a/srchybrid/ExitBox.cpp b/srchybrid/ExitBox.cpp index 2e4ec467..d2e8bbd6 100644 --- a/srchybrid/ExitBox.cpp +++ b/srchybrid/ExitBox.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ExitBox.h b/srchybrid/ExitBox.h index b1c279bc..2716f55d 100644 --- a/srchybrid/ExitBox.h +++ b/srchybrid/ExitBox.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FileDetailDialog.cpp b/srchybrid/FileDetailDialog.cpp index b4a8971a..368f356f 100644 --- a/srchybrid/FileDetailDialog.cpp +++ b/srchybrid/FileDetailDialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FileDetailDialog.h b/srchybrid/FileDetailDialog.h index c179bdcc..5aab9be4 100644 --- a/srchybrid/FileDetailDialog.h +++ b/srchybrid/FileDetailDialog.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FileDetailDialogInfo.cpp b/srchybrid/FileDetailDialogInfo.cpp index db1feb73..03b9e275 100644 --- a/srchybrid/FileDetailDialogInfo.cpp +++ b/srchybrid/FileDetailDialogInfo.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FileDetailDialogName.cpp b/srchybrid/FileDetailDialogName.cpp index 55093884..12294b6c 100644 --- a/srchybrid/FileDetailDialogName.cpp +++ b/srchybrid/FileDetailDialogName.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FileDetailDlgStatistics.cpp b/srchybrid/FileDetailDlgStatistics.cpp index c306b495..40d8abc2 100644 --- a/srchybrid/FileDetailDlgStatistics.cpp +++ b/srchybrid/FileDetailDlgStatistics.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FileDetailDlgStatistics.h b/srchybrid/FileDetailDlgStatistics.h index 5db8dd0d..271c6f15 100644 --- a/srchybrid/FileDetailDlgStatistics.h +++ b/srchybrid/FileDetailDlgStatistics.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FileIdentifier.cpp b/srchybrid/FileIdentifier.cpp index 81b99307..375fea9e 100644 --- a/srchybrid/FileIdentifier.cpp +++ b/srchybrid/FileIdentifier.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -206,7 +206,7 @@ bool CFileIdentifier::SetMD4HashSet(const CArray &aHashset) DeleteMD4Hashset(); // set new hash - for (int i = 0; i < aHashset.GetCount(); ++i) { + for (INT_PTR i = 0; i < aHashset.GetCount(); ++i) { uchar *pucHash = new uchar[MDX_DIGEST_SIZE]; md4cpy(pucHash, aHashset[i]); m_aMD4HashSet.Add(pucHash); diff --git a/srchybrid/FileIdentifier.h b/srchybrid/FileIdentifier.h index 011fde5a..13f03b95 100644 --- a/srchybrid/FileIdentifier.h +++ b/srchybrid/FileIdentifier.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FileInfoDialog.cpp b/srchybrid/FileInfoDialog.cpp index c86f6631..f1935d1d 100644 --- a/srchybrid/FileInfoDialog.cpp +++ b/srchybrid/FileInfoDialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -134,8 +134,8 @@ class CMediaInfoDLL // --- ULONGLONG ullVersion = GetModuleVersion(m_hLib); if (ullVersion >= MAKEDLLVERULL(0, 7, 13, 0) - && ((thePrefs.GetWindowsVersion() == _WINVER_XP_ && ullVersion < MAKEDLLVERULL(21, 4, 0, 0)) - || ullVersion < MAKEDLLVERULL(23, 11, 0, 0))) + && (thePrefs.GetWindowsVersion() >= _WINVER_VISTA_ && ullVersion < MAKEDLLVERULL(24, 7, 0, 0) + || ullVersion < MAKEDLLVERULL(21, 4, 0, 0))) //21.03 for Windows XP { (FARPROC &)m_pfnMediaInfo_New = GetProcAddress(m_hLib, "MediaInfo_New"); (FARPROC &)m_pfnMediaInfo_Delete = GetProcAddress(m_hLib, "MediaInfo_Delete"); @@ -642,7 +642,7 @@ LRESULT CFileInfoDialog::OnMediaInfoResult(WPARAM, LPARAM lParam) if (ami.video.dwBitRate == _UI32_MAX) buffer = _T("Variable"); else - buffer.Format(_T("%u %s"), (ami.video.dwBitRate + 500) / 1000, (LPCTSTR)GetResString(IDS_KBITSSEC)); + buffer.Format(_T("%lu %s"), (ami.video.dwBitRate + SEC2MS(1) / 2) / SEC2MS(1), (LPCTSTR)GetResString(IDS_KBITSSEC)); SetDlgItemText(IDC_VBITRATE, buffer); } else SetDlgItemText(IDC_VBITRATE, _T("")); @@ -706,7 +706,7 @@ LRESULT CFileInfoDialog::OnMediaInfoResult(WPARAM, LPARAM lParam) if (ami.audio.nAvgBytesPerSec == _UI32_MAX) buffer = _T("Variable"); else - buffer.Format(_T("%u %s"), (UINT)(ami.audio.nAvgBytesPerSec * 8.0f / 1000.0f + 0.5f), (LPCTSTR)GetResString(IDS_KBITSSEC)); + buffer.Format(_T("%u %s"), (UINT)((ami.audio.nAvgBytesPerSec * 16ull + SEC2MS(1)) / SEC2MS(2)), (LPCTSTR)GetResString(IDS_KBITSSEC)); SetDlgItemText(IDC_ABITRATE, buffer); } else SetDlgItemText(IDC_ABITRATE, _T("")); @@ -934,9 +934,9 @@ bool CGetMediaInfoThread::GetMediaInfo(HWND hWndOwner, const CShareableFile *pFi if (!bSingleFile) { mi->strInfo << _T(" ") << GetResString(IDS_CODEC) << _T(":\t") << mi->strAudioFormat << _T("\n"); //no vbr bit rate - //mi->strInfo << _T(" ") << GetResString(IDS_BITRATE) << _T(":\t") << ((mp3info->vbr_bitrate ? mp3info->vbr_bitrate : mp3info->bitrate) + 500) / 1000 << _T(" ") << GetResString(IDS_KBITSSEC) << _T("\n"); - mi->strInfo << _T(" ") << GetResString(IDS_BITRATE) << _T(":\t") << (mp3info->bitrate + 500) / 1000 << _T(" ") << GetResString(IDS_KBITSSEC) << _T("\n"); - mi->strInfo << _T(" ") << GetResString(IDS_SAMPLERATE) << _T(":\t") << mp3info->frequency / 1000.0 << _T(" kHz\n"); + //mi->strInfo << _T(" ") << GetResString(IDS_BITRATE) << _T(":\t") << ((mp3info->vbr_bitrate ? mp3info->vbr_bitrate : mp3info->bitrate) + SEC2MS(1) / 2) / SEC2MS(1) << _T(" ") << GetResString(IDS_KBITSSEC) << _T("\n"); + mi->strInfo << _T(" ") << GetResString(IDS_BITRATE) << _T(":\t") << (mp3info->bitrate + SEC2MS(1) / 2) / SEC2MS(1) << _T(" ") << GetResString(IDS_KBITSSEC) << _T("\n"); + mi->strInfo << _T(" ") << GetResString(IDS_SAMPLERATE) << _T(":\t") << mp3info->frequency / SEC2MS(1.0) << _T(" kHz\n"); } ++mi->iAudioStreams; @@ -1404,7 +1404,7 @@ bool CGetMediaInfoThread::GetMediaInfo(HWND hWndOwner, const CShareableFile *pFi str = InfoGet(MediaInfo_Stream_General, 0, _T("Duration")); if (str.IsEmpty()) str = InfoGet(MediaInfo_Stream_General, 0, _T("PlayTime")); //deprecated - float fFileLengthSec = _tstoi(str) / 1000.0F; + float fFileLengthSec = _tstoi(str) / SEC2MS(1.0f); UINT uAllBitrates = 0; str = InfoGet(MediaInfo_Stream_General, 0, _T("VideoCount")); @@ -1477,7 +1477,7 @@ bool CGetMediaInfoThread::GetMediaInfo(HWND hWndOwner, const CShareableFile *pFi strBitrate = _T("Variable"); uAllBitrates = _UI32_MAX; } else { - strBitrate.Format(_T("%u %s"), (iBitrate + 500u) / 1000, (LPCTSTR)GetResString(IDS_KBITSSEC)); + strBitrate.Format(_T("%u %s"), (iBitrate + SEC2MS(1u) / 2) / SEC2MS(1), (LPCTSTR)GetResString(IDS_KBITSSEC)); if (uAllBitrates != _UI32_MAX) uAllBitrates += iBitrate; } @@ -1576,7 +1576,7 @@ bool CGetMediaInfoThread::GetMediaInfo(HWND hWndOwner, const CShareableFile *pFi strBitrate = _T("Variable"); uAllBitrates = _UI32_MAX; } else { - strBitrate.Format(_T("%u %s"), (iBitrate + 500u) / 1000, (LPCTSTR)GetResString(IDS_KBITSSEC)); + strBitrate.Format(_T("%u %s"), (iBitrate + SEC2MS(1u) / 2) / SEC2MS(1), (LPCTSTR)GetResString(IDS_KBITSSEC)); if (uAllBitrates != _UI32_MAX) uAllBitrates += iBitrate; } @@ -1845,7 +1845,7 @@ bool CGetMediaInfoThread::GetMediaInfo(HWND hWndOwner, const CShareableFile *pFi if (wfx->nAvgBytesPerSec == _UI32_MAX) strBitrate = _T("Variable"); else - strBitrate.Format(_T("%u %s"), (UINT)(((wfx->nAvgBytesPerSec * 8.0) + 500.0) / 1000.0), (LPCTSTR)GetResString(IDS_KBITSSEC)); + strBitrate.Format(_T("%u %s"), (unsigned)(((wfx->nAvgBytesPerSec * 16ull) + SEC2MS(1)) / SEC2MS(2)), (LPCTSTR)GetResString(IDS_KBITSSEC)); mi->strInfo << _T(" ") << GetResString(IDS_BITRATE) << _T(":\t") << strBitrate << _T("\n"); } diff --git a/srchybrid/FirewallOpener.cpp b/srchybrid/FirewallOpener.cpp index e753d6eb..7c5613e1 100644 --- a/srchybrid/FirewallOpener.cpp +++ b/srchybrid/FirewallOpener.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FirewallOpener.h b/srchybrid/FirewallOpener.h index edc97af2..981383f2 100644 --- a/srchybrid/FirewallOpener.h +++ b/srchybrid/FirewallOpener.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FrameGrabThread.cpp b/srchybrid/FrameGrabThread.cpp index 86c51ea7..643057f9 100644 --- a/srchybrid/FrameGrabThread.cpp +++ b/srchybrid/FrameGrabThread.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2003-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2003-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FrameGrabThread.h b/srchybrid/FrameGrabThread.h index cf3bec90..babe7b7c 100644 --- a/srchybrid/FrameGrabThread.h +++ b/srchybrid/FrameGrabThread.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2003-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2003-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Friend.cpp b/srchybrid/Friend.cpp index 89f970af..6baaf47e 100644 --- a/srchybrid/Friend.cpp +++ b/srchybrid/Friend.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Friend.h b/srchybrid/Friend.h index 054a7f6b..db1009c0 100644 --- a/srchybrid/Friend.h +++ b/srchybrid/Friend.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FriendList.cpp b/srchybrid/FriendList.cpp index d22a0703..667d1a18 100644 --- a/srchybrid/FriendList.cpp +++ b/srchybrid/FriendList.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -52,17 +52,12 @@ CFriendList::~CFriendList() bool CFriendList::LoadList() { - const CString &strFileName(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + EMFRIENDS_MET_FILENAME); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(strFileName, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(GetResString(IDS_ERR_READEMFRIENDS)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } + if (!CFileOpen(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + EMFRIENDS_MET_FILENAME + , CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite + , GetResString(IDS_ERR_READEMFRIENDS))) + { return false; } @@ -80,15 +75,13 @@ bool CFriendList::LoadList() } file.Close(); return true; - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) LogError(LOG_STATUSBAR, GetResString(IDS_ERR_EMFRIENDSINVALID)); else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_READEMFRIENDS), buffer); + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_READEMFRIENDS), (LPCTSTR)CExceptionStr(*ex)); } - error->Delete(); + ex->Delete(); } return false; } @@ -99,37 +92,25 @@ void CFriendList::SaveList() AddDebugLogLine(false, _T("Saving friends list file \"%s\""), EMFRIENDS_MET_FILENAME); m_nLastSaved = ::GetTickCount(); - const CString &strFileName(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + EMFRIENDS_MET_FILENAME); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(strFileName, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - CString strError(_T("Failed to save ") EMFRIENDS_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + if (!CFileOpen(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + EMFRIENDS_MET_FILENAME + , CFile::modeCreate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to save ") EMFRIENDS_MET_FILENAME)) + { return; } - ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { file.WriteUInt8(MET_HEADER); file.WriteUInt32((uint32)m_listFriends.GetCount()); for (POSITION pos = m_listFriends.GetHeadPosition(); pos != NULL;) m_listFriends.GetNext(pos)->WriteToFile(file); - if (thePrefs.GetCommitFiles() >= 2 || (thePrefs.GetCommitFiles() >= 1 && theApp.IsClosing())) { - file.Flush(); // flush file stream buffers to disk buffers - if (_commit(_fileno(file.m_pStream)) != 0) // commit disk buffers to disk - AfxThrowFileException(CFileException::hardIO, ::GetLastError(), file.GetFileName()); - } - file.Close(); - } catch (CFileException *error) { - CString strError(_T("Failed to save ") EMFRIENDS_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*error, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - error->Delete(); + CommitAndClose(file); + } catch (CFileException *ex) { + LogError(LOG_STATUSBAR, _T("%s%s"), _T("Failed to save ") EMFRIENDS_MET_FILENAME, (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } diff --git a/srchybrid/FriendList.h b/srchybrid/FriendList.h index 8e0a178e..77a590e0 100644 --- a/srchybrid/FriendList.h +++ b/srchybrid/FriendList.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FriendListCtrl.cpp b/srchybrid/FriendListCtrl.cpp index ed49f729..49768566 100644 --- a/srchybrid/FriendListCtrl.cpp +++ b/srchybrid/FriendListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/FriendListCtrl.h b/srchybrid/FriendListCtrl.h index 7a2d01db..b8aa4689 100644 --- a/srchybrid/FriendListCtrl.h +++ b/srchybrid/FriendListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/GDIThread.cpp b/srchybrid/GDIThread.cpp index 5e0e0399..cac7cdde 100644 --- a/srchybrid/GDIThread.cpp +++ b/srchybrid/GDIThread.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/GZipFile.cpp b/srchybrid/GZipFile.cpp index 5cb1e746..1c7cce53 100644 --- a/srchybrid/GZipFile.cpp +++ b/srchybrid/GZipFile.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/GZipFile.h b/srchybrid/GZipFile.h index 6f74a422..d790d441 100644 --- a/srchybrid/GZipFile.h +++ b/srchybrid/GZipFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/HTRichEditCtrl.cpp b/srchybrid/HTRichEditCtrl.cpp index 732d0ae9..1cfb9fac 100644 --- a/srchybrid/HTRichEditCtrl.cpp +++ b/srchybrid/HTRichEditCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -202,7 +202,7 @@ COLORREF GetLogLineColor(UINT eMsgType) void CHTRichEditCtrl::FlushBuffer() { if (!m_astrBuff.IsEmpty()) { // flush buffer - for (int i = 0; i < m_astrBuff.GetCount(); ++i) { + for (INT_PTR i = 0; i < m_astrBuff.GetCount(); ++i) { const CString &rstrLine(m_astrBuff[i]); if (!rstrLine.IsEmpty()) { if ((UINT)rstrLine[0] < 8) @@ -929,19 +929,19 @@ CBitmapDataObject::CBitmapDataObject(HBITMAP hBitmap) #pragma warning(disable:4100) // unreferenced parameter #pragma warning(disable:4555) // expression has no effect; expected expression with side-effect (because of the 'METHOD_PROLOGUE' macro) -STDMETHODIMP CBitmapDataObject::XDataObject::QueryInterface(REFIID iid, LPVOID *ppvObj) XP_NOEXCEPT +STDMETHODIMP CBitmapDataObject::XDataObject::QueryInterface(REFIID iid, LPVOID *ppvObj) NOEXCEPT { METHOD_PROLOGUE(CBitmapDataObject, DataObject); return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj); } -STDMETHODIMP_(ULONG) CBitmapDataObject::XDataObject::AddRef() XP_NOEXCEPT +STDMETHODIMP_(ULONG) CBitmapDataObject::XDataObject::AddRef() NOEXCEPT { METHOD_PROLOGUE(CBitmapDataObject, DataObject); return pThis->ExternalAddRef(); } -STDMETHODIMP_(ULONG) CBitmapDataObject::XDataObject::Release() XP_NOEXCEPT +STDMETHODIMP_(ULONG) CBitmapDataObject::XDataObject::Release() NOEXCEPT { METHOD_PROLOGUE(CBitmapDataObject, DataObject); return pThis->ExternalRelease(); diff --git a/srchybrid/HighColorTab.hpp b/srchybrid/HighColorTab.hpp index 310b068d..444d5327 100644 --- a/srchybrid/HighColorTab.hpp +++ b/srchybrid/HighColorTab.hpp @@ -21,7 +21,7 @@ namespace HighColorTab { - /*! \brief Policy class for creating image list. +/*! \brief Policy class for creating image list. Policy for creating a high color (32 bits) image list. The policy ensure that there is a Win32 image list associated with the CImageList. @@ -29,7 +29,8 @@ namespace HighColorTab Returned image list is wrapped in an std::auto_ptr. - \sa UpdateImageListFull */ + \sa UpdateImageListFull +*/ struct CHighColorListCreator { /*! Create the image list. diff --git a/srchybrid/HttpClientReqSocket.cpp b/srchybrid/HttpClientReqSocket.cpp index 908a6aa6..485bf851 100644 --- a/srchybrid/HttpClientReqSocket.cpp +++ b/srchybrid/HttpClientReqSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -85,9 +85,7 @@ void CHttpClientReqSocket::DataReceived(const BYTE *pucData, UINT uSize) strError.Format(_T("Memory exception; %s"), (LPCTSTR)DbgGetClientInfo()); ex->Delete(); } catch (CFileException *ex) { - TCHAR szError[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*ex, szError, _countof(szError)); - strError.Format(_T("File exception - %s"), szError); + strError.Format(_T("File exception%s"), (LPCTSTR)CExceptionStrDash(*ex)); ex->Delete(); } catch (const CString &ex) { strError.Format(_T("%s; %s"), (LPCTSTR)ex, (LPCTSTR)DbgGetClientInfo()); @@ -97,7 +95,7 @@ void CHttpClientReqSocket::DataReceived(const BYTE *pucData, UINT uSize) if (!bResult && !deletethis) { if (thePrefs.GetVerbose() && thePrefs.GetDebugClientTCPLevel() <= 0) - for (int i = 0; i < m_astrHttpHeaders.GetCount(); ++i) + for (INT_PTR i = 0; i < m_astrHttpHeaders.GetCount(); ++i) AddDebugLogLine(false, _T("<%hs"), (LPCSTR)m_astrHttpHeaders[i]); // In case this socket is attached to a CUrlClient, we are dealing with the real CUpDownClient here diff --git a/srchybrid/HttpClientReqSocket.h b/srchybrid/HttpClientReqSocket.h index 51b31166..90dc8df0 100644 --- a/srchybrid/HttpClientReqSocket.h +++ b/srchybrid/HttpClientReqSocket.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/HttpDownloadDlg.cpp b/srchybrid/HttpDownloadDlg.cpp index 24978f64..4ce95bad 100644 --- a/srchybrid/HttpDownloadDlg.cpp +++ b/srchybrid/HttpDownloadDlg.cpp @@ -596,10 +596,10 @@ void CHttpDownloadDlg::DownloadThread() //Write the data to file try { DECODE_DATA(m_FileToWrite, szReadBuf, dwBytesRead); - } catch (CFileException *e) { + } catch (CFileException *ex) { TRACE(_T("An exception occurred while writing to the download file\n")); - HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_ERROR_READFILE), e->m_lOsError); - e->Delete(); + HandleThreadErrorWithLastError(GetResString(IDS_HTTPDOWNLOAD_ERROR_READFILE), ex->m_lOsError); + ex->Delete(); //clean up any encoding data before we return ENCODING_CLEAN_UP; return; diff --git a/srchybrid/HttpDownloadDlg.h b/srchybrid/HttpDownloadDlg.h index 26749c1e..4546c1c9 100644 --- a/srchybrid/HttpDownloadDlg.h +++ b/srchybrid/HttpDownloadDlg.h @@ -79,7 +79,7 @@ class CHttpDownloadDlg : public CDialog void PlayAnimation(); void SetProgress(DWORD dwBytesRead); void UpdateControlsDuringTransfer(DWORD dwStartTicks, DWORD &dwCurrentTicks, DWORD dwTotalBytesRead, DWORD &dwLastTotalBytes - , DWORD& dwLastPercentage, BOOL bGotFileSize, DWORD dwFileSize); + , DWORD &dwLastPercentage, BOOL bGotFileSize, DWORD dwFileSize); CFile m_FileToWrite; CString m_sError; diff --git a/srchybrid/I18n.cpp b/srchybrid/I18n.cpp index 711de213..c94a1570 100644 --- a/srchybrid/I18n.cpp +++ b/srchybrid/I18n.cpp @@ -103,7 +103,7 @@ static SLanguage s_aLanguages[] = {LANGID_DE_DE, false, 1252, _T("de_DE"), _T("windows-1252")}, // German (Germany) {LANGID_EL_GR, false, 1253, _T("el_GR"), _T("windows-1253")}, // Greek {LANGID_EN_US, true, 1252, _T("en_US"), _T("windows-1252")}, // English - {LANGID_ES_AS, false, 1252, _T("es_AS"), _T("windows-1252")}, // Asturian + {LANGID_ES_AS, false, 1252, _T("es_AS"), _T("windows-1252")}, // Asturian {LANGID_ES_ES_T, false, 1252, _T("es_ES_T"), _T("windows-1252")}, // Spanish (Castilian) {LANGID_ET_EE, false, 1257, _T("et_EE"), _T("windows-1257")}, // Estonian {LANGID_FA_IR, false, 1256, _T("fa_IR"), _T("windows-1256")}, // Farsi @@ -133,7 +133,7 @@ static SLanguage s_aLanguages[] = {LANGID_TR_TR, false, 1254, _T("tr_TR"), _T("windows-1254")}, // Turkish {LANGID_UA_UA, false, 1251, _T("ua_UA"), _T("windows-1251")}, // Ukrainian {LANGID_UG_CN, false, 1256, _T("ug_CN"), _T("windows-1256")}, // Uighur - {LANGID_VA_ES, false, 1252, _T("va_ES"), _T("windows-1252")}, // Valencian AVL + {LANGID_VA_ES, false, 1252, _T("va_ES"), _T("windows-1252")}, // Valencian AVL {LANGID_VA_ES_RACV, false, 1252, _T("va_ES_RACV"), _T("windows-1252")}, // Valencian RACV {LANGID_VI_VN, false, 1258, _T("vi_VN"), _T("windows-1258")}, // Vietnamese {LANGID_ZH_CN, false, 936, _T("zh_CN"), _T("gb2312")}, // Chinese (P.R.C.) diff --git a/srchybrid/IESecurity.cpp b/srchybrid/IESecurity.cpp index 101a7b12..ed94331c 100644 --- a/srchybrid/IESecurity.cpp +++ b/srchybrid/IESecurity.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -136,19 +136,19 @@ void DumpIID(REFIID iid, LPCTSTR pszClassName) #pragma warning(push) #pragma warning(disable:4555) // expression has no effect; expected expression with side-effect (because of the 'METHOD_PROLOGUE' macro) -STDMETHODIMP CMuleBrowserControlSite::XInternetSecurityManager::QueryInterface(REFIID iid, LPVOID *ppvObj) XP_NOEXCEPT +STDMETHODIMP CMuleBrowserControlSite::XInternetSecurityManager::QueryInterface(REFIID iid, LPVOID *ppvObj) NOEXCEPT { METHOD_PROLOGUE(CMuleBrowserControlSite, InternetSecurityManager); return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj); } -STDMETHODIMP_(ULONG) CMuleBrowserControlSite::XInternetSecurityManager::AddRef() XP_NOEXCEPT +STDMETHODIMP_(ULONG) CMuleBrowserControlSite::XInternetSecurityManager::AddRef() NOEXCEPT { METHOD_PROLOGUE(CMuleBrowserControlSite, InternetSecurityManager); return pThis->ExternalAddRef(); } -STDMETHODIMP_(ULONG) CMuleBrowserControlSite::XInternetSecurityManager::Release() XP_NOEXCEPT +STDMETHODIMP_(ULONG) CMuleBrowserControlSite::XInternetSecurityManager::Release() NOEXCEPT { METHOD_PROLOGUE(CMuleBrowserControlSite, InternetSecurityManager); return pThis->ExternalRelease(); @@ -267,19 +267,19 @@ STDMETHODIMP CMuleBrowserControlSite::XInternetSecurityManager::GetZoneMappings( // IServiceProvider // -STDMETHODIMP_(ULONG) CMuleBrowserControlSite::XServiceProvider::AddRef() XP_NOEXCEPT +STDMETHODIMP_(ULONG) CMuleBrowserControlSite::XServiceProvider::AddRef() NOEXCEPT { METHOD_PROLOGUE(CMuleBrowserControlSite, ServiceProvider); return pThis->ExternalAddRef(); } -STDMETHODIMP_(ULONG) CMuleBrowserControlSite::XServiceProvider::Release() XP_NOEXCEPT +STDMETHODIMP_(ULONG) CMuleBrowserControlSite::XServiceProvider::Release() NOEXCEPT { METHOD_PROLOGUE(CMuleBrowserControlSite, ServiceProvider); return pThis->ExternalRelease(); } -STDMETHODIMP CMuleBrowserControlSite::XServiceProvider::QueryInterface(REFIID iid, LPVOID *ppvObj) XP_NOEXCEPT +STDMETHODIMP CMuleBrowserControlSite::XServiceProvider::QueryInterface(REFIID iid, LPVOID *ppvObj) NOEXCEPT { METHOD_PROLOGUE(CMuleBrowserControlSite, ServiceProvider); return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj); diff --git a/srchybrid/IPFilter.cpp b/srchybrid/IPFilter.cpp index 0f98f70a..205fd94d 100644 --- a/srchybrid/IPFilter.cpp +++ b/srchybrid/IPFilter.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -217,7 +217,7 @@ INT_PTR CIPFilter::AddFromFile(LPCTSTR pszFilePath, bool bShowResponse) int iNumToDelete = 0; SIPFilter *pPrv = m_iplist[0]; - for (int i = 1; i < m_iplist.GetCount(); ++i) { + for (INT_PTR i = 1; i < m_iplist.GetCount(); ++i) { 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 @@ -277,7 +277,7 @@ void CIPFilter::SaveToDefaultFile() const CString &strFilePath(GetDefaultFilePath()); FILE *fp = _tfsopen(strFilePath, _T("wt"), _SH_DENYWR); if (fp != NULL) { - for (int i = 0; i < m_iplist.GetCount(); ++i) { + for (INT_PTR i = 0; i < m_iplist.GetCount(); ++i) { const SIPFilter *flt = m_iplist[i]; CHAR szStart[16]; diff --git a/srchybrid/IPFilter.h b/srchybrid/IPFilter.h index 9932fed7..4d41edd1 100644 --- a/srchybrid/IPFilter.h +++ b/srchybrid/IPFilter.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/IPFilterDlg.cpp b/srchybrid/IPFilterDlg.cpp index c1799563..f43267b6 100644 --- a/srchybrid/IPFilterDlg.cpp +++ b/srchybrid/IPFilterDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -81,9 +81,9 @@ CIPFilterDlg::CIPFilterDlg(CWnd *pParent /*=NULL*/) : CResizableDialog(CIPFilterDlg::IDD, pParent) , m_pMenuIPFilter() , m_icoDlg() - , m_uIPFilterItems() , m_ppIPFilterItems() , m_ulFilteredIPs() + , m_uIPFilterItems() { m_ipfilter.m_pParent = this; m_ipfilter.SetRegistryKey(PREF_INI_SECTION); @@ -382,7 +382,7 @@ void CIPFilterDlg::OnBnClickedAppend() rar.Close(); } else { CString strError; - strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\nDownload latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."), (LPCTSTR)strFilePath); + strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\n%s"), (LPCTSTR)strFilePath, CRARFile::sUnrar_download); AfxMessageBox(strError, MB_ICONERROR); } } else if (szExt == _T(".gz")) { diff --git a/srchybrid/IPFilterDlg.h b/srchybrid/IPFilterDlg.h index 3bbe5d82..5c62f1e7 100644 --- a/srchybrid/IPFilterDlg.h +++ b/srchybrid/IPFilterDlg.h @@ -22,9 +22,9 @@ class CIPFilterDlg : public CResizableDialog CMenu *m_pMenuIPFilter; CListCtrlX m_ipfilter; HICON m_icoDlg; - UINT m_uIPFilterItems; const SIPFilter **m_ppIPFilterItems; ULONG m_ulFilteredIPs; + UINT m_uIPFilterItems; void SortIPFilterItems(); void InitIPFilters(); diff --git a/srchybrid/IconStatic.cpp b/srchybrid/IconStatic.cpp index e9798b04..044b0a32 100644 --- a/srchybrid/IconStatic.cpp +++ b/srchybrid/IconStatic.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -99,10 +99,10 @@ void CIconStatic::SetIcon(LPCTSTR lpszIconID) if (pPixels) { if (m_MemBMP.GetBitmapBits(dwSize, pPixels) == dwSize) { LPBYTE pLine = pPixels; - for (int iLines = bmMem.bmHeight; iLines-- > 0;) { + for (int iLines = bmMem.bmHeight; iLines > 0; --iLines) { LPDWORD pdwPixel = (LPDWORD)pLine; for (int x = 0; x < bmMem.bmWidth; ++x) - *pdwPixel++ &= 0x00FFFFFFu; + *pdwPixel++ &= ~0xFF000000u; pLine += bmMem.bmWidthBytes; } m_MemBMP.SetBitmapBits(dwSize, pPixels); diff --git a/srchybrid/Ini2.h b/srchybrid/Ini2.h index f7a034a4..907a26dc 100644 --- a/srchybrid/Ini2.h +++ b/srchybrid/Ini2.h @@ -9,7 +9,7 @@ How to use: - void CMyClass::UpdateFromIni(bool bFromIni) +void CMyClass::UpdateFromIni(bool bFromIni) { CIni ini(m_strFileName,m_strSection); ini.SER_GET(bFromIni,m_nValueXY); @@ -37,7 +37,7 @@ class CIni // the module's directory will be added to the FileName, // bModulePath=true: ModuleDir, bModulePath=false: CurrentDir static void AddModulePath(CString &rstrFileName, bool bModulPath = true); - static CString GetDefaultSection() { return AfxGetAppName(); }; + static CString GetDefaultSection() { return AfxGetAppName(); } static CString GetDefaultIniFile(bool bModulPath = true); CIni(); @@ -47,10 +47,10 @@ class CIni CIni& operator=(const CIni &Ini); virtual ~CIni() = default; - void SetFileName(const CString &rstrFileName) { m_strFileName = rstrFileName; }; - void SetSection(const CString &rstrSection) { m_strSection = rstrSection; }; - const CString& GetFileName() const { return m_strFileName; }; - const CString& GetSection() const { return m_strSection;}; + void SetFileName(const CString &rstrFileName) { m_strFileName = rstrFileName; } + void SetSection(const CString &rstrSection) { m_strSection = rstrSection; } + const CString& GetFileName() const { return m_strFileName; } + const CString& GetSection() const { return m_strSection;} CString GetStringUTF8(LPCTSTR lpszEntry,LPCTSTR lpszDefault = NULL, LPCTSTR lpszSection = NULL); CString GetStringLong(LPCTSTR lpszEntry,LPCTSTR lpszDefault = NULL, LPCTSTR lpszSection = NULL); diff --git a/srchybrid/InputBox.cpp b/srchybrid/InputBox.cpp index da5046f8..50f0e6b0 100644 --- a/srchybrid/InputBox.cpp +++ b/srchybrid/InputBox.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/InputBox.h b/srchybrid/InputBox.h index b8c5effc..1ebc01bc 100644 --- a/srchybrid/InputBox.h +++ b/srchybrid/InputBox.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/IrcChannelListCtrl.cpp b/srchybrid/IrcChannelListCtrl.cpp index 4e88ada7..4db7f218 100644 --- a/srchybrid/IrcChannelListCtrl.cpp +++ b/srchybrid/IrcChannelListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "IrcChannelListCtrl.h" #include "emuleDlg.h" diff --git a/srchybrid/IrcChannelListCtrl.h b/srchybrid/IrcChannelListCtrl.h index 6260942b..9fabcd2d 100644 --- a/srchybrid/IrcChannelListCtrl.h +++ b/srchybrid/IrcChannelListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/IrcChannelTabCtrl.cpp b/srchybrid/IrcChannelTabCtrl.cpp index 70ccd3c6..47ac4436 100644 --- a/srchybrid/IrcChannelTabCtrl.cpp +++ b/srchybrid/IrcChannelTabCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #define MMNODRV // mmsystem: Installable driver support //#define MMNOSOUND // mmsystem: Sound support @@ -49,6 +48,7 @@ BEGIN_MESSAGE_MAP(CIrcChannelTabCtrl, CClosableTabCtrl) ON_MESSAGE(UM_CLOSETAB, OnCloseTab) ON_MESSAGE(UM_QUERYTAB, OnQueryTab) ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnTcnSelChange) + ON_NOTIFY_REFLECT(TCN_SELCHANGING, OnTcnSelChanging) END_MESSAGE_MAP() CIrcChannelTabCtrl::CIrcChannelTabCtrl() @@ -223,7 +223,7 @@ Channel* CIrcChannelTabCtrl::NewChannel(const CString &sChannel, Channel::EType #endif RECT rcSplitter = { rcChannelPane.left, rcTopic.bottom, rcChannelPane.right, rcTopic.bottom + IRC_CHANNEL_SPLITTER_HEIGHT }; - pChannel->m_wndSplitter.Create(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rcSplitter, m_pParent, IDC_SPLITTER_IRC_CHANNEL); + pChannel->m_wndSplitter.CreateWnd(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rcSplitter, m_pParent, IDC_SPLITTER_IRC_CHANNEL); pChannel->m_wndSplitter.SetRange(rcTopic.top + IRC_TITLE_WND_MIN_HEIGHT + IRC_CHANNEL_SPLITTER_HEIGHT / 2, rcTopic.top + IRC_TITLE_WND_MAX_HEIGHT - IRC_CHANNEL_SPLITTER_HEIGHT / 2); rcLog.top = rcSplitter.bottom; rcLog.bottom = rcChannelPane.bottom; @@ -279,19 +279,19 @@ Channel* CIrcChannelTabCtrl::NewChannel(const CString &sChannel, Channel::EType } m_lstChannels.AddTail(pChannel); - TCITEM newitem; - newitem.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; - newitem.lParam = (LPARAM)pChannel; + TCITEM ti; + ti.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; + ti.lParam = (LPARAM)pChannel; CString strTcLabel(sChannel); DupAmpersand(strTcLabel); - newitem.pszText = const_cast((LPCTSTR)strTcLabel); + ti.pszText = const_cast((LPCTSTR)strTcLabel); if (eType == Channel::ctStatus) - newitem.iImage = 0; + ti.iImage = 0; else if (eType == Channel::ctChannelList) - newitem.iImage = 1; + ti.iImage = 1; else //Channel::ctNormal or Channel::ctPrivate - newitem.iImage = 2; - int iItem = InsertItem((eType == Channel::ctChannelList ? 1 : GetItemCount()), &newitem); //append + ti.iImage = 2; + int iItem = InsertItem((eType == Channel::ctChannelList ? 1 : GetItemCount()), &ti); //append if (eType == Channel::ctNormal) SelectChannel(iItem); return pChannel; @@ -309,10 +309,10 @@ void CIrcChannelTabCtrl::DetachChannel(Channel *pChannel) int iIndex = FindTabIndex(pChannel); if (iIndex >= 0) { pChannel->m_sTitle = _T('(') + pChannel->m_sTitle + _T(')'); - TCITEM item; - item.mask = TCIF_TEXT; - item.pszText = const_cast((LPCTSTR)pChannel->m_sTitle); - SetItem(iIndex, &item); + TCITEM ti; + ti.mask = TCIF_TEXT; + ti.pszText = const_cast((LPCTSTR)pChannel->m_sTitle); + SetItem(iIndex, &ti); } } @@ -323,11 +323,11 @@ void CIrcChannelTabCtrl::DetachChannel(const CString &sChannel) int CIrcChannelTabCtrl::FindTabIndex(const Channel *pChannel) { - TCITEM item; - item.mask = TCIF_PARAM; - item.lParam = -1; + TCITEM ti; + ti.mask = TCIF_PARAM; + ti.lParam = -1; for (int iIndex = GetItemCount(); --iIndex >= 0;) - if (GetItem(iIndex, &item) && reinterpret_cast(item.lParam) == pChannel) + if (GetItem(iIndex, &ti) && reinterpret_cast(ti.lParam) == pChannel) return iIndex; return -1; @@ -336,9 +336,11 @@ int CIrcChannelTabCtrl::FindTabIndex(const Channel *pChannel) void CIrcChannelTabCtrl::SelectChannel(int iItem) { ASSERT(iItem >= 0 && iItem < GetItemCount()); + LRESULT result; + OnTcnSelChanging(NULL, &result); SetCurSel(iItem); SetCurFocus(iItem); - OnTcnSelChange(NULL, NULL); + OnTcnSelChange(NULL, &result); } void CIrcChannelTabCtrl::SelectChannel(const Channel *pChannel) @@ -413,12 +415,12 @@ void CIrcChannelTabCtrl::OnTcnSelChange(LPNMHDR, LRESULT *pResult) { //What channel did we select? int iCurSel = GetCurSel(); - if (iCurSel == -1) + if (iCurSel < 0) return; //No channel, abort. - TCITEM item; - item.mask = TCIF_PARAM; - if (!GetItem(iCurSel, &item)) { + TCITEM ti; + ti.mask = TCIF_PARAM; + if (!GetItem(iCurSel, &ti)) { //We had no valid item here. Something isn't right. //TODO: this should never happen, so maybe we should remove this tab? return; @@ -432,7 +434,7 @@ void CIrcChannelTabCtrl::OnTcnSelChange(LPNMHDR, LRESULT *pResult) } //Set our current channel to the new one for quick reference. - m_pCurrentChannel = reinterpret_cast(item.lParam); + m_pCurrentChannel = reinterpret_cast(ti.lParam); //We entered the channel, set activity flag off. SetActivity(m_pCurrentChannel, false); @@ -446,16 +448,6 @@ void CIrcChannelTabCtrl::OnTcnSelChange(LPNMHDR, LRESULT *pResult) m_pParent->m_wndNicks.ShowWindow(SW_SHOW); //Show our ChanList. m_pParent->m_wndChanList.ShowWindow(SW_SHOW); - TCITEM tci; - tci.mask = TCIF_PARAM; - //Go through the channel tabs and hide the channels. - //Maybe overkill? Maybe just remember our previous channel and hide it? - - for (int iIndex = 0; GetItem(iIndex++, &tci);) { - Channel *pCh2 = reinterpret_cast(tci.lParam); - if (pCh2 != m_pCurrentChannel && pCh2->m_wndLog.m_hWnd != NULL) - pCh2->Hide(); - } SetInput(m_pCurrentChannel->m_sTabd.IsEmpty() ? m_pCurrentChannel->m_sTyped : m_pCurrentChannel->m_sTabd); return; } @@ -464,25 +456,28 @@ void CIrcChannelTabCtrl::OnTcnSelChange(LPNMHDR, LRESULT *pResult) m_pCurrentChannel->Show(); m_pParent->UpdateChannelChildWindowsSize(); - //Hide all channels not in focus. - //Maybe an overkill? Maybe remember previous channel and hide? - TCITEM tci; - tci.mask = TCIF_PARAM; - int iIndex = 0; - while (GetItem(iIndex++, &tci)) { - Channel *pCh2 = reinterpret_cast(tci.lParam); - if (pCh2 != m_pCurrentChannel && pCh2->m_wndLog.m_hWnd != NULL) - pCh2->Hide(); - } - //Make sure channelList is hidden. m_pParent->m_wndChanList.ShowWindow(SW_HIDE); //Update nick list to the new channel. m_pParent->m_wndNicks.RefreshNickList(m_pCurrentChannel); //Push focus back to the input box. SetInput(m_pCurrentChannel->m_sTabd.IsEmpty() ? m_pCurrentChannel->m_sTyped : m_pCurrentChannel->m_sTabd); - if (pResult) - *pResult = 0; + *pResult = 0; +} + +void CIrcChannelTabCtrl::OnTcnSelChanging(LPNMHDR, LRESULT *pResult) +{ + int iCurSel = GetCurSel(); + if (iCurSel >= 0) { + TCITEM ti; + ti.mask = TCIF_PARAM; + if (GetItem(iCurSel, &ti)) { + Channel *pCh = reinterpret_cast(ti.lParam); + if (pCh->m_wndLog.m_hWnd != NULL) + pCh->Hide(); + } + } + *pResult = 0; } void CIrcChannelTabCtrl::ScrollHistory(bool bDown) @@ -514,19 +509,19 @@ void CIrcChannelTabCtrl::SetActivity(Channel *pChannel, bool bFlag) return; if (pChannel->m_eType == Channel::ctNormal || pChannel->m_eType == Channel::ctPrivate) { - TCITEM item; - item.mask = TCIF_IMAGE; - if (!GetItem(iIndex, &item)) + TCITEM ti; + ti.mask = TCIF_IMAGE; + if (!GetItem(iIndex, &ti)) return; if (bFlag) { - if (item.iImage != 3) { - item.iImage = 3; // 'MessagePending' - SetItem(iIndex, &item); + if (ti.iImage != 3) { + ti.iImage = 3; // 'MessagePending' + SetItem(iIndex, &ti); } } else { - if (item.iImage != 2) { - item.iImage = 2; // 'Message' - SetItem(iIndex, &item); + if (ti.iImage != 2) { + ti.iImage = 2; // 'Message' + SetItem(iIndex, &ti); } } } @@ -557,7 +552,7 @@ void CIrcChannelTabCtrl::ChatSend(CString sSend) bMe = (_tcsnicmp(sSend, _T("/me"), 3) == 0); bSound = (_tcsnicmp(sSend, _T("/sound"), 6) == 0); - if (!bMe && ! bSound) { + if (!bMe && !bSound) { if (_tcsnicmp(sSend, _T("/msg"), 4) == 0) { int i = 5; const CString &cs(sSend.Tokenize(_T(" "), i)); @@ -573,9 +568,7 @@ void CIrcChannelTabCtrl::ChatSend(CString sSend) m_pParent->AddStatusF(_T(" -> *%s* %s"), (LPCTSTR)cs, CPTR(sSend, i)); else m_pParent->AddInfoMessageF(m_pCurrentChannel->m_sName, _T(" -> *%s* %s"), (LPCTSTR)cs, CPTR(sSend, i)); - } - - if (_tcsnicmp(sSend, _T("/privmsg nickserv"), 17) == 0) + } else if (_tcsnicmp(sSend, _T("/privmsg nickserv"), 17) == 0) sSend.Format(_T("/ns%s"), CPTR(sSend, 17)); else if (_tcsnicmp(sSend, _T("/privmsg chanserv"), 17) == 0) sSend.Format(_T("/cs%s"), CPTR(sSend, 17)); @@ -636,21 +629,21 @@ void CIrcChannelTabCtrl::ChatSend(CString sSend) void CIrcChannelTabCtrl::Localize() { - TCITEM item; - item.mask = TCIF_PARAM; - for (int iIndex = GetItemCount(); --iIndex >= 0;) { - if (GetItem(iIndex, &item)) { - Channel *pChannel = reinterpret_cast(item.lParam); + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int iIndex = GetItemCount(); --iIndex >= 0;) + if (GetItem(iIndex, &ti)) { + Channel *pChannel = reinterpret_cast(ti.lParam); if (pChannel && (pChannel->m_eType == Channel::ctStatus || pChannel->m_eType == Channel::ctChannelList)) { pChannel->m_sTitle = GetResString(pChannel->m_eType == Channel::ctStatus ? IDS_STATUS : IDS_IRC_CHANNELLIST); - item.mask = TCIF_TEXT; + ti.mask = TCIF_TEXT; CString strTcLabel(pChannel->m_sTitle); DupAmpersand(strTcLabel); - item.pszText = const_cast((LPCTSTR)strTcLabel); - SetItem(iIndex, &item); + ti.pszText = const_cast((LPCTSTR)strTcLabel); + SetItem(iIndex, &ti); } } - } + SetAllIcons(); } @@ -662,10 +655,10 @@ LRESULT CIrcChannelTabCtrl::OnCloseTab(WPARAM wParam, LPARAM) LRESULT CIrcChannelTabCtrl::OnQueryTab(WPARAM wParam, LPARAM) { - TCITEM item; - item.mask = TCIF_PARAM; - if (GetItem((int)wParam, &item)) { - const Channel *pPartChannel = reinterpret_cast(item.lParam); + TCITEM ti; + ti.mask = TCIF_PARAM; + if (GetItem((int)wParam, &ti)) { + const Channel *pPartChannel = reinterpret_cast(ti.lParam); if (pPartChannel && pPartChannel->m_eType >= Channel::ctChannelList) return 0; } @@ -713,7 +706,7 @@ void Channel::Hide() { if (m_wndTopic.m_hWnd) { m_wndTopic.ShowWindow(SW_HIDE); - m_wndTopic .EnableWindow(FALSE); + m_wndTopic.EnableWindow(FALSE); } if (m_wndSplitter.m_hWnd) { diff --git a/srchybrid/IrcChannelTabCtrl.h b/srchybrid/IrcChannelTabCtrl.h index e548b6c3..676275e9 100644 --- a/srchybrid/IrcChannelTabCtrl.h +++ b/srchybrid/IrcChannelTabCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "ClosableTabCtrl.h" #include "HTRichEditCtrl.h" @@ -105,6 +104,7 @@ class CIrcChannelTabCtrl : public CClosableTabCtrl DECLARE_MESSAGE_MAP() afx_msg void OnTcnSelChange(LPNMHDR pNMHDR, LRESULT *pResult); + afx_msg void OnTcnSelChanging(LPNMHDR pNMHDR, LRESULT *pResult); afx_msg void OnSysColorChange(); afx_msg LRESULT OnCloseTab(WPARAM wParam, LPARAM); afx_msg LRESULT OnQueryTab(WPARAM wParam, LPARAM); diff --git a/srchybrid/IrcMain.cpp b/srchybrid/IrcMain.cpp index cba15da9..fe514b61 100644 --- a/srchybrid/IrcMain.cpp +++ b/srchybrid/IrcMain.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -16,7 +16,7 @@ //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //A lot of documentation for the IRC protocol within this code came -//directly from http://www.irchelp.org/irchelp/rfc/rfc2812.txt +//directly from https://www.irchelp.org/protocol/rfc/rfc2812.txt //Much of it may never be used, but it's here just in case. #include "stdafx.h" #define MMNODRV // mmsystem: Installable driver support diff --git a/srchybrid/IrcMain.h b/srchybrid/IrcMain.h index 7d5b9e0e..ed42828c 100644 --- a/srchybrid/IrcMain.h +++ b/srchybrid/IrcMain.h @@ -11,7 +11,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once class CIrcWnd; diff --git a/srchybrid/IrcNickListCtrl.cpp b/srchybrid/IrcNickListCtrl.cpp index 84bcc20d..74d6b42a 100644 --- a/srchybrid/IrcNickListCtrl.cpp +++ b/srchybrid/IrcNickListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -313,23 +313,23 @@ bool CIrcNickListCtrl::ChangeAllNick(const CString &sOldNick, const CString &sNe { bool bChanged = false; //Change the nick in ALL channels. - CIrcChannelTabCtrl& ChanSel = m_pParent->m_wndChanSel; + CIrcChannelTabCtrl &ChanSel = m_pParent->m_wndChanSel; Channel *pChannel = ChanSel.FindChannelByName(sOldNick); if (pChannel) { //We had a private room opened with this nick. Update the title of the channel! pChannel->m_sName = sNewNick; - TCITEM item; - item.mask = TCIF_PARAM; - item.lParam = -1; + TCITEM ti; + ti.mask = TCIF_PARAM; + ti.lParam = -1; for (int iItem = ChanSel.GetItemCount(); --iItem >= 0;) - if (ChanSel.GetItem(iItem, &item) && reinterpret_cast(item.lParam) == pChannel) { - item.mask = TCIF_TEXT; + if (ChanSel.GetItem(iItem, &ti) && reinterpret_cast(ti.lParam) == pChannel) { + ti.mask = TCIF_TEXT; CString strTcLabel(sNewNick); DupAmpersand(strTcLabel); - item.pszText = const_cast((LPCTSTR)strTcLabel); - ChanSel.SetItem(iItem, &item); + ti.pszText = const_cast((LPCTSTR)strTcLabel); + ChanSel.SetItem(iItem, &ti); bChanged = true; break; } @@ -374,10 +374,10 @@ BOOL CIrcNickListCtrl::OnCommand(WPARAM wParam, LPARAM) int iNickItem = GetNextItem(-1, LVIS_SELECTED | LVIS_FOCUSED); int iChanItem = m_pParent->m_wndChanSel.GetCurSel(); const Nick *pNick = reinterpret_cast(GetItemData(iNickItem)); - TCITEM item; - item.mask = TCIF_PARAM; - m_pParent->m_wndChanSel.GetItem(iChanItem, &item); - Channel *pChannel = reinterpret_cast(item.lParam); + TCITEM ti; + ti.mask = TCIF_PARAM; + m_pParent->m_wndChanSel.GetItem(iChanItem, &ti); + Channel *pChannel = reinterpret_cast(ti.lParam); switch (wParam) { case Irc_Priv: diff --git a/srchybrid/IrcNickListCtrl.h b/srchybrid/IrcNickListCtrl.h index ec2f688f..57c76373 100644 --- a/srchybrid/IrcNickListCtrl.h +++ b/srchybrid/IrcNickListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "MuleListCtrl.h" diff --git a/srchybrid/IrcSocket.cpp b/srchybrid/IrcSocket.cpp index 535f31bd..533a207a 100644 --- a/srchybrid/IrcSocket.cpp +++ b/srchybrid/IrcSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/IrcSocket.h b/srchybrid/IrcSocket.h index 9ab351ba..d4fc59ba 100644 --- a/srchybrid/IrcSocket.h +++ b/srchybrid/IrcSocket.h @@ -11,7 +11,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "AsyncSocketEx.h" diff --git a/srchybrid/IrcWnd.cpp b/srchybrid/IrcWnd.cpp index 86e534c7..cb17d2e5 100644 --- a/srchybrid/IrcWnd.cpp +++ b/srchybrid/IrcWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -165,7 +165,7 @@ BOOL CIrcWnd::OnInitDialog() ScreenToClient(&rcSpl); rcSpl.left = rcSpl.right + SPLITTER_HORZ_MARGIN; rcSpl.right = rcSpl.left + SPLITTER_HORZ_WIDTH; - m_wndSplitterHorz.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_IRC); + m_wndSplitterHorz.CreateWnd(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_IRC); AddAnchor(IDC_BN_IRCCONNECT, BOTTOM_LEFT); AddAnchor(IDC_CLOSECHAT, BOTTOM_LEFT); @@ -343,10 +343,10 @@ LRESULT CIrcWnd::DefWindowProc(UINT uMessage, WPARAM wParam, LPARAM lParam) void CIrcWnd::UpdateFonts(CFont *pFont) { - TCITEM tci; - tci.mask = TCIF_PARAM; - for (int iIndex = 0; m_wndChanSel.GetItem(iIndex, &tci); ++iIndex) { - Channel *pChannel = reinterpret_cast(tci.lParam); + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int iIndex = 0; m_wndChanSel.GetItem(iIndex, &ti); ++iIndex) { + Channel *pChannel = reinterpret_cast(ti.lParam); if (pChannel->m_wndTopic.m_hWnd != NULL) { pChannel->m_wndTopic.SetFont(pFont); pChannel->m_wndTopic.ScrollToFirstLine(); @@ -501,8 +501,8 @@ void CIrcWnd::OnBnClickedIrcConnect() void CIrcWnd::OnBnClickedCloseChannel(int iItem) { //Remove a channel. - TCITEM item; - item.mask = TCIF_PARAM; + TCITEM ti; + ti.mask = TCIF_PARAM; if (iItem == -1) //If no item was send, get our current channel. iItem = m_wndChanSel.GetCurSel(); @@ -511,12 +511,12 @@ void CIrcWnd::OnBnClickedCloseChannel(int iItem) //We have no channel, abort. return; - if (!m_wndChanSel.GetItem(iItem, &item)) + if (!m_wndChanSel.GetItem(iItem, &ti)) //We had no valid item here. Something isn't right. //TODO: this should never happen, so maybe we should remove this tab? return; - Channel *pPartChannel = reinterpret_cast(item.lParam); + Channel *pPartChannel = reinterpret_cast(ti.lParam); if (pPartChannel->m_eType == Channel::ctNormal && !pPartChannel->m_bDetached && m_bConnected) //If this was a channel and we were connected, do not just delete the channel!! //Send 'part' command and the server must respond with a successful part which will remove the channel! @@ -1112,10 +1112,10 @@ LRESULT CIrcWnd::OnCloseTab(WPARAM wParam, LPARAM) LRESULT CIrcWnd::OnQueryTab(WPARAM wParam, LPARAM) { - TCITEM item; - item.mask = TCIF_PARAM; - m_wndChanSel.GetItem((int)wParam, &item); - const Channel *pPartChannel = reinterpret_cast(item.lParam); + TCITEM ti; + ti.mask = TCIF_PARAM; + m_wndChanSel.GetItem((int)wParam, &ti); + const Channel *pPartChannel = reinterpret_cast(ti.lParam); return !pPartChannel || pPartChannel->m_eType < Channel::ctChannelList; } @@ -1219,7 +1219,7 @@ void CIrcWnd::OnBnClickedSmiley() m_wndFormat.GetWindowRect(&rcBtn); rcBtn.top -= 2; - if (!m_pwndSmileySel->Create(this, &rcBtn, &m_wndInput)) { + if (!m_pwndSmileySel->CreateWnd(this, &rcBtn, &m_wndInput)) { delete m_pwndSmileySel; m_pwndSmileySel = NULL; } diff --git a/srchybrid/IrcWnd.h b/srchybrid/IrcWnd.h index fb0bb150..9938f8b7 100644 --- a/srchybrid/IrcWnd.h +++ b/srchybrid/IrcWnd.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "ResizableLib/ResizableDialog.h" #include "IrcNickListCtrl.h" @@ -42,11 +41,11 @@ class CIrcWnd : public CResizableDialog virtual ~CIrcWnd(); void Localize(); - bool GetLoggedIn() const { return m_bLoggedIn; }; - void SetLoggedIn(bool bFlag) { m_bLoggedIn = bFlag; }; - void SetSendFileString(const CString &sInFile) { m_sSendString = sInFile; }; - const CString& GetSendFileString() const { return m_sSendString; }; - bool IsConnected() const { return m_bConnected; }; + bool GetLoggedIn() const { return m_bLoggedIn; } + void SetLoggedIn(bool bFlag) { m_bLoggedIn = bFlag; } + void SetSendFileString(const CString &sInFile) { m_sSendString = sInFile; } + const CString& GetSendFileString() const { return m_sSendString; } + bool IsConnected() const { return m_bConnected; } void UpdateFonts(CFont *pFont); void ParseChangeMode(const CString &sChannel, const CString &sChanger, CString sCommands, const CString &sParams); void AddCurrent(const CString &sLine, bool bShowActivity = true, UINT uStatusCode = 0); diff --git a/srchybrid/KadContactHistogramCtrl.cpp b/srchybrid/KadContactHistogramCtrl.cpp index c87dc4e5..0a1b9435 100644 --- a/srchybrid/KadContactHistogramCtrl.cpp +++ b/srchybrid/KadContactHistogramCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/KadContactListCtrl.cpp b/srchybrid/KadContactListCtrl.cpp index a46ff627..cb8457a2 100644 --- a/srchybrid/KadContactListCtrl.cpp +++ b/srchybrid/KadContactListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/KadContactListCtrl.h b/srchybrid/KadContactListCtrl.h index 0596e58e..be586e67 100644 --- a/srchybrid/KadContactListCtrl.h +++ b/srchybrid/KadContactListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/KadLookupGraph.cpp b/srchybrid/KadLookupGraph.cpp index 5a10e0a3..8ca7d6c3 100644 --- a/srchybrid/KadLookupGraph.cpp +++ b/srchybrid/KadLookupGraph.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2010-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2010-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "kadlookupgraph.h" #include "emule.h" @@ -28,6 +27,7 @@ #include "MenuCmds.h" #include "VisualStylesXP.h" #include "preferences.h" +//#include "log.h" //only for m_bDbgLog #ifdef _DEBUG #define new DEBUG_NEW @@ -51,18 +51,17 @@ BEGIN_MESSAGE_MAP(CKadLookupGraph, CWnd) END_MESSAGE_MAP() CKadLookupGraph::CKadLookupGraph() + : m_pLookupHistory() + , m_pToolTip() + , m_iHotItemIdx(-1) + , m_iMaxLabelHeight(8) + , m_iMaxNumLabelWidth(3 * 8) + , m_bInitializedFontMetrics() +// , m_bDbgLog(true) { m_penAxis.CreatePen(PS_SOLID, 1, RGB(128, 128, 128)); m_penAux.CreatePen(PS_SOLID, 1, RGB(192, 192, 192)); m_penRed.CreatePen(PS_SOLID, 1, RGB(255, 32, 32)); - - m_iMaxNumLabelWidth = 3 * 8; - m_iMaxLabelHeight = 8; - m_bInitializedFontMetrics = false; - m_pLookupHistory = NULL; - m_iHotItemIdx = -1; - m_bDbgLog = true; - m_pToolTip = NULL; } CKadLookupGraph::~CKadLookupGraph() @@ -115,7 +114,7 @@ BOOL CKadLookupGraph::PreTranslateMessage(MSG *pMsg) void CKadLookupGraph::UpdateSearch(CLookupHistory *pLookupHistory) { if (m_pLookupHistory == pLookupHistory && pLookupHistory != NULL) { - m_bDbgLog = true; + //m_bDbgLog = true; if (m_hWnd) Invalidate(); } @@ -183,9 +182,9 @@ void CKadLookupGraph::OnPaint() int iBaseLineX = iLeftBorder; int iBaseLineY = rcClient.bottom - iBottomBorder; - UINT uHistWidth = rcClient.Width() - iLeftBorder - iRightBorder; - UINT uHistHeight = rcClient.Height() - iTopBorder - iBottomBorder; - if (uHistHeight == 0) { + int iHistWidth = rcClient.Width() - iLeftBorder - iRightBorder; + int iHistHeight = rcClient.Height() - iTopBorder - iBottomBorder; + if (iHistHeight == 0) { dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); return; @@ -194,7 +193,7 @@ void CKadLookupGraph::OnPaint() dc.MoveTo(iBaseLineX, rcClient.top + iTopBorder); dc.LineTo(iBaseLineX, iBaseLineY); - dc.LineTo(iBaseLineX + uHistWidth, iBaseLineY); + dc.LineTo(iBaseLineX + iHistWidth, iBaseLineY); dc.SelectObject(&m_penAux); @@ -209,28 +208,28 @@ void CKadLookupGraph::OnPaint() if (m_pLookupHistory != NULL && m_pLookupHistory->GetHistoryEntries().GetCount() >= 1) { const CArray &he = m_pLookupHistory->GetHistoryEntries(); - const uint32 hecount = (uint32)he.GetCount(); + const INT_PTR hecount = he.GetCount(); // How many nodes can we show without scrolling? - uint32 uMaxNodes = uHistWidth / NODE_ENTRY_WIDTH; - uint32 uNodeEntryWidth; - if (hecount > uMaxNodes /*|| !m_pLookupHistory->IsSearchStopped()*/) - uNodeEntryWidth = NODE_ENTRY_WIDTH; // While the search is running, use a fixed width + int iMaxNodes = iHistWidth / NODE_ENTRY_WIDTH; + int iNodeEntryWidth; + if (hecount > iMaxNodes /*|| !m_pLookupHistory->IsSearchStopped()*/) + iNodeEntryWidth = NODE_ENTRY_WIDTH; // While the search is running, use a fixed width else - uNodeEntryWidth = uHistWidth / hecount; // when the search is finished, use all available screen space + iNodeEntryWidth = (int)(iHistWidth / hecount); // when the search is finished, use all available screen space - uint32 iVisibleNodes = min(uMaxNodes, hecount); + INT_PTR iVisibleNodes = min(iMaxNodes, hecount); // Set the scaling. 3 times the highest distance of the 1/3 closest nodes is the max distance CArray aClosest; - INT_PTR k = (INT_PTR)(iVisibleNodes / 3); + INT_PTR k = iVisibleNodes / 3; if (!k) k = 1; - for (uint32 i = 1; i <= iVisibleNodes; ++i) { + for (INT_PTR i = 1; i <= iVisibleNodes; ++i) { if (aClosest.GetCount() < k) aClosest.Add(he[hecount - i]->m_uDistance); else { - int iReplace = -1; - for (int j = (int)aClosest.GetCount(); --j >= 0;) + INT_PTR iReplace = -1; + for (INT_PTR j = aClosest.GetCount(); --j >= 0;) if ((iReplace == -1 && aClosest[j] > he[hecount - i]->m_uDistance) || (iReplace >= 0 && aClosest[j] > aClosest[iReplace])) { @@ -259,7 +258,7 @@ void CKadLookupGraph::OnPaint() iStartChunk = 2; uScalingDistance = uTmpScalingDistance.Get32BitChunk(3); } - uScalingDistance /= (uHistHeight - NODE_ENTRY_HEIGHT); + uScalingDistance /= (iHistHeight - NODE_ENTRY_HEIGHT); uScalingDistance *= 3; ASSERT(uScalingDistance > 0); if (uScalingDistance == 0) @@ -267,14 +266,14 @@ void CKadLookupGraph::OnPaint() //if (m_bDbgLog) - // AddDebugLogLine(false, _T("KadGraph: Considering %u of %u Nodes, 1/3 Max Distance found: %s"), iVisibleNodes, hecount, uTmpScalingDistance.ToHexString()); + // AddDebugLogLine(false, _T("KadGraph: Considering %i of %i Nodes, 1/3 Max Distance found: %s"), (int)iVisibleNodes, (int)hecount, uTmpScalingDistance.ToHexString()); CUInt128 uMaxScalingDistance(uTmpScalingDistance); uMaxScalingDistance.Add(uTmpScalingDistance); uMaxScalingDistance.Add(uTmpScalingDistance); // wow, what a mess, now lets collect drawing points - for (uint32 i = 1; i <= iVisibleNodes; ++i) { + for (INT_PTR i = 1; i <= iVisibleNodes; ++i) { CUInt128 uTmpDist = he[hecount - i]->m_uDistance; uint64 uDrawYPos; if (uTmpDist > uMaxScalingDistance) @@ -286,18 +285,18 @@ void CKadLookupGraph::OnPaint() uDrawYPos = (iBaseLineY - NODE_ENTRY_HEIGHT) - uDrawYPos; } //if (m_bDbgLog) - // AddDebugLogLine(false, _T("KadGraph: Drawing Node %u of %u, Distance: %s, Y-Pos: %u"), (iVisibleNodes - i) + 1, iVisibleNodes, uTmpDist.ToHexString(), uDrawYPos); + // AddDebugLogLine(false, _T("KadGraph: Drawing Node %i of %i, Distance: %s, Y-Pos: %u"), (int)(iVisibleNodes - i + 1), (int)iVisibleNodes, uTmpDist.ToHexString(), (unsigned)uDrawYPos); - ASSERT(uDrawYPos <= (uHistHeight)); - uint32 nXOffset = 0; - //if (uMaxNodes > iVisibleNodes && !m_pLookupHistory->IsSearchStopped()) // Fixed width for ongoing searches - // nXOffset = NODE_ENTRY_WIDTH * (uMaxNodes - iVisibleNodes); - CPoint pointNode(uHistWidth - nXOffset - (i * uNodeEntryWidth), (uint32)uDrawYPos); + ASSERT(uDrawYPos <= (uint64)iHistHeight); + int nXOffset = 0; + //if (iMaxNodes > iVisibleNodes && !m_pLookupHistory->IsSearchStopped()) // Fixed width for ongoing searches + // nXOffset = NODE_ENTRY_WIDTH * (iMaxNodes - iVisibleNodes); + CPoint pointNode((int)(iHistWidth - nXOffset - (i * iNodeEntryWidth)), (int)uDrawYPos); m_aNodesDrawRects.Add(CRect(pointNode, CSize(NODE_ENTRY_WIDTH, NODE_ENTRY_HEIGHT))); } - ASSERT(iVisibleNodes == (uint32)m_aNodesDrawRects.GetCount()); + ASSERT(iVisibleNodes == m_aNodesDrawRects.GetCount()); - // find HotItem (if any) + // find HotItem, if any m_iHotItemIdx = -1; CPoint ptCursor; if (::GetCursorPos(&ptCursor)) { @@ -338,12 +337,12 @@ void CKadLookupGraph::OnPaint() const CLookupHistory::SLookupHistoryEntry *sEntry = he[hecount - (i + 1)]; for (INT_PTR j = 0; j < sEntry->m_liReceivedFromIdx.GetCount(); ++j) { INT_PTR iIdx = sEntry->m_liReceivedFromIdx[j]; - if (iIdx >= (int)(hecount - iVisibleNodes)) { + if (iIdx >= hecount - iVisibleNodes) { CPoint pFrom = m_aNodesDrawRects[hecount - (iIdx + 1)].CenterPoint(); CPoint pointTo = m_aNodesDrawRects[i].CenterPoint(); Gdiplus::Pen *pen; - if ((int)hecount - (iIdx + 1) == m_iHotItemIdx) { + if (hecount - (iIdx + 1) == m_iHotItemIdx) { abHotItemConnected[i] = true; pen = &gdipPenRed; } else if (i == m_iHotItemIdx) { @@ -363,12 +362,12 @@ void CKadLookupGraph::OnPaint() const CLookupHistory::SLookupHistoryEntry *sEntry = he[hecount - (i + 1)]; for (INT_PTR j = 0; j < sEntry->m_liReceivedFromIdx.GetCount(); ++j) { INT_PTR iIdx = sEntry->m_liReceivedFromIdx[j]; - if (iIdx >= (INT_PTR)(hecount - iVisibleNodes)) { + if (iIdx >= hecount - iVisibleNodes) { CPoint pFrom = m_aNodesDrawRects[hecount - (iIdx + 1)].CenterPoint(); CPoint pointTo = m_aNodesDrawRects[i].CenterPoint(); - if ((INT_PTR)hecount - (iIdx + 1) == m_iHotItemIdx) { + if (hecount - (iIdx + 1) == m_iHotItemIdx) { abHotItemConnected[i] = true; dc.SelectObject(&m_penRed); } else { @@ -384,7 +383,7 @@ void CKadLookupGraph::OnPaint() aptPoly[0] = pointTo; // build the line vector - float vecLine[2] = { (float)aptPoly[0].x - pFrom.x, (float)aptPoly[0].y - pFrom.y }; + const float vecLine[2] = { (float)aptPoly[0].x - pFrom.x, (float)aptPoly[0].y - pFrom.y }; // build the arrow base vector - normal to the line const float vecLeft[2] = { -vecLine[1], vecLine[0] }; @@ -477,7 +476,7 @@ void CKadLookupGraph::OnPaint() } } } - m_bDbgLog = false; + //m_bDbgLog = false; dc.SelectObject(pOldPen); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); @@ -503,8 +502,8 @@ void CKadLookupGraph::UpdateToolTip() CString strToolText; if (m_iHotItemIdx >= 0) { const CArray &he = m_pLookupHistory->GetHistoryEntries(); - const int hecount = (int)he.GetCount(); - int iHotItemRealIdx = hecount - (m_iHotItemIdx + 1); + const INT_PTR hecount = he.GetCount(); + INT_PTR iHotItemRealIdx = hecount - (m_iHotItemIdx + 1); const CLookupHistory::SLookupHistoryEntry *sEntry = he[iHotItemRealIdx]; CString strDiscovered; if (sEntry->m_liReceivedFromIdx.IsEmpty()) @@ -520,12 +519,12 @@ void CKadLookupGraph::UpdateToolTip() else strFoundNodes = GetResString(IDS_ASKING); } else { - uint32 iUseful = 0; - for (int i = 0; i < hecount; ++i) - for (int j = 0; j < he[i]->m_liReceivedFromIdx.GetCount(); ++j) - iUseful += static_cast(he[i]->m_liReceivedFromIdx[j] == iHotItemRealIdx); + unsigned useful = 0; + for (INT_PTR i = hecount; --i >= 0;) + for (INT_PTR j = he[i]->m_liReceivedFromIdx.GetCount(); --j >= 0;) + useful += static_cast(he[i]->m_liReceivedFromIdx[j] == iHotItemRealIdx); - strFoundNodes.Format(_T("%u (%u)"), sEntry->m_uRespondedContact, iUseful); + strFoundNodes.Format(_T("%u (%u)"), sEntry->m_uRespondedContact, useful); } } else strFoundNodes = GetResString(IDS_NOTASKED); diff --git a/srchybrid/KadLookupGraph.h b/srchybrid/KadLookupGraph.h index 093761fc..c8e6ad58 100644 --- a/srchybrid/KadLookupGraph.h +++ b/srchybrid/KadLookupGraph.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2010-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2010-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once namespace Kademlia { @@ -65,5 +64,5 @@ class CKadLookupGraph : public CWnd int m_iMaxLabelHeight; int m_iMaxNumLabelWidth; bool m_bInitializedFontMetrics; - bool m_bDbgLog; +// bool m_bDbgLog; }; \ No newline at end of file diff --git a/srchybrid/KadSearchListCtrl.cpp b/srchybrid/KadSearchListCtrl.cpp index fd289860..72dc0f0d 100644 --- a/srchybrid/KadSearchListCtrl.cpp +++ b/srchybrid/KadSearchListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/KadSearchListCtrl.h b/srchybrid/KadSearchListCtrl.h index a4245284..b29cde3e 100644 --- a/srchybrid/KadSearchListCtrl.h +++ b/srchybrid/KadSearchListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/KademliaWnd.cpp b/srchybrid/KademliaWnd.cpp index 9bdfcc9c..4789dfd3 100644 --- a/srchybrid/KademliaWnd.cpp +++ b/srchybrid/KademliaWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/KnownFile.cpp b/srchybrid/KnownFile.cpp index 851bc821..3912e6ea 100644 --- a/srchybrid/KnownFile.cpp +++ b/srchybrid/KnownFile.cpp @@ -1,6 +1,6 @@ // parts of this file are based on work from pan One (http://home-3.tiscali.nl/~meost/pms/) //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -253,26 +253,24 @@ void CKnownFile::UpdatePartsInfo() // SLUGFILLER: heapsortCompletesrc // calculate range - int i = n >> 1; // (n / 2) int j = (n * 3) >> 2; // (n * 3) / 4 - int k = (n * 7) >> 3; // (n * 7) / 8 //For complete files, trust people you had uploaded more... if (n < 20) { //For low guess and normal guess count // If we see more sources then the guessed low and normal, use what we see. - // If we see less sources then the guessed low, adjust network accounts for 100%, we account for 0% with what we see and make sure we are still above the normal. + // If we see less sources then the guessed low, adjust network accounts for 100%, + // we account for 0% with what we see and make sure we are still above the normal. //For high guess - // Adjust 100% network and 0% what we see. + // Adjust 100% network and 0% what we see. + int i = n >> 1; // (n / 2) if (acount[i] < m_nCompleteSourcesCount) m_nCompleteSourcesCountLo = m_nCompleteSourcesCount; else m_nCompleteSourcesCountLo = acount[i]; m_nCompleteSourcesCount = m_nCompleteSourcesCountLo; m_nCompleteSourcesCountHi = acount[j]; - if (m_nCompleteSourcesCountHi < m_nCompleteSourcesCount) - m_nCompleteSourcesCountHi = m_nCompleteSourcesCount; } else { //Many sources. //For low guess @@ -285,10 +283,11 @@ void CKnownFile::UpdatePartsInfo() m_nCompleteSourcesCount = acount[j]; if (m_nCompleteSourcesCount < m_nCompleteSourcesCountLo) m_nCompleteSourcesCount = m_nCompleteSourcesCountLo; + int k = (n * 7) >> 3; // (n * 7) / 8 m_nCompleteSourcesCountHi = acount[k]; - if (m_nCompleteSourcesCountHi < m_nCompleteSourcesCount) - m_nCompleteSourcesCountHi = m_nCompleteSourcesCount; } + if (m_nCompleteSourcesCountHi < m_nCompleteSourcesCount) + m_nCompleteSourcesCountHi = m_nCompleteSourcesCount; } m_nCompleteSourcesTime = tNow + MIN2S(1); } @@ -337,7 +336,7 @@ void CKnownFile::SetFileName(LPCTSTR pszFileName, bool bReplaceInvalidFileSystem if (pFile == this) theApp.sharedfiles->RemoveKeywords(this); - CAbstractFile::SetFileName(pszFileName, bReplaceInvalidFileSystemChars, true, bRemoveControlChars); + SetAFileName(pszFileName, bReplaceInvalidFileSystemChars, true, bRemoveControlChars); m_verifiedFileType = FILETYPE_UNKNOWN; wordlist.clear(); @@ -377,7 +376,7 @@ bool CKnownFile::CreateFromFile(LPCTSTR in_directory, LPCTSTR in_filename, LPVOI if (llFileSize <= 0) LogError(_T("Failed to hash file \"%s\" - %s"), (LPCTSTR)strFilePath, _tcserror(errno)); else - LogError(_T("Skipped hashing of file \"%s\" - File size exceeds limit."), (LPCTSTR)strFilePath); + LogError(_T("Skipped hashing file \"%s\" - File size exceeds limit."), (LPCTSTR)strFilePath); fclose(file); return false; // not supported by network } @@ -422,9 +421,13 @@ bool CKnownFile::CreateFromFile(LPCTSTR in_directory, LPCTSTR in_filename, LPVOI delete[] newhash; } else m_FileIdentifier.GetRawMD4HashSet().Add(newhash); + togo -= uSize; if (!togo) - break; + if (uSize == PARTSIZE) + continue; + else + break; if (pvProgressParam) { if (theApp.IsClosing()) { @@ -834,11 +837,11 @@ bool CKnownFile::WriteToFile(CFileDataIO &file) try { m_FileIdentifier.WriteAICHHashsetToFile(hashSetFile); bWriteHashSet = true; - } catch (CFileException *pError) { + } catch (CFileException *ex) { ASSERT(0); DebugLogError(_T("Memfile Error while storing AICH Part HashSet")); delete[] hashSetFile.Detach(); - pError->Delete(); + ex->Delete(); } if (bWriteHashSet) { CTag tagAICHHashSet(FT_AICHHASHSET, hashSetFile.Detach(), nAICHHashSetSize); @@ -907,9 +910,9 @@ bool CKnownFile::WriteToFile(CFileDataIO &file) } // other tags - for (int j = 0; j < m_taglist.GetCount(); ++j) { - if (m_taglist[j]->IsStr() || m_taglist[j]->IsInt()) { - m_taglist[j]->WriteTagToFile(file, UTF8strOptBOM); + for (INT_PTR i = 0; i < m_taglist.GetCount(); ++i) { + if (m_taglist[i]->IsStr() || m_taglist[i]->IsInt()) { + m_taglist[i]->WriteTagToFile(file, UTF8strOptBOM); ++uTagCount; } } @@ -924,6 +927,7 @@ bool CKnownFile::WriteToFile(CFileDataIO &file) void CKnownFile::CreateHash(CFile *pFile, uint64 Length, uchar *pMd4HashOut, CAICHHashTree *pShaHashOut) { + ASSERT(!Length || pFile); ASSERT(pMd4HashOut != NULL || pShaHashOut != NULL); uchar X[64 * 128]; @@ -1486,10 +1490,10 @@ void CKnownFile::UpdateMetaDataTags() uint32 uBitrate; if (mi->iVideoStreams) { strCodec = GetED2KVideoCodec(mi->video.bmiHeader.biCompression); - uBitrate = (mi->video.dwBitRate + 500) / 1000; + uBitrate = (mi->video.dwBitRate + SEC2MS(1) / 2) / SEC2MS(1); } else if (mi->iAudioStreams) { strCodec = GetED2KAudioCodec(mi->audio.wFormatTag); - uBitrate = (mi->audio.nAvgBytesPerSec * 8 + 500) / 1000; + uBitrate = (uint32)((mi->audio.nAvgBytesPerSec * 16ull + SEC2MS(1)) / SEC2MS(2)); } else uBitrate = 0; diff --git a/srchybrid/KnownFile.h b/srchybrid/KnownFile.h index 5ea3ee57..ca768cf2 100644 --- a/srchybrid/KnownFile.h +++ b/srchybrid/KnownFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/KnownFileList.cpp b/srchybrid/KnownFileList.cpp index 73811d46..9b8a170a 100644 --- a/srchybrid/KnownFileList.cpp +++ b/srchybrid/KnownFileList.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -44,7 +44,7 @@ static char THIS_FILE[] = __FILE__; #define CANCELLED_MET_FILENAME _T("cancelled.met") #define CANCELLED_HEADER_OLD MET_HEADER -#define CANCELLED_HEADER (MET_HEADER + 0x01) +#define CANCELLED_HEADER MET_HEADER_I64TAGS #define CANCELLED_VERSION 0x01 CKnownFileList::CKnownFileList() @@ -74,21 +74,16 @@ bool CKnownFileList::Init() bool CKnownFileList::LoadKnownFiles() { - const CString &fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + KNOWN_MET_FILENAME); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(fullpath, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") KNOWN_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } + if (!CFileOpen(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + KNOWN_MET_FILENAME + , CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to load ") KNOWN_MET_FILENAME)) + { return false; } - ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); CKnownFile *pRecord = NULL; try { uint8 header = file.ReadUInt8(); @@ -97,10 +92,10 @@ bool CKnownFileList::LoadKnownFiles() LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_BAD)); return false; } - AddDebugLogLine(false, _T("Known.met file version is %u (%s support 64bit tags)"), header, (header == MET_HEADER) ? _T("doesn't") : _T("does")); + AddDebugLogLine(false, _T("Known.met file version is %u (%s support 64-bit tags)"), header, (header == MET_HEADER) ? _T("doesn't") : _T("does")); - uint32 RecordsNumber = file.ReadUInt32(); - for (uint32 i = 0; i < RecordsNumber; ++i) { + uint32 uRecordsNumber = file.ReadUInt32(); + for (uint32 i = 0; i < uRecordsNumber; ++i) { pRecord = new CKnownFile(); if (!pRecord->LoadFromFile(file)) { TRACE(_T("*** Failed to load entry %u (name=%s hash=%s size=%I64u parthashes=%u expected parthashes=%u) from known.met\n") @@ -112,15 +107,12 @@ bool CKnownFileList::LoadKnownFiles() pRecord = NULL; } file.Close(); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_BAD)); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN), buffer); - } - error->Delete(); + else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_SERVERMET_UNKNOWN), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); delete pRecord; return false; } @@ -133,17 +125,12 @@ bool CKnownFileList::LoadCancelledFiles() // cancelled.met Format:
[[Tags TagCount] Count] if (!thePrefs.IsRememberingCancelledFiles()) return true; - const CString &fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + CANCELLED_MET_FILENAME); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(fullpath, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") CANCELLED_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } + if (!CFileOpen(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + CANCELLED_MET_FILENAME + , CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to load ") CANCELLED_MET_FILENAME)) + { return false; } ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); @@ -191,15 +178,12 @@ bool CKnownFileList::LoadCancelledFiles() } file.Close(); return true; - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) LogError(LOG_STATUSBAR, GetResString(IDS_ERR_CONFIGCORRUPT), CANCELLED_MET_FILENAME); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FAILEDTOLOAD), CANCELLED_MET_FILENAME, buffer); - } - error->Delete(); + else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FAILEDTOLOAD), CANCELLED_MET_FILENAME, (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); } return false; } @@ -207,65 +191,47 @@ bool CKnownFileList::LoadCancelledFiles() void CKnownFileList::Save() { if (thePrefs.GetLogFileSaving()) - AddDebugLogLine(false, _T("Saving known files list file \"%s\""), KNOWN_MET_FILENAME); + AddDebugLogLine(false, _T("Saving known files list in \"%s\""), KNOWN_MET_FILENAME); m_nLastSaved = ::GetTickCount(); const CString &sConfDir(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR)); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(sConfDir + KNOWN_MET_FILENAME, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - CString strError(_T("Failed to save ") KNOWN_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } else { + if (CFileOpen(file + , sConfDir + KNOWN_MET_FILENAME + , CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to save ") KNOWN_MET_FILENAME)) + { ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); - try { - file.WriteUInt8(0); // we will write the version tag later depending if any large files are on the list - UINT nRecordsNumber = 0; - bool bContainsAnyLargeFiles = false; - file.WriteUInt32(nRecordsNumber); + file.WriteUInt8(MET_HEADER_I64TAGS); + file.WriteUInt32((uint32)m_Files_map.GetCount()); // the number may be rewritten + INT_PTR iRecordsNumber = 0; for (const CKnownFilesMap::CPair *pair = m_Files_map.PGetFirstAssoc(); pair != NULL; pair = m_Files_map.PGetNextAssoc(pair)) { CKnownFile *pFile = pair->value; if (thePrefs.IsRememberingDownloadedFiles() || theApp.sharedfiles->IsFilePtrInList(pFile)) { pFile->WriteToFile(file); - ++nRecordsNumber; - bContainsAnyLargeFiles |= pFile->IsLargeFile(); + ++iRecordsNumber; } } - file.SeekToBegin(); - file.WriteUInt8(bContainsAnyLargeFiles ? MET_HEADER_I64TAGS : MET_HEADER); - file.WriteUInt32(nRecordsNumber); - - if (thePrefs.GetCommitFiles() >= 2 || (thePrefs.GetCommitFiles() >= 1 && theApp.IsClosing())) { - file.Flush(); // flush file stream buffers to disk buffers - if (_commit(_fileno(file.m_pStream)) != 0) // commit disk buffers to disk - AfxThrowFileException(CFileException::hardIO, ::GetLastError(), file.GetFileName()); + if (m_Files_map.GetCount() > iRecordsNumber) { + file.Seek(1, CFile::begin); + file.WriteUInt32((uint32)iRecordsNumber); } - file.Close(); - } catch (CFileException *error) { - CString strError(_T("Failed to save ") KNOWN_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*error, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - error->Delete(); + CommitAndClose(file); + } catch (CFileException *ex) { + LogError(LOG_STATUSBAR, _T("%s %s%s"), (LPCTSTR)GetResString(IDS_ERROR_SAVEFILE), KNOWN_MET_FILENAME, (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } - if (thePrefs.GetLogFileSaving()) - AddDebugLogLine(false, _T("Saving known files list file \"%s\""), CANCELLED_MET_FILENAME); - if (!file.Open(sConfDir + CANCELLED_MET_FILENAME, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - CString strError(_T("Failed to save ") CANCELLED_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } else { + AddDebugLogLine(false, _T("Saving cancelled files list in \"%s\""), CANCELLED_MET_FILENAME); + if (CFileOpen(file + , sConfDir + CANCELLED_MET_FILENAME + , CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to save ") CANCELLED_MET_FILENAME)) + { ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { @@ -278,23 +244,13 @@ void CKnownFileList::Save() file.WriteUInt32((uint32)m_mapCancelledFiles.GetCount()); for (const CancelledFilesMap::CPair *pair = m_mapCancelledFiles.PGetFirstAssoc(); pair != NULL; pair = m_mapCancelledFiles.PGetNextAssoc(pair)) { file.WriteHash16(pair->key.m_key); - file.WriteUInt8(0); + file.WriteUInt8(0); //number of tags } } - - if (thePrefs.GetCommitFiles() >= 2 || (thePrefs.GetCommitFiles() >= 1 && theApp.IsClosing())) { - file.Flush(); // flush file stream buffers to disk buffers - if (_commit(_fileno(file.m_pStream)) != 0) // commit disk buffers to disk - AfxThrowFileException(CFileException::hardIO, ::GetLastError(), file.GetFileName()); - } - file.Close(); - } catch (CFileException *error) { - CString strError(_T("Failed to save ") CANCELLED_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*error, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - error->Delete(); + CommitAndClose(file); + } catch (CFileException *ex) { + LogError(LOG_STATUSBAR, _T("%s %s%s"), (LPCTSTR)GetResString(IDS_ERROR_SAVEFILE), CANCELLED_MET_FILENAME, (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } } diff --git a/srchybrid/KnownFileList.h b/srchybrid/KnownFileList.h index 879f44d0..0b85f15e 100644 --- a/srchybrid/KnownFileList.h +++ b/srchybrid/KnownFileList.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -46,7 +46,7 @@ class CKnownFileList void AddCancelledFileID(const uchar *hash); bool IsCancelledFileByID(const uchar *hash) const; - const CKnownFilesMap &GetKnownFiles() const { return m_Files_map; } + const CKnownFilesMap& GetKnownFiles() const { return m_Files_map; } void CopyKnownFileMap(CKnownFilesMap &Files_Map); bool ShouldPurgeAICHHashset(const CAICHHash &rAICHHash) const; diff --git a/srchybrid/LastCommonRouteFinder.cpp b/srchybrid/LastCommonRouteFinder.cpp index 050a9dcb..8eba754b 100644 --- a/srchybrid/LastCommonRouteFinder.cpp +++ b/srchybrid/LastCommonRouteFinder.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/LastCommonRouteFinder.h b/srchybrid/LastCommonRouteFinder.h index 17daf7ad..9056b010 100644 --- a/srchybrid/LastCommonRouteFinder.h +++ b/srchybrid/LastCommonRouteFinder.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/LayeredWindowHelperST.cpp b/srchybrid/LayeredWindowHelperST.cpp index dbad9f4a..6c523c22 100644 --- a/srchybrid/LayeredWindowHelperST.cpp +++ b/srchybrid/LayeredWindowHelperST.cpp @@ -63,8 +63,5 @@ LONG_PTR CLayeredWindowHelperST::RemoveLayeredStyle(HWND hWnd) BOOL CLayeredWindowHelperST::SetTransparentPercentage(HWND hWnd, UINT byPercentage) { // Do not accept values greater than 100% - if (byPercentage > 100) - byPercentage = 100; - - return ::SetLayeredWindowAttributes(hWnd, 0, (BYTE)(255 * byPercentage / 100), LWA_ALPHA); + return ::SetLayeredWindowAttributes(hWnd, 0, (BYTE)(255 * min(byPercentage, 100) / 100), LWA_ALPHA); } // End of SetTransparentPercentage \ No newline at end of file diff --git a/srchybrid/ListBoxST.cpp b/srchybrid/ListBoxST.cpp index 1d0597a6..fd25a996 100644 --- a/srchybrid/ListBoxST.cpp +++ b/srchybrid/ListBoxST.cpp @@ -123,7 +123,7 @@ void CListBoxST::DrawItem(LPDRAWITEMSTRUCT lpDIStruct) const CRect *pRect = (m_byRowSelect == ST_TEXTSELECT ? &rcCenteredText : &rcText); OnDrawTextBackground(lpDIStruct->itemID, pDC, &rcItem, pRect, bIsDisabled, bIsSelected, crColor); - // Draw the icon (if any) + // Draw the icon, if any if (m_pImageList) OnDrawIcon(lpDIStruct->itemID, pDC, &rcItem, &rcIcon, lpLBData->nImage, bIsDisabled, bIsSelected); diff --git a/srchybrid/ListCtrlX.cpp b/srchybrid/ListCtrlX.cpp index 6216d9da..f016d7a9 100644 --- a/srchybrid/ListCtrlX.cpp +++ b/srchybrid/ListCtrlX.cpp @@ -538,75 +538,61 @@ void CreateItemReport(CListCtrl &lv, CString &rstrReport) } TCHAR szItem[512]; int iItems = lv.GetItemCount(); + LVCOLUMN lvc; + lvc.mask = LVCF_TEXT | LVCF_WIDTH; + lvc.pszText = szItem; + lvc.cchTextMax = _countof(szItem); + LVITEM lvi; + lvi.mask = LVIF_TEXT; + lvi.cchTextMax = _countof(szItem); -// memset(paiColWidths, 0, (sizeof *paiColWidths) * iCols); - for (int iCol = 0; iCol < iCols; ++iCol) { - LVCOLUMN lvc; - lvc.mask = LVCF_TEXT | LVCF_WIDTH; - lvc.pszText = szItem; - lvc.cchTextMax = _countof(szItem); + for (int iCol = 0; iCol < iCols; ++iCol) if (lv.GetColumn(iCol, &lvc) && lvc.cx > 0) { - szItem[_countof(szItem) - 1] = _T('\0'); int iLen = (int)_tcslen(lvc.pszText); if (iLen > paiColWidths[iCol]) paiColWidths[iCol] = iLen; for (int iItem = 0; iItem < iItems; ++iItem) { - LVITEM lvi; - lvi.mask = LVIF_TEXT; lvi.iItem = iItem; lvi.iSubItem = iCol; lvi.pszText = szItem; - lvi.cchTextMax = _countof(szItem); if (lv.GetItem(&lvi)) { - szItem[_countof(szItem) - 1] = _T('\0'); iLen = (int)_tcslen(lvi.pszText); if (iLen > paiColWidths[iCol]) paiColWidths[iCol] = iLen; } } } - } CString strLine; - for (int iCol = 0; iCol < iCols; ++iCol) { - if (paiColWidths[iCol] > 0) { - LVCOLUMN lvc; - lvc.mask = LVCF_TEXT; - lvc.pszText = szItem; - lvc.cchTextMax = _countof(szItem); - if (lv.GetColumn(iCol, &lvc)) { - szItem[_countof(szItem) - 1] = _T('\0'); - strLine.AppendFormat(_T("%-*s"), paiColWidths[iCol] + 2, szItem); - } - } - } + lvc.mask = LVCF_TEXT; + for (int iCol = 0; iCol < iCols; ++iCol) + if (paiColWidths[iCol] > 0 && lv.GetColumn(iCol, &lvc)) + strLine.AppendFormat(_T("%-*s"), paiColWidths[iCol] + 2, szItem); + if (!strLine.IsEmpty()) { if (!rstrReport.IsEmpty()) rstrReport += _T("\r\n"); rstrReport.AppendFormat(_T("%s\r\n%s"), (LPCTSTR)strLine, (LPCTSTR)CString(_T('-'), strLine.GetLength())); + strLine.Empty(); } + lvi.mask = LVIF_TEXT; for (int iItem = 0; iItem < iItems; ++iItem) { - for (int iCol = 0; iCol < iCols; ++iCol) { + for (int iCol = 0; iCol < iCols; ++iCol) if (paiColWidths[iCol] > 0) { - LVITEM lvi; - lvi.mask = LVIF_TEXT; lvi.iItem = iItem; lvi.iSubItem = iCol; lvi.pszText = szItem; - lvi.cchTextMax = _countof(szItem); - if (lv.GetItem(&lvi)) { - szItem[_countof(szItem) - 1] = _T('\0'); + if (lv.GetItem(&lvi)) strLine.AppendFormat(_T("%-*s"), paiColWidths[iCol] + 2, szItem); - } } - } if (!strLine.IsEmpty()) { if (!rstrReport.IsEmpty()) rstrReport += _T("\r\n"); rstrReport += strLine; + strLine.Empty(); } } @@ -656,9 +642,7 @@ void SetItemFocus(CListCtrl &ctl) if (ctl.GetItemCount() > 0) { int iSel = ctl.GetNextItem(-1, LVNI_FOCUSED); if (iSel < 0) { - iSel = ctl.GetNextItem(-1, LVNI_SELECTED); - if (iSel < 0) - iSel = 0; + iSel = max(0, ctl.GetNextItem(-1, LVNI_SELECTED)); ctl.SetItemState(iSel, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); ctl.SetSelectionMark(iSel); } @@ -667,7 +651,7 @@ void SetItemFocus(CListCtrl &ctl) bool CListCtrlX::FindItem(const CListCtrlX &lv, int iItem, DWORD_PTR) { - CString strItemText(lv.GetItemText(iItem, lv.GetFindColumn())); + const CString &strItemText(lv.GetItemText(iItem, lv.GetFindColumn())); if (!strItemText.IsEmpty()) { if (lv.GetFindMatchCase() ? _tcsstr(strItemText, lv.GetFindText()) != NULL diff --git a/srchybrid/ListViewSearchDlg.cpp b/srchybrid/ListViewSearchDlg.cpp index c02011e7..67322e39 100644 --- a/srchybrid/ListViewSearchDlg.cpp +++ b/srchybrid/ListViewSearchDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -89,7 +89,6 @@ BOOL CListViewSearchDlg::OnInitDialog() lvc.pszText = szColTitle; int iCol = 0; while (m_pListView->GetColumn(iCol++, &lvc)) { - szColTitle[_countof(szColTitle) - 1] = _T('\0'); m_ctlSearchCol.AddString(szColTitle); if (!m_bCanSearchInAllColumns) break; diff --git a/srchybrid/ListViewWalkerPropertySheet.cpp b/srchybrid/ListViewWalkerPropertySheet.cpp index 523f1a09..3fca6af2 100644 --- a/srchybrid/ListViewWalkerPropertySheet.cpp +++ b/srchybrid/ListViewWalkerPropertySheet.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ListenSocket.cpp b/srchybrid/ListenSocket.cpp index 9a2c5ff5..43fce415 100644 --- a/srchybrid/ListenSocket.cpp +++ b/srchybrid/ListenSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -18,7 +18,6 @@ #include "DebugHelpers.h" #include "emule.h" #include "ListenSocket.h" -#include "PeerCacheSocket.h" #include "opcodes.h" #include "UpDownClient.h" #include "ClientList.h" @@ -37,7 +36,6 @@ #include "TransferDlg.h" #include "ClientListCtrl.h" #include "ChatWnd.h" -#include "PeerCacheFinder.h" #include "Exceptions.h" #include "Kademlia/Utils/uint128.h" #include "Kademlia/Kademlia/kademlia.h" @@ -121,26 +119,6 @@ void CClientReqSocket::ResetTimeOutTimer() timeout_timer = ::GetTickCount(); } -DWORD CClientReqSocket::GetTimeOut() const -{ - // PC-TODO - // the PC socket may even already be disconnected and deleted and we still need to keep the - // ed2k socket open because remote client may still be downloading from cache. - DWORD uTimeout = CEMSocket::GetTimeOut(); - DWORD u1 = 0; - if (client) - if (client->IsUploadingToPeerCache() && (client->m_pPCUpSocket == NULL || !client->m_pPCUpSocket->IsConnected())) - // we are uploading (or at least allow uploading) but currently no socket - u1 = GetPeerCacheSocketUploadTimeout(); - else if (client->m_pPCUpSocket && client->m_pPCUpSocket->IsConnected()) - // we have an uploading PC socket, but that socket is not used (nor can it be closed) - u1 = client->m_pPCUpSocket->GetTimeOut(); - else if (client->m_pPCDownSocket && client->m_pPCDownSocket->IsConnected()) - // we have a downloading PC socket - u1 = client->m_pPCDownSocket->GetTimeOut(); - return max(uTimeout, u1); -} - bool CClientReqSocket::CheckTimeOut() { const DWORD curTick = ::GetTickCount(); @@ -190,7 +168,7 @@ void CClientReqSocket::OnClose(int nErrorCode) void CClientReqSocket::Disconnect(LPCTSTR pszReason) { - CEMSocket::SetConState(ES_DISCONNECTED); + CEMSocket::SetConState(EMS_DISCONNECTED); AsyncSelect(FD_CLOSE); if (client) { CString sMsg; @@ -218,7 +196,7 @@ void CClientReqSocket::Delete_Timed() void CClientReqSocket::Safe_Delete() { ASSERT(theApp.listensocket->IsValidSocket(this)); - CEMSocket::SetConState(ES_DISCONNECTED); + CEMSocket::SetConState(EMS_DISCONNECTED); AsyncSelect(FD_CLOSE); deltimer = ::GetTickCount(); if (m_SocketData.hSocket != INVALID_SOCKET) // deadlake PROXYSUPPORT - changed to AsyncSocketEx @@ -346,7 +324,7 @@ bool CClientReqSocket::ProcessPacket(const BYTE *packet, uint32 size, UINT opcod client->SetCommentDirty(); client->SetUploadFileID(reqfile); - if (!client->ProcessExtendedInfo(&data_in, reqfile)) { + if (!client->ProcessExtendedInfo(data_in, reqfile)) { if (thePrefs.GetDebugClientTCPLevel() > 0) DebugSend("OP_FileReqAnsNoFil", client, packet); Packet *replypacket = new Packet(OP_FILEREQANSNOFIL, 16); @@ -476,7 +454,7 @@ bool CClientReqSocket::ProcessPacket(const BYTE *packet, uint32 size, UINT opcod CPartFile *file = theApp.downloadqueue->GetFileByID(cfilehash); if (file == NULL) client->CheckFailedFileIdReqs(cfilehash); - client->ProcessFileInfo(&data, file); + client->ProcessFileInfo(data, file); } break; case OP_FILESTATUS: @@ -491,7 +469,7 @@ bool CClientReqSocket::ProcessPacket(const BYTE *packet, uint32 size, UINT opcod CPartFile *file = theApp.downloadqueue->GetFileByID(cfilehash); if (file == NULL) client->CheckFailedFileIdReqs(cfilehash); - client->ProcessFileStatus(false, &data, file); + client->ProcessFileStatus(false, data, file); } break; case OP_STARTUPLOADREQ: @@ -607,10 +585,10 @@ bool CClientReqSocket::ProcessPacket(const BYTE *packet, uint32 size, UINT opcod if (!creqfile->IsStopped() && creqfile->GetStatus() == PS_PAUSED || creqfile->GetStatus() == PS_ERROR) newDS = DS_ONQUEUE; else - newDS = DS_CONNECTED; //anything but DS_NONE or DS_ONQUEUE + newDS = DS_CONNECTED; //any state but DS_NONE or DS_ONQUEUE } } - if (newDS != DS_CONNECTED && client) { //could be deleted while debugging + if (newDS != DS_CONNECTED && client) { //client could have been deleted while debugging client->SendCancelTransfer(); client->SetDownloadState(newDS); } @@ -971,7 +949,7 @@ bool CClientReqSocket::ProcessExtPacket(const BYTE *packet, uint32 size, UINT op if (thePrefs.GetDebugClientTCPLevel() > 0) DebugRecv("OP_MPReqFileName", client, packet); - if (!client->ProcessExtendedInfo(&data_in, reqfile)) { + if (!client->ProcessExtendedInfo(data_in, reqfile)) { if (thePrefs.GetDebugClientTCPLevel() > 0) DebugSend("OP_FileReqAnsNoFil", client, packet); Packet *replypacket = new Packet(OP_FILEREQANSNOFIL, 16); @@ -1115,13 +1093,13 @@ bool CClientReqSocket::ProcessExtPacket(const BYTE *packet, uint32 size, UINT op if (thePrefs.GetDebugClientTCPLevel() > 0) DebugRecv("OP_MPReqFileNameAns", client, packet); - client->ProcessFileInfo(&data_in, reqfile); + client->ProcessFileInfo(data_in, reqfile); break; case OP_FILESTATUS: if (thePrefs.GetDebugClientTCPLevel() > 0) DebugRecv("OP_MPFileStatus", client, packet); - client->ProcessFileStatus(false, &data_in, reqfile); + client->ProcessFileStatus(false, data_in, reqfile); break; case OP_AICHFILEHASHANS: if (thePrefs.GetDebugClientTCPLevel() > 0) @@ -1344,38 +1322,9 @@ bool CClientReqSocket::ProcessExtPacket(const BYTE *packet, uint32 size, UINT op client->ProcessPreviewAnswer(packet, size); break; case OP_PEERCACHE_QUERY: - theStats.AddDownDataOverheadFileRequest(uRawSize); - if (!client->ProcessPeerCacheQuery(packet, size)) { - CSafeMemFile dataSend(128); - dataSend.WriteUInt8(PCPCK_VERSION); - dataSend.WriteUInt8(PCOP_NONE); - if (thePrefs.GetDebugClientTCPLevel() > 0) { - DebugSend("OP_PeerCacheAnswer", client); - Debug(_T(" %s\n"), _T("Not supported")); - } - Packet *pEd2kPacket = new Packet(dataSend, OP_EMULEPROT, OP_PEERCACHE_ANSWER); - theStats.AddUpDataOverheadFileRequest(pEd2kPacket->size); - SendPacket(pEd2kPacket); - } - break; case OP_PEERCACHE_ANSWER: - theStats.AddDownDataOverheadFileRequest(uRawSize); - if ((!client->ProcessPeerCacheAnswer(packet, size)) && client->GetDownloadState() != DS_NONEEDEDPARTS) { - // We have sent a PeerCache Query to the remote client, for any reason the remote client - // can not process it -> fall back to ed2k download. - client->SetPeerCacheDownState(PCDS_NONE); - ASSERT(client->m_pPCDownSocket == NULL); - - // PC-TODO: Check client state. - ASSERT(client->GetDownloadState() == DS_DOWNLOADING); - client->SetDownloadState(DS_ONQUEUE, _T("Peer cache query trouble")); // clear block requests - if (client) - client->StartDownload(); - } - break; case OP_PEERCACHE_ACK: theStats.AddDownDataOverheadFileRequest(uRawSize); - client->ProcessPeerCacheAcknowledge(packet, size); break; case OP_PUBLICIP_ANSWER: if (thePrefs.GetDebugClientTCPLevel() > 0) @@ -1526,7 +1475,7 @@ bool CClientReqSocket::ProcessExtPacket(const BYTE *packet, uint32 size, UINT op //anything to the extended info data as this will be taken care of in ProcessExtendedInfo() //Update extended info. if (sender->GetUDPVersion() > 3) - sender->ProcessExtendedInfo(&data_in, reqfile); + sender->ProcessExtendedInfo(data_in, reqfile); //Update our complete source counts. else if (sender->GetUDPVersion() > 2) { uint16 nCompleteCountLast = sender->GetUpCompleteSourcesCount(); @@ -1684,10 +1633,10 @@ bool CClientReqSocket::ProcessExtPacket(const BYTE *packet, uint32 size, UINT op if (!creqfile->IsStopped() && creqfile->GetStatus() == PS_PAUSED || creqfile->GetStatus() == PS_ERROR) newDS = DS_ONQUEUE; else - newDS = DS_CONNECTED; //anything but DS_NONE or DS_ONQUEUE + newDS = DS_CONNECTED; //any state but DS_NONE or DS_ONQUEUE } } - if (newDS != DS_CONNECTED) { + if (newDS != DS_CONNECTED && client) { //client could have been deleted while debugging client->SendCancelTransfer(); client->SetDownloadState(newDS); } @@ -1746,11 +1695,11 @@ bool CClientReqSocket::ProcessExtPacket(const BYTE *packet, uint32 size, UINT op theStats.AddDownDataOverheadOther(uRawSize); PacketToDebugLogLine(_T("eMule"), packet, size, opcode); } - } catch(CFileException *error) { - error->Delete(); + } catch(CFileException *ex) { + ex->Delete(); throw GetResString(IDS_ERR_INVALIDPACKET); - } catch(CMemoryException *error) { - error->Delete(); + } catch(CMemoryException *ex) { + ex->Delete(); throwCStr(_T("Memory exception")); } return true; @@ -1760,7 +1709,7 @@ void CClientReqSocket::PacketToDebugLogLine(LPCTSTR protocol, const uchar *packe { if (thePrefs.GetVerbose()) { CString buffer; - buffer.Format(_T("Unknown %s Protocol Opcode: 0x%02x, Size=%u, Data=["), protocol, opcode, size); + buffer.Format(_T("Unknown %s protocol Opcode: 0x%02x, Size=%u, Data=["), protocol, opcode, size); UINT i; for (i = 0; i < size && i < 50; ++i) buffer.AppendFormat(*(&_T(" %02x")[static_cast(i > 0)]), packet[i]); @@ -1835,7 +1784,7 @@ void CClientReqSocket::OnError(int nErrorCode) bool CClientReqSocket::PacketReceived(Packet *packet) { - CString *sErr; + CString *psErr; bool bDelClient; const uint8 opcode = packet->opcode; const UINT uRawSize = packet->size; @@ -1878,41 +1827,41 @@ bool CClientReqSocket::PacketReceived(Packet *packet) client->SetDownloadState(DS_ERROR, _T("Unknown protocol")); Disconnect(_T("Unknown protocol")); } - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); throw GetResString(IDS_ERR_INVALIDPACKET); - } catch (CMemoryException *error) { - error->Delete(); + } catch (CMemoryException *ex) { + ex->Delete(); throwCStr(_T("Memory exception")); } catch (...) { //trying to catch "Unspecified error" throwCStr(_T("Unhandled exception")); } return true; - } catch (CClientException *ex) { // nearly the same as the 'CString' exception but with optional deleting of the client + } catch (CClientException *ex) { // similar to 'CString&' exception but client deletion is optional bDelClient = ex->m_bDelete; - sErr = new CString(ex->m_strMsg); + psErr = new CString(ex->m_strMsg); ex->Delete(); - } catch (const CString &error) { + } catch (const CString &ex) { bDelClient = true; - sErr = new CString(error); + psErr = new CString(ex); } //Error handling bool bIsDonkey = (packet->prot == OP_EDONKEYPROT); LPCTSTR sProtocol = bIsDonkey ? _T("eDonkey") : _T("eMule"); if (thePrefs.GetVerbose()) DebugLogWarning(_T("Error: '%s' while processing %s packet: opcode=%s size=%u; %s") - , (LPCTSTR)sErr + , (LPCTSTR)*psErr , sProtocol , (LPCTSTR)(bIsDonkey ? DbgGetDonkeyClientTCPOpcode(opcode) : DbgGetMuleClientTCPOpcode(opcode)) , uRawSize , (LPCTSTR)DbgGetClientInfo()); CString sErr2; - sErr2.Format(_T("Error while processing %s packet: %s"), (LPCTSTR)sProtocol, (LPCTSTR)sErr); + sErr2.Format(_T("Error while processing %s packet: %s"), (LPCTSTR)sProtocol, (LPCTSTR)*psErr); if (bDelClient && client) client->SetDownloadState(DS_ERROR, sErr2); Disconnect(sErr2); - delete sErr; + delete psErr; return false; } @@ -2248,13 +2197,13 @@ void CListenSocket::RecalculateStats() memset(m_ConnectionStates, 0, sizeof m_ConnectionStates); for (POSITION pos = socket_list.GetHeadPosition(); pos != NULL;) switch (socket_list.GetNext(pos)->GetConState()) { - case ES_DISCONNECTED: + case EMS_DISCONNECTED: ++m_ConnectionStates[0]; break; - case ES_NOTCONNECTED: + case EMS_NOTCONNECTED: ++m_ConnectionStates[1]; break; - case ES_CONNECTED: + case EMS_CONNECTED: ++m_ConnectionStates[2]; } } diff --git a/srchybrid/ListenSocket.h b/srchybrid/ListenSocket.h index 7d1dc8f9..40a2522d 100644 --- a/srchybrid/ListenSocket.h +++ b/srchybrid/ListenSocket.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -42,9 +42,8 @@ class CClientReqSocket : public CEMSocket void WaitForOnConnect(); void ResetTimeOutTimer(); bool CheckTimeOut(); - virtual DWORD GetTimeOut() const; virtual void Safe_Delete(); - virtual void Close() { CAsyncSocketEx::Close(); } + //virtual void Close() { CAsyncSocketEx::Close(); } bool Create(); virtual void SendPacket(Packet *packet, bool controlpacket = true, uint32 actualPayloadSize = 0, bool bForceImmediateSend = false); diff --git a/srchybrid/Log.cpp b/srchybrid/Log.cpp index 8542c645..2a25a1f7 100644 --- a/srchybrid/Log.cpp +++ b/srchybrid/Log.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/MapKey.h b/srchybrid/MapKey.h index 3b36e627..5f53337a 100644 --- a/srchybrid/MapKey.h +++ b/srchybrid/MapKey.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "otherfunctions.h" diff --git a/srchybrid/Mdump.cpp b/srchybrid/Mdump.cpp index 2aba3d03..c6211aba 100644 --- a/srchybrid/Mdump.cpp +++ b/srchybrid/Mdump.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -36,14 +36,14 @@ TCHAR CMiniDumper::m_szDumpDir[MAX_PATH] = {}; void CMiniDumper::Enable(LPCTSTR pszAppName, bool bShowErrors, LPCTSTR pszDumpDir) { - // if this assert fires then you have two instances of CMiniDumper which is not allowed - ASSERT(m_szAppName[0] == _T('\0')); - _tcsncpy(m_szAppName, pszAppName, _countof(m_szAppName) - 1); + // This assert fires if you have two instances of CMiniDumper which is not allowed + ASSERT(*m_szAppName == _T('\0')); + _tcsncpy(m_szAppName, pszAppName, _countof(m_szAppName)); m_szAppName[_countof(m_szAppName) - 1] = _T('\0'); // eMule may not have the permission to create a DMP file in the directory where the "emule.exe" is located. // Need to pre-determine a valid directory. - _tcsncpy(m_szDumpDir, pszDumpDir, _countof(m_szDumpDir) - 2); + _tcsncpy(m_szDumpDir, pszDumpDir, _countof(m_szDumpDir)); m_szDumpDir[_countof(m_szDumpDir) - 2] = _T('\0'); ::PathAddBackslash(m_szDumpDir); @@ -91,69 +91,55 @@ LONG WINAPI CMiniDumper::TopLevelFilter(struct _EXCEPTION_POINTERS *pExceptionIn HMODULE hDll = GetDebugHelperDll((FARPROC*)&pfnMiniDumpWriteDump, true); if (hDll) { if (pfnMiniDumpWriteDump) { - time_t tNow = time(NULL); //time of the crash - // Ask user if they want to save a dump file + SYSTEMTIME t; + GetLocalTime(&t); //time of this crash + // Ask user to confirm writing a dump file // Do *NOT* localize that string (in fact, do not use MFC to load it)! if (theCrashDumper.uCreateCrashDump == 2 || MessageBox(NULL, CRASHTEXT, m_szAppName, MB_ICONSTOP | MB_YESNO) == IDYES) { - // Create full path for DUMP file - TCHAR szDumpPath[MAX_PATH]; - _tcsncpy(szDumpPath, m_szDumpDir, _countof(szDumpPath) - 1); - szDumpPath[_countof(szDumpPath) - 1] = _T('\0'); - size_t uDumpPathLen = _tcslen(szDumpPath); - TCHAR szBaseName[MAX_PATH]; - _tcsncpy(szBaseName, m_szAppName, _countof(szBaseName) - 1); + _sntprintf(szBaseName, MAX_PATH, _T("%s_%4d%02d%02d-%02d%02d%02d") + , m_szAppName, t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); szBaseName[_countof(szBaseName) - 1] = _T('\0'); - size_t uBaseNameLen = _tcslen(szBaseName); - - _tcsftime(szBaseName + uBaseNameLen, _countof(szBaseName) - uBaseNameLen, _T("_%Y%m%d-%H%M%S"), localtime(&tNow)); - szBaseName[_countof(szBaseName) - 1] = _T('\0'); - // Replace spaces and dots in file name. - LPTSTR psz = szBaseName; - while (*psz != _T('\0')) { - if (*psz == _T('.')) - *psz = _T('-'); - else if (*psz == _T(' ')) - *psz = _T('_'); - ++psz; - } - if (uDumpPathLen < _countof(szDumpPath) - 1) { - _tcsncat(szDumpPath, szBaseName, _countof(szDumpPath) - uDumpPathLen - 1); - szDumpPath[_countof(szDumpPath) - 1] = _T('\0'); - uDumpPathLen = _tcslen(szDumpPath); - if (uDumpPathLen < _countof(szDumpPath) - 1) { - _tcsncat(szDumpPath, _T(".dmp"), _countof(szDumpPath) - uDumpPathLen - 1); - szDumpPath[_countof(szDumpPath) - 1] = _T('\0'); - } - } + for (LPTSTR p = szBaseName; *p != _T('\0'); ++p) + if (*p == _T('.')) + *p = _T('-'); + else if (*p == _T(' ')) + *p = _T('_'); + + // Create full path for the dump file + TCHAR szDumpPath[MAX_PATH]; + _sntprintf(szDumpPath, MAX_PATH, _T("%s%s.dmp"), m_szDumpDir, szBaseName); + szDumpPath[_countof(szDumpPath) - 1] = _T('\0'); TCHAR szResult[MAX_PATH + 1024]; *szResult = _T('\0'); HANDLE hFile = ::CreateFile(szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { - _MINIDUMP_EXCEPTION_INFORMATION ExInfo = {}; - ExInfo.ThreadId = GetCurrentThreadId(); - ExInfo.ExceptionPointers = pExceptionInfo; - ExInfo.ClientPointers = NULL; - + _MINIDUMP_EXCEPTION_INFORMATION ExInfo = { GetCurrentThreadId(), pExceptionInfo, FALSE }; BOOL bOK = (*pfnMiniDumpWriteDump)(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL); if (bOK) { - // Do *NOT* localize that string (in fact, do not use MFC to load it)! - _sntprintf(szResult, _countof(szResult) - 1, _T("Saved dump file to \"%s\".\r\n\r\nPlease send this file together with a detailed bug report to dumps@emule-project.net !\r\n\r\nThank you for helping to improve eMule."), szDumpPath); + // Do *NOT* localize this string (in fact, do not use MFC to load it)! + _sntprintf(szResult, _countof(szResult) + , _T("Saved dump file to \"%s\".\r\n\r\n") + _T("Please attach this file to a detailed bug report at forum.emule-project.net\r\n\r\n") + _T("Thank you for helping to improve eMule!") + , szDumpPath); szResult[_countof(szResult) - 1] = _T('\0'); #ifdef _DEBUG lRetValue = EXCEPTION_EXECUTE_HANDLER; #endif } else { - // Do *NOT* localize that string (in fact, do not use MFC to load it)! - _sntprintf(szResult, _countof(szResult) - 1, _T("Failed to save dump file to \"%s\".\r\n\r\nError: %lu"), szDumpPath, ::GetLastError()); + // Do *NOT* localize this string (in fact, do not use MFC to load it)! + _sntprintf(szResult, _countof(szResult), _T("Failed to save dump file to \"%s\".\r\n\r\nError: %lu") + , szDumpPath, ::GetLastError()); szResult[_countof(szResult) - 1] = _T('\0'); } ::CloseHandle(hFile); } else { - // Do *NOT* localize that string (in fact, do not use MFC to load it)! - _sntprintf(szResult, _countof(szResult) - 1, _T("Failed to create dump file \"%s\".\r\n\r\nError: %lu"), szDumpPath, ::GetLastError()); + // Do *NOT* localize this string (in fact, do not use MFC to load it)! + _sntprintf(szResult, _countof(szResult), _T("Failed to create dump file \"%s\".\r\n\r\nError: %lu") + , szDumpPath, ::GetLastError()); szResult[_countof(szResult) - 1] = _T('\0'); } if (*szResult != _T('\0')) @@ -165,7 +151,7 @@ LONG WINAPI CMiniDumper::TopLevelFilter(struct _EXCEPTION_POINTERS *pExceptionIn #ifndef _DEBUG // Exit the process only in release builds, so that in debug builds the exception - // is passed to a possible installed debugger + // is passed to an installed debugger ExitProcess(0); #else return lRetValue; diff --git a/srchybrid/MediaInfo.cpp b/srchybrid/MediaInfo.cpp index 7bfdf7c2..8514514b 100644 --- a/srchybrid/MediaInfo.cpp +++ b/srchybrid/MediaInfo.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -323,9 +323,8 @@ CString GetVideoFormatDisplayName(DWORD biCompression) { sName = CStringA((LPCSTR)&biCompression, 4); DWORD fcc; - unsigned char *cp = (unsigned char*)&biCompression; for (int i = 0; i < sizeof(DWORD); ++i) - ((byte*)&fcc)[i] = (byte)toupper(*cp++); + ((byte*)&fcc)[i] = (byte)toupper(((unsigned char*)&biCompression)[i]); switch (fcc) { case MAKEFOURCC('D', 'I', 'V', '3'): @@ -416,7 +415,7 @@ CString GetVideoFormatDisplayName(DWORD biCompression) } } if (pFormat) - sName += pFormat;; + sName += pFormat; return sName; } @@ -1079,9 +1078,9 @@ struct SRmFileProp { } SRmFileProp(const SRmFileProp &r) + : strName(r.strName) + , strValue(r.strValue) { - strName = r.strName; - strValue = r.strValue; } SRmFileProp& operator=(const SRmFileProp &r) @@ -1158,7 +1157,6 @@ bool GetRMHeaders(LPCTSTR pszFileName, SMediaInfo *mi, bool &rbIsRM, bool bFullI bool bReadPROP = false; bool bReadMDPR_Video = false; bool bReadMDPR_Audio = false; - bool bReadMDPR_File = false; bool bReadCONT = false; UINT nFileBitrate = 0; CString strCopyright; @@ -1194,6 +1192,7 @@ bool GetRMHeaders(LPCTSTR pszFileName, SMediaInfo *mi, bool &rbIsRM, bool bFullI rbIsRM = true; mi->strFileFormat = _T("Real Media"); + bool bReadMDPR_File = false; bool bBrokenFile = false; while (!bBrokenFile && (!bReadCONT || !bReadPROP || !bReadMDPR_Video || !bReadMDPR_Audio || (bFullInfo && !bReadMDPR_File))) { ullCurFilePos = file.GetPosition(); @@ -1495,7 +1494,7 @@ bool GetRMHeaders(LPCTSTR pszFileName, SMediaInfo *mi, bool &rbIsRM, bool bFullI mi->strInfo << _T(" ") << _T("Copyright") << _T(":\t") << strCopyright << _T("\n"); if (!strComment.IsEmpty()) mi->strInfo << _T(" ") << GetResString(IDS_COMMENT) << _T(":\t") << strComment << _T("\n"); - for (int i = 0; i < aFileProps.GetCount(); ++i) + for (INT_PTR i = 0; i < aFileProps.GetCount(); ++i) if (!aFileProps[i].strValue.IsEmpty()) mi->strInfo << _T(" ") << (CString)aFileProps[i].strName << _T(":\t") << (CString)aFileProps[i].strValue << _T("\n"); } @@ -1989,7 +1988,7 @@ bool GetWMHeaders(LPCTSTR pszFileName, SMediaInfo *mi, bool &rbIsWM, bool bFullI HRESULT hr = E_FAIL; // 1st, try to read the file with the 'WMEditor'. This object tends to give more (stream) information than the 'WMSyncReader'. - // Though the 'WMEditor' is not capable of reading files which are currently opened for 'writing'. + // Though the 'WMEditor' cannot read files that are open for 'writing'. if (pIUnkReader == NULL) { CComPtr pIWMMetadataEditor; if (theWmvCoreDLL.m_pfnWMCreateEditor != NULL && (hr = (*theWmvCoreDLL.m_pfnWMCreateEditor)(&pIWMMetadataEditor)) == S_OK) { @@ -2731,11 +2730,11 @@ bool GetWMHeaders(LPCTSTR pszFileName, SMediaInfo *mi, bool &rbIsWM, bool bFullI CComQIPtr pIWMMetadataEditor(pIUnkReader); if (pIWMMetadataEditor) VERIFY(pIWMMetadataEditor->Close() == S_OK); - } - if (pIUnkReader) { - CComQIPtr pIWMSyncReader(pIUnkReader); - if (pIWMSyncReader) - VERIFY(pIWMSyncReader->Close() == S_OK); + else { + CComQIPtr pIWMSyncReader(pIUnkReader); + if (pIWMSyncReader) + VERIFY(pIWMSyncReader->Close() == S_OK); + } } return mi->iAudioStreams > 0 diff --git a/srchybrid/MediaInfo.h b/srchybrid/MediaInfo.h index 8c27bd93..8989f3cd 100644 --- a/srchybrid/MediaInfo.h +++ b/srchybrid/MediaInfo.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/MenuCmds.h b/srchybrid/MenuCmds.h index 385872b7..f7b1beef 100644 --- a/srchybrid/MenuCmds.h +++ b/srchybrid/MenuCmds.h @@ -3,7 +3,8 @@ /////////////////////////////////////////////////////////////////////////////// // Menu commands for GUI only -// Menu entries for the application system menu -> require a set of IDs with special restrictions! +// Menu entries for the application system menu require IDs compatible with +// WM_SYSCOMMAND - bit mask 0xfff0 will be applied. #define MP_RESTORE 0x110 #define MP_CONNECT 0x120 #define MP_DISCONNECT 0x130 @@ -12,6 +13,7 @@ #define MP_VERSIONCHECK 0x160 #define MP_MINIMIZETOTRAY 0x170 + #define MP_MESSAGE 10102 #define MP_DETAIL 10103 #define MP_ADDFRIEND 10104 diff --git a/srchybrid/MetaDataDlg.cpp b/srchybrid/MetaDataDlg.cpp index f57c0a94..720eb04b 100644 --- a/srchybrid/MetaDataDlg.cpp +++ b/srchybrid/MetaDataDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/MeterIcon.cpp b/srchybrid/MeterIcon.cpp index afd79c67..0af488da 100644 --- a/srchybrid/MeterIcon.cpp +++ b/srchybrid/MeterIcon.cpp @@ -1,6 +1,6 @@ // Created: 04/02/2001 {mm/dm/yyyyy} // Written by: Anish Mistry http://am-productions.yi.org/ -/* This code is licensed under the GNU GPL. See License.txt or (http://www.gnu.org/copyleft/gpl.html). */ +/* This code is licensed under the GNU GPL. See License.txt or (https://www.gnu.org/copyleft/gpl.html). */ #include "stdafx.h" #include "MeterIcon.h" diff --git a/srchybrid/MeterIcon.h b/srchybrid/MeterIcon.h index 30809922..b7eb2439 100644 --- a/srchybrid/MeterIcon.h +++ b/srchybrid/MeterIcon.h @@ -2,7 +2,7 @@ // // Created: 04/02/2001 {mm/dm/yyyyy} // Written by: Anish Mistry http://am-productions.yi.org/ -/* This code is licensed under the GNU GPL. See License.txt or (http://www.gnu.org/copyleft/gpl.html). */ +/* This code is licensed under the GNU GPL. See License.txt or (https://www.gnu.org/copyleft/gpl.html). */ ////////////////////////////////////////////////////////////////////// #pragma once diff --git a/srchybrid/MiniMule.cpp b/srchybrid/MiniMule.cpp index 9ad181da..a3eb853d 100644 --- a/srchybrid/MiniMule.cpp +++ b/srchybrid/MiniMule.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/MiniMule.h b/srchybrid/MiniMule.h index c052ef45..3df3eab7 100644 --- a/srchybrid/MiniMule.h +++ b/srchybrid/MiniMule.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/MuleListCtrl.cpp b/srchybrid/MuleListCtrl.cpp index 34587328..a488b414 100644 --- a/srchybrid/MuleListCtrl.cpp +++ b/srchybrid/MuleListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -100,39 +100,24 @@ CMuleListCtrl::CMuleListCtrl(PFNLVCOMPARE pfnCompare, LPARAM iParamSort) , m_hAccel() , m_eUpdateMode(lazy) , m_iAutoSizeWidth(LVSCW_AUTOSIZE) + , m_iFindDirection(1) + , m_iFindColumn() , m_bGeneralPurposeFind() , m_bCanSearchInAllColumns() , m_bFindMatchCase() - , m_iFindDirection(1) - , m_iFindColumn() - , m_iColumnsTracked() , m_aColumns() + , m_iColumnsTracked() , m_iCurrentSortItem(-1) , m_atSortArrow() , m_iRedrawCount() { } -CMuleListCtrl::~CMuleListCtrl() -{ - delete[] m_aColumns; -} - int CALLBACK CMuleListCtrl::SortProc(LPARAM /*lParam1*/, LPARAM /*lParam2*/, LPARAM /*lParamSort*/) { return 0; } -void CMuleListCtrl::SetPrefsKey(LPCTSTR lpszName) -{ - m_Name = lpszName; -} - -DWORD CMuleListCtrl::SetExtendedStyle(DWORD dwNewStyle) -{ - return CListCtrl::SetExtendedStyle(dwNewStyle | LVS_EX_HEADERDRAGDROP); -} - void CMuleListCtrl::PreSubclassWindow() { SetColors(); @@ -458,7 +443,7 @@ void CMuleListCtrl::SetColors() if (!strBkImage.IsEmpty() && !g_bLowColorDesktop) { // expand any optional available environment strings TCHAR szExpSkinRes[MAX_PATH]; - if (ExpandEnvironmentStrings(strBkImage, szExpSkinRes, _countof(szExpSkinRes)) != 0) + if (::ExpandEnvironmentStrings(strBkImage, szExpSkinRes, _countof(szExpSkinRes)) != 0) strBkImage = szExpSkinRes; // create absolute path to icon resource file @@ -598,7 +583,6 @@ int CMuleListCtrl::MoveItem(int iOldIndex, int iNewIndex) lvi.iIndent = 0; if (!GetItem(&lvi)) return -1; - szText[_countof(szText) - 1] = _T('\0'); // copy strings of sub items CSimpleArray aSubItems; @@ -608,19 +592,18 @@ int CMuleListCtrl::MoveItem(int iOldIndex, int iNewIndex) LVITEM lvi1; lvi1.mask = LVIF_TEXT | LVIF_NORECOMPUTE; lvi1.iItem = iOldIndex; + lvi1.cchTextMax = _countof(szText1); for (int i = 1; i < m_iColumnsTracked; ++i) { + void *pstrSubItem; lvi1.iSubItem = i; - lvi1.cchTextMax = _countof(szText1); lvi1.pszText = szText1; - void *pstrSubItem = NULL; - if (GetItem(&lvi1)) { + if (GetItem(&lvi1)) if (lvi1.pszText == LPSTR_TEXTCALLBACK) pstrSubItem = LPSTR_TEXTCALLBACK; - else { - szText1[_countof(szText1) - 1] = _T('\0'); + else pstrSubItem = new CString(szText1); - } - } + else + pstrSubItem = NULL; aSubItems.Add(pstrSubItem); } } @@ -764,7 +747,6 @@ BOOL CMuleListCtrl::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT item.mask = HDI_TEXT; item.cchTextMax = _countof(text); pHeaderCtrl->GetItem(iCurrent, &item); - text[_countof(text) - 1] = _T('\0'); tmColumnMenu.AppendMenu(MF_STRING | (m_aColumns[iCurrent].bHidden ? 0 : MF_CHECKED) , MLC_IDC_MENU + iCurrent, item.pszText); @@ -1623,11 +1605,6 @@ void CMuleListCtrl::OnLvnGetInfoTip(LPNMHDR pNMHDR, LRESULT *pResult) *pResult = 0; } -void CMuleListCtrl::SetAutoSizeWidth(int iAutoSizeWidth) -{ - m_iAutoSizeWidth = iAutoSizeWidth; -} - int CMuleListCtrl::InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem, bool bHiddenByDefault) { if (bHiddenByDefault) diff --git a/srchybrid/MuleListCtrl.h b/srchybrid/MuleListCtrl.h index b1b81b5f..e4fa8f90 100644 --- a/srchybrid/MuleListCtrl.h +++ b/srchybrid/MuleListCtrl.h @@ -33,13 +33,13 @@ class CMuleListCtrl : public CListCtrl public: CMuleListCtrl(PFNLVCOMPARE pfnCompare = SortProc, LPARAM iParamSort = 0); - virtual ~CMuleListCtrl(); + virtual ~CMuleListCtrl() { delete[] m_aColumns; }; // Default sort proc, this does nothing static int CALLBACK SortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); // Sets the list name, used for settings in "preferences.ini" - void SetPrefsKey(LPCTSTR lpszName); + void SetPrefsKey(LPCTSTR lpszName) { m_Name = lpszName; }; // Save to preferences void SaveSettings(); @@ -47,7 +47,7 @@ class CMuleListCtrl : public CListCtrl // Load from preferences void LoadSettings(); - DWORD SetExtendedStyle(DWORD dwNewStyle); + DWORD SetExtendedStyle(DWORD dwNewStyle) { return CListCtrl::SetExtendedStyle(dwNewStyle | LVS_EX_HEADERDRAGDROP); }; // Hide the column void HideColumn(int iColumn); @@ -56,7 +56,7 @@ class CMuleListCtrl : public CListCtrl void ShowColumn(int iColumn); // Check to see if the column is hidden - bool IsColumnHidden(int iColumn) const { return iColumn >= 1 && iColumn < m_iColumnsTracked && m_aColumns[iColumn].bHidden; } + bool IsColumnHidden(int iColumn) const { return iColumn >= 1 && iColumn < m_iColumnsTracked && m_aColumns[iColumn].bHidden; } // Get the correct column width even if column is hidden int GetColumnWidth(int iColumn) const @@ -151,28 +151,13 @@ class CMuleListCtrl : public CListCtrl int GetSortType(ArrowType at); ArrowType GetArrowType(int iat); - int GetSortItem() const - { - return m_iCurrentSortItem; - } - bool GetSortAscending() const - { - return m_atSortArrow == arrowUp || m_atSortArrow == arrowDoubleUp; - } - bool GetSortSecondValue() const - { - return m_atSortArrow == arrowDoubleDown || m_atSortArrow == arrowDoubleUp; - } + int GetSortItem() const { return m_iCurrentSortItem; } + bool GetSortAscending() const { return m_atSortArrow == arrowUp || m_atSortArrow == arrowDoubleUp; } + bool GetSortSecondValue() const { return m_atSortArrow == arrowDoubleDown || m_atSortArrow == arrowDoubleUp; } // Places a sort arrow in a column void SetSortArrow(int iColumn, ArrowType atType); - void SetSortArrow() - { - SetSortArrow(m_iCurrentSortItem, m_atSortArrow); - } - void SetSortArrow(int iColumn, bool bAscending) - { - SetSortArrow(iColumn, bAscending ? arrowUp : arrowDown); - } + void SetSortArrow() { SetSortArrow(m_iCurrentSortItem, m_atSortArrow); } + void SetSortArrow(int iColumn, bool bAscending) { SetSortArrow(iColumn, bAscending ? arrowUp : arrowDown); } LPARAM GetNextSortOrder(LPARAM iCurrentSortOrder) const; void UpdateSortHistory(LPARAM dwNewOrder); @@ -192,14 +177,14 @@ class CMuleListCtrl : public CListCtrl none }; EUpdateMode SetUpdateMode(EUpdateMode eUpdateMode); - void SetAutoSizeWidth(int iAutoSizeWidth); + void SetAutoSizeWidth(int iAutoSizeWidth) { m_iAutoSizeWidth = iAutoSizeWidth; }; int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT, int nWidth = -1, int nSubItem = -1, bool bHiddenByDefault = false); HIMAGELIST ApplyImageList(HIMAGELIST himl); void AutoSelectItem(); - void SetSkinKey(LPCTSTR pszKey) { m_strSkinKey = pszKey; } - const CString& GetSkinKey() const { return m_strSkinKey; } + void SetSkinKey(LPCTSTR pszKey) { m_strSkinKey = pszKey; } + const CString& GetSkinKey() const { return m_strSkinKey; } protected: virtual void PreSubclassWindow(); @@ -250,7 +235,7 @@ class CMuleListCtrl : public CListCtrl CList m_liSortHistory; UINT m_uIDAccel; HACCEL m_hAccel; - enum EUpdateMode m_eUpdateMode; + EUpdateMode m_eUpdateMode; int m_iAutoSizeWidth; static const int sm_iIconOffset; static const int sm_iLabelOffset; @@ -258,12 +243,12 @@ class CMuleListCtrl : public CListCtrl // General purpose listview find dialog+functions (optional) - bool m_bGeneralPurposeFind; - bool m_bCanSearchInAllColumns; CString m_strFindText; - bool m_bFindMatchCase; int m_iFindDirection; int m_iFindColumn; + bool m_bGeneralPurposeFind; + bool m_bCanSearchInAllColumns; + bool m_bFindMatchCase; void OnFindStart(); void OnFindNext(); void OnFindPrev(); @@ -278,8 +263,8 @@ class CMuleListCtrl : public CListCtrl bool bHidden; }; - int m_iColumnsTracked; MULE_COLUMN *m_aColumns; + int m_iColumnsTracked; int GetHiddenColumnCount() const { diff --git a/srchybrid/MuleStatusBarCtrl.cpp b/srchybrid/MuleStatusBarCtrl.cpp index e9e6cdd5..731bf849 100644 --- a/srchybrid/MuleStatusBarCtrl.cpp +++ b/srchybrid/MuleStatusBarCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/MuleToolBarCtrl.cpp b/srchybrid/MuleToolBarCtrl.cpp index 87ae2e0a..1c29ee8c 100644 --- a/srchybrid/MuleToolBarCtrl.cpp +++ b/srchybrid/MuleToolBarCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -349,7 +349,7 @@ void CMuleToolbarCtrl::OnNmRClick(LPNMHDR, LRESULT *pResult) if (!astrToolbarFiles.IsEmpty()) { Sort(astrToolbarFiles); - for (int f = 0; f < astrToolbarFiles.GetCount(); ++f) { + for (INT_PTR f = 0; f < astrToolbarFiles.GetCount(); ++f) { const CString &bitmapFileName(astrToolbarFiles[f]); LPCTSTR pTbBaseExt = stristr(bitmapFileName, EMULTB_BASEEXT); int iBaseLen = pTbBaseExt ? (int)(pTbBaseExt - (LPCTSTR)bitmapFileName - 1) : bitmapFileName.GetLength(); @@ -407,7 +407,7 @@ void CMuleToolbarCtrl::OnNmRClick(LPNMHDR, LRESULT *pResult) if (!astrSkinFiles.IsEmpty()) { Sort(astrSkinFiles); - for (int f = 0; f < astrSkinFiles.GetCount(); ++f) { + for (INT_PTR f = 0; f < astrSkinFiles.GetCount(); ++f) { const CString &skinFileName(astrSkinFiles[f]); LPCTSTR pSkinBaseExt = stristr(skinFileName, _T(".") EMULSKIN_BASEEXT _T(".ini")); int iBaseLen = pSkinBaseExt ? (int)(pSkinBaseExt - (LPCTSTR)skinFileName - 1) : skinFileName.GetLength(); @@ -906,7 +906,7 @@ void CMuleToolbarCtrl::UpdateIdealSize() #ifdef _DEBUG -void CMuleToolbarCtrl::Dump() +void CMuleToolbarCtrl::DumpInfo() { TRACE("---\n"); CRect rcWnd; @@ -964,10 +964,8 @@ void CMuleToolbarCtrl::Dump() TCHAR szLabel[256]; tbbi.cchText = _countof(szLabel); tbbi.pszText = szLabel; - if (GetButtonInfo(i, &tbbi) >= 0) { - szLabel[_countof(szLabel) - 1] = _T('\0'); + if (GetButtonInfo(i, &tbbi) >= 0) TRACE(" %2d ", tbbi.cx); - } } TRACE("\n"); } diff --git a/srchybrid/MuleToolBarCtrl.h b/srchybrid/MuleToolBarCtrl.h index 1cad336c..ec8b781a 100644 --- a/srchybrid/MuleToolBarCtrl.h +++ b/srchybrid/MuleToolBarCtrl.h @@ -62,7 +62,7 @@ class CMuleToolbarCtrl : public CToolBarCtrl void SetAllButtonsWidth(); #ifdef _DEBUG - void Dump(); + void DumpInfo(); #endif void AutoSize(); diff --git a/srchybrid/NetworkInfoDlg.cpp b/srchybrid/NetworkInfoDlg.cpp index 01f99b36..149caef6 100644 --- a/srchybrid/NetworkInfoDlg.cpp +++ b/srchybrid/NetworkInfoDlg.cpp @@ -132,10 +132,10 @@ void CreateNetworkInfo(CRichEditCtrlX &rCtrl, CHARFORMAT &rcfDef, CHARFORMAT &rc CString buffer; if (theApp.serverconnect->IsConnected()) { rCtrl << GetResString(IDS_IP) << _T(":") << GetResString(IDS_PORT) << _T(":"); - if (theApp.serverconnect->IsLowID() && theApp.GetPublicIP(true) == 0) + if (theApp.serverconnect->IsLowID() && theApp.GetED2KPublicIP() == 0) buffer = GetResString(IDS_UNKNOWN); else - buffer.Format(_T("%s:%u"), (LPCTSTR)ipstr(theApp.GetPublicIP(true)), thePrefs.GetPort()); + buffer.Format(_T("%s:%u"), (LPCTSTR)ipstr(theApp.GetED2KPublicIP()), thePrefs.GetPort()); rCtrl << _T("\t") << buffer << _T("\r\n"); rCtrl << GetResString(IDS_ID) << _T(":\t"); diff --git a/srchybrid/OScopeCtrl.cpp b/srchybrid/OScopeCtrl.cpp index 397fb1d6..3e3d3e06 100644 --- a/srchybrid/OScopeCtrl.cpp +++ b/srchybrid/OScopeCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -175,7 +175,7 @@ COScopeCtrl::~COScopeCtrl() delete[] m_PlotData; } -BOOL COScopeCtrl::Create(DWORD dwStyle, const CRect &rect, CWnd *pParentWnd, UINT nID) +BOOL COScopeCtrl::CreateWnd(DWORD dwStyle, const CRect &rect, CWnd *pParentWnd, UINT nID) { static const CString &className(AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, AfxGetApp()->LoadStandardCursor(IDC_ARROW))); diff --git a/srchybrid/OScopeCtrl.h b/srchybrid/OScopeCtrl.h index d8c5b6bb..6c200805 100644 --- a/srchybrid/OScopeCtrl.h +++ b/srchybrid/OScopeCtrl.h @@ -9,7 +9,7 @@ class COScopeCtrl : public CWnd explicit COScopeCtrl(int NTrends = 1); virtual ~COScopeCtrl(); - virtual BOOL Create(DWORD dwStyle, const CRect &rect, CWnd *pParentWnd, UINT nID = NULL); + virtual BOOL CreateWnd(DWORD dwStyle, const CRect &rect, CWnd *pParentWnd, UINT nID = NULL); void SetTrendRatio(int iTrend, unsigned iRatio = 1); void SetLegendLabel(const CString &string, int iTrend); diff --git a/srchybrid/Opcodes.h b/srchybrid/Opcodes.h index 7061a766..58914ba5 100644 --- a/srchybrid/Opcodes.h +++ b/srchybrid/Opcodes.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -261,9 +261,9 @@ #define OP_PREVIEWANSWER 0x91 // {frames * } #define OP_MULTIPACKET 0x92 // *DEPRECATED* #define OP_MULTIPACKETANSWER 0x93 // *DEPRECATED* -#define OP_PEERCACHE_QUERY 0x94 // *DEPRECATED* -#define OP_PEERCACHE_ANSWER 0x95 // *DEPRECATED* -#define OP_PEERCACHE_ACK 0x96 // *DEPRECATED* +#define OP_PEERCACHE_QUERY 0x94 // *DEFUNCT* +#define OP_PEERCACHE_ANSWER 0x95 // *DEFUNCT* +#define OP_PEERCACHE_ACK 0x96 // *DEFUNCT* #define OP_PUBLICIP_REQ 0x97 #define OP_PUBLICIP_ANSWER 0x98 #define OP_CALLBACK 0x99 // @@ -330,11 +330,11 @@ #define FT_FILEFORMAT 0x04 // #define TAG_FILEFORMAT "\x04" // #define FT_LASTSEENCOMPLETE 0x05 // -#define TAG_COLLECTION "\x05" -#define TAG_PART_PATH "\x06" // -#define TAG_PART_HASH "\x07" +//#define TAG_COLLECTION "\x05" +//#define TAG_PART_PATH "\x06" // +//#define TAG_PART_HASH "\x07" #define FT_TRANSFERRED 0x08 // -#define TAG_TRANSFERRED "\x08" // +//#define TAG_TRANSFERRED "\x08" // #define FT_GAPSTART 0x09 // #define TAG_GAPSTART "\x09" // #define FT_GAPEND 0x0A // @@ -350,7 +350,7 @@ #define FT_PARTFILENAME 0x12 // #define TAG_PARTFILENAME "\x12" // //#define FT_PRIORITY 0x13 // Not used any more -#define TAG_PRIORITY "\x13" // +//#define TAG_PRIORITY "\x13" // #define FT_STATUS 0x14 // #define TAG_STATUS "\x14" // #define FT_SOURCES 0x15 // @@ -358,9 +358,9 @@ #define FT_PERMISSIONS 0x16 // #define TAG_PERMISSIONS "\x16" //#define FT_ULPRIORITY 0x17 // Not used any more -#define TAG_PARTS "\x17" -#define FT_DLPRIORITY 0x18 // Was 13 -#define FT_ULPRIORITY 0x19 // Was 17 +//#define TAG_PARTS "\x17" +#define FT_DLPRIORITY 0x18 // replaces unused 0x13 +#define FT_ULPRIORITY 0x19 // replaces unused 0x17 #define FT_COMPRESSION 0x1A #define FT_CORRUPTED 0x1B #define FT_KADLASTPUBLISHKEY 0x20 // @@ -368,20 +368,21 @@ #define FT_FLAGS 0x22 // #define FT_DL_ACTIVE_TIME 0x23 // #define FT_CORRUPTEDPARTS 0x24 // -#define FT_DL_PREVIEW 0x25 +#define FT_DL_PREVIEW 0x25 // #define FT_KADLASTPUBLISHNOTES 0x26 // #define FT_AICH_HASH 0x27 #define FT_FILEHASH 0x28 -#define FT_COMPLETE_SOURCES 0x30 // nr. of sources which share a complete version of the associated file (supported by eserver 16.46+) +#define FT_COMPLETE_SOURCES 0x30 // nr. of sources which share the complete version of the associated file (supported by eserver 16.46+) #define TAG_COMPLETE_SOURCES "\x30" -#define FT_COLLECTIONAUTHOR 0x31 -#define FT_COLLECTIONAUTHORKEY 0x32 +#define FT_COLLECTIONAUTHOR 0x31 // +#define FT_COLLECTIONAUTHORKEY 0x32 // #define FT_PUBLISHINFO 0x33 // #define TAG_PUBLISHINFO "\x33" // #define FT_LASTSHARED 0x34 // #define FT_AICHHASHSET 0x35 // #define TAG_KADAICHHASHPUB "\x36" // #define TAG_KADAICHHASHRESULT "\x37" // { Count} +#define FT_FOLDERNAME 0x38 // in reply to View files request // statistic #define FT_ATTRANSFERRED 0x50 // #define FT_ATREQUESTED 0x51 // @@ -546,13 +547,13 @@ #define PCPCK_VERSION 0x01 -// PeerCache packet sub objcodes +// Defunct. PeerCache packet sub objcodes #define PCOP_NONE 0x00 #define PCOP_REQ 0x01 #define PCOP_RES 0x02 #define PCOP_ACK 0x03 -// PeerCache tags (NOTE: those tags are using the new eD2K tags (short tags)) +// Defunct. PeerCache tags (NOTE: those tags are using the new eD2K tags (short tags)) #define PCTAG_CACHEIP 0x01 #define PCTAG_CACHEPORT 0x02 #define PCTAG_PUBLICIP 0x03 diff --git a/srchybrid/OtherFunctions.cpp b/srchybrid/OtherFunctions.cpp index 4f6e71ef..3157abd2 100644 --- a/srchybrid/OtherFunctions.cpp +++ b/srchybrid/OtherFunctions.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -284,6 +284,42 @@ bool CheckFileOpen(LPCTSTR pszFilePath, LPCTSTR pszFileTitle) return true; } +CString CExceptionStr(CException &ex) +{ + TCHAR szError[MAX_PATH + 256]; + GetExceptionMessage(ex, szError, _countof(szError)); + return CString(szError); +} + +CString CExceptionStrDash(CException &ex) +{ + CString s(CExceptionStr(ex)); + if (!s.IsEmpty()) + s.Insert(0, _T(" - ")); + return s; +} + +bool CFileOpen(CFile &file, LPCTSTR lpszFileName, UINT nOpenFlags, LPCTSTR lpszMsg) +{ + CFileException ex; + if (!file.Open(lpszFileName, nOpenFlags, &ex)) { + if (ex.m_cause != CFileException::fileNotFound) + LogError(LOG_STATUSBAR, _T("%s%s"), lpszMsg, (LPCTSTR)CExceptionStrDash(ex)); + return false; + } + return true; +} + +void CommitAndClose(CStdioFile &file) +{ + if (thePrefs.GetCommitFiles() >= 2 || (thePrefs.GetCommitFiles() >= 1 && theApp.IsClosing())) { + file.Flush(); // flush file stream buffers to disk buffers + if (_commit(_fileno(file.m_pStream)) != 0) // commit disk buffers to disk + AfxThrowFileException(CFileException::hardIO, ::GetLastError(), file.GetFileName()); + } + file.Close(); +} + HINSTANCE BrowserOpen(LPCTSTR lpURL, LPCTSTR lpDirectory) { return ShellExecute(NULL, NULL, lpURL, NULL, lpDirectory, SW_SHOWDEFAULT); @@ -699,7 +735,7 @@ WORD DetectWinVersion() return _WINVER_8_1_; } if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0) - return _WINVER_10_; + return _WINVER_10_; //for Windows 11 - osvi.dwBuildNumber>=22000 return _WINVER_7_; // never return Win95 if we get the info about a NT system case VER_PLATFORM_WIN32_WINDOWS: @@ -874,7 +910,7 @@ uint32 DecodeBase32(LPCTSTR pszInput, uchar *paucOutput, uint32 nBufferLen) DWORD nBits = 0; int nCount = 0; - for (int nChars = nInputLen; nChars-- > 0; ++pszInput) { + for (; nInputLen > 0; --nInputLen) { if (*pszInput >= 'A' && *pszInput <= 'Z') nBits |= (*pszInput - 'A'); else if (*pszInput >= 'a' && *pszInput <= 'z') @@ -883,9 +919,9 @@ uint32 DecodeBase32(LPCTSTR pszInput, uchar *paucOutput, uint32 nBufferLen) nBits |= (*pszInput - '2' + 26); else return 0; + ++pszInput; nCount += 5; - if (nCount >= 8) { *paucOutput++ = (BYTE)(nBits >> (nCount - 8)); nCount -= 8; @@ -995,7 +1031,7 @@ int CWebServices::GetAllMenuEntries(CTitleMenu *pMenu, DWORD dwFlags) bool CWebServices::RunURL(const CAbstractFile *file, UINT uMenuID) { - for (int i = 0; i < m_aServices.GetCount(); ++i) { + for (INT_PTR i = 0; i < m_aServices.GetCount(); ++i) { const SEd2kLinkService &rSvc(m_aServices[i]); if (rSvc.uMenuID == uMenuID) { CString strUrlTemplate(rSvc.strUrl); @@ -1796,7 +1832,7 @@ CString GetErrorMessage(DWORD dwError, DWORD dwFlags) BOOL GetExceptionMessage(const CException &ex, LPTSTR lpszErrorMsg, UINT nMaxError) { - BOOL ret = ex.GetErrorMessage(lpszErrorMsg, nMaxError); + BOOL ret = ex.GetErrorMessage(lpszErrorMsg, nMaxError, NULL); if (lpszErrorMsg) lpszErrorMsg[(ret && nMaxError) ? nMaxError - 1 : 0] = 0; //terminate string return ret; @@ -1975,7 +2011,7 @@ void DbgSetThreadName(LPCSTR szThreadName, ...) lenBuf += 128; delete[] buffer; buffer = new char[lenBuf]; - lenResult = _vsnprintf(buffer, lenBuf, szThreadName, args); + lenResult = vsnprintf(buffer, lenBuf, szThreadName, args); } while (lenResult == -1); va_end(args); THREADNAME_INFO info; @@ -2171,12 +2207,12 @@ void DebugHexDump(CFile &file) data = new uint8[iSize]; file.Read(data, iSize); DebugHexDump(data, iSize); - } catch (CFileException *e) { + } catch (CFileException *ex) { TRACE("*** DebugHexDump(CFile&); CFileException\n"); - e->Delete(); - } catch (CMemoryException *e) { + ex->Delete(); + } catch (CMemoryException *ex) { TRACE("*** DebugHexDump(CFile&); CMemoryException\n"); - e->Delete(); + ex->Delete(); } delete[] data; } @@ -2206,7 +2242,7 @@ CString DbgGetFileInfo(const uchar *hash) return strInfo; } -CString DbgGetFileStatus(UINT nPartCount, CSafeMemFile *data) +CString DbgGetFileStatus(UINT nPartCount, CSafeMemFile &data) { CString strFileStatus; if (nPartCount == 0) @@ -2218,7 +2254,7 @@ CString DbgGetFileStatus(UINT nPartCount, CSafeMemFile *data) while (nPart < nPartCount) { uint8 ucPartMask; try { - ucPartMask = data->ReadUInt8(); + ucPartMask = data.ReadUInt8(); } catch (CFileException *ex) { ex->Delete(); strPartStatus = _T("*PacketException*"); @@ -2497,7 +2533,7 @@ void DebugRecv(LPCSTR pszOpcode, uint32 ip, uint16 port) void DebugHttpHeaders(const CStringAArray &astrHeaders) { - for (int i = 0; i < astrHeaders.GetCount(); ++i) + for (INT_PTR i = 0; i < astrHeaders.GetCount(); ++i) Debug(_T("<%hs\n"), (LPCSTR)astrHeaders[i]); } @@ -2637,7 +2673,7 @@ CStringA ipstrA(uint32 nIP) void ipstrA(CHAR *pszAddress, int iMaxAddress, uint32 nIP) { const BYTE *pucIP = (BYTE*)&nIP; - _snprintf(pszAddress, iMaxAddress, "%u.%u.%u.%u", pucIP[0], pucIP[1], pucIP[2], pucIP[3]); + snprintf(pszAddress, iMaxAddress, "%u.%u.%u.%u", pucIP[0], pucIP[1], pucIP[2], pucIP[3]); } bool IsDaylightSavingTimeActive(LONG &rlDaylightBias) @@ -2831,7 +2867,7 @@ __time64_t FileTimeToUnixTime(const FILETIME &ft) int statUTC(LPCTSTR pName, struct _stat64 &ft) { WIN32_FILE_ATTRIBUTE_DATA fa; - if (GetFileAttributesEx(pName, GetFileExInfoStandard, &fa)) { + if (::GetFileAttributesEx(pName, GetFileExInfoStandard, &fa)) { memset(&ft, 0, sizeof ft); ft.st_atime = FileTimeToUnixTime(fa.ftLastAccessTime); ft.st_ctime = FileTimeToUnixTime(fa.ftCreationTime); @@ -2845,7 +2881,7 @@ int statUTC(LPCTSTR pName, struct _stat64 &ft) int statUTC(HANDLE hFile, struct _stat64 &ft) { BY_HANDLE_FILE_INFORMATION fi; - if (GetFileInformationByHandle(hFile, &fi)) { + if (::GetFileInformationByHandle(hFile, &fi)) { memset(&ft, 0, sizeof ft); ft.st_atime = FileTimeToUnixTime(fi.ftLastAccessTime); ft.st_ctime = FileTimeToUnixTime(fi.ftCreationTime); @@ -2858,12 +2894,12 @@ int statUTC(HANDLE hFile, struct _stat64 &ft) bool ExpandEnvironmentStrings(CString &rstrStrings) { - DWORD dwSize = ExpandEnvironmentStrings(rstrStrings, NULL, 0); + DWORD dwSize = ::ExpandEnvironmentStrings(rstrStrings, NULL, 0); if (dwSize == 0) return false; CString strExpanded; - DWORD dwCount = ExpandEnvironmentStrings(rstrStrings, strExpanded.GetBuffer(dwSize - 1), dwSize); + DWORD dwCount = ::ExpandEnvironmentStrings(rstrStrings, strExpanded.GetBuffer(dwSize - 1), dwSize); if (dwCount == 0 || dwCount != dwSize) { ASSERT(0); return false; @@ -2878,9 +2914,9 @@ uint16 GetRandomUInt16() #if RAND_MAX == 0x7fff uint32 uRand0 = rand(); uint32 uRand1 = rand(); + // NOTE: if the assert fires, most likely this function was called *without* calling 'srand' first. + // NOTE: each spawned thread HAS to call 'srand' for getting really random numbers. ASSERT(uRand0 != 41 || uRand1 != 18467); - // NOTE: if this assert fires, most likely this function was called *without* calling 'srand' first. - // NOTE: each spawned thread HAS to call 'srand' for itself to get real random numbers. uRand0 |= (uRand1 & 0x4000) << 1; srand(::GetTickCount() ^ (uRand0 << 16)); @@ -3057,8 +3093,8 @@ void InstallSkin(LPCTSTR pszSkinPackage) rar.Close(); } else { - CString strError(GetResString(IDS_INSTALL_SKIN_PKG_ERROR)); - strError += _T("\r\n\r\nDownload latest version of UNRAR.DLL from https://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."); + CString strError; + strError.Format(_T("%s\r\n\r\n%s"), (LPCTSTR)GetResString(IDS_INSTALL_SKIN_PKG_ERROR), CRARFile::sUnrar_download); AfxMessageBox(strError, MB_ICONERROR); } } @@ -3076,14 +3112,14 @@ void TriggerPortTest(uint16 tcp, uint16 udp) // the port check will need to do an obfuscated callback too if obfuscation is requested, // hence we have to provide our userhash so it can create the key - if (thePrefs.IsClientCryptLayerRequested()) + if (thePrefs.IsCryptLayerPreferred()) m_sTestURL.AppendFormat(_T("&obf=1&clienthash=%s"), (LPCTSTR)md4str(thePrefs.GetUserHash())); else m_sTestURL += _T("&obf=0"); ShellOpenFile(m_sTestURL); } - //CSTR_LESS_THAN=1 CSTR_EQUAL=2 CSTR_GREATER_THAN=3 +//CSTR_LESS_THAN=1 CSTR_EQUAL=2 CSTR_GREATER_THAN=3 int CompareLocaleStringNoCaseA(LPCSTR psz1, LPCSTR psz2) { // SDK says: The 'CompareString' function is optimized to run at the highest speed when 'dwCmpFlags' is set to 0 @@ -3759,7 +3795,7 @@ uint32 LevenshteinDistance(const CString &str1, const CString &str2) // Wrapper for _tmakepath which ensures that the output buffer does not exceed MAX_PATH // using a smaller buffer without checking the sizes prior calling this function is not safe -// If the resulting path would be bigger than MAX_PATH-1, it will be empty and return false (similar to PathCombine) +// If the resulting path would be longer than MAX_PATH-1, it will be empty and return false (similar to PathCombine) bool _tmakepathlimit(LPTSTR path, LPCTSTR drive, LPCTSTR dir, LPCTSTR fname, LPCTSTR ext) { if (path == NULL) { @@ -3824,9 +3860,9 @@ uint8 GetMyConnectOptions(bool bEncryption, bool bCallback) // 1 CryptLayer Required // 1 CryptLayer Requested // 1 CryptLayer Supported - const uint8 uSupportsCryptLayer = static_cast(thePrefs.IsClientCryptLayerSupported() && bEncryption); - const uint8 uRequestsCryptLayer = static_cast(thePrefs.IsClientCryptLayerRequested() && bEncryption); - const uint8 uRequiresCryptLayer = static_cast(thePrefs.IsClientCryptLayerRequired() && bEncryption); + const uint8 uSupportsCryptLayer = static_cast(thePrefs.IsCryptLayerEnabled() && bEncryption); + const uint8 uRequestsCryptLayer = static_cast(thePrefs.IsCryptLayerPreferred() && bEncryption); + const uint8 uRequiresCryptLayer = static_cast(thePrefs.IsCryptLayerRequired() && bEncryption); // direct callback is only possible if connected to kad, TCP firewalled and verified UDP open (for example on a full cone NAT) const uint8 uDirectUDPCallback = static_cast(bCallback && theApp.IsFirewalled() && Kademlia::CKademlia::IsRunning() && !Kademlia::CUDPFirewallTester::IsFirewalledUDP(true) && Kademlia::CUDPFirewallTester::IsVerified()); diff --git a/srchybrid/OtherFunctions.h b/srchybrid/OtherFunctions.h index d22a6fb0..48d7d1c2 100644 --- a/srchybrid/OtherFunctions.h +++ b/srchybrid/OtherFunctions.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -193,12 +193,14 @@ bool DirAccsess(const CString &strDir); #define CompareLocaleStringNoCase CompareLocaleStringNoCaseA #endif // !UNICODE bool IsThumbsDb(const CString &sFilePath, const CString &sFileName); +bool CheckFileOpen(LPCTSTR pszFilePath, LPCTSTR pszFileTitle = NULL); +bool CFileOpen(CFile &file, LPCTSTR lpszFileName, UINT nOpenFlags, LPCTSTR lpszMsg); +void CommitAndClose(CStdioFile &file); /////////////////////////////////////////////////////////////////////////////// // GUI helpers // void InstallSkin(LPCTSTR pszSkinPackage); -bool CheckFileOpen(LPCTSTR pszFilePath, LPCTSTR pszFileTitle = NULL); HINSTANCE BrowserOpen(LPCTSTR lpURL, LPCTSTR lpDirectory); void ShellOpen(LPCTSTR lpName, LPCTSTR lpParameters); void ShellOpenFile(LPCTSTR lpName); @@ -208,6 +210,7 @@ CString ShellGetFolderPath(int iCSIDL); bool SelectDir(HWND hWnd, LPTSTR pszPath, LPCTSTR pszTitle = NULL, LPCTSTR pszDlgTitle = NULL); BOOL DialogBrowseFile(CString &rstrPath, LPCTSTR pszFilters, LPCTSTR pszDefaultFileName = NULL, DWORD dwFlags = 0, bool openfilestyle = true); void AddBuddyButton(HWND hwndEdit, HWND hwndButton); +void DestroyIconsArr(HICON *pIcon, size_t cnt); bool InitAttachedBrowseButton(HWND hwndButton, HICON &ricoBrowse); void GetPopupMenuPos(const CListCtrl &lv, CPoint &point); void GetPopupMenuPos(const CTreeCtrl &tv, CPoint &point); @@ -246,6 +249,8 @@ int GetSystemErrorString(DWORD dwError, CString &rstrError); int GetModuleErrorString(DWORD dwError, CString &rstrError, LPCTSTR pszModule); int GetErrorMessage(DWORD dwError, CString &rstrErrorMsg, DWORD dwFlags = 0); CString GetErrorMessage(DWORD dwError, DWORD dwFlags = 0); +CString CExceptionStr(CException &ex); +CString CExceptionStrDash(CException &ex); BOOL GetExceptionMessage(const CException &ex, LPTSTR lpszErrorMsg, UINT nMaxError); LPCTSTR GetShellExecuteErrMsg(DWORD dwShellExecError); CString DbgGetHexDump(const uint8 *data, UINT size); //limited to the first 50 bytes @@ -254,7 +259,7 @@ void Debug(LPCTSTR pszFmtMsg, ...); void DebugHexDump(const void *data, UINT lenData); void DebugHexDump(CFile &file); CString DbgGetFileInfo(const uchar *hash); -CString DbgGetFileStatus(UINT nPartCount, CSafeMemFile *data); +CString DbgGetFileStatus(UINT nPartCount, CSafeMemFile &data); LPCTSTR DbgGetHashTypeString(const uchar *hash); CString DbgGetClientID(uint32 nClientID); CString DbgGetDonkeyClientTCPOpcode(UINT opcode); diff --git a/srchybrid/PPgConnection.cpp b/srchybrid/PPgConnection.cpp index d3e82791..0b5bbe99 100644 --- a/srchybrid/PPgConnection.cpp +++ b/srchybrid/PPgConnection.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgDebug.cpp b/srchybrid/PPgDebug.cpp index ae1ae0e8..296503ce 100644 --- a/srchybrid/PPgDebug.cpp +++ b/srchybrid/PPgDebug.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgDirectories.cpp b/srchybrid/PPgDirectories.cpp index 033a4693..40add5f9 100644 --- a/srchybrid/PPgDirectories.cpp +++ b/srchybrid/PPgDirectories.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -42,7 +42,6 @@ BEGIN_MESSAGE_MAP(CPPgDirectories, CPropertyPage) ON_EN_CHANGE(IDC_INCFILES, OnSettingsChange) ON_EN_CHANGE(IDC_TEMPFILES, OnSettingsChange) ON_BN_CLICKED(IDC_UNCADD, OnBnClickedAddUNC) - ON_BN_CLICKED(IDC_UNCREM, OnBnClickedRemUNC) ON_WM_HELPINFO() ON_BN_CLICKED(IDC_SELTEMPDIRADD, OnBnClickedSeltempdiradd) ON_WM_DESTROY() @@ -58,12 +57,11 @@ void CPPgDirectories::DoDataExchange(CDataExchange *pDX) { CPropertyPage::DoDataExchange(pDX); DDX_Control(pDX, IDC_SHARESELECTOR, m_ShareSelector); - DDX_Control(pDX, IDC_UNCLIST, m_ctlUncPaths); } BOOL CPPgDirectories::OnInitDialog() { - CWaitCursor curWait; // initialization of that dialog may take a while. + CWaitCursor curWait; // initialization of that dialog may take a while CPropertyPage::OnInitDialog(); InitWindowStyles(this); @@ -75,9 +73,6 @@ BOOL CPPgDirectories::OnInitDialog() AddBuddyButton(GetDlgItem(IDC_TEMPFILES)->m_hWnd, ::GetDlgItem(m_hWnd, IDC_SELTEMPDIR)); InitAttachedBrowseButton(::GetDlgItem(m_hWnd, IDC_SELTEMPDIR), m_icoBrowse); - m_ctlUncPaths.InsertColumn(0, GetResString(IDS_UNCFOLDERS), LVCFMT_LEFT, 280); - m_ctlUncPaths.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); - GetDlgItem(IDC_SELTEMPDIRADD)->ShowWindow(thePrefs.IsExtControlsEnabled() ? SW_SHOW : SW_HIDE); LoadSettings(); @@ -100,7 +95,6 @@ void CPPgDirectories::LoadSettings() SetDlgItemText(IDC_TEMPFILES, tempfolders); m_ShareSelector.SetSharedDirectories(thePrefs.shareddir_list); - FillUNClist(); } void CPPgDirectories::OnBnClickedSelincdir() @@ -227,7 +221,6 @@ BOOL CPPgDirectories::OnApply() thePrefs.shareddir_list.RemoveAll(); m_ShareSelector.GetSharedDirectories(thePrefs.shareddir_list); - FillUNClist(); // check shared directories for reserved folder names for (POSITION pos = thePrefs.shareddir_list.GetHeadPosition(); pos != NULL;) { @@ -286,17 +279,6 @@ void CPPgDirectories::Localize() } } -void CPPgDirectories::FillUNClist() -{ - m_ctlUncPaths.DeleteAllItems(); - - for (POSITION pos = thePrefs.shareddir_list.GetHeadPosition(); pos != NULL;) { - const CString &sDir(thePrefs.shareddir_list.GetNext(pos)); - if (::PathIsUNC(sDir)) - m_ctlUncPaths.InsertItem(INT_MAX, sDir); - } -} - void CPPgDirectories::OnBnClickedAddUNC() { InputBox inputbox; @@ -316,21 +298,8 @@ void CPPgDirectories::OnBnClickedAddUNC() if (EqualPaths(thePrefs.shareddir_list.GetNext(pos), unc)) return; - for (int i = m_ctlUncPaths.GetItemCount(); --i >= 0;) - if (EqualPaths(m_ctlUncPaths.GetItemText(i, 0), unc)) - return; - - m_ctlUncPaths.InsertItem(INT_MAX, unc); - SetModified(); -} - -void CPPgDirectories::OnBnClickedRemUNC() -{ - int index = m_ctlUncPaths.GetSelectionMark(); - if (index >= 0 && m_ctlUncPaths.GetSelectedCount() > 0) { - m_ctlUncPaths.DeleteItem(index); + if (m_ShareSelector.AddUNCShare(unc)) SetModified(); - } } void CPPgDirectories::OnHelp() diff --git a/srchybrid/PPgDirectories.h b/srchybrid/PPgDirectories.h index 096146d6..b7f90a49 100644 --- a/srchybrid/PPgDirectories.h +++ b/srchybrid/PPgDirectories.h @@ -17,11 +17,9 @@ class CPPgDirectories : public CPropertyPage protected: CDirectoryTreeCtrl m_ShareSelector; - CListCtrl m_ctlUncPaths; HICON m_icoBrowse; void LoadSettings(); - void FillUNClist(); virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support virtual BOOL OnInitDialog(); @@ -33,7 +31,6 @@ class CPPgDirectories : public CPropertyPage afx_msg void OnBnClickedSelincdir(); afx_msg void OnBnClickedSeltempdir(); afx_msg void OnBnClickedAddUNC(); - afx_msg void OnBnClickedRemUNC(); afx_msg void OnHelp(); afx_msg BOOL OnHelpInfo(HELPINFO*); afx_msg void OnBnClickedSeltempdiradd(); diff --git a/srchybrid/PPgDisplay.cpp b/srchybrid/PPgDisplay.cpp index e91cd252..c3d6a6ce 100644 --- a/srchybrid/PPgDisplay.cpp +++ b/srchybrid/PPgDisplay.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgFiles.cpp b/srchybrid/PPgFiles.cpp index 74525ce4..042863d0 100644 --- a/srchybrid/PPgFiles.cpp +++ b/srchybrid/PPgFiles.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgGeneral.cpp b/srchybrid/PPgGeneral.cpp index b9569737..e28260fc 100644 --- a/srchybrid/PPgGeneral.cpp +++ b/srchybrid/PPgGeneral.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -116,7 +116,7 @@ BOOL CPPgGeneral::OnInitDialog() CWordArray aLanguageIDs; thePrefs.GetLanguages(aLanguageIDs); - for (int i = 0; i < aLanguageIDs.GetCount(); ++i) { + for (INT_PTR i = 0; i < aLanguageIDs.GetCount(); ++i) { TCHAR szLang[128]; TCHAR *pLang = szLang; int ret = GetLocaleInfo(aLanguageIDs[i], LOCALE_SLANGUAGE, szLang, _countof(szLang)); diff --git a/srchybrid/PPgIRC.cpp b/srchybrid/PPgIRC.cpp index 5d3d029c..a9c93ee6 100644 --- a/srchybrid/PPgIRC.cpp +++ b/srchybrid/PPgIRC.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgMessages.cpp b/srchybrid/PPgMessages.cpp index 72a28de3..b68bc8d1 100644 --- a/srchybrid/PPgMessages.cpp +++ b/srchybrid/PPgMessages.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgMessages.h b/srchybrid/PPgMessages.h index 08fb5588..1780befd 100644 --- a/srchybrid/PPgMessages.h +++ b/srchybrid/PPgMessages.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once class CPPgMessages : public CPropertyPage diff --git a/srchybrid/PPgNotify.cpp b/srchybrid/PPgNotify.cpp index 5553e2de..19343296 100644 --- a/srchybrid/PPgNotify.cpp +++ b/srchybrid/PPgNotify.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -52,7 +52,7 @@ BEGIN_MESSAGE_MAP(CPPgNotify, CPropertyPage) ON_BN_CLICKED(IDC_SMTPSERVER, OnBnClickedSMTPserver) ON_EN_CHANGE(IDC_EDIT_SENDER, OnSettingsChange) ON_EN_CHANGE(IDC_EDIT_RECEIVER, OnSettingsChange) - ON_BN_CLICKED(IDC_CB_ENABLENOTIFICATIONS, OnBnClickedCbEnablenotifications) + ON_BN_CLICKED(IDC_CB_ENABLENOTIFICATIONS, OnBnClickedCbEnableNotifications) ON_WM_DESTROY() END_MESSAGE_MAP() @@ -120,11 +120,11 @@ BOOL CPPgNotify::OnInitDialog() void CPPgNotify::UpdateControls() { - UINT b = IsDlgButtonChecked(IDC_CB_TBN_USESOUND); + bool b = IsDlgButtonChecked(IDC_CB_TBN_USESOUND) != 0; GetDlgItem(IDC_EDIT_TBN_WAVFILE)->EnableWindow(b); GetDlgItem(IDC_BTN_BROWSE_WAV)->EnableWindow(b); - b = IsDlgButtonChecked(IDC_CB_ENABLENOTIFICATIONS); + b = IsDlgButtonChecked(IDC_CB_ENABLENOTIFICATIONS) != 0; GetDlgItem(IDC_SMTPSERVER)->EnableWindow(b); GetDlgItem(IDC_EDIT_RECEIVER)->EnableWindow(b); GetDlgItem(IDC_EDIT_SENDER)->EnableWindow(b); @@ -274,7 +274,7 @@ BOOL CPPgNotify::OnHelpInfo(HELPINFO*) return TRUE; } -void CPPgNotify::OnBnClickedCbEnablenotifications() +void CPPgNotify::OnBnClickedCbEnableNotifications() { UpdateControls(); SetModified(); diff --git a/srchybrid/PPgNotify.h b/srchybrid/PPgNotify.h index 831dabb9..3b739828 100644 --- a/srchybrid/PPgNotify.h +++ b/srchybrid/PPgNotify.h @@ -50,7 +50,7 @@ class CPPgNotify : public CPropertyPage afx_msg void OnBnClickedOnChat(); afx_msg void OnBnClickedBrowseAudioFile(); afx_msg void OnBnClickedTestNotification(); - afx_msg void OnBnClickedCbEnablenotifications(); + afx_msg void OnBnClickedCbEnableNotifications(); afx_msg void OnBnClickedSMTPserver(); afx_msg void OnDestroy(); }; \ No newline at end of file diff --git a/srchybrid/PPgProxy.cpp b/srchybrid/PPgProxy.cpp index 199b9d5a..b63af0c3 100644 --- a/srchybrid/PPgProxy.cpp +++ b/srchybrid/PPgProxy.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -110,7 +110,7 @@ void CPPgProxy::OnBnClickedEnableProxy() { SetModified(TRUE); - BOOL bEnable = IsDlgButtonChecked(IDC_ENABLEPROXY); + bool bEnable = IsDlgButtonChecked(IDC_ENABLEPROXY) != 0; GetDlgItem(IDC_PROXYTYPE)->EnableWindow(bEnable); GetDlgItem(IDC_PROXYNAME)->EnableWindow(bEnable); GetDlgItem(IDC_PROXYPORT)->EnableWindow(bEnable); @@ -121,7 +121,7 @@ void CPPgProxy::OnBnClickedEnableProxy() void CPPgProxy::OnBnClickedEnableAuthentication() { SetModified(TRUE); - BOOL bEnable = IsDlgButtonChecked(IDC_ENABLEAUTH); + bool bEnable = IsDlgButtonChecked(IDC_ENABLEAUTH) != 0; GetDlgItem(IDC_USERNAME_A)->EnableWindow(bEnable); GetDlgItem(IDC_PASSWORD)->EnableWindow(bEnable); } diff --git a/srchybrid/PPgScheduler.cpp b/srchybrid/PPgScheduler.cpp index aec35c07..86efb2f5 100644 --- a/srchybrid/PPgScheduler.cpp +++ b/srchybrid/PPgScheduler.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgSecurity.cpp b/srchybrid/PPgSecurity.cpp index 056de2a5..14c7873e 100644 --- a/srchybrid/PPgSecurity.cpp +++ b/srchybrid/PPgSecurity.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -84,19 +84,16 @@ void CPPgSecurity::LoadSettings() CheckDlgButton(IDC_USESECIDENT, thePrefs.m_bUseSecureIdent); - GetDlgItem(IDC_RUNASUSER)->EnableWindow( - (thePrefs.GetWindowsVersion() == _WINVER_XP_ || thePrefs.GetWindowsVersion() == _WINVER_2K_ || thePrefs.GetWindowsVersion() == _WINVER_2003_) - && thePrefs.m_nCurrentUserDirMode == 2); + WORD wv = thePrefs.GetWindowsVersion(); + GetDlgItem(IDC_RUNASUSER)->EnableWindow(wv >= _WINVER_2K_ && wv <= _WINVER_2003_ && thePrefs.m_nCurrentUserDirMode == 2); CheckDlgButton(IDC_RUNASUSER, thePrefs.IsRunAsUserEnabled()); - CheckDlgButton(IDC_DISABLEOBFUSCATION, static_cast(!thePrefs.IsClientCryptLayerSupported())); - GetDlgItem(IDC_ENABLEOBFUSCATION)->EnableWindow(thePrefs.IsClientCryptLayerSupported()); - GetDlgItem(IDC_ONLYOBFUSCATED)->EnableWindow(thePrefs.IsClientCryptLayerSupported()); + CheckDlgButton(IDC_DISABLEOBFUSCATION, static_cast(!thePrefs.IsCryptLayerEnabled())); + GetDlgItem(IDC_ENABLEOBFUSCATION)->EnableWindow(thePrefs.IsCryptLayerEnabled()); + CheckDlgButton(IDC_ENABLEOBFUSCATION, static_cast(thePrefs.IsCryptLayerPreferred())); + GetDlgItem(IDC_ONLYOBFUSCATED)->EnableWindow(thePrefs.IsCryptLayerPreferred()); - CheckDlgButton(IDC_ENABLEOBFUSCATION, static_cast(thePrefs.IsClientCryptLayerRequested())); - GetDlgItem(IDC_ONLYOBFUSCATED)->EnableWindow(thePrefs.IsClientCryptLayerRequested()); - - CheckDlgButton(IDC_ONLYOBFUSCATED, thePrefs.IsClientCryptLayerRequired()); + CheckDlgButton(IDC_ONLYOBFUSCATED, thePrefs.IsCryptLayerRequired()); CheckDlgButton(IDC_SEARCHSPAMFILTER, thePrefs.IsSearchSpamFilterEnabled()); CheckDlgButton(IDC_CHECK_FILE_OPEN, thePrefs.GetCheckFileOpen()); @@ -135,18 +132,11 @@ BOOL CPPgSecurity::OnInitDialog() BOOL CPPgSecurity::OnApply() { - bool bIPFilterSettingsChanged = false; - - UINT iNewFilterLevel = GetDlgItemInt(IDC_FILTERLEVEL, NULL, FALSE); - if (iNewFilterLevel != thePrefs.filterlevel) { - thePrefs.filterlevel = iNewFilterLevel; - bIPFilterSettingsChanged = IsDlgButtonChecked(IDC_FILTERSERVERBYIPFILTER) != 0; - } - - if (!thePrefs.filterserverbyip && IsDlgButtonChecked(IDC_FILTERSERVERBYIPFILTER)) - bIPFilterSettingsChanged = true; + UINT uLevel = thePrefs.filterlevel; + bool bFilter = thePrefs.filterserverbyip; + thePrefs.filterlevel = GetDlgItemInt(IDC_FILTERLEVEL, NULL, FALSE); thePrefs.filterserverbyip = IsDlgButtonChecked(IDC_FILTERSERVERBYIPFILTER) != 0; - if (bIPFilterSettingsChanged) + if (thePrefs.filterserverbyip && (!bFilter || uLevel != thePrefs.filterlevel)) theApp.emuledlg->serverwnd->serverlistctrl.RemoveAllFilteredServers(); thePrefs.m_bUseSecureIdent = IsDlgButtonChecked(IDC_USESECIDENT) != 0; @@ -324,7 +314,7 @@ void CPPgSecurity::OnLoadIPFFromURL() rar.Close(); } else { CString strError; - strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\nDownload latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."), (LPCTSTR)url); + strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\n%s"), (LPCTSTR)url, CRARFile::sUnrar_download); AfxMessageBox(strError, MB_ICONERROR); } } else { @@ -509,12 +499,11 @@ void CPPgSecurity::OnObfuscatedDisabledChange() void CPPgSecurity::OnObfuscatedRequestedChange() { - if (IsDlgButtonChecked(IDC_ENABLEOBFUSCATION)) { - GetDlgItem(IDC_ENABLEOBFUSCATION)->EnableWindow(TRUE); - GetDlgItem(IDC_ONLYOBFUSCATED)->EnableWindow(TRUE); - } else { - GetDlgItem(IDC_ONLYOBFUSCATED)->EnableWindow(FALSE); - CheckDlgButton(IDC_ONLYOBFUSCATED, 0); - } + bool bCheck = IsDlgButtonChecked(IDC_ENABLEOBFUSCATION) != 0; + if (bCheck) + GetDlgItem(IDC_ENABLEOBFUSCATION)->EnableWindow(bCheck); + else + CheckDlgButton(IDC_ONLYOBFUSCATED, bCheck); + GetDlgItem(IDC_ONLYOBFUSCATED)->EnableWindow(bCheck); OnSettingsChange(); } \ No newline at end of file diff --git a/srchybrid/PPgServer.cpp b/srchybrid/PPgServer.cpp index b02ee578..9b28b7a0 100644 --- a/srchybrid/PPgServer.cpp +++ b/srchybrid/PPgServer.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgStats.cpp b/srchybrid/PPgStats.cpp index ef9c12f9..48573432 100644 --- a/srchybrid/PPgStats.cpp +++ b/srchybrid/PPgStats.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PPgTweaks.cpp b/srchybrid/PPgTweaks.cpp index 863db425..afdb2492 100644 --- a/srchybrid/PPgTweaks.cpp +++ b/srchybrid/PPgTweaks.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -321,10 +321,11 @@ void CPPgTweaks::DoDataExchange(CDataExchange *pDX) ///////////////////////////////////////////////////////////////////////////// // Miscellaneous group // + WORD wv = thePrefs.GetWindowsVersion(); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiAutoTakeEd2kLinks, m_bAutoTakeEd2kLinks); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiCreditSystem, m_bCreditSystem); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiFirewallStartup, m_bFirewallStartup); - m_ctrlTreeOptions.SetCheckBoxEnable(m_htiFirewallStartup, thePrefs.GetWindowsVersion() == _WINVER_XP_ && !IsRunningXPSP2()); + m_ctrlTreeOptions.SetCheckBoxEnable(m_htiFirewallStartup, wv == _WINVER_XP_ && !IsRunningXPSP2()); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiFilterLANIPs, m_bFilterLANIPs); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiExtControls, m_bExtControls); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiA4AFSaveCpu, m_bA4AFSaveCpu); @@ -335,7 +336,7 @@ void CPPgTweaks::DoDataExchange(CDataExchange *pDX) // File related group // DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiSparsePartFiles, m_bSparsePartFiles); - m_ctrlTreeOptions.SetCheckBoxEnable(m_htiSparsePartFiles, thePrefs.GetWindowsVersion() != _WINVER_VISTA_ /*only disable on Vista, not later versions*/); + m_ctrlTreeOptions.SetCheckBoxEnable(m_htiSparsePartFiles, wv != _WINVER_VISTA_ /*only disable on Vista, not later versions*/); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiImportParts, m_bImportParts); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiFullAlloc, m_bFullAlloc); DDX_TreeCheck(pDX, IDC_EXT_OPTS, m_htiCheckDiskspace, m_bCheckDiskspace); @@ -421,7 +422,7 @@ void CPPgTweaks::DoDataExchange(CDataExchange *pDX) // eMule Shared User // DDX_TreeRadio(pDX, IDC_EXT_OPTS, m_htiShareeMule, m_iShareeMule); - m_ctrlTreeOptions.SetRadioButtonEnable(m_htiShareeMulePublicUser, thePrefs.GetWindowsVersion() >= _WINVER_VISTA_); + m_ctrlTreeOptions.SetRadioButtonEnable(m_htiShareeMulePublicUser, wv >= _WINVER_VISTA_); } BOOL CPPgTweaks::OnInitDialog() diff --git a/srchybrid/PPgWebServer.cpp b/srchybrid/PPgWebServer.cpp index 6acbf7dc..e2a34dc4 100644 --- a/srchybrid/PPgWebServer.cpp +++ b/srchybrid/PPgWebServer.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -51,7 +51,7 @@ struct options LPCSTR issuer_name; //issuer name for certificate LPCSTR not_before; //validity period not before LPCSTR not_after; //validity period not after - LPCSTR serial; //serial number string + uint16 serial; //serial number string }; static int write_buffer(LPCTSTR output_file, const unsigned char *buffer) @@ -76,48 +76,24 @@ static int write_private_key(mbedtls_pk_context *key, LPCTSTR output_file) return ret ? ret : write_buffer(output_file, output_buf); } +//create RSA 2048 key int KeyCreate(mbedtls_pk_context *key, mbedtls_ctr_drbg_context *ctr_drbg, LPCTSTR output_file) { - mbedtls_mpi N, P, Q, D, E, DP, DQ, QP; LPCTSTR pmsg = NULL; - int ret; - - mbedtls_mpi_init(&N); - mbedtls_mpi_init(&P); - mbedtls_mpi_init(&Q); - mbedtls_mpi_init(&D); - mbedtls_mpi_init(&E); - mbedtls_mpi_init(&DP); - mbedtls_mpi_init(&DQ); - mbedtls_mpi_init(&QP); - - //create RSA 2048 key - ret = mbedtls_pk_setup(key, mbedtls_pk_info_from_type(MBEDTLS_PK_RSA)); - if (ret) { + int ret = mbedtls_pk_setup(key, mbedtls_pk_info_from_type(MBEDTLS_PK_RSA)); + if (ret) pmsg = _T("mbedtls_pk_setup"); - goto exit; - } - ret = mbedtls_rsa_gen_key(mbedtls_pk_rsa(key), mbedtls_ctr_drbg_random, ctr_drbg, 2048u, 65537); - if (ret) { - pmsg = _T("mbedtls_rsa_gen_key"); - goto exit; + else { + ret = mbedtls_rsa_gen_key(mbedtls_pk_rsa(*key), mbedtls_ctr_drbg_random, ctr_drbg, 2048u, 65537); + if (ret) + pmsg = _T("mbedtls_rsa_gen_key"); + else { + ret = write_private_key(key, output_file); //write the key to a file + if (ret) + pmsg = _T("write_private_key"); + } } - //write the key to a file - ret = write_private_key(key, output_file); - if (ret) - DebugLogError(_T("Error: writing private key failed")); - -exit: - mbedtls_mpi_free(&N); - mbedtls_mpi_free(&P); - mbedtls_mpi_free(&Q); - mbedtls_mpi_free(&D); - mbedtls_mpi_free(&E); - mbedtls_mpi_free(&DP); - mbedtls_mpi_free(&DQ); - mbedtls_mpi_free(&QP); - if (pmsg) DebugLogError(_T("Error: %s returned -0x%04x - %s"), pmsg, -ret, (LPCTSTR)SSLerror(ret)); return ret; @@ -127,7 +103,7 @@ int write_certificate(mbedtls_x509write_cert *crt, LPCTSTR output_file, int(*f_r { unsigned char output_buf[4096]; - int ret = mbedtls_x509write_crt_pem(crt, output_buf, 4096, f_rng, p_rng); + int ret = mbedtls_x509write_crt_pem(crt, output_buf, sizeof output_buf, f_rng, p_rng); return ret ? ret : write_buffer(output_file, output_buf); } @@ -136,41 +112,31 @@ int CertCreate(const struct options &opt) static const char pers[] = "cert create"; mbedtls_pk_context issuer_key; mbedtls_x509write_cert crt; - mbedtls_mpi serial; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; LPCTSTR pmsg = NULL; - int ret; mbedtls_threading_set_alt(threading_mutex_init_alt, threading_mutex_free_alt, threading_mutex_lock_alt, threading_mutex_unlock_alt); mbedtls_x509write_crt_init(&crt); mbedtls_pk_init(&issuer_key); - mbedtls_mpi_init(&serial); mbedtls_ctr_drbg_init(&ctr_drbg); + mbedtls_entropy_init(&entropy); //seed the PRNG - mbedtls_entropy_init(&entropy); - ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (unsigned char*)pers, strlen(pers)); + int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (unsigned char*)pers, sizeof pers); if (ret) { - DebugLogError(_T("Error: mbedtls_ctr_drbg_seed returned %d - %s"), ret, (LPCTSTR)SSLerror(ret)); + pmsg = _T("mbedtls_ctr_drbg_seed"); goto exit; } //generate the key ret = KeyCreate(&issuer_key, &ctr_drbg, opt.issuer_key); if (ret) - goto exit; + goto exit; //the bug already was reported mbedtls_x509write_crt_set_subject_key(&crt, &issuer_key); mbedtls_x509write_crt_set_issuer_key(&crt, &issuer_key); - // Parse serial to MPI - ret = mbedtls_mpi_read_string(&serial, 10, opt.serial); - if (ret) { - pmsg = _T("mbedtls_mpi_read_string"); - goto exit; - } - //set parameters ret = mbedtls_x509write_crt_set_subject_name(&crt, opt.subject_name); if (ret) { @@ -183,12 +149,12 @@ int CertCreate(const struct options &opt) goto exit; } - mbedtls_x509write_crt_set_version(&crt, 2); //2 for v3 version + mbedtls_x509write_crt_set_version(&crt, MBEDTLS_X509_CRT_VERSION_3); mbedtls_x509write_crt_set_md_alg(&crt, MBEDTLS_MD_SHA256); - ret = mbedtls_x509write_crt_set_serial(&crt, &serial); + ret = mbedtls_x509write_crt_set_serial_raw(&crt, (unsigned char*)&opt.serial, 1 + static_cast(opt.serial > 0xff)); if (ret) { - pmsg = _T("mbedtls_x509write_crt_set_serial"); + pmsg = _T("mbedtls_x509write_crt_set_serial_raw"); goto exit; } ret = mbedtls_x509write_crt_set_validity(&crt, opt.not_before, opt.not_after); @@ -211,16 +177,6 @@ int CertCreate(const struct options &opt) pmsg = _T("mbedtls_x509write_crt_set_authority_key_identifier"); goto exit; } - ret = mbedtls_x509write_crt_set_key_usage(&crt, MBEDTLS_X509_KU_KEY_ENCIPHERMENT); - if (ret) { - pmsg = _T("mbedtls_x509write_crt_set_key_usage"); - goto exit; - } - ret = mbedtls_x509write_crt_set_ns_cert_type(&crt, MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER); - if (ret) { - pmsg = _T("mbedtls_x509write_crt_set_ns_cert_type"); - goto exit; - } //write the certificate to a file ret = write_certificate(&crt, opt.cert_file, mbedtls_ctr_drbg_random, &ctr_drbg); @@ -228,11 +184,10 @@ int CertCreate(const struct options &opt) pmsg = _T("write_certificate"); exit: - mbedtls_x509write_crt_free(&crt); - mbedtls_pk_free(&issuer_key); - mbedtls_mpi_free(&serial); - mbedtls_ctr_drbg_free(&ctr_drbg); mbedtls_entropy_free(&entropy); + mbedtls_ctr_drbg_free(&ctr_drbg); + mbedtls_pk_free(&issuer_key); + mbedtls_x509write_crt_free(&crt); if (pmsg) DebugLogError(_T("Error: %s returned -0x%04x - %s"), pmsg, -ret, (LPCTSTR)SSLerror(ret)); @@ -472,7 +427,7 @@ void CPPgWebServer::OnChangeHTTPS() void CPPgWebServer::OnEnChangeWSEnabled() { - BOOL bIsWIEnabled = (BOOL)IsDlgButtonChecked(IDC_WSENABLED); + bool bIsWIEnabled = IsDlgButtonChecked(IDC_WSENABLED) != 0; GetDlgItem(IDC_WS_GZIP)->EnableWindow(bIsWIEnabled); GetDlgItem(IDC_WSPORT)->EnableWindow(bIsWIEnabled); GetDlgItem(IDC_TMPLPATH)->EnableWindow(bIsWIEnabled); @@ -517,13 +472,11 @@ void CPPgWebServer::OnGenerateCertificate() const CString &confdir(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR)); const CString &fkey(confdir + _T("cert.key")); const CString &fcrt(confdir + _T("cert.crt")); - CStringA not_after, not_before, serial; + CStringA not_after, not_before; SYSTEMTIME st; GetSystemTime(&st); not_before.Format("%4hu%02hu01000000", st.wYear, st.wMonth); - not_after.Format("%4hu%02hu01235959", st.wYear + 1, st.wMonth); - int nserial = rand() & 0xfff; //avoid repeated serials (kind of) - serial.Format("%d", nserial); + not_after.Format("%4hu%02hu01000000", st.wYear + 1, st.wMonth); struct options opt; opt.issuer_key = (LPCTSTR)fkey; @@ -532,10 +485,12 @@ void CPPgWebServer::OnGenerateCertificate() opt.issuer_name = "CN=eMule,O=emule-project.net"; opt.not_before = (LPCSTR)not_before; opt.not_after = (LPCSTR)not_after; - opt.serial = (LPCSTR)serial; + opt.serial = _byteswap_ushort(rand() & 0xfff); //avoid repeated serials (kind of) + if (!opt.serial) + ++opt.serial; //must be positive m_bNewCert = !CertCreate(opt); if (m_bNewCert) { - AddLogLine(false, _T("New certificate created; serial %d"), nserial); + AddLogLine(false, _T("New certificate created; serial %d"), opt.serial); SetDlgItemText(IDC_KEYPATH, fkey); SetDlgItemText(IDC_CERTPATH, fcrt); GetDlgItem(IDC_WEB_GENERATE)->EnableWindow(FALSE); diff --git a/srchybrid/PShtWiz1.cpp b/srchybrid/PShtWiz1.cpp index 6942b55c..f8145876 100644 --- a/srchybrid/PShtWiz1.cpp +++ b/srchybrid/PShtWiz1.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -806,7 +806,7 @@ BOOL FirstTimeWizard() page3.m_uUDP = thePrefs.GetUDPPort(); page4.m_iDAP = 1; page4.m_iUAP = 1; - page5.m_iObfuscation = static_cast(thePrefs.IsClientCryptLayerSupported()); //was Requested() + page5.m_iObfuscation = static_cast(thePrefs.IsCryptLayerEnabled()); //was Requested() page6.m_iSafeServerConnect = 0; page6.m_iKademlia = 1; page6.m_iED2K = 1; diff --git a/srchybrid/Packets.cpp b/srchybrid/Packets.cpp index 43d91de1..170e0b2a 100644 --- a/srchybrid/Packets.cpp +++ b/srchybrid/Packets.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -740,7 +740,6 @@ CString CTag::GetFullInfo(CString(*pfnDbgGetFileMetaTagName)(UINT uMetaTagID)) c return strTag; } - void CTag::cleanup() { if (IsStr()) diff --git a/srchybrid/Packets.h b/srchybrid/Packets.h index 37ee6f9e..7b321348 100644 --- a/srchybrid/Packets.h +++ b/srchybrid/Packets.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PartFile.cpp b/srchybrid/PartFile.cpp index b8b2d159..7cb9133a 100644 --- a/srchybrid/PartFile.cpp +++ b/srchybrid/PartFile.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -51,7 +51,6 @@ #include "ClientList.h" #include "Statistics.h" #include "shahashset.h" -#include "PeerCacheSocket.h" #include "Log.h" #include "Collection.h" #include "CollectionViewDialog.h" @@ -98,7 +97,7 @@ CPartFile::CPartFile(CSearchFile *searchresult, UINT cat) m_pAICHRecoveryHashSet->SetMasterHash(fileid.GetAICHHash(), AICH_VERIFIED); } - for (int i = 0; i < searchresult->m_taglist.GetCount(); ++i) { + for (INT_PTR i = 0; i < searchresult->m_taglist.GetCount(); ++i) { const CTag *pTag = searchresult->m_taglist[i]; switch (pTag->GetNameID()) { case FT_FILENAME: @@ -196,11 +195,9 @@ void CPartFile::InitializeFromLink(const CED2KFileLink &fileLink, UINT cat) AddDebugLogLine(false, _T("eD2K link \"%s\" specified with invalid hashset"), fileLink.GetName()); } else m_bMD4HashsetNeeded = false; - } catch (CFileException *e) { - TCHAR szError[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*e, szError, _countof(szError)); - AddDebugLogLine(false, _T("Error: Failed to process hashset for eD2K link \"%s\" - %s"), fileLink.GetName(), szError); - e->Delete(); + } catch (CFileException *ex) { + AddDebugLogLine(false, _T("Error: Failed to process hashset for eD2K link \"%s\"%s"), fileLink.GetName(), (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } CreatePartFile(cat); @@ -262,6 +259,7 @@ void CPartFile::Init() lastSwapForSourceExchangeTick = m_lastpurgetime = ::GetTickCount(); m_lastRefreshedDLDisplay = 0; m_nLastBufferFlushTime = 0; + m_nNextMetFlushTime = 0; m_nFileFlushTime = 0; //nothing to flush m_dwFileAttributes = 0; m_random_update_wait = (DWORD)(rand() % SEC2MS(1)); @@ -404,7 +402,7 @@ void CPartFile::CreatePartFile(UINT cat) return; } - CTag* partnametag = new CTag(FT_PARTFILENAME, RemoveFileExtension(m_partmetfilename)); + CTag *partnametag = new CTag(FT_PARTFILENAME, RemoveFileExtension(m_partmetfilename)); m_taglist.Add(partnametag); AddGap(0, (uint64)m_nFileSize - 1); @@ -493,14 +491,11 @@ EPartFileLoadResult CPartFile::ImportShareazaTempfile(LPCTSTR in_directory, LPCT // open the file CFile sdFile; - CFileException fexpMet; - if (!sdFile.Open(fullname, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexpMet)) { - CString strError; - strError.Format(GetResString(IDS_ERR_OPENMET), in_filename, _T("")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexpMet, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), (LPCTSTR)strError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + CFileException fex; + if (!sdFile.Open(fullname, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fex)) { + CString s; + s.Format(GetResString(IDS_ERR_OPENMET), in_filename, _T("")); + LogError(LOG_STATUSBAR, _T("%s%s"), (LPCTSTR)s, (LPCTSTR)CExceptionStrDash(fex)); return PLR_FAILED_METFILE_NOACCESS; } //::setvbuf(sdFile.m_pStream, NULL, _IOFBF, 16384); @@ -676,30 +671,24 @@ EPartFileLoadResult CPartFile::ImportShareazaTempfile(LPCTSTR in_directory, LPCT // Close the file sdFile.Close(); - } catch (CArchiveException *error) { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR), in_filename, (LPCTSTR)GetFileName(), buffer); - error->Delete(); + } catch (CArchiveException *ex) { + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR), in_filename, (LPCTSTR)GetFileName(), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); return PLR_FAILED_OTHER; - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) LogError(LOG_STATUSBAR, GetResString(IDS_ERR_METCORRUPT), in_filename, (LPCTSTR)GetFileName()); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR), in_filename, (LPCTSTR)GetFileName(), buffer); - } - error->Delete(); + else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR), in_filename, (LPCTSTR)GetFileName(), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); return PLR_FAILED_OTHER; - } #ifndef _DEBUG - catch (...) { + } catch (...) { LogError(LOG_STATUSBAR, GetResString(IDS_ERR_METCORRUPT), in_filename, (LPCTSTR)GetFileName()); ASSERT(0); return PLR_FAILED_OTHER; - } #endif + } // The part below would be a copy of the CPartFile::LoadPartFile, // so it is smarter to save and reload the file instead of duplicating the whole stuff @@ -725,16 +714,13 @@ EPartFileLoadResult CPartFile::LoadPartFile(LPCTSTR in_directory, LPCTSTR in_fil ASSERT(GetPath().Right(1) == _T("\\")); m_fullname.Format(_T("%s%s"), (LPCTSTR)GetPath(), (LPCTSTR)m_partmetfilename); - // read file data form part.met file + // read data from part.met file CSafeBufferedFile metFile; - CFileException fexpMet; - if (!metFile.Open(m_fullname, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexpMet)) { - CString strError; - strError.Format(GetResString(IDS_ERR_OPENMET), (LPCTSTR)m_partmetfilename, _T("")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexpMet, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), (LPCTSTR)strError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + CFileException fex; + if (!metFile.Open(m_fullname, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fex)) { + CString s; + s.Format(GetResString(IDS_ERR_OPENMET), (LPCTSTR)m_partmetfilename, _T("")); + LogError(LOG_STATUSBAR, _T("%s%s"), (LPCTSTR)s, (LPCTSTR)CExceptionStrDash(fex)); return PLR_FAILED_METFILE_NOACCESS; } ::setvbuf(metFile.m_pStream, NULL, _IOFBF, 16384); @@ -1020,24 +1006,20 @@ EPartFileLoadResult CPartFile::LoadPartFile(LPCTSTR in_directory, LPCTSTR in_fil } metFile.Close(); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) LogError(LOG_STATUSBAR, GetResString(IDS_ERR_METCORRUPT), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName()); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName(), buffer); - } - error->Delete(); + else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName(), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); return PLR_FAILED_METFILE_CORRUPT; - } #ifndef _DEBUG - catch (...) { + } catch (...) { LogError(LOG_STATUSBAR, GetResString(IDS_ERR_METCORRUPT), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName()); ASSERT(0); return PLR_FAILED_METFILE_CORRUPT; - } #endif + } if ((uint64)m_nFileSize > MAX_EMULE_FILE_SIZE) { LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName(), _T("File size exceeds supported limit")); @@ -1073,14 +1055,11 @@ EPartFileLoadResult CPartFile::LoadPartFile(LPCTSTR in_directory, LPCTSTR in_fil // open permanent handle const CString &searchpath(RemoveFileExtension(m_fullname)); ASSERT(searchpath.Right(5) == _T(".part")); - CFileException fexpPart; - if (!m_hpartfile.Open(searchpath, CFile::modeReadWrite | CFile::shareDenyNone | CFile::osSequentialScan, &fexpPart)) { - CString strError; - strError.Format(GetResString(IDS_ERR_FILEOPEN), (LPCTSTR)searchpath, (LPCTSTR)GetFileName()); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexpPart, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), (LPCTSTR)strError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + //CFileException fex; + if (!m_hpartfile.Open(searchpath, CFile::modeReadWrite | CFile::shareDenyNone | CFile::osSequentialScan, &fex)) { + CString s; + s.Format(GetResString(IDS_ERR_FILEOPEN), (LPCTSTR)searchpath, (LPCTSTR)GetFileName()); + LogError(LOG_STATUSBAR, _T("%s%s"), (LPCTSTR)s, (LPCTSTR)CExceptionStrDash(fex)); return PLR_FAILED_OTHER; } @@ -1165,14 +1144,12 @@ EPartFileLoadResult CPartFile::LoadPartFile(LPCTSTR in_directory, LPCTSTR in_fil SetStatus(PS_ERROR); } } - } catch (CFileException *error) { - CString strError; - strError.Format(_T("Failed to initialize part file \"%s\" (%s)"), (LPCTSTR)m_hpartfile.GetFilePath(), (LPCTSTR)GetFileName()); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*error, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), (LPCTSTR)strError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - error->Delete(); + } catch (CFileException *ex) { + LogError(LOG_STATUSBAR, _T("Failed to initialize part file \"%s\" (%s)%s") + , (LPCTSTR)m_hpartfile.GetFilePath() + , (LPCTSTR)GetFileName() + , (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); return PLR_FAILED_OTHER; } @@ -1212,14 +1189,11 @@ bool CPartFile::SavePartFile(bool bDontOverrideBak) // save file data to part.met file CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(strTmpFile, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - CString strError; - strError.Format(GetResString(IDS_ERR_SAVEMET), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName()); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), (LPCTSTR)strError); - LogError(_T("%s"), (LPCTSTR)strError); + CFileException fex; + if (!file.Open(strTmpFile, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fex)) { + CString s; + s.Format(GetResString(IDS_ERR_SAVEMET), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName()); + LogError(_T("%s%s"), (LPCTSTR)s, (LPCTSTR)CExceptionStrDash(fex)); return false; } ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); @@ -1462,21 +1436,12 @@ bool CPartFile::SavePartFile(bool bDontOverrideBak) file.Seek(uTagCountFilePos, CFile::begin); file.WriteUInt32(uTagCount); file.SeekToEnd(); - - if (thePrefs.GetCommitFiles() >= 2 || (thePrefs.GetCommitFiles() >= 1 && theApp.IsClosing())) { - file.Flush(); // flush file stream buffers to disk buffers - if (_commit(_fileno(file.m_pStream)) != 0) // commit disk buffers to disk - AfxThrowFileException(CFileException::hardIO, ::GetLastError(), file.GetFileName()); - } - file.Close(); - } catch (CFileException *error) { + CommitAndClose(file); + } catch (CFileException *ex) { CString strError; strError.Format(GetResString(IDS_ERR_SAVEMET), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName()); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*error, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), (LPCTSTR)strError); - LogError(_T("%s"), (LPCTSTR)strError); - error->Delete(); + LogError(_T("%s%s"), (LPCTSTR)strError, (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); // remove the partially written or otherwise damaged temporary file, // need to close the file before removing it. @@ -1554,7 +1519,7 @@ void CPartFile::PartFileHashFinished(CKnownFile *result) errorfound = true; LogWarning(GetResString(IDS_ERR_FOUNDCORRUPTION), nPart, (LPCTSTR)GetFileName()); const uint64 nPartStart = nPart * PARTSIZE; - AddGap(nPartStart, min(nPartStart + PARTSIZE - 1, (uint64)m_nFileSize - 1)); + AddGap(nPartStart, min(nPartStart + PARTSIZE, (uint64)m_nFileSize) - 1); if (bMD4Checked && bAICHChecked && bMD4Error != bAICHError) DebugLogError(_T("AICH and MD4 HashSet disagree on verifying part %u for file %s. MD4: %s - AICH: %s"), nPart , (LPCTSTR)GetFileName(), bMD4Error ? _T("Corrupt") : _T("OK"), bAICHError ? _T("Corrupt") : _T("OK")); @@ -1809,14 +1774,14 @@ uint64 CPartFile::GetTotalGapSizeInPart(UINT uPart) const return GetTotalGapSizeInRange(uPart * PARTSIZE, uPart * PARTSIZE + PARTSIZE - 1); } -bool CPartFile::GetNextEmptyBlockInPart(UINT partNumber, Requested_Block_Struct *result) const +bool CPartFile::GetNextEmptyBlockInPart(UINT partNumber, Requested_Block_Struct *pReqBlock) const { // Find start of this part uint64 partStart = PARTSIZE * partNumber; uint64 start = partStart; // The end of the part must be within file size - uint64 partEnd = min(partStart + PARTSIZE - 1, (uint64)m_nFileSize - 1); + uint64 partEnd = min(partStart + PARTSIZE, (uint64)m_nFileSize) - 1; ASSERT(partStart <= partEnd); // Loop until a suitable gap is found and return true, or no more gaps and return false @@ -1850,11 +1815,11 @@ bool CPartFile::GetNextEmptyBlockInPart(UINT partNumber, Requested_Block_Struct // If this gap has not already been requested, we have found a valid entry if (!IsAlreadyRequested(start, end, true)) { // Was this block to be returned - if (result != NULL) { - result->StartOffset = start; - result->EndOffset = end; - md4cpy(result->FileID, GetFileHash()); - result->transferred = 0; + if (pReqBlock != NULL) { + pReqBlock->StartOffset = start; + pReqBlock->EndOffset = end; + md4cpy(pReqBlock->FileID, GetFileHash()); + pReqBlock->transferred = 0; } return true; } @@ -1865,11 +1830,11 @@ bool CPartFile::GetNextEmptyBlockInPart(UINT partNumber, Requested_Block_Struct AddDebugLogLine(false, _T("Shrunk interval to prevent collision with already requested block: Old interval %I64u-%I64u. New interval: %I64u-%I64u. File %s."), start, end, tempStart, tempEnd, (LPCTSTR)GetFileName()); // Was this block to be returned - if (result != NULL) { - result->StartOffset = tempStart; - result->EndOffset = tempEnd; - md4cpy(result->FileID, GetFileHash()); - result->transferred = 0; + if (pReqBlock != NULL) { + pReqBlock->StartOffset = tempStart; + pReqBlock->EndOffset = tempEnd; + md4cpy(pReqBlock->FileID, GetFileHash()); + pReqBlock->transferred = 0; } return true; } @@ -1960,7 +1925,7 @@ void CPartFile::DrawShareStatusBar(CDC *dc, LPCRECT rect, bool onlygreyrect, boo const COLORREF crNooneAsked(bFlat ? RGB(0, 0, 0) : RGB(104, 104, 104)); for (UINT i = GetPartCount(); i-- > 0;) { uint64 uBegin = PARTSIZE * i; - if (IsCompleteBD(uBegin, uBegin + PARTSIZE - 1)) { + if (IsCompleteBDSafe(uBegin, uBegin + PARTSIZE - 1)) { COLORREF colour; if (GetStatus() != PS_PAUSED || !m_ClientUploadList.IsEmpty() || m_nCompleteSourcesCountHi > 0) { uint16 frequency; @@ -2258,8 +2223,6 @@ uint32 CPartFile::Process(uint32 reducedownload, UINT icounter/*in percent*/) else if (limit < 1) limit = 1; cur_src->socket->SetDownloadLimit(limit); - if (cur_src->IsDownloadingFromPeerCache() && cur_src->m_pPCDownSocket && cur_src->m_pPCDownSocket->IsConnected()) - cur_src->m_pPCDownSocket->SetDownloadLimit(limit); } } } @@ -2322,14 +2285,8 @@ uint32 CPartFile::Process(uint32 reducedownload, UINT icounter/*in percent*/) else if (limit < 1) limit = 1; cur_src->socket->SetDownloadLimit(limit); - if (cur_src->IsDownloadingFromPeerCache() && cur_src->m_pPCDownSocket && cur_src->m_pPCDownSocket->IsConnected()) - cur_src->m_pPCDownSocket->SetDownloadLimit(limit); - - } else { + } else cur_src->socket->DisableDownloadLimit(); - if (cur_src->IsDownloadingFromPeerCache() && cur_src->m_pPCDownSocket && cur_src->m_pPCDownSocket->IsConnected()) - cur_src->m_pPCDownSocket->DisableDownloadLimit(); - } } break; case DS_BANNED: // Do nothing with this client. @@ -2505,11 +2462,11 @@ void CPartFile::AddSources(CSafeMemFile *sources, uint32 serverip, uint16 server if ((byCryptOptions & 0x80) != 0) sources->ReadHash16(achUserHash); - if ((thePrefs.IsClientCryptLayerRequested() && (byCryptOptions & 0x01/*supported*/) > 0 && (byCryptOptions & 0x80) == 0) - || (thePrefs.IsClientCryptLayerSupported() && (byCryptOptions & 0x02/*requested*/) > 0 && (byCryptOptions & 0x80) == 0)) + if ((thePrefs.IsCryptLayerPreferred() && (byCryptOptions & 0x01/*supported*/) > 0 && (byCryptOptions & 0x80) == 0) + || (thePrefs.IsCryptLayerEnabled() && (byCryptOptions & 0x02/*requested*/) > 0 && (byCryptOptions & 0x80) == 0)) { DebugLogWarning(_T("Server didn't provide UserHash for source %u, even if it was expected to (or local obfuscation settings changed during server connect)"), userid); - } else if (!thePrefs.IsClientCryptLayerRequested() && (byCryptOptions & 0x02/*requested*/) == 0 && (byCryptOptions & 0x80) != 0) + } else if (!thePrefs.IsCryptLayerPreferred() && (byCryptOptions & 0x02/*requested*/) == 0 && (byCryptOptions & 0x80) != 0) DebugLogWarning(_T("Server provided UserHash for source %u, even if it wasn't expected to (or local obfuscation settings changed during server connect)"), userid); } @@ -2712,11 +2669,6 @@ bool CPartFile::RemoveBlockFromList(uint64 start, uint64 end) return false; } -void CPartFile::RemoveAllRequestedBlocks() -{ - requestedblocks_list.RemoveAll(); -} - void CPartFile::CompleteFile(bool bIsHashingDone) { ASSERT(m_iWrites <= 0 && m_gaplist.IsEmpty() && m_BufferedData_list.IsEmpty()); @@ -2894,11 +2846,9 @@ BOOL CPartFile::PerformFileComplete() try { if ((HANDLE)m_hpartfile != INVALID_HANDLE_VALUE) m_hpartfile.Close(); - } catch (CFileException *error) { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - theApp.QueueLogLine(true, GetResString(IDS_ERR_FILEERROR), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName(), buffer); - error->Delete(); + } catch (CFileException *ex) { + theApp.QueueLogLine(true, GetResString(IDS_ERR_FILEERROR), (LPCTSTR)m_partmetfilename, (LPCTSTR)GetFileName(), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); } CString strNewname(indir); @@ -3248,11 +3198,6 @@ bool CPartFile::HashSinglePart(UINT partnumber, bool *pbAICHReportedOK) return !bMD4Error && !bAICHError; } -bool CPartFile::IsCorruptedPart(UINT partnumber) const -{ - return (corrupted_list.Find((uint16)partnumber) != NULL); -} - // Barry - Also want to preview zip/rar files bool CPartFile::IsArchive(bool onlyPreviewable) const { @@ -3877,7 +3822,7 @@ void CPartFile::AddClientSources(CSafeMemFile *sources, uint8 uClientSXVersion, } else { // for SX2: // We only check if the version is known by us and do a quick sanitize check on known version - // other then SX1, the packet will be ignored if any error appears, since it can't be a "misunderstanding" any more + // other then SX1, the packet will be ignored in case of error, since it can't be a "misunderstanding" any more if (uClientSXVersion > SOURCEEXCHANGE2_VERSION || uClientSXVersion == 0) { if (thePrefs.GetVerbose()) { CString strDbgClientInfo; @@ -3920,7 +3865,7 @@ void CPartFile::AddClientSources(CSafeMemFile *sources, uint8 uClientSXVersion, uPacketSXVersion = uClientSXVersion; } - for (UINT i = nCount; i-- > 0;) { + for (; nCount > 0; --nCount) { uint32 dwID = sources->ReadUInt32(); uint16 nPort = sources->ReadUInt16(); uint32 dwServerIP = sources->ReadUInt32(); @@ -3983,14 +3928,6 @@ void CPartFile::AddClientSources(CSafeMemFile *sources, uint8 uClientSXVersion, } } -// making this function return a higher value when more sources have the extended -// protocol will force you to ask a larger variety of people for sources -/*int CPartFile::GetCommonFilePenalty() const -{ - //TODO: implement, but never return less than MINCOMMONPENALTY! - return MINCOMMONPENALTY; -} -*/ /* Barry - Replaces BlockReceived() Originally this only wrote to disk when a full 180k block @@ -4090,7 +4027,7 @@ uint32 CPartFile::WriteToBuffer(uint64 transize, const BYTE *data, uint64 start, if (!client && requestedblocks_list.Find(block) != NULL) block->transferred += lenData; // We prefer to flush the buffer on timer, but if we get over our limit too far - // (high speed upload), flush here to save memory and time on the buffer list + // (high speed upload), flush here to save memory and time on the buffer list if (m_gaplist.IsEmpty() || (GetStatus() != PS_READY && GetStatus() != PS_EMPTY) //import parts || (m_nTotalBufferData > thePrefs.GetFileBufferSize() * 2ull)) @@ -4221,7 +4158,7 @@ void CPartFile::FlushBuffer(bool bForceICH, bool bNoAICH) m_aChangedPart[uPartNumber] = false; const uint64 uStart = PARTSIZE * uPartNumber; - const uint64 uEnd = min(uStart + PARTSIZE - 1, (uint64)m_nFileSize - 1); + const uint64 uEnd = min(uStart + PARTSIZE, (uint64)m_nFileSize) - 1; // Is this 9MB part complete if (IsCompleteBD(uStart, uEnd)) { // Is part corrupt @@ -4292,7 +4229,10 @@ void CPartFile::FlushBuffer(bool bForceICH, bool bNoAICH) } } - SavePartFile(); // Update met file + if (m_nNextMetFlushTime < m_nLastBufferFlushTime) { + SavePartFile(); // Update met file + m_nNextMetFlushTime = m_nLastBufferFlushTime + SEC2MS(29); + } if (!theApp.IsClosing()) { // may be called during shutdown! // Is this file finished? @@ -4333,19 +4273,18 @@ void CPartFile::FlushBuffer(bool bForceICH, bool bNoAICH) } } } - } catch (CFileException *error) { - FlushBuffersExceptionHandler(error); - } + } catch (CFileException *ex) { + FlushBuffersExceptionHandler(ex); #ifndef _DEBUG - catch (...) { + } catch (...) { FlushBuffersExceptionHandler(); - } #endif + } } -void CPartFile::FlushBuffersExceptionHandler(CFileException *error) +void CPartFile::FlushBuffersExceptionHandler(CFileException *ex) { - if (thePrefs.IsCheckDiskspaceEnabled() && error->m_cause == CFileException::diskFull) { + if (thePrefs.IsCheckDiskspaceEnabled() && ex->m_cause == CFileException::diskFull) { CString msg; msg.Format(GetResString(IDS_ERR_OUTOFSPACE), (LPCTSTR)GetFileName()); LogError(LOG_STATUSBAR, msg); @@ -4362,7 +4301,7 @@ void CPartFile::FlushBuffersExceptionHandler(CFileException *error) if (thePrefs.IsErrorBeepEnabled()) Beep(800, 200); - if (error->m_cause == CFileException::diskFull) { + if (ex->m_cause == CFileException::diskFull) { CString msg; msg.Format(GetResString(IDS_ERR_OUTOFSPACE), (LPCTSTR)GetFileName()); LogError(LOG_STATUSBAR, msg); @@ -4370,9 +4309,7 @@ void CPartFile::FlushBuffersExceptionHandler(CFileException *error) if (thePrefs.GetNotifierOnImportantError() && !theApp.IsClosing()) theApp.emuledlg->ShowNotifier(msg, TBN_IMPORTANTEVENT); } else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_WRITEERROR), (LPCTSTR)GetFileName(), buffer); + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_WRITEERROR), (LPCTSTR)GetFileName(), (LPCTSTR)CExceptionStr(*ex)); SetStatus(PS_ERROR); } m_paused = true; @@ -4388,7 +4325,7 @@ void CPartFile::FlushBuffersExceptionHandler(CFileException *error) UpdateDisplayedInfo(); } - error->Delete(); + ex->Delete(); } void CPartFile::FlushBuffersExceptionHandler() @@ -4633,17 +4570,6 @@ void CPartFile::NotifyStatusChange() theApp.emuledlg->transferwnd->GetDownloadList()->UpdateCurrentCategoryView(this); } -EMFileSize CPartFile::GetRealFileSize() const -{ - return GetDiskFileSize(GetFilePath()); -} - -UINT CPartFile::GetSrcStatisticsValue(EDownloadState nDLState) const -{ - ASSERT(nDLState < _countof(m_anStates)); - return m_anStates[nDLState]; -} - UINT CPartFile::GetTransferringSrcCount() const { return GetSrcStatisticsValue(DS_DOWNLOADING); @@ -4738,13 +4664,13 @@ bool CPartFile::GetNextRequestedBlock(CUpDownClient *sender, Requested_Block_Str // Add to the list a new entry for this chunk chunksList.AddTail(Chunk{ (uint16)i, { m_SrcPartFrequency[i]} }); - // Check if any block(s) could be downloaded + // Check if any blocks need to be downloaded if (chunksList.IsEmpty()) - break; // Exit the main loop + break; // Nothing to do; exit the main loop // Define the bounds of the zones (very rare, rare etc) // more depending on available sources - const uint16 limit = (uint16)max(ceil(GetSourceCount() / 10.0), 3); + const uint16 limit = (uint16)max((GetSourceCount() + 9) / 10, 3); const uint16 veryRareBound = limit; const uint16 rareBound = 2 * limit; @@ -4762,7 +4688,7 @@ bool CPartFile::GetNextRequestedBlock(CUpDownClient *sender, Requested_Block_Str // Offsets of chunk UINT uCurChunkPart = cur_chunk.part; // help VC71... const uint64 uStart = uCurChunkPart * PARTSIZE; - const uint64 uEnd = min(uStart + PARTSIZE - 1, (uint64)m_nFileSize - 1); + const uint64 uEnd = min(uStart + PARTSIZE, (uint64)m_nFileSize) - 1; ASSERT(uStart <= uEnd); // Criterion 2. Parts used for preview @@ -4837,7 +4763,7 @@ bool CPartFile::GetNextRequestedBlock(CUpDownClient *sender, Requested_Block_Str if (partSize > PARTSIZE) partSize = PARTSIZE; - uint16 critCompletion = (uint16)ceil(partSize * 100.0 / PARTSIZE); // in [%]. Last chunk is always counted as a full size chunk, to not give it any advantage in this comparison due to smaller size. So a 1/3 of PARTSIZE downloaded in last chunk will give 33% even if there's just one more byte do download to complete the chunk. + uint16 critCompletion = (uint16)((partSize * 100 + PARTSIZE - 1) / PARTSIZE); // in [%]. Last chunk is always counted as a full size chunk, to not give it any advantage in this comparison due to smaller size. So a 1/3 of PARTSIZE downloaded in last chunk will give 33% even if there's just one more byte do download to complete the chunk. if (critCompletion > 100) critCompletion = 100; @@ -4927,8 +4853,8 @@ bool CPartFile::GetNextRequestedBlock(CUpDownClient *sender, Requested_Block_Str } } - if (chunksList.IsEmpty()) // No chunks remained to download - break; // Exit the main loop + //if (chunksList.IsEmpty()) // No chunks remained to download + // break; // Exit the main loop // Select the next chunk to download // Find and count the chunk(s) with the highest priority @@ -5053,8 +4979,8 @@ bool CPartFile::CopyPartFile(CArray &raFilled, const CString & tempF } m_bPreviewing = false; return true; - } catch (CFileException *error) { - error->Delete(); + } catch (CFileException *ex) { + ex->Delete(); } catch (...) { ASSERT(0); } @@ -5107,11 +5033,6 @@ void CPartFile::GetLeftToTransferAndAdditionalNeededSpace(uint64 &rui64LeftToTra rui64AdditionalNeededSpace = rui64LeftToTransfer; } -void CPartFile::SetLastAnsweredTimeTimeout() -{ - m_ClientSrcAnswered = ::GetTickCount() + 2 * CONNECTION_LATENCY - SOURCECLIENTREASKS; -} - /*Checks, if a given item should be shown in a given category AllcatTypes: 0 all @@ -5213,15 +5134,11 @@ void CPartFile::SetActive(bool bActive) { time_t tNow = time(NULL); if (bActive) { - if (theApp.IsConnected()) { - if (m_tActivated == 0) - m_tActivated = tNow; - } - } else { - if (m_tActivated != 0) { - m_nDlActiveTime += tNow - m_tActivated; - m_tActivated = 0; - } + if (theApp.IsConnected() && m_tActivated == 0) + m_tActivated = tNow; + } else if (m_tActivated != 0) { + m_nDlActiveTime += tNow - m_tActivated; + m_tActivated = 0; } } @@ -5233,17 +5150,6 @@ time_t CPartFile::GetDlActiveTime() const return nDlActiveTime; } -void CPartFile::SetFileOp(EPartFileOp eFileOp) -{ - m_eFileOp = eFileOp; -} - -void CPartFile::SetFileOpProgress(WPARAM uProgress) -{ - ASSERT(uProgress <= 100); - m_uFileOpProgress = uProgress; -} - bool CPartFile::RightFileHasHigherPrio(CPartFile *left, CPartFile *right) { if (!right) @@ -5429,8 +5335,8 @@ void CPartFile::AICHRecoveryDataAvailable(UINT nPart) // Update met file SavePartFile(); // make sure the user appreciates our great recovery work :P - AddLogLine(true, GetResString(IDS_AICH_WORKED), (LPCTSTR)CastItoXBytes(nRecovered), (LPCTSTR)CastItoXBytes(length), nPart, (LPCTSTR)GetFileName()); //AICH successfully recovered %s of %s from part %u for %s + AddLogLine(true, GetResString(IDS_AICH_WORKED), (LPCTSTR)CastItoXBytes(nRecovered), (LPCTSTR)CastItoXBytes(length), nPart, (LPCTSTR)GetFileName()); } UINT CPartFile::GetMaxSources() const diff --git a/srchybrid/PartFile.h b/srchybrid/PartFile.h index 685ca600..b792a8ca 100644 --- a/srchybrid/PartFile.h +++ b/srchybrid/PartFile.h @@ -1,4 +1,4 @@ -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -146,7 +146,7 @@ class CPartFile : public CKnownFile // local file system related properties bool IsNormalFile() const { return (m_dwFileAttributes & (FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_SPARSE_FILE)) == 0; } - EMFileSize GetRealFileSize() const; + EMFileSize GetRealFileSize() const { return GetDiskFileSize(GetFilePath()); } void GetLeftToTransferAndAdditionalNeededSpace(uint64 &rui64LeftToTransfer, uint64 &rui64AdditionalNeededSpace) const; uint64 GetNeededSpace() const; virtual void SetFileSize(EMFileSize nFileSize); @@ -182,7 +182,7 @@ class CPartFile : public CKnownFile bool IsPureGap(uint64 start, uint64 end) const; bool IsAlreadyRequested(uint64 start, uint64 end, bool bCheckBuffers = false) const; bool ShrinkToAvoidAlreadyRequested(uint64 &start, uint64 &end) const; - bool IsCorruptedPart(UINT partnumber) const; + bool IsCorruptedPart(UINT partnumber) const { return (corrupted_list.Find((uint16)partnumber) != NULL); } uint64 GetTotalGapSizeInRange(uint64 uRangeStart, uint64 uRangeEnd) const; uint64 GetTotalGapSizeInPart(UINT uPart) const; void UpdateCompletedInfos(); @@ -215,7 +215,7 @@ class CPartFile : public CKnownFile UINT GetSourceCount() const { return static_cast(srclist.GetCount()); } UINT GetSrcA4AFCount() const { return static_cast(A4AFsrclist.GetCount()); } - UINT GetSrcStatisticsValue(EDownloadState nDLState) const; + UINT GetSrcStatisticsValue(EDownloadState nDLState) const { return m_anStates[nDLState]; } //ASSERT(nDLState < _countof(m_anStates)); UINT GetTransferringSrcCount() const; uint64 GetTransferred() const { return m_uTransferred; } uint32 GetDatarate() const { return m_datarate; } @@ -230,12 +230,12 @@ class CPartFile : public CKnownFile // Barry - Added as replacement for BlockReceived to buffer data before writing to disk uint32 WriteToBuffer(uint64 transize, const BYTE *data, uint64 start, uint64 end, Requested_Block_Struct *block, const CUpDownClient *client, bool bCopyData); void FlushBuffer(bool bForceICH = false, bool bNoAICH = false); - // Barry - This will invert the gap list, up to caller to delete gaps when done + // Barry - This will invert the gap list, up to the caller to delete gaps when done // 'Gaps' returned are really the filled areas, and guaranteed to be in order void GetFilledArray(CArray &filled) const; // Barry - Added to prevent list containing deleted blocks on shutdown - void RemoveAllRequestedBlocks(); + void RemoveAllRequestedBlocks() { requestedblocks_list.RemoveAll(); } bool RemoveBlockFromList(uint64 start, uint64 end); void RemoveAllSources(bool bTryToSwap); @@ -264,7 +264,7 @@ class CPartFile : public CKnownFile DWORD GetLastAnsweredTime() const { return m_ClientSrcAnswered; } void SetLastAnsweredTime() { m_ClientSrcAnswered = ::GetTickCount(); } - void SetLastAnsweredTimeTimeout(); + void SetLastAnsweredTimeTimeout() { m_ClientSrcAnswered = ::GetTickCount() + 2 * CONNECTION_LATENCY - SOURCECLIENTREASKS; } uint64 GetCorruptionLoss() const { return m_uCorruptionLoss; } uint64 GetCompressionGain() const { return m_uCompressionGain; } @@ -279,7 +279,6 @@ class CPartFile : public CKnownFile const CStringA GetProgressString(uint16 size) const; CString GetInfoSummary(bool bNoFormatCommands = false) const; -// int GetCommonFilePenalty() const; void UpdateDisplayedInfo(bool force = false); UINT GetCategory() /*const*/; @@ -292,14 +291,14 @@ class CPartFile : public CKnownFile virtual bool GrabImage(uint8 nFramesToGrab, double dStartTime, bool bReduceColor, uint16 nMaxWidth, void *pSender); virtual void GrabbingFinished(CxImage **imgResults, uint8 nFramesGrabbed, void *pSender); - void FlushBuffersExceptionHandler(CFileException *error); + void FlushBuffersExceptionHandler(CFileException *ex); void FlushBuffersExceptionHandler(); void PerformFileCompleteEnd(DWORD dwResult); - void SetFileOp(EPartFileOp eFileOp); + void SetFileOp(EPartFileOp eFileOp) { m_eFileOp = eFileOp; } EPartFileOp GetFileOp() const { return m_eFileOp; } - void SetFileOpProgress(WPARAM uProgress); + void SetFileOpProgress(WPARAM uProgress) { m_uFileOpProgress = uProgress; } //ASSERT(uProgress <= 100); WPARAM GetFileOpProgress() const { return m_uFileOpProgress; } CAICHRecoveryHashSet* GetAICHRecoveryHashSet() const { return m_pAICHRecoveryHashSet; } @@ -308,7 +307,7 @@ class CPartFile : public CKnownFile bool IsAICHPartHashSetNeeded() const { return m_FileIdentifier.HasAICHHash() && !m_FileIdentifier.HasExpectedAICHHashCount() && m_bAICHPartHashsetNeeded; } void SetAICHHashSetNeeded(bool bVal) { m_bAICHPartHashsetNeeded = bVal; } - bool AllowSwapForSourceExchange() { return ::GetTickCount() >= lastSwapForSourceExchangeTick + SEC2MS(30); } // ZZ:DownloadManager + bool AllowSwapForSourceExchange(DWORD dwTick) const { return dwTick >= lastSwapForSourceExchangeTick + SEC2MS(30); } // ZZ:DownloadManager void SetSwapForSourceExchangeTick() { lastSwapForSourceExchangeTick = ::GetTickCount(); } // ZZ:DownloadManager UINT SetPrivateMaxSources(uint32 in) { return m_uMaxSources = in; } @@ -348,7 +347,7 @@ class CPartFile : public CKnownFile bool m_bMD4HashsetNeeded; protected: - bool GetNextEmptyBlockInPart(UINT partNumber, Requested_Block_Struct *result) const; + bool GetNextEmptyBlockInPart(UINT partNumber, Requested_Block_Struct *pReqBlock) const; void CompleteFile(bool bIsHashingDone); void CreatePartFile(UINT cat = 0); void Init(); @@ -389,6 +388,7 @@ class CPartFile : public CKnownFile DWORD lastSwapForSourceExchangeTick; // ZZ:DownloadManaager DWORD m_lastRefreshedDLDisplay; DWORD m_nLastBufferFlushTime; + DWORD m_nNextMetFlushTime; //update .part.met file DWORD m_nFileFlushTime; //if file is idle long enough, flush new data to disk DWORD m_dwFileAttributes; DWORD m_random_update_wait; diff --git a/srchybrid/PartFileConvert.cpp b/srchybrid/PartFileConvert.cpp index 54469bf1..2702ba46 100644 --- a/srchybrid/PartFileConvert.cpp +++ b/srchybrid/PartFileConvert.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -280,13 +280,9 @@ int CPartFileConvert::performConvertToeMule(const CString &folder) if (!::WriteFile((HANDLE)file->m_hpartfile, ba.GetData(), nRead, NULL, &ov)) CFileException::ThrowOsError((LONG)::GetLastError(), file->m_hpartfile.GetFileName()); } - } catch (CFileException *error) { - CString strError(GetResString(IDS_IMP_IOERROR)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*error, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_DEFAULT, _T("%s"), (LPCTSTR)strError); - error->Delete(); + } catch (CFileException *ex) { + LogError(LOG_DEFAULT, _T("%s%s"), (LPCTSTR)GetResString(IDS_IMP_IOERROR), (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); delete file; return CONV_IOERROR; } diff --git a/srchybrid/PartFileConvert.h b/srchybrid/PartFileConvert.h index c24959a2..cb31c78e 100644 --- a/srchybrid/PartFileConvert.h +++ b/srchybrid/PartFileConvert.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PartFileWriteThread.cpp b/srchybrid/PartFileWriteThread.cpp index 5375bc74..8f0cabc9 100644 --- a/srchybrid/PartFileWriteThread.cpp +++ b/srchybrid/PartFileWriteThread.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2020-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2020-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,8 +14,8 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" +#include #include "updownclient.h" #include "PartFileWriteThread.h" #include "emule.h" @@ -31,19 +31,25 @@ static char THIS_FILE[] = __FILE__; #endif +#define RUN_STOP 0 +#define RUN_IDLE 1 +#define RUN_WORK 2 +#define WAKEUP ((ULONG_PTR)(~0)) + IMPLEMENT_DYNCREATE(CPartFileWriteThread, CWinThread) CPartFileWriteThread::CPartFileWriteThread() : m_eventThreadEnded(FALSE, TRUE) , m_hPort() - , m_bRun() + , m_Run(RUN_STOP) + , m_bNewData() { AfxBeginThread(RunProc, (LPVOID)this, THREAD_PRIORITY_BELOW_NORMAL); } CPartFileWriteThread::~CPartFileWriteThread() { - ASSERT(!m_hPort && !m_bRun); + ASSERT(!m_hPort && !m_Run); } UINT AFX_CDECL CPartFileWriteThread::RunProc(LPVOID pParam) @@ -55,7 +61,7 @@ UINT AFX_CDECL CPartFileWriteThread::RunProc(LPVOID pParam) void CPartFileWriteThread::EndThread() { - m_bRun = false; + m_Run = RUN_STOP; PostQueuedCompletionStatus(m_hPort, 0, 0, NULL); m_eventThreadEnded.Lock(); } @@ -67,37 +73,39 @@ UINT CPartFileWriteThread::RunInternal() return ::GetLastError(); DWORD dwWrite = 0; - ULONG_PTR completionKey = 0; //pointer to CPartFile? + ULONG_PTR completionKey = 0; OverlappedWrite_Struct *pCurIO = NULL; - m_bRun = true; - while (m_bRun + m_Run = RUN_IDLE; + while (m_Run && ::GetQueuedCompletionStatus(m_hPort, &dwWrite, &completionKey, (LPOVERLAPPED*)&pCurIO, INFINITE) && completionKey) { + m_Run = RUN_WORK; //move buffer lists into the local storage if (!m_FlushList.IsEmpty()) { m_lockFlushList.Lock(); while (!m_FlushList.IsEmpty()) m_listToWrite.AddTail(m_FlushList.RemoveHead()); + InterlockedExchange8(&m_bNewData, 0); m_lockFlushList.Unlock(); } - - //write new buffers + //start new I/O WriteBuffers(); - //completed I/O do { if (!completionKey) break; - if (completionKey != (ULONG_PTR)(~0)) //wake up call + if (completionKey != WAKEUP) //ignore wakeups WriteCompletionRoutine(dwWrite, pCurIO); } while (::GetQueuedCompletionStatus(m_hPort, &dwWrite, &completionKey, (LPOVERLAPPED*)&pCurIO, 0)); - //thread termination - if (!completionKey) // && !dwRead && !pCurIO) + if (!completionKey) //thread termination break; + m_Run = RUN_IDLE; + if (InterlockedExchange8(&m_bNewData, 0) && m_listPendingIO.IsEmpty()) + PostQueuedCompletionStatus(m_hPort, 0, WAKEUP, NULL); } - m_bRun = false; + m_Run = RUN_STOP; //Improper termination of asynchronous I/O follows... //close file handles to release I/O completion port @@ -114,7 +122,7 @@ UINT CPartFileWriteThread::RunInternal() void CPartFileWriteThread::WriteBuffers() { //process internal list - while (!m_listToWrite.IsEmpty() && m_bRun) { + while (!m_listToWrite.IsEmpty() && m_Run) { const ToWrite &item = m_listToWrite.RemoveHead(); PartFileBufferedData *pBuffer = item.pBuffer; ASSERT(pBuffer->end >= pBuffer->start && (pBuffer->data || pBuffer->end == pBuffer->start)); //verifies allocation requests too @@ -160,7 +168,7 @@ void CPartFileWriteThread::WriteCompletionRoutine(DWORD dwBytesWritten, const Ov return; } CPartFile *pFile = pOvWrite->pFile; - if (m_bRun) { + if (m_Run) { PartFileBufferedData *pBuffer = pOvWrite->pBuffer; const DWORD dwWrite = (DWORD)(pBuffer->end - pBuffer->start + 1); @@ -191,17 +199,17 @@ void CPartFileWriteThread::WriteCompletionRoutine(DWORD dwBytesWritten, const Ov bool CPartFileWriteThread::AddFile(CPartFile *pFile) { - ASSERT(m_hPort && m_bRun); + ASSERT(m_hPort && m_Run); if (pFile && pFile->m_hWrite == INVALID_HANDLE_VALUE) { const CString sPartFile(RemoveFileExtension(pFile->GetFullName())); pFile->m_hWrite = ::CreateFile(sPartFile, GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (pFile->m_hWrite == INVALID_HANDLE_VALUE) { - DebugLogError(_T("Failed to open \"%s\" for overlapped write: %s"), (LPCTSTR)sPartFile, (LPCTSTR)GetErrorMessage(::GetLastError(), 1)); + theApp.QueueDebugLogLineEx(LOG_ERROR, _T("Failed to open \"%s\" for overlapped write: %s"), (LPCTSTR)sPartFile, (LPCTSTR)GetErrorMessage(::GetLastError(), 1)); pFile->SetStatus(PS_ERROR); return false; } if (m_hPort != ::CreateIoCompletionPort(pFile->m_hWrite, m_hPort, (ULONG_PTR)pFile, 0)) { - DebugLogError(_T("Failed to associate \"%s\" with IOCP: %s"), (LPCTSTR)sPartFile, (LPCTSTR)GetErrorMessage(::GetLastError(), 1)); + theApp.QueueDebugLogLineEx(LOG_ERROR, _T("Failed to associate \"%s\" with IOCP: %s"), (LPCTSTR)sPartFile, (LPCTSTR)GetErrorMessage(::GetLastError(), 1)); RemFile(pFile); pFile->SetStatus(PS_ERROR); return false; @@ -219,13 +227,11 @@ void CPartFileWriteThread::RemFile(CPartFile *pFile) } } -bool CPartFileWriteThread::IsRunning() -{ - return m_bRun; -} - void CPartFileWriteThread::WakeUpCall() { - if (m_bRun) - PostQueuedCompletionStatus(m_hPort, 0, (ULONG_PTR)(~0), NULL); + //pending I/O makes posting unnecessary + if (m_Run == RUN_IDLE && m_listPendingIO.IsEmpty()) + PostQueuedCompletionStatus(m_hPort, 0, WAKEUP, NULL); + else + InterlockedExchange8(&m_bNewData, 1); } \ No newline at end of file diff --git a/srchybrid/PartFileWriteThread.h b/srchybrid/PartFileWriteThread.h index 28f27ce3..b248a7ab 100644 --- a/srchybrid/PartFileWriteThread.h +++ b/srchybrid/PartFileWriteThread.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2020-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2020-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once struct PartFileBufferedData; @@ -45,7 +44,7 @@ class CPartFileWriteThread : public CWinThread void EndThread(); //completionkey == 0 void WakeUpCall(); //completionkey == -1 - bool IsRunning(); + bool IsRunning() const { return m_Run > 0; } bool AddFile(CPartFile *pFile); static void RemFile(CPartFile *pFile); @@ -64,5 +63,6 @@ class CPartFileWriteThread : public CWinThread CEvent m_eventThreadEnded; HANDLE m_hPort; - volatile bool m_bRun; + volatile char m_Run; //0 - not running; 1 - idle; 2 - processing + volatile char m_bNewData; }; \ No newline at end of file diff --git a/srchybrid/PeerCacheClient.cpp b/srchybrid/PeerCacheClient.cpp deleted file mode 100644 index b750b491..00000000 --- a/srchybrid/PeerCacheClient.cpp +++ /dev/null @@ -1,1025 +0,0 @@ -//this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) -// -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU General Public License -//as published by the Free Software Foundation; either -//version 2 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. -// -//You should have received a copy of the GNU General Public License -//along with this program; if not, write to the Free Software -//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#include "stdafx.h" -#include -#include "emule.h" -#include "UrlClient.h" -#include "PartFile.h" -#include "SafeFile.h" -#include "Statistics.h" -#include "Packets.h" -#include "ListenSocket.h" -#include "Preferences.h" -#include "OtherFunctions.h" -#include "SharedFileList.h" -#include "PeerCacheSocket.h" -#include "UploadBandwidthThrottler.h" -#include "PeerCacheFinder.h" -#include "UploadQueue.h" -#include "Log.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#define HTTP_STATUS_INV_RANGE 416 - -DWORD GetPeerCacheSocketUploadTimeout() -{ - return DOWNLOADTIMEOUT + SEC2MS(20 + 30); -} - -DWORD GetPeerCacheSocketDownloadTimeout() -{ - return DOWNLOADTIMEOUT + SEC2MS(20); // must be lower than Upload timeout -} - - -/////////////////////////////////////////////////////////////////////////////// -// CPeerCacheSocket - -IMPLEMENT_DYNCREATE(CPeerCacheSocket, CHttpClientReqSocket) - -CPeerCacheSocket::CPeerCacheSocket(CUpDownClient *pClient) -{ - ASSERT(client == NULL); - client = NULL; - m_client = pClient; -} - -CPeerCacheSocket::~CPeerCacheSocket() -{ - CPeerCacheSocket::DetachFromClient(); -} - -void CPeerCacheSocket::DetachFromClient() -{ - if (GetClient()) { - // fail safe, should never be needed - if (GetClient()->m_pPCDownSocket == this) { - ASSERT(0); - GetClient()->m_pPCDownSocket = NULL; - } - if (GetClient()->m_pPCUpSocket == this) { - ASSERT(0); - GetClient()->m_pPCUpSocket = NULL; - } - } -} - -void CPeerCacheSocket::Safe_Delete() -{ - DetachFromClient(); - CClientReqSocket::Safe_Delete(); - m_client = NULL; - ASSERT(GetClient() == NULL); - ASSERT(client == NULL); -} - -void CPeerCacheSocket::OnSend(int nErrorCode) -{ -// Debug("%08x %hs\n", this, __FUNCTION__); - // PC-TODO: We have to keep the ed2k connection of a client as long active as we are using - // the associated PeerCache connection -> Update the timeout of the ed2k socket. - if (nErrorCode == 0 && GetClient() && GetClient()->socket) - GetClient()->socket->ResetTimeOutTimer(); - CHttpClientReqSocket::OnSend(nErrorCode); -} - -void CPeerCacheSocket::OnReceive(int nErrorCode) -{ -// Debug("%08x %hs\n", this, __FUNCTION__); - // PC-TODO: We have to keep the ed2k connection of a client as long active as we are using - // the associated PeerCache connection -> Update the timeout of the ed2k socket. - if (nErrorCode == 0 && GetClient() && GetClient()->socket) - GetClient()->socket->ResetTimeOutTimer(); - CHttpClientReqSocket::OnReceive(nErrorCode); -} - -void CPeerCacheSocket::OnError(int nErrorCode) -{ - DEBUG_ONLY(Debug(_T("%08x %hs\n"), this, __FUNCTION__)); - CHttpClientReqSocket::OnError(nErrorCode); -} - -bool CPeerCacheSocket::ProcessHttpResponse() -{ - ASSERT(0); - return false; -} - -bool CPeerCacheSocket::ProcessHttpResponseBody(const BYTE* /*pucData*/, UINT /*size*/) -{ - ASSERT(0); - return false; -} - -bool CPeerCacheSocket::ProcessHttpRequest() -{ - ASSERT(0); - return false; -} - - -/////////////////////////////////////////////////////////////////////////////// -// CPeerCacheDownSocket - -IMPLEMENT_DYNCREATE(CPeerCacheDownSocket, CPeerCacheSocket) - -CPeerCacheDownSocket::CPeerCacheDownSocket(CUpDownClient *pClient) - : CPeerCacheSocket(pClient) -{ - DEBUG_ONLY(Debug(_T("%08x %hs\n"), this, __FUNCTION__)); -} - -CPeerCacheDownSocket::~CPeerCacheDownSocket() -{ - DEBUG_ONLY(Debug(_T("%08x %hs\n"), this, __FUNCTION__)); - CPeerCacheDownSocket::DetachFromClient(); -} - -void CPeerCacheDownSocket::DetachFromClient() -{ - if (GetClient()) { - if (GetClient()->m_pPCDownSocket == this) - GetClient()->m_pPCDownSocket = NULL; - } -} - -void CPeerCacheDownSocket::OnClose(int nErrorCode) -{ - DEBUG_ONLY(Debug(_T("%08x %hs\n"), this, __FUNCTION__)); - - DisableDownloadLimit(); // receive pending data - CUpDownClient *pCurClient = GetClient(); - if (pCurClient && pCurClient->m_pPCDownSocket != this) - pCurClient = NULL; - - CPeerCacheSocket::OnClose(nErrorCode); - - if (pCurClient) { - ASSERT(pCurClient->m_pPCDownSocket == NULL); - - // this callback is only invoked if that closed socket was(!) currently attached to the client - pCurClient->OnPeerCacheDownSocketClosed(nErrorCode); - } -} - -bool CPeerCacheDownSocket::ProcessHttpResponse() -{ - if (GetClient() == NULL) - throw CString(__FUNCTION__ " - No client attached to HTTP socket"); - - if (!GetClient()->ProcessPeerCacheDownHttpResponse(m_astrHttpHeaders)) - return false; - - return true; -} - -bool CPeerCacheDownSocket::ProcessHttpResponseBody(const BYTE *pucData, UINT uSize) -{ - if (GetClient() == NULL) - throw CString(__FUNCTION__ " - No client attached to HTTP socket"); - - GetClient()->ProcessPeerCacheDownHttpResponseBody(pucData, uSize); - - return true; -} - -bool CPeerCacheDownSocket::ProcessHttpRequest() -{ - throw CString(_T("Unexpected HTTP request received")); -} - - -/////////////////////////////////////////////////////////////////////////////// -// CPeerCacheUpSocket - -IMPLEMENT_DYNCREATE(CPeerCacheUpSocket, CPeerCacheSocket) - -CPeerCacheUpSocket::CPeerCacheUpSocket(CUpDownClient *pClient) - : CPeerCacheSocket(pClient) -{ - DEBUG_ONLY(Debug(_T("%08x %hs\n"), this, __FUNCTION__)); -} - -CPeerCacheUpSocket::~CPeerCacheUpSocket() -{ - DEBUG_ONLY(Debug(_T("%08x %hs\n"), this, __FUNCTION__)); - theApp.uploadBandwidthThrottler->RemoveFromAllQueues(this); - CPeerCacheUpSocket::DetachFromClient(); -} - -void CPeerCacheUpSocket::DetachFromClient() -{ - if (GetClient()) { - if (GetClient()->m_pPCUpSocket == this) { - GetClient()->m_pPCUpSocket = NULL; - theApp.uploadBandwidthThrottler->RemoveFromStandardList(this); - } - } -} - -void CPeerCacheUpSocket::OnSend(int nErrorCode) -{ - DEBUG_ONLY(Debug(_T("%08x %hs\n"), this, __FUNCTION__)); - CPeerCacheSocket::OnSend(nErrorCode); -} - -void CPeerCacheUpSocket::OnClose(int nErrorCode) -{ - DEBUG_ONLY(Debug(_T("%08x %hs\n"), this, __FUNCTION__)); - CPeerCacheSocket::OnClose(nErrorCode); - if (GetClient() && GetClient()->m_pPCUpSocket == this) { - DetachFromClient(); - - // this callback is only invoked if that closed socket was(!) currently attached to the client - //GetClient()->OnPeerCacheUpSocketClosed(nErrorCode); - } -} - -#pragma warning(push) -#pragma warning(disable: 4702) //unreachable code -bool CPeerCacheUpSocket::ProcessHttpResponse() -{ - if (GetClient() == NULL) - throw CString(__FUNCTION__ " - No client attached to HTTP socket"); - - GetClient()->ProcessPeerCacheUpHttpResponse(m_astrHttpHeaders); - - return true; -} -#pragma warning(pop) - -bool CPeerCacheUpSocket::ProcessHttpResponseBody(const BYTE* /*pucData*/, UINT /*uSize*/) -{ - throw CString(_T("Unexpected HTTP body in response received")); -} - -bool CPeerCacheUpSocket::ProcessHttpRequest() -{ - if (GetClient() == NULL) - throw CString(__FUNCTION__ " - No client attached to HTTP socket"); - - UINT uHttpRes = GetClient()->ProcessPeerCacheUpHttpRequest(m_astrHttpHeaders); - if (uHttpRes != HTTP_STATUS_OK) { - CStringA strResponse; - strResponse.Format("HTTP/1.0 %u\r\n" - "Content-Length: 0\r\n" - "\r\n" - , uHttpRes); - - if (thePrefs.GetDebugClientTCPLevel() > 0) - Debug(_T("Sending PeerCache HTTP response:\n%hs"), (LPCSTR)strResponse); - CRawPacket *pHttpPacket = new CRawPacket(strResponse); - theStats.AddUpDataOverheadFileRequest(pHttpPacket->size); - SendPacket(pHttpPacket); - SetHttpState(HttpStateUnknown); - - // PC-TODO: Problem, the packet which was queued for sending will not be sent, if we immediately - // close that socket. Currently I just let it timeout. - //return false; - SetTimeOut(SEC2MS(30)); - return true; - } - GetClient()->SetHttpSendState(0); - - SetHttpState(HttpStateRecvExpected); - GetClient()->SetUploadState(US_UPLOADING); - - return true; -} - - -/////////////////////////////////////////////////////////////////////////////// -// PeerCache client - -bool CUpDownClient::ProcessPeerCacheDownHttpResponse(const CStringAArray &astrHeaders) -{ - ASSERT(GetDownloadState() == DS_DOWNLOADING); - ASSERT(m_ePeerCacheDownState == PCDS_WAIT_CACHE_REPLY); - - if (m_reqfile == NULL) - throwCStr(_T("Failed to process HTTP response - No 'reqfile' attached")); - if (GetDownloadState() != DS_DOWNLOADING) - throwCStr(_T("Failed to process HTTP response - Invalid client download state")); - if (astrHeaders.IsEmpty()) - throwCStr(_T("Unexpected HTTP response - No headers available")); - - const CStringA &rstrHdr = astrHeaders[0]; - UINT uHttpMajVer, uHttpMinVer, uHttpStatusCode; - if (sscanf(rstrHdr, "HTTP/%u.%u %u", &uHttpMajVer, &uHttpMinVer, &uHttpStatusCode) != 3) { - CString strError; - strError.Format(_T("Unexpected HTTP response: \"%hs\""), (LPCSTR)rstrHdr); - throw strError; - } - if (uHttpMajVer != 1 || (uHttpMinVer != 0 && uHttpMinVer != 1)) { - CString strError; - strError.Format(_T("Unexpected HTTP version: \"%hs\""), (LPCSTR)rstrHdr); - throw strError; - } - if (uHttpStatusCode != HTTP_STATUS_OK && uHttpStatusCode != HTTP_STATUS_PARTIAL_CONTENT) { - CString strError; - strError.Format(_T("Unexpected HTTP status code \"%u\""), uHttpStatusCode); - throw strError; - } - - uint64 uContentLength = 0; - bool bCacheHit = false; - bool bValidContentRange = false; - for (int i = 1; i < astrHeaders.GetCount(); ++i) { - const CStringA &rstrHdr1(astrHeaders[i]); - if (_strnicmp(rstrHdr1, "Content-Length:", 15) == 0) { - uContentLength = _atoi64((LPCSTR)rstrHdr1 + 15); - if (uContentLength > m_uReqEnd - m_uReqStart + 1) { - CString strError; - strError.Format(_T("Unexpected HTTP header field \"%hs\""), (LPCSTR)rstrHdr1); - throw strError; - } - } else if (_strnicmp(rstrHdr1, "Content-Range:", 14) == 0) { - uint64 ui64Start = 0, ui64End = 0, ui64Len = 0; - if (sscanf((LPCSTR)rstrHdr1 + 14, " bytes %I64u - %I64u / %I64u", &ui64Start, &ui64End, &ui64Len) != 3) { - CString strError; - strError.Format(_T("Unexpected HTTP header field \"%hs\""), (LPCSTR)rstrHdr1); - throw strError; - } - - if (ui64Start > ui64End - || ui64Len != m_reqfile->GetFileSize() - || ui64Start < m_uReqStart || ui64Start > m_uReqEnd - || ui64End < m_uReqStart || ui64End > m_uReqEnd) - { - CString strError; - strError.Format(_T("Unexpected HTTP header field \"%hs\""), (LPCSTR)rstrHdr1); - throw strError; - } - bValidContentRange = true; - m_nUrlStartPos = ui64Start; - } else if (_strnicmp(rstrHdr1, "Server:", 7) == 0) { - if (m_strClientSoftware.IsEmpty()) - m_strClientSoftware = rstrHdr1.Mid(7).Trim(); - } else if (_strnicmp(rstrHdr1, "X-Cache: MISS", 13) == 0) - bCacheHit = false; - else if (_strnicmp(rstrHdr1, "X-Cache: HIT", 12) == 0) - bCacheHit = true; - } - - // we either get a 'Content-Range' or (for very small files) just a 'Content-Length' for the entire file - if (!bValidContentRange && uContentLength == m_reqfile->GetFileSize()) { - bValidContentRange = true; - m_nUrlStartPos = 0; - } - - if (!bValidContentRange) { - if (thePrefs.GetDebugClientTCPLevel() <= 0) - DebugHttpHeaders(astrHeaders); - CString strError; - strError.Format(_T("Unexpected HTTP response - No valid HTTP content range found")); - throw strError; - } - - if (m_pPCDownSocket) { - CSafeMemFile dataAck(128); - dataAck.WriteUInt8(static_cast(bCacheHit)); - if (thePrefs.GetDebugClientTCPLevel() > 0) { - DebugSend("OP_PeerCacheAck", this, m_reqfile->GetFileHash()); - Debug(_T(" %s\n"), bCacheHit ? _T("CacheHit") : _T("CacheMiss")); - } - - Packet *pEd2kPacket = new Packet(dataAck, OP_EMULEPROT, OP_PEERCACHE_ACK); - theStats.AddUpDataOverheadFileRequest(pEd2kPacket->size); - socket->SendPacket(pEd2kPacket); - } - -// SetDownloadState(DS_DOWNLOADING); - - //PC-TODO: Where does this flag need to be cleared again? - // When client is allowed to send more block requests? - // Also, we have to support both type of downloads within in the same connection. - SetPeerCacheDownState(PCDS_DOWNLOADING); - m_bPeerCacheDownHit = bCacheHit; - - return true; -} - -bool CUpDownClient::ProcessPeerCacheDownHttpResponseBody(const BYTE *pucData, UINT uSize) -{ - ProcessHttpBlockPacket(pucData, uSize); - return true; -} - -UINT CUpDownClient::ProcessPeerCacheUpHttpRequest(const CStringAArray &astrHeaders) -{ - ASSERT(m_ePeerCacheUpState == PCUS_WAIT_CACHE_REPLY); - - if (astrHeaders.IsEmpty()) - return HTTP_STATUS_BAD_REQUEST; - - const CStringA &rstrHdr = astrHeaders[0]; - char szUrl[1024]; - UINT uHttpMajVer, uHttpMinVer; - if (sscanf(rstrHdr, "GET %1023s HTTP/%u.%u", szUrl, &uHttpMajVer, &uHttpMinVer) != 3) { - DebugHttpHeaders(astrHeaders); - return HTTP_STATUS_BAD_REQUEST; - } - if (uHttpMajVer != 1 || (uHttpMinVer != 0 && uHttpMinVer != 1)) { - DebugHttpHeaders(astrHeaders); - return HTTP_STATUS_BAD_REQUEST; - } - - char szFileHash[33]; - if (sscanf(szUrl, "/.ed2khash=%32s", szFileHash) != 1) { - DebugHttpHeaders(astrHeaders); - return HTTP_STATUS_BAD_REQUEST; - } - uchar aucUploadFileID[MDX_DIGEST_SIZE]; - if (!strmd4(szFileHash, aucUploadFileID)) { - DebugHttpHeaders(astrHeaders); - return HTTP_STATUS_BAD_REQUEST; - } - - CKnownFile *pUploadFile = theApp.sharedfiles->GetFileByID(aucUploadFileID); - if (pUploadFile == NULL) { - DebugHttpHeaders(astrHeaders); - return HTTP_STATUS_NOT_FOUND; - } - - bool bValidRange = false; - uint64 ui64RangeStart = 0; - uint64 ui64RangeEnd = 0; - DWORD dwPushID = 0; - for (int i = 1; i < astrHeaders.GetCount(); ++i) { - const CStringA &rstrHdr2(astrHeaders[i]); - if (_strnicmp(rstrHdr2, "Range:", 6) == 0) { - int iParams; - if ((iParams = sscanf((LPCSTR)rstrHdr2 + 6, " bytes = %I64u - %I64u", &ui64RangeStart, &ui64RangeEnd)) != 2 - && (iParams = sscanf((LPCSTR)rstrHdr2 + 6, " bytes = %I64u -", &ui64RangeStart)) != 1) - { - DebugHttpHeaders(astrHeaders); - TRACE("*** Unexpected HTTP %hs\n", (LPCSTR)rstrHdr2); - return HTTP_STATUS_BAD_REQUEST; - } - if (iParams == 1) - ui64RangeEnd = pUploadFile->GetFileSize() - (uint64)1; - - if (ui64RangeEnd < ui64RangeStart) { - DebugHttpHeaders(astrHeaders); - TRACE("*** Unexpected HTTP %hs\n", (LPCSTR)rstrHdr2); - return HTTP_STATUS_INV_RANGE; - } - - bValidRange = true; - } else if (_strnicmp(rstrHdr2, "X-ED2K-PushId:", 14) == 0) - if (sscanf((LPCSTR)rstrHdr2 + 14, "%lu", &dwPushID) != 1) { - DebugHttpHeaders(astrHeaders); - TRACE("*** Unexpected HTTP %hs\n", (LPCSTR)rstrHdr2); - return HTTP_STATUS_BAD_REQUEST; - } - - } - - if (!bValidRange) { - DebugHttpHeaders(astrHeaders); - return HTTP_STATUS_LENGTH_REQUIRED; - } - - m_uPeerCacheUploadPushId = dwPushID; - - //PC-TODO: Where does this flag need to be cleared again? - // When client is removed from uploading list? - // When client is allowed to send more block requests? - - // everything is setup for uploading with PeerCache. - SetPeerCacheUpState(PCUS_UPLOADING); - - Requested_Block_Struct *reqblock = new Requested_Block_Struct; - reqblock->StartOffset = ui64RangeStart; - reqblock->EndOffset = ui64RangeEnd + 1; - md4cpy(reqblock->FileID, aucUploadFileID); - reqblock->transferred = 0; - AddReqBlock(reqblock, true); - - return HTTP_STATUS_OK; -} - -void CUpDownClient::ProcessPeerCacheUpHttpResponse(const CStringAArray &astrHeaders) -{ - ASSERT(m_ePeerCacheUpState == PCUS_WAIT_CACHE_REPLY); - - if (astrHeaders.IsEmpty()) - throwCStr(_T("Unexpected HTTP response - No headers available")); - - const CStringA &rstrHdr(astrHeaders[0]); - UINT uHttpMajVer, uHttpMinVer, uHttpStatusCode; - if (sscanf(rstrHdr, "HTTP/%u.%u %u", &uHttpMajVer, &uHttpMinVer, &uHttpStatusCode) != 3) { - CString strError; - strError.Format(_T("Unexpected HTTP response: \"%hs\""), (LPCSTR)rstrHdr); - throw strError; - } - if (uHttpMajVer != 1 || (uHttpMinVer != 0 && uHttpMinVer != 1)) { - CString strError; - strError.Format(_T("Unexpected HTTP version: \"%hs\""), (LPCSTR)rstrHdr); - throw strError; - } - - CString strError; - strError.Format(_T("Unexpected HTTP status code \"%u\""), uHttpStatusCode); - throw strError; -} - -bool CUpDownClient::SendHttpBlockRequests() -{ - ASSERT(GetDownloadState() == DS_DOWNLOADING); - ASSERT(m_ePeerCacheDownState == PCDS_WAIT_CLIENT_REPLY || m_ePeerCacheDownState == PCDS_DOWNLOADING); - - m_bPeerCacheDownHit = false; - m_dwLastBlockReceived = ::GetTickCount(); - if (m_reqfile == NULL) - throwCStr(_T("Failed to send block requests - No 'reqfile' attached")); - - CreateBlockRequests(1); - if (m_PendingBlocks_list.IsEmpty()) { - if (m_pPCDownSocket != NULL) { - m_pPCDownSocket->Safe_Delete(); - ASSERT(m_pPCDownSocket == NULL); - SetPeerCacheDownState(PCDS_NONE); - } - SetDownloadState(DS_NONEEDEDPARTS); - SwapToAnotherFile(_T("A4AF for NNP file. CUpDownClient::SendHttpBlockRequests()"), true, false, false, NULL, true, true); - return false; - } - - // PeerCache does not support persistent HTTP connections - if (m_pPCDownSocket != NULL) { - m_pPCDownSocket->Safe_Delete(); - ASSERT(m_pPCDownSocket == NULL); - SetPeerCacheDownState(PCDS_NONE); - return SendPeerCacheFileRequest(); - } - - ASSERT(m_pPCDownSocket == NULL); - m_pPCDownSocket = new CPeerCacheDownSocket(this); - m_pPCDownSocket->SetTimeOut(GetPeerCacheSocketDownloadTimeout()); - if (!m_pPCDownSocket->Create()) { - m_pPCDownSocket->Safe_Delete(); - ASSERT(m_pPCDownSocket == NULL); - return false; - } - - ASSERT(!m_pPCDownSocket->IsConnected()); - SOCKADDR_IN sockAddr = {}; - sockAddr.sin_family = AF_INET; - sockAddr.sin_port = htons(theApp.m_pPeerCache->GetCachePort()); - sockAddr.sin_addr.s_addr = theApp.m_pPeerCache->GetCacheIP(); - //Try to always tell the socket to WaitForOnConnect before you call Connect. - m_pPCDownSocket->WaitForOnConnect(); - m_pPCDownSocket->Connect((LPSOCKADDR)&sockAddr, sizeof sockAddr); - - Pending_Block_Struct *pending = m_PendingBlocks_list.GetHead(); - ASSERT(pending->block->StartOffset <= pending->block->EndOffset); - - m_uReqStart = pending->block->StartOffset; - m_uReqEnd = pending->block->EndOffset; - m_nUrlStartPos = _UI64_MAX; - - CStringA strPCRequest; - strPCRequest.Format("GET http://%s/.ed2khash=%S HTTP/1.0\r\n" - "X-ED2K-PushId: %u\r\n" - "Range: bytes=%I64u-%I64u\r\n" - "User-Agent: eMule/%S\r\n" - "X-Network: eDonkey,Kademlia\r\n" - "\r\n" - , (LPCSTR)ipstrA(m_uPeerCacheRemoteIP), (LPCTSTR)md4str(m_reqfile->GetFileHash()) - , m_uPeerCacheDownloadPushId - , m_uReqStart, m_uReqEnd - , (LPCTSTR)theApp.m_strCurVersionLong); - - if (thePrefs.GetDebugClientTCPLevel() > 0) { - DebugSend("PeerCache-GET", this, m_reqfile->GetFileHash()); - Debug(_T(" %hs\n"), (LPCSTR)strPCRequest); - } - CRawPacket *pHttpPacket = new CRawPacket(strPCRequest); - theStats.AddUpDataOverheadFileRequest(pHttpPacket->size); - m_pPCDownSocket->SendPacket(pHttpPacket); - m_pPCDownSocket->SetHttpState(HttpStateRecvExpected); - SetPeerCacheDownState(PCDS_WAIT_CACHE_REPLY); - return true; -} - -bool CUpDownClient::SendPeerCacheFileRequest() -{ - if (GetDownloadState() == DS_ONQUEUE) { - ASSERT(m_ePeerCacheDownState == PCDS_NONE); - ASSERT(m_pPCDownSocket == NULL); - } else if (GetDownloadState() == DS_DOWNLOADING) { - ASSERT(m_ePeerCacheDownState == PCDS_NONE); - ASSERT(m_pPCDownSocket == NULL); - } else - ASSERT(0); - - if (!SupportPeerCache() || socket == NULL) { - ASSERT(0); - return false; - } - - m_uPeerCacheDownloadPushId = GetRandomUInt32(); - - CSafeMemFile data(128); - data.WriteUInt8(PCPCK_VERSION); - data.WriteUInt8(PCOP_REQ); - data.WriteUInt8(5); - CTag tagCacheIP(PCTAG_CACHEIP, theApp.m_pPeerCache->GetCacheIP()); - tagCacheIP.WriteNewEd2kTag(data); - CTag tagPushId(PCTAG_PUSHID, m_uPeerCacheDownloadPushId); - tagPushId.WriteNewEd2kTag(data); - CTag tagFileId(PCTAG_FILEID, (uchar*)m_reqfile->GetFileHash()); - tagFileId.WriteNewEd2kTag(data); - CTag tagPublicIP(PCTAG_PUBLICIP, theApp.GetPublicIP()); - tagPublicIP.WriteNewEd2kTag(data); - CTag tagCachePort(PCTAG_CACHEPORT, theApp.m_pPeerCache->GetCachePort()); - tagCachePort.WriteNewEd2kTag(data); - - if (thePrefs.GetDebugClientTCPLevel() > 0) { - DebugSend("OP_PeerCacheQuery", this, m_reqfile->GetFileHash()); - Debug(_T(" CacheIP=%s PushId=%u PublicIP=%s FileId=%s\n"), (LPCTSTR)ipstr(tagCacheIP.GetInt()), tagPushId.GetInt(), (LPCTSTR)ipstr(tagPublicIP.GetInt()), (LPCTSTR)md4str(tagFileId.GetHash())); - } - - Packet *pEd2kPacket = new Packet(data, OP_EMULEPROT, OP_PEERCACHE_QUERY); - theStats.AddUpDataOverheadFileRequest(pEd2kPacket->size); - socket->SendPacket(pEd2kPacket); - SetDownloadState(DS_DOWNLOADING); - m_dwLastBlockReceived = ::GetTickCount(); - SetPeerCacheDownState(PCDS_WAIT_CLIENT_REPLY); - return true; -} - -bool CUpDownClient::ProcessPeerCacheQuery(const uchar *packet, UINT size) -{ - const bool bDebug = (thePrefs.GetDebugClientTCPLevel() > 0); - if (bDebug) - DebugRecv("OP_PeerCacheQuery", this); - - if (socket == NULL) { - ASSERT(0); - return false; - } - - CSafeMemFile dataRecv(packet, size); - uint8 uPCVersion = dataRecv.ReadUInt8(); - if (uPCVersion != PCPCK_VERSION) { - if (bDebug) - Debug(_T(" ***Invalid packet version: 0x%02x\n"), uPCVersion); - ASSERT(0); - return false; - } - uint8 uPCOpcode = dataRecv.ReadUInt8(); - if (uPCOpcode != PCOP_REQ) { - if (bDebug) - Debug(_T(" ***Invalid packet opcode: 0x%02x\n"), uPCOpcode); - ASSERT(0); - return false; - } - - uchar aucFileHash[MDX_DIGEST_SIZE] = {}; - uint32 uPushId = 0; - uint32 uCacheIP = 0; - uint16 uCachePort = 0; - - CString strInfo; - for (UINT uTags = dataRecv.ReadUInt8(); uTags > 0; --uTags) { - CTag tag(dataRecv, GetUnicodeSupport() != UTF8strNone); - if (tag.GetNameID() == PCTAG_CACHEIP && tag.IsInt()) { - uCacheIP = tag.GetInt(); - if (bDebug) - strInfo.AppendFormat(_T(" CacheIP=%s"), (LPCTSTR)ipstr(uCacheIP)); - } else if (tag.GetNameID() == PCTAG_CACHEPORT && tag.IsInt()) { - uCachePort = (uint16)tag.GetInt(); - if (bDebug) - strInfo.AppendFormat(_T(" CachePort=%u"), uCachePort); - } else if (tag.GetNameID() == PCTAG_PUSHID && tag.IsInt()) { - uPushId = tag.GetInt(); - if (bDebug) - strInfo.AppendFormat(_T(" PushId=%u"), uPushId); - } else if (tag.GetNameID() == PCTAG_FILEID && tag.IsHash() && tag.GetHash() != NULL) { - md4cpy(aucFileHash, tag.GetHash()); - if (bDebug) - strInfo.AppendFormat(_T(" FileId=%s"), (LPCTSTR)md4str(aucFileHash)); - } else if (tag.GetNameID() == PCTAG_PUBLICIP && tag.IsInt()) { - if (bDebug) { - uint32 uPublicIP = tag.GetInt(); - strInfo.AppendFormat(_T(" PublicIP=%s"), (LPCTSTR)ipstr(uPublicIP)); - } - } else { - if (bDebug) - strInfo.AppendFormat(_T(" ***UnkTag: %s"), (LPCTSTR)tag.GetFullInfo()); - ASSERT(0); - } - } - - if (bDebug) { - if (dataRecv.GetPosition() < dataRecv.GetLength()) - strInfo.AppendFormat(_T(" ***AddData: %u bytes"), (UINT)(dataRecv.GetLength() - dataRecv.GetPosition())); - Debug(_T("%s\n"), (LPCTSTR)strInfo); - } - - if (uCacheIP == 0 || uCachePort == 0 || uPushId == 0 || isnulmd4(aucFileHash)) { - if (thePrefs.GetVerbose()) - AddDebugLogLine(false, _T("Invalid PeerCacheQuery; %s"), (LPCTSTR)DbgGetClientInfo()); - return false; - } - - CKnownFile *pUploadFile = theApp.sharedfiles->GetFileByID(aucFileHash); - if (pUploadFile == NULL) { - if (thePrefs.GetVerbose()) - AddDebugLogLine(false, _T("PeerCacheQuery reqfile does not match ed2k reqfile; %s"), (LPCTSTR)DbgGetClientInfo()); - return false; - } - - if (m_pPCUpSocket != NULL) { - SetPeerCacheUpState(PCUS_NONE); - m_pPCUpSocket->Safe_Delete(); - ASSERT(m_pPCUpSocket == NULL); - } - m_pPCUpSocket = new CPeerCacheUpSocket(this); - m_pPCUpSocket->SetTimeOut(GetPeerCacheSocketUploadTimeout()); - m_pPCUpSocket->Create(); - - SOCKADDR_IN sockAddr = {}; - sockAddr.sin_family = AF_INET; - sockAddr.sin_port = htons(uCachePort); - sockAddr.sin_addr.s_addr = uCacheIP; - //Try to always tell the socket to WaitForOnConnect before you call Connect. - m_pPCUpSocket->WaitForOnConnect(); - m_pPCUpSocket->Connect((LPSOCKADDR)&sockAddr, sizeof sockAddr); - - CStringA strPCRequest; - strPCRequest.Format("GIVE %u\r\n", uPushId); - - if (thePrefs.GetDebugClientTCPLevel() > 0) { - DebugSend("PeerCache-GIVE", this, pUploadFile->GetFileHash()); - Debug(_T(" %hs\n"), (LPCSTR)strPCRequest); - } - - CRawPacket *pHttpPacket = new CRawPacket(strPCRequest); - theStats.AddUpDataOverheadFileRequest(pHttpPacket->size); - m_pPCUpSocket->SendPacket(pHttpPacket); - m_pPCUpSocket->SetHttpState(HttpStateRecvExpected); - m_bPeerCacheUpHit = false; - SetPeerCacheUpState(PCUS_WAIT_CACHE_REPLY); - //theApp.uploadBandwidthThrottler->AddToStandardList(0, m_pPCUpSocket); - - CSafeMemFile dataSend(128); - dataSend.WriteUInt8(PCPCK_VERSION); - dataSend.WriteUInt8(PCOP_RES); - dataSend.WriteUInt8(3); - CTag tagPushId(PCTAG_PUSHID, uPushId); - tagPushId.WriteNewEd2kTag(dataSend); - CTag tagPublicIP(PCTAG_PUBLICIP, theApp.GetPublicIP()); - tagPublicIP.WriteNewEd2kTag(dataSend); - CTag tagFileId(PCTAG_FILEID, (BYTE*)aucFileHash); - tagFileId.WriteNewEd2kTag(dataSend); - - if (thePrefs.GetDebugClientTCPLevel() > 0) { - DebugSend("OP_PeerCacheAnswer", this, aucFileHash); - Debug(_T(" PushId=%u PublicIP=%s FileId=%s\n"), tagPushId.GetInt(), (LPCTSTR)ipstr(tagPublicIP.GetInt()), (LPCTSTR)md4str(tagFileId.GetHash())); - } - - Packet *pEd2kPacket = new Packet(dataSend, OP_EMULEPROT, OP_PEERCACHE_ANSWER); - theStats.AddUpDataOverheadFileRequest(pEd2kPacket->size); - socket->SendPacket(pEd2kPacket); - return true; -} - -bool CUpDownClient::ProcessPeerCacheAnswer(const uchar *packet, UINT size) -{ - const bool bDebug = (thePrefs.GetDebugClientTCPLevel() > 0); - ASSERT(GetDownloadState() == DS_DOWNLOADING); - ASSERT(m_ePeerCacheDownState == PCDS_WAIT_CLIENT_REPLY); - - if (bDebug) - DebugRecv("OP_PeerCacheAnswer", this); - - if (socket == NULL || m_reqfile == NULL) { - ASSERT(0); - return false; - } - - CSafeMemFile dataRecv(packet, size); - uint8 uPCVersion = dataRecv.ReadUInt8(); - if (uPCVersion != PCPCK_VERSION) { - if (bDebug) - Debug(_T(" ***Invalid packet version: 0x%02x\n"), uPCVersion); - ASSERT(0); - return false; - } - uint8 uPCOpcode = dataRecv.ReadUInt8(); - if (uPCOpcode == PCOP_NONE) { - if (thePrefs.GetVerbose()) - AddDebugLogLine(false, _T("Client does not support PeerCache; %s"), (LPCTSTR)DbgGetClientInfo()); - return false; - } - if (uPCOpcode != PCOP_RES) { - if (bDebug) - Debug(_T(" ***Invalid packet opcode: 0x%02x\n"), uPCOpcode); - ASSERT(0); - return false; - } - - uchar aucFileHash[MDX_DIGEST_SIZE] = {}; - uint32 uPushId = 0; - uint32 uRemoteIP = 0; - - CString strInfo; - for (UINT uTags = dataRecv.ReadUInt8(); uTags > 0; --uTags) { - CTag tag(dataRecv, GetUnicodeSupport() != UTF8strNone); - if (tag.GetNameID() == PCTAG_PUSHID && tag.IsInt()) { - uPushId = tag.GetInt(); - if (bDebug) - strInfo.AppendFormat(_T(" PushId=%u"), uPushId); - } else if (tag.GetNameID() == PCTAG_PUBLICIP && tag.IsInt()) { - uRemoteIP = tag.GetInt(); - if (bDebug) - strInfo.AppendFormat(_T(" RemoteIP=%s"), (LPCTSTR)ipstr(uRemoteIP)); - } else if (tag.GetNameID() == PCTAG_FILEID && tag.IsHash() && tag.GetHash() != NULL) { - md4cpy(aucFileHash, tag.GetHash()); - if (bDebug) - strInfo.AppendFormat(_T(" FileId=%s"), (LPCTSTR)md4str(aucFileHash)); - } else { - if (bDebug) - strInfo.AppendFormat(_T(" ***UnkTag: %s"), (LPCTSTR)tag.GetFullInfo()); - ASSERT(0); - } - } - - if (bDebug) { - if (dataRecv.GetPosition() < dataRecv.GetLength()) - strInfo.AppendFormat(_T(" ***AddData: %u bytes"), (UINT)(dataRecv.GetLength() - dataRecv.GetPosition())); - Debug(_T("%s\n"), (LPCTSTR)strInfo); - } - - if (uPushId == 0 || uRemoteIP == 0 || isnulmd4(aucFileHash)) { - if (thePrefs.GetVerbose()) - AddDebugLogLine(false, _T("Invalid PeerCacheAnswer; %s"), (LPCTSTR)DbgGetClientInfo()); - return false; - } - - if (!md4equ(aucFileHash, m_reqfile->GetFileHash())) { - if (thePrefs.GetVerbose()) - AddDebugLogLine(false, _T("PeerCacheAnswer reqfile does not match ed2k reqfile; %s"), (LPCTSTR)DbgGetClientInfo()); - return false; - } - - m_uPeerCacheDownloadPushId = uPushId; - m_uPeerCacheRemoteIP = uRemoteIP; - - if (!SendHttpBlockRequests()) - return false; - - theApp.m_pPeerCache->DownloadAttemptStarted(); - ASSERT(m_ePeerCacheDownState == PCDS_WAIT_CACHE_REPLY); - return true; -} - -bool CUpDownClient::ProcessPeerCacheAcknowledge(const uchar *packet, UINT size) -{ - const bool bDebug = (thePrefs.GetDebugClientTCPLevel() > 0); - if (bDebug) - DebugRecv("OP_PeerCacheAck", this); - - if (socket == NULL) { - ASSERT(0); - return false; - } - - m_bPeerCacheUpHit = false; - CSafeMemFile data(packet, size); - UINT uAck = data.ReadUInt8(); - if (uAck == 1) { - // Cache hit - if (bDebug) - Debug(_T(" Cache hit\n")); - - // PC-TODO: If this socket is closed, PeerCache also closes the socket which it had opened to the - // remote client! So, to give the remote client a chance to receive all the data from the PeerCache, - // we have to keep this socket open, although it's not needed nor could it be reused! - if (m_pPCUpSocket == NULL) { - if (thePrefs.GetVerbose()) - DebugLogError(_T("PeerCacheAck received - missing socket; %s"), (LPCTSTR)DbgGetClientInfo()); - ASSERT(0); - return false; - } -// m_pPCUpSocket->Safe_Delete(); -// m_pPCUpSocket = NULL; - m_pPCUpSocket->SetTimeOut(MIN2MS(60)); // set socket timeout to 1 hour ?? - m_bPeerCacheUpHit = true; - } else if (uAck == 0) { - // Cache miss, keep uploading - if (bDebug) - Debug(_T(" Cache miss\n")); - } else { - ASSERT(0); - return false; - } - - // PC-TODO: Since we can not close the PC socket, what exactly do we need this ACK-packet for? - ; - - UpdateDisplayedInfo(); - - return true; -} - -bool CUpDownClient::IsUploadingToPeerCache() const -{ - // this function should not check any socket ptrs, as the according sockets may already be closed/deleted - return m_ePeerCacheUpState == PCUS_UPLOADING; -} - -bool CUpDownClient::IsDownloadingFromPeerCache() const -{ - // this function should not check any socket ptrs, as the according sockets may already be closed/deleted - return m_ePeerCacheDownState == PCDS_DOWNLOADING; -} - -void CUpDownClient::OnPeerCacheDownSocketClosed(int nErrorCode) -{ - if (nErrorCode) - return; - - // restart PC download if cache just closed the connection without obvious reason - if (GetDownloadState() == DS_DOWNLOADING - && m_ePeerCacheDownState == PCDS_DOWNLOADING - && !m_PendingBlocks_list.IsEmpty()) - { - if (thePrefs.GetVerbose()) - AddDebugLogLine(DLP_HIGH, false, _T("PeerCache: Socket closed unexpectedly, trying to reestablish connection")); - theApp.m_pPeerCache->DownloadAttemptFailed(); - TRACE("+++ Restarting PeerCache download - socket closed\n"); - ASSERT(m_pPCDownSocket == NULL); - SetPeerCacheDownState(PCDS_NONE); - ClearDownloadBlockRequests(); - SendPeerCacheFileRequest(); - } -} - -bool CUpDownClient::OnPeerCacheDownSocketTimeout() -{ - // restart PC download if cache just stalls - if (GetDownloadState() != DS_DOWNLOADING || m_ePeerCacheDownState != PCDS_DOWNLOADING - || m_PendingBlocks_list.IsEmpty()) - return false; - - if (thePrefs.GetVerbose()) - AddDebugLogLine(DLP_HIGH, false, _T("PeerCache Error: Socket TimeOut, trying to reestablish connection")); - theApp.m_pPeerCache->DownloadAttemptFailed(); - TRACE("+++ Restarting PeerCache download - socket timeout\n"); - if (m_pPCDownSocket) { - m_pPCDownSocket->Safe_Delete(); - ASSERT(m_pPCDownSocket == NULL); - } - SetPeerCacheDownState(PCDS_NONE); - ClearDownloadBlockRequests(); - return SendPeerCacheFileRequest(); -} - -void CUpDownClient::SetPeerCacheDownState(EPeerCacheDownState eState) -{ - if (m_ePeerCacheDownState != eState) { - m_ePeerCacheDownState = eState; - if (m_ePeerCacheDownState == PCDS_NONE) - m_bPeerCacheDownHit = false; - UpdateDisplayedInfo(); - } -} - -void CUpDownClient::SetPeerCacheUpState(EPeerCacheUpState eState) -{ - if (m_ePeerCacheUpState != eState) { - //if (thePrefs.GetVerbose()) - //AddDebugLogLine(false, _T(" %s changed PeercacheState to %i"), (LPCTSTR)DbgGetClientInfo(), eState); - - m_ePeerCacheUpState = eState; - if (m_ePeerCacheUpState == PCUS_NONE) - m_bPeerCacheUpHit = false; - - theApp.uploadqueue->ReSortUploadSlots(true); - - UpdateDisplayedInfo(); - } -} \ No newline at end of file diff --git a/srchybrid/PeerCacheFinder.cpp b/srchybrid/PeerCacheFinder.cpp deleted file mode 100644 index d06ee275..00000000 --- a/srchybrid/PeerCacheFinder.cpp +++ /dev/null @@ -1,691 +0,0 @@ -//this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) -// -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU General Public License -//as published by the Free Software Foundation; either -//version 2 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. -// -//You should have received a copy of the GNU General Public License -//along with this program; if not, write to the Free Software -#include "StdAfx.h" -#include "peercachefinder.h" -#include "emule.h" -#include "emuledlg.h" -#include "otherfunctions.h" -#include "Preferences.h" -#include "opcodes.h" -#include "md5sum.h" -#include "Log.h" -#include "UserMsgs.h" -#include "cryptopp/rsa.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - - -#define PCBASELOCATION "edcache.p2p." -#define RETRYDAYS 2 -#define SIGNATURELENGTH 256 - -static char s_acDNSBuffer[MAXGETHOSTSTRUCT]; - -static const uint16 anPeerCachePorts[3] = {4662, 1214, 80}; - -static const uchar achVerify_Key[256] = { - 0xCE, 0x9A, 0x90, 0x08, 0x47, 0xE7, 0x1E, 0x15, 0x94, 0xFD, 0x65, 0xC7, 0x82, 0xF9, 0xB2, - 0xB7, 0xB7, 0x6A, 0xF2, 0x4A, 0x31, 0x08, 0xFC, 0x36, 0x6C, 0xB1, 0xD9, 0x3F, 0x3B, 0x94, 0x6B, - 0xC4, 0x55, 0x39, 0xAF, 0x53, 0x4D, 0x78, 0xE7, 0x1A, 0xE9, 0x83, 0x34, 0x1D, 0x6C, 0xE3, 0xEF, - 0xAD, 0x56, 0x88, 0x0D, 0x38, 0x94, 0x86, 0x0F, 0x81, 0x7C, 0x9C, 0x21, 0xCF, 0x49, 0xDA, 0xE8, - 0x13, 0x38, 0x30, 0x88, 0xBD, 0x6A, 0xCE, 0x66, 0x4C, 0xB0, 0x36, 0x3E, 0x43, 0x0B, 0x74, 0x1F, - 0xCC, 0xA8, 0xB6, 0x7A, 0xC9, 0xEE, 0x45, 0xBD, 0xB6, 0x2C, 0x55, 0xA7, 0x8E, 0x20, 0x65, 0x60, - 0x54, 0x0B, 0xBF, 0x68, 0x99, 0x4B, 0x30, 0x69, 0x16, 0xF7, 0xB7, 0x6E, 0xFC, 0x4E, 0x4B, 0x4F, - 0xD8, 0x28, 0x56, 0x4E, 0xC2, 0xCE, 0x91, 0x0C, 0x74, 0xFB, 0xAE, 0x79, 0xAB, 0x86, 0x03, 0xEA, - 0x35, 0x92, 0xB1, 0x10, 0x4B, 0x7F, 0xF2, 0xA9, 0x39, 0x56, 0xDB, 0xFF, 0x83, 0x5E, 0x44, 0x8F, - 0xF2, 0x41, 0x61, 0x62, 0x74, 0x36, 0xB3, 0xCF, 0x3E, 0xE5, 0xAC, 0x0B, 0x04, 0x1B, 0x2B, 0x59, - 0x81, 0x8A, 0xFC, 0x80, 0xC5, 0x4B, 0x36, 0x2E, 0x5F, 0xD0, 0xD3, 0x66, 0x7B, 0x40, 0xD3, 0x82, - 0x57, 0xF7, 0xA5, 0x05, 0x8D, 0xA9, 0xC9, 0xEE, 0xA8, 0x5F, 0x82, 0x5F, 0xD5, 0x4B, 0xBB, 0x00, - 0x4D, 0xA3, 0xD8, 0x72, 0x48, 0x84, 0xC0, 0x4B, 0x59, 0x6E, 0xDC, 0x49, 0xCF, 0x00, 0xDD, 0x7C, - 0xF8, 0xB7, 0xAC, 0x7A, 0xD8, 0x43, 0x6F, 0xA4, 0x21, 0x51, 0x93, 0xDF, 0x58, 0x9A, 0xC1, 0xC7, - 0x77, 0x45, 0xD7, 0xBE, 0x9B, 0x55, 0x0F, 0x2E, 0xC9, 0xD5, 0x85, 0x8F, 0xB5, 0xF9, 0xF0, 0x49, - 0xF6, 0x85, 0x24, 0x7A, 0xA8, 0x74, 0x64, 0xB1, 0x8B, 0x71, 0x63, 0xFC, 0x1F, 0x1B, 0x5E, 0x26, - 0xF5 -}; - -CPeerCacheFinder::CPeerCacheFinder() - : m_PCStatus(PCS_NOINIT) - , m_PCLUState(LUS_NONE) - , m_dwPCIP() - , m_dwMyIP() - , m_nDownloadAttempts() - , m_nFailedDownloads() - , m_posCurrentLookUp() - , m_nPCPort() - , m_bValidated() - , m_bNotReSearched() - , m_bNotReValdited() -{ -} - -void CPeerCacheFinder::Save() -{ - if (m_PCStatus > 10) { // permanent error range - if (!m_bNotReSearched) { - struct tm tmTemp; - thePrefs.SetPeerCacheLastSearch(mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp))); - thePrefs.SetPeerCacheWasFound(false); - thePrefs.SetPeerCachePort(0); - } - } else if (m_PCStatus == PCS_READY) { - if (!m_bNotReValdited) { - struct tm tmTemp; - thePrefs.SetPeerCacheLastSearch(mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp))); - } - thePrefs.SetPeerCachePort(m_nPCPort); - thePrefs.SetPeerCacheWasFound(true); - } -} - -void CPeerCacheFinder::Init(time_t dwLastSearch, bool bLastSearchSuccess, bool bEnabled, uint16 nPort) -{ - if (!bEnabled) - m_PCStatus = PCS_DISABLED; - else { - if (bLastSearchSuccess) { // sanity check - bool bOK = false; - for (unsigned i = 0; i < _countof(anPeerCachePorts); ++i) - if (anPeerCachePorts[i] == nPort){ - bOK = true; - break; - } - - if (!bOK) { - dwLastSearch = 0; - bLastSearchSuccess = false; - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("Sanity check for PeerCache-Port '%u' failed"), nPort)); - } else - m_nPCPort = nPort; - } - - if (dwLastSearch != 0) { - CTime last(dwLastSearch); - struct tm tmTemp; - time_t tLast = safe_mktime(last.GetLocalTm(&tmTemp)); - time_t tNow = safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp)); - if ((difftime(tNow, tLast) / DAY2S(1)) < RETRYDAYS) { - if (!bLastSearchSuccess) { - // no retry to find the cache - m_PCStatus = PCS_NOTFOUND; - m_bNotReSearched = true; - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Not starting a search - last failed search is too near"))); - return; - } - // no need to revalidate the cache yet - m_bValidated = true; - m_bNotReValdited = true; - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: CacheIdent still valid, not trying to revalidate this time"))); - } else - m_bNotReValdited = false; - } - m_bNotReSearched = false; - SearchForPC(); - } -} - -void CPeerCacheFinder::FoundMyPublicIPAddress(uint32 dwIP) -{ - m_dwMyIP = dwIP; - if (m_PCStatus == PCS_OWNIPUNKNOWN) { - m_PCStatus = PCS_DOINGLOOKUPS; - SearchForPC(); - } -} - -void CPeerCacheFinder::SearchForPC() -{ - switch (m_PCStatus) { - case PCS_NOINIT: - m_PCStatus = PCS_DOINGLOOKUPS; - case PCS_DOINGLOOKUPS: - switch (m_PCLUState) { - case LUS_NONE: - // OK lets start, base pos first - m_PCLUState = LUS_BASEPCLOCATION; - DoLookUp(PCBASELOCATION); - break; - case LUS_BASEPCLOCATION: - // so the first lookup failed, now we need our host name - if (m_dwMyIP == 0) - // we have to wait until we get our IP from a reverse lookup - m_PCStatus = PCS_OWNIPUNKNOWN; - else { - m_PCLUState = LUS_MYHOSTNAME; - DoReverseLookUp(m_dwMyIP); - } - break; - case LUS_MYHOSTNAME: - // we should have found the host name and now start to construct sub-locations to lookup - m_PCLUState = LUS_EXTPCLOCATION; - m_posCurrentLookUp = 0; - case LUS_EXTPCLOCATION: - ASSERT(!m_strMyHostname.IsEmpty()); - // build string - m_posCurrentLookUp = m_strMyHostname.Find('.', m_posCurrentLookUp + 1); - if (m_posCurrentLookUp == -1 || m_posCurrentLookUp + 1 >= m_strMyHostname.GetLength() || m_strMyHostname.Find('.', m_posCurrentLookUp + 1) < 0) { - // failed: - m_PCLUState = LUS_NONE; - m_PCStatus = PCS_NOTFOUND; - } else - DoLookUp(PCBASELOCATION + CStringA(m_strMyHostname.Mid(m_posCurrentLookUp + 1))); - break; - case LUS_FINISHED: - if (m_dwMyIP == 0) - // we have to wait until we get our IP from a reverse lookup - m_PCStatus = PCS_OWNIPUNKNOWN; - else { - if (!m_bValidated) { - m_PCStatus = PCS_VALDATING; - ValidateDescriptorFile(); - } else { - DEBUG_ONLY(theApp.QueueLogLine(false, GetResString(IDS_PEERCACHE_ENABLED))); - m_PCStatus = PCS_READY; - } - } - } - } -} - -LRESULT CPeerCacheFinder::OnPeerCacheCheckResponse(WPARAM, LPARAM lParam) -{ - if (m_PCLUState == LUS_MYHOSTNAME) { - if (WSAGETASYNCERROR(lParam) == 0) { - if (WSAGETASYNCBUFLEN(lParam) >= sizeof(HOSTENT)) { - LPHOSTENT pHost = (LPHOSTENT)s_acDNSBuffer; - m_strMyHostname = pHost->h_name; - if (!m_strMyHostname.IsEmpty()) { - DEBUG_ONLY(AddDebugLogLine(false, _T("PeerCache: Found my Hostname: %s, continue search"), (LPCTSTR)m_strMyHostname)); - SearchForPC(); - return 0; - } - } - } - m_PCStatus = PCS_NOTFOUND; - DEBUG_ONLY(AddDebugLogLine(false, _T("DNS Reverse Lookup for own IP failed, aborting PC search"))); - - } else { - if (WSAGETASYNCERROR(lParam) == 0) { - WORD iBufLen = WSAGETASYNCBUFLEN(lParam); - if (iBufLen >= sizeof(HOSTENT)) { - LPHOSTENT pHost = (LPHOSTENT)s_acDNSBuffer; - if (pHost->h_length == 4 && pHost->h_addr_list && pHost->h_addr_list[0]) { - m_dwPCIP = ((LPIN_ADDR)(pHost->h_addr_list[0]))->s_addr; - DEBUG_ONLY(AddDebugLogLine(false, _T("Found PeerCache IP: %s"), (LPCTSTR)ipstr(m_dwPCIP))); - - m_PCLUState = LUS_FINISHED; - SearchForPC(); - return 0; - } - } - } - // no luck, continue searching - DEBUG_ONLY(AddDebugLogLine(false, _T("DNS Lookup for PC, state %i, failed - PC not found yet"), m_PCLUState)); - SearchForPC(); - } - return 0; -} - -void CPeerCacheFinder::DoLookUp(const CStringA &strHostname) -{ - if (WSAAsyncGetHostByName(theApp.emuledlg->m_hWnd, UM_PEERCACHE_RESPONSE, strHostname, s_acDNSBuffer, sizeof(s_acDNSBuffer)) == 0) - DEBUG_ONLY(AddDebugLogLine(false, _T("DNS Lookup for PC, state %i, failed (DoLookUP) - PC not found yet"), m_PCLUState)); -} - -bool CPeerCacheFinder::IsCacheAvailable() const -{ - if (m_nDownloadAttempts > 20 && m_nFailedDownloads > 0) - if (m_nDownloadAttempts / m_nFailedDownloads < 2) - return false; - return m_PCStatus == PCS_READY && theApp.GetPublicIP() != 0 && m_nPCPort != 0; -} - -CString ReverseDnsLookup(DWORD dwIP) -{ - CString strHostName; - - HMODULE hLib = LoadLibrary(_T("dnsapi.dll")); - if (hLib) { - DNS_STATUS(WINAPI *pfnDnsQueryConfig)(DNS_CONFIG_TYPE Config, DWORD Flag, PCWSTR pwsAdapterName, PVOID pReserved, PVOID pBuffer, PDWORD pBufferLength); - DNS_STATUS(WINAPI *pfnDnsQuery)(PCTSTR pszName, WORD wType, DWORD Options, PIP4_ARRAY aipServers, PDNS_RECORD *ppQueryResults, PVOID *pReserved); - VOID(WINAPI *pfnDnsRecordListFree)(PDNS_RECORD pRecordList, DNS_FREE_TYPE FreeType); - - (FARPROC&)pfnDnsQueryConfig = GetProcAddress(hLib, "DnsQueryConfig"); - (FARPROC&)pfnDnsQuery = GetProcAddress(hLib, _TWINAPI("DnsQuery_")); - (FARPROC&)pfnDnsRecordListFree = GetProcAddress(hLib, "DnsRecordListFree"); - - if (pfnDnsQueryConfig && pfnDnsQuery && pfnDnsRecordListFree) { - // WinXP: We explicitly need to pass the DNS servers to be used in DnsQuery, - // otherwise that function will never query a DNS server for a *local* host name. - IP4_ARRAY *pDnsServers = NULL; - DWORD aucBuff[4000] = {}; //was BYTE[16384]; changed to fix alignment & stack usage warnings - DWORD dwSize = (DWORD)sizeof aucBuff; - DNS_STATUS nDnsState = (*pfnDnsQueryConfig)(DnsConfigDnsServerList, FALSE, NULL, NULL, aucBuff, &dwSize); - if (nDnsState == 0) { - ASSERT(dwSize >= 4); - DWORD dwDnsServers = *aucBuff; - if (dwDnsServers >= 1 && dwSize == sizeof(DWORD) * (dwDnsServers + 1)) { - size_t uArrSize = sizeof(IP4_ARRAY) + sizeof(IP4_ADDRESS) * dwDnsServers; - pDnsServers = (IP4_ARRAY*)new BYTE[uArrSize](); - pDnsServers->AddrCount = dwDnsServers; - for (DWORD s = 0; s < dwDnsServers; ++s) - pDnsServers->AddrArray[s] = aucBuff[1 + s]; - } - } else if (thePrefs.GetVerbose()) - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("ReverseDNS: Failed to get list of DNS servers - %s"), (LPCTSTR)GetErrorMessage(nDnsState, 1))); - - CString strDnsQuery; - strDnsQuery.Format(_T("%lu.%lu.%lu.%lu.IN-ADDR.ARPA"), (dwIP >> 24) & 0xFF, (dwIP >> 16) & 0xFF, (dwIP >> 8) & 0xFF, (dwIP >> 0) & 0xFF); - - // This is a *blocking* call! - PDNS_RECORD pDnsRecords = NULL; - nDnsState = (*pfnDnsQuery)(strDnsQuery, DNS_TYPE_PTR, DNS_QUERY_BYPASS_CACHE, pDnsServers, &pDnsRecords, NULL); - if (nDnsState == 0) { - if (!IsBadReadPtr(pDnsRecords, sizeof(*pDnsRecords) - sizeof(pDnsRecords->Data) + sizeof(pDnsRecords->Data.PTR))) { - if (!IsBadReadPtr(pDnsRecords->Data.PTR.pNameHost, sizeof(TCHAR))) - strHostName = pDnsRecords->Data.PTR.pNameHost; - (*pfnDnsRecordListFree)(pDnsRecords, DnsFreeRecordListDeep); - } - } else if (thePrefs.GetVerbose()) - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("ReverseDNS: Failed to resolve address \"%s\" - %s"), (LPCTSTR)strDnsQuery, (LPCTSTR)GetErrorMessage(nDnsState, 1))); - - delete[] (BYTE*)pDnsServers; - } - FreeLibrary(hLib); - } - - return strHostName; -} - -void CPeerCacheFinder::DoReverseLookUp(uint32 dwIP) -{ - CPCReverseDnsThread *pThread = static_cast(AfxBeginThread(RUNTIME_CLASS(CPCReverseDnsThread), THREAD_PRIORITY_BELOW_NORMAL, 0, CREATE_SUSPENDED)); - pThread->m_dwIP = dwIP; - pThread->m_wndAsyncResult = theApp.emuledlg; - pThread->ResumeThread(); -} - -void CPeerCacheFinder::ValidateDescriptorFile() -{ - CPCValidateThread *pValidateThread = static_cast(AfxBeginThread(RUNTIME_CLASS(CPCValidateThread), THREAD_PRIORITY_BELOW_NORMAL, 0, CREATE_SUSPENDED)); - pValidateThread->SetValues(this, m_dwPCIP, m_dwMyIP); - pValidateThread->ResumeThread(); -} - -void CPeerCacheFinder::AddBannedVersion(const CClientVersionInfo &cviVersion) -{ - // Thread safe, due to logic this is not really needed at this time - // (because no one will access the list while the ValidateThread is running), - // but better to be on the safe side in case the code changes - CSingleLock lock(&m_SettingsMutex, TRUE); - liBannedVersions.Add(cviVersion); -} - -void CPeerCacheFinder::AddAllowedVersion(const CClientVersionInfo &cviVersion) -{ - CSingleLock lock(&m_SettingsMutex, TRUE); - liAllowedVersions.Add(cviVersion); -} - -bool CPeerCacheFinder::IsClientPCCompatible(uint32 dwTagVersionInfo, UINT nClientSoft) -{ - return IsClientPCCompatible(CClientVersionInfo(dwTagVersionInfo, nClientSoft)); -} - -bool CPeerCacheFinder::IsClientPCCompatible(const CClientVersionInfo &cviToCheck) -{ - CSingleLock lock(&m_SettingsMutex, TRUE); - for (INT_PTR i = liAllowedVersions.GetCount(); --i >= 0;) - if (cviToCheck < liAllowedVersions[i]) - return false; - - for (INT_PTR i = liBannedVersions.GetCount(); --i >= 0;) - if (cviToCheck == liBannedVersions[i]) - return false; - - return true; -} - -void CPeerCacheFinder::DownloadAttemptFailed() -{ - ++m_nFailedDownloads; - if (m_nDownloadAttempts > 20 && m_nFailedDownloads > 0) { - DEBUG_ONLY(AddDebugLogLine(DLP_LOW, false, _T("PeerCache fail value: %0.2f"), (float)(m_nDownloadAttempts / m_nFailedDownloads))); - if (m_nDownloadAttempts / m_nFailedDownloads < 2) - AddDebugLogLine(DLP_LOW, false, _T("PeerCache fail value too high, disabling cache downloads")); - } -} - -/////////////////////////////////////////////////////////////////////////////////////// -/// CPCValidateThread - -IMPLEMENT_DYNCREATE(CPCValidateThread, CWinThread) - -CPCValidateThread::CPCValidateThread() - : m_dwPCIP() - , m_dwMyIP() - , m_pOwner() - , m_nPCPort() -{ -} - -BOOL CPCValidateThread::InitInstance() -{ - DbgSetThreadName("PCValidateThread"); - InitThreadLocale(); - return TRUE; -} - -BOOL CPCValidateThread::Run() -{ - if (!theApp.IsClosing()) { - if (Validate()) { - m_pOwner->m_bValidated = true; - m_pOwner->m_nPCPort = m_nPCPort; - if (m_pOwner->m_PCStatus == PCS_VALDATING) { - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Validating .p2pinfo succeeded"))); - DEBUG_ONLY(theApp.QueueLogLine(false, GetResString(IDS_PEERCACHE_ENABLED))); - m_pOwner->m_PCStatus = PCS_READY; - } else - ASSERT(0); - } else { - m_pOwner->m_bValidated = false; - m_pOwner->m_PCStatus = PCS_NOTVERIFIED; - m_pOwner->m_nPCPort = 0; - } - } - return 0; -} - -void CPCValidateThread::SetValues(CPeerCacheFinder *in_pOwner, uint32 dwPCIP, uint32 dwMyIP) -{ - m_dwPCIP = dwPCIP; - m_dwMyIP = dwMyIP; - m_pOwner = in_pOwner; -} - -bool CPCValidateThread::Validate() -{ - ASSERT(m_dwPCIP && m_dwMyIP); - - CInternetSession session; - CInternetFile *file = NULL; - for (unsigned i = 0; i < _countof(anPeerCachePorts); ++i) { - try { - // try to connect to the URL - CString strURL; - strURL.Format(_T("http://%s:%u/.p2pinfo"), (LPCTSTR)ipstr(m_dwPCIP), anPeerCachePorts[i]); - file = (CInternetFile*)session.OpenURL(strURL); - m_nPCPort = anPeerCachePorts[i]; - break; - } catch (CInternetException *pException) { - // set file to NULL if there's an error - file = NULL; - CString strError; - GetExceptionMessage(*pException, strError.GetBuffer(512), 512); - strError.ReleaseBuffer(); - strError.Trim(_T(" \r\n")); - pException->Delete(); - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Failed to retrieve .p2pinfo file on Port %u - %s"), anPeerCachePorts[i], (LPCTSTR)strError)); - if (i == (_countof(anPeerCachePorts) - 1)) { // was last try - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Failed to retrieve .p2pinfo file, cache disabled"), anPeerCachePorts[i])); - return false; - } - } - } - ASSERT(file != NULL); - // TODO: This will work successfully only for very small files which were received completely right at the - // time the 'GetLength' function is called. -> Use a polling loop which reads everything up to get bytes - // specified in 'Content-Length' or some other appropriate limit in case 'Content-Length' is missing. - uint32 nIFileSize = file ? (uint32)file->GetLength() : 0; - ASSERT(nIFileSize > SIGNATURELENGTH); - - if (file && nIFileSize > SIGNATURELENGTH) { - // read content - CArray adwCacheIPs; - CStringAArray astrIPRanges; - bool bContentCheckFailed = false; - - UINT uContentSize = nIFileSize - SIGNATURELENGTH; - char *pcContent = new char[uContentSize + 1]; - if (file->Read(pcContent, uContentSize) != uContentSize) - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Failed to read p2pinfo file content"))); - pcContent[uContentSize] = '\0'; - - //----------- CHECKING .P2PINFO CONTENT - // NOTE: 'pcContent' gets destroyed with 'strtok' ! - for (LPSTR pszLine = strtok(pcContent, "\r\n"); pszLine && !bContentCheckFailed; pszLine = strtok(NULL, "\r\n")) { - CStringA strLine(pszLine); - int posSeparator = strLine.Find('=', 1); - if (posSeparator >= 0 && strLine.GetLength() - posSeparator > 1) { - CStringA strTopic(strLine, posSeparator); - strTopic.Trim(); - CStringA strContent(strLine.Mid(posSeparator + 1).Trim()); - - //DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Current line to be processed: %hs"), strLine); - - ///////***** CacheIP - if (strTopic == "CacheIP") - adwCacheIPs.Add(inet_addr(strContent)); - ///////***** ClientIPRange - else if (strTopic == "ClientIPRange") - astrIPRanges.Add(strContent); - ///////***** ExpireDate - else if (strTopic == "ExpireDate") { - bool bDateCheckFailed = true; - - if (strContent.GetLength() == 8) { - uint32 nYear = atol(strContent.Left(4)); - uint32 nMonth = atol(strContent.Mid(4, 2)); - uint32 nDay = atol(strContent.Mid(6, 2)); - if (nYear <= 3000 && nMonth <= 12 && nDay <= 31) { - CTime timeExpireDate(nYear, nMonth, nDay, 0, 0, 0); - if (timeExpireDate >= CTime::GetCurrentTime()) - bDateCheckFailed = false; // check passed - } - } - if (bDateCheckFailed) { - bContentCheckFailed = true; - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: ExpireDate check failed. Expiring date: %hs"), (LPCSTR)strContent)); - } - } - ///////***** EnableED2K - else if (strTopic == "EnableED2K") { - if (atol(strContent) != 1) { - bContentCheckFailed = true; - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: EnableED2K check failed. Value: %hs"), (LPCSTR)strContent)); - } - } else - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Unused content tag for validity check: %hs"), (LPCSTR)strLine)); - - } - } - // finish the CacheIP check - bool bIPRangeCheckFailed = true; - for (INT_PTR i = adwCacheIPs.GetCount(); --i >= 0;) - if (adwCacheIPs[i] == m_dwPCIP) { - bIPRangeCheckFailed = false; - break; - } - - if (bIPRangeCheckFailed) { - bContentCheckFailed = true; - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: CacheIP check failed."))); - } - // finish the RangeChack - bool bIPCheckFailed = true; - for (int i = 0; i != astrIPRanges.GetCount(); ++i) { - const CStringA &strCurRange(astrIPRanges[i]); - int posContentSeparator = strCurRange.Find('-', 7); - if (!(posContentSeparator == -1 || strCurRange.GetLength() - posContentSeparator <= 7)) { - uint32 dwIPRangeStart = inet_addr(strCurRange.Left(posContentSeparator).Trim()); - uint32 dwIPRangeEnd = inet_addr(strCurRange.Mid(posContentSeparator + 1).Trim()); - if (dwIPRangeStart != INADDR_NONE || dwIPRangeEnd != INADDR_NONE) { - if (ntohl(dwIPRangeStart) <= ntohl(m_dwMyIP) && ntohl(dwIPRangeEnd) >= ntohl(m_dwMyIP)) - bIPCheckFailed = false; // check passed - } - } - } - if (bIPCheckFailed) { - bContentCheckFailed = true; - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: ClientIPRange check failed. my IP: %s"), (LPCTSTR)ipstr(m_dwMyIP))); - } - - //----------- CHECKING SPECIAL HEADERS CONTENT - char achBuffer[3072]; // 3KiB should be enough for headers - DWORD nBufferSize = (DWORD)sizeof achBuffer; - if (!bContentCheckFailed && HttpQueryInfo(*file, HTTP_QUERY_RAW_HEADERS_CRLF, achBuffer, &nBufferSize, NULL)) { - const CStringA &strHeaders(achBuffer); - for (int iPos = 0; iPos >= 0;) { - const CStringA &strCurHeader(strHeaders.Tokenize("\r\n", iPos)); - if (strCurHeader.IsEmpty()) - break; - int posSeparator = strCurHeader.Find(':', 1); - if (posSeparator >= 0 && strCurHeader.GetLength() > posSeparator + 1) { - const CStringA &strTopic(strCurHeader.Left(posSeparator).Trim()); - const CStringA &strContent(strCurHeader.Mid(posSeparator + 1).Trim()); - - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Current Header to be processed: %hs"), (LPCSTR)strCurHeader)); - bool bAllow = (strTopic == "X-eMule-Require-Version"); - if (!bAllow && (strTopic != "X-eMule-Reject-Version")) - continue; - - const CString strPCEncodedVersion(strContent); - for (int jPos = 0; jPos >= 0;) { - const CString &strVersion(strPCEncodedVersion.Tokenize(_T(" "), jPos)); - if (strVersion.IsEmpty()) - break; - const CClientVersionInfo vInfo(strVersion); - if (bAllow) - m_pOwner->AddAllowedVersion(vInfo); //***** X-eMule-Require-Version - else - m_pOwner->AddBannedVersion(vInfo); //***** X-eMule-Reject-Version - } - } - } - ///////***** Own version check - if (!m_pOwner->IsClientPCCompatible(CClientVersionInfo(CemuleApp::m_nVersionMjr, CemuleApp::m_nVersionMin, CemuleApp::m_nVersionUpd, CemuleApp::m_nVersionBld, SO_EMULE))) { - bContentCheckFailed = true; - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Current Version not allowed to use this PC-Server, please update"))); - } - } else if (!bContentCheckFailed) - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache Error: Failed to retrieve headers, Errornumber %s"), (LPCTSTR)GetErrorMessage(::GetLastError()))); - - - //----------- CHECKING .P2PINFO SIGNATURE - bool bSignatureCheckResult = false; - if (!bContentCheckFailed) { - uchar *pachCompleteFile = new uchar[nIFileSize]; - file->SeekToBegin(); - if (file->Read(pachCompleteFile, nIFileSize) != nIFileSize) { - ASSERT(0); - bSignatureCheckResult = false; - } else { - using namespace CryptoPP; - Integer e = 3, m, n; - n.Decode(achVerify_Key, _countof(achVerify_Key)); - - uchar aucSignature[SIGNATURELENGTH]; - for (int i = 0; i != SIGNATURELENGTH; ++i) - aucSignature[(SIGNATURELENGTH - 1) - i] = pachCompleteFile[(nIFileSize - SIGNATURELENGTH) + i]; - m.Decode(aucSignature, SIGNATURELENGTH); - - RSAFunction rsa; - rsa.SetPublicExponent(e); - rsa.SetModulus(n); - Integer result = rsa.ApplyFunction(m); - uchar aucResult[SIGNATURELENGTH]; - result.Encode(aucResult, SIGNATURELENGTH); - - uchar aucHash1[MDX_DIGEST_SIZE]; - for (int i = 0; i < 16; ++i) - aucHash1[i] = aucResult[(SIGNATURELENGTH - 1) - i]; - bSignatureCheckResult = md4equ(MD5Sum(pachCompleteFile, nIFileSize - SIGNATURELENGTH).GetRawHash(), aucHash1); - } - delete[] pachCompleteFile; - if (!bSignatureCheckResult) - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("PeerCache: Failed to verify PeerCache Server, not using it"))); - } - - delete[] pcContent; - file->Close(); - delete file; - return (bSignatureCheckResult && !bContentCheckFailed); - } - return false; -} - -BEGIN_MESSAGE_MAP(CPCValidateThread, CWinThread) -END_MESSAGE_MAP() - - - -IMPLEMENT_DYNCREATE(CPCReverseDnsThread, CWinThread) -BOOL CPCReverseDnsThread::InitInstance() -{ - ASSERT(m_wndAsyncResult && m_dwIP); - InitThreadLocale(); - - memset(s_acDNSBuffer, 0, sizeof s_acDNSBuffer); - const CString &strHostname(ReverseDnsLookup(m_dwIP)); - if (strHostname.IsEmpty()) { - in_addr IPHost; - // FIXME: Unable to resolve my own host - will always get the Windows Computer/Domain name. Dunno how to avoid this - // cheap walk around below by using another IP - IPHost.s_addr = htonl(ntohl(m_dwIP) + 1); - if (WSAAsyncGetHostByAddr(theApp.emuledlg->m_hWnd, UM_PEERCACHE_RESPONSE, (char*)&IPHost, sizeof(struct in_addr), AF_INET, s_acDNSBuffer, sizeof(s_acDNSBuffer)) == 0) { - if (thePrefs.GetVerbose()) - DEBUG_ONLY(theApp.QueueDebugLogLine(false, _T("DNS Reverse Lookup for own IP failed"))); - } - } else { - UINT uError; - const CStringA strHostnameA(strHostname); - UINT uBufLen = sizeof(HOSTENT) // 'hostent' structure - + sizeof(char*) // h_aliases list + NUL entry - + sizeof(DWORD) * 2 // h_addr_list + NUL entry - + strHostnameA.GetLength() + 1; - if (uBufLen <= sizeof(s_acDNSBuffer)) { - LPHOSTENT pHost = (LPHOSTENT)s_acDNSBuffer; - char *p = (char*)(pHost + 1); - - pHost->h_aliases = (char **)p; - pHost->h_aliases[0] = NULL; - p += sizeof(char*); - - pHost->h_addrtype = AF_INET; - pHost->h_length = sizeof(DWORD); - - pHost->h_addr_list = (char**)p; - pHost->h_addr_list[0] = (char*)m_dwIP; - pHost->h_addr_list[1] = NULL; - p += sizeof(char*) * 2; - - pHost->h_name = p; - strcpy(pHost->h_name, strHostnameA); - p += strHostnameA.GetLength() + 1; - - ASSERT((UINT)(p - s_acDNSBuffer) == uBufLen); - uError = 0; - } else - uError = WSAENOBUFS; - - VERIFY(m_wndAsyncResult->PostMessage(UM_PEERCACHE_RESPONSE, 0, WSAMAKEASYNCREPLY(uBufLen, uError))); - } - return FALSE; -} \ No newline at end of file diff --git a/srchybrid/PeerCacheFinder.h b/srchybrid/PeerCacheFinder.h deleted file mode 100644 index c061c4cb..00000000 --- a/srchybrid/PeerCacheFinder.h +++ /dev/null @@ -1,140 +0,0 @@ -//this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) -// -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU General Public License -//as published by the Free Software Foundation; either -//version 2 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. -// -//You should have received a copy of the GNU General Public License -//along with this program; if not, write to the Free Software - -#pragma once -#include -#include "ClientVersionInfo.h" - -enum EPeerCacheStatus -{ - // permanent failure: 20..11 - PCS_NOTFOUND = 20, - PCS_NOTVERIFIED = 19, - PCS_DISABLED = 18, - - // still trying to find & validate: 10..1 - PCS_DOINGLOOKUPS = 10, - PCS_VALDATING = 9, - PCS_NOINIT = 8, - PCS_OWNIPUNKNOWN = 7, - - // success 0 - PCS_READY = 0 -}; - -enum EPCLookUpState -{ - LUS_NONE = 0, - LUS_BASEPCLOCATION, - LUS_MYHOSTNAME, - LUS_EXTPCLOCATION, - LUS_FINISHED -}; - -//////////////////////////////////////////////////////////////////////////////////// -/// CPeerCacheFinder - -class CPeerCacheFinder -{ - friend class CPCValidateThread; - -public: - CPeerCacheFinder(); - ~CPeerCacheFinder() = default; - - void Init(time_t dwLastSearch, bool bLastSearchSuccess, bool bEnabled, uint16 nPort); - void Save(); - void FoundMyPublicIPAddress(uint32 dwIP); - bool IsCacheAvailable() const; - uint32 GetCacheIP() const { return m_dwPCIP; } - uint16 GetCachePort() const { return m_nPCPort; } - void DownloadAttemptStarted() { ++m_nDownloadAttempts; } - void DownloadAttemptFailed(); - void AddBannedVersion(const CClientVersionInfo &cviVersion); - void AddAllowedVersion(const CClientVersionInfo &cviVersion); - bool IsClientPCCompatible(uint32 dwTagVersionInfo, UINT nClientSoft); - bool IsClientPCCompatible(const CClientVersionInfo &cviToCheck); - LRESULT OnPeerCacheCheckResponse(WPARAM, LPARAM lParam); - -protected: - void DoLookUp(const CStringA &strHostname); - static void DoReverseLookUp(uint32 dwIP); - void SearchForPC(); - void ValidateDescriptorFile(); - -private: - EPeerCacheStatus m_PCStatus; - EPCLookUpState m_PCLUState; - CArray liBannedVersions; - CArray liAllowedVersions; - CMutex m_SettingsMutex; - CString m_strMyHostname; - uint32 m_dwPCIP; - uint32 m_dwMyIP; - uint32 m_nDownloadAttempts; - uint32 m_nFailedDownloads; - int m_posCurrentLookUp; - uint16 m_nPCPort; - bool m_bValidated; - bool m_bNotReSearched; - bool m_bNotReValdited; - -}; - -/////////////////////////////////////////////////////////////////////////////////////// -/// CPCValidateThread - -class CPCValidateThread : public CWinThread -{ - DECLARE_DYNCREATE(CPCValidateThread) - -protected: - CPCValidateThread(); // protected constructor used by dynamic creation - - DECLARE_MESSAGE_MAP() - bool Validate(); - -public: - virtual BOOL InitInstance(); - virtual int Run(); - void SetValues(CPeerCacheFinder *in_pOwner, uint32 dwPCIP, uint32 dwMyIP); - -private: - - uint32 m_dwPCIP; - uint32 m_dwMyIP; - CPeerCacheFinder *m_pOwner; - uint16 m_nPCPort; -}; - -/////////////////////////////////////////////////////////////////////////////////////// -/// CPCReverseDnsThread - -class CPCReverseDnsThread : public CWinThread -{ - DECLARE_DYNCREATE(CPCReverseDnsThread) - -public: - CPCReverseDnsThread() - : m_wndAsyncResult() - , m_dwIP() - { - } - BOOL InitInstance(); - - CWnd *m_wndAsyncResult; - DWORD m_dwIP; -}; \ No newline at end of file diff --git a/srchybrid/PeerCacheSocket.h b/srchybrid/PeerCacheSocket.h deleted file mode 100644 index 350ce6ee..00000000 --- a/srchybrid/PeerCacheSocket.h +++ /dev/null @@ -1,95 +0,0 @@ -//this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) -// -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU General Public License -//as published by the Free Software Foundation; either -//version 2 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. -// -//You should have received a copy of the GNU General Public License -//along with this program; if not, write to the Free Software -//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#pragma once - -#include "HttpClientReqSocket.h" - -DWORD GetPeerCacheSocketUploadTimeout(); -DWORD GetPeerCacheSocketDownloadTimeout(); - - -/////////////////////////////////////////////////////////////////////////////// -// CPeerCacheSocket - -class CPeerCacheSocket : public CHttpClientReqSocket -{ - DECLARE_DYNCREATE(CPeerCacheSocket) - -public: - virtual CUpDownClient* GetClient() const { return m_client; } - virtual void OnSend(int nErrorCode); - virtual void OnReceive(int nErrorCode); - virtual void Safe_Delete(); - -protected: - explicit CPeerCacheSocket(CUpDownClient *pClient = NULL); - virtual ~CPeerCacheSocket(); - virtual void DetachFromClient(); - - virtual void OnError(int nErrorCode); - - virtual bool ProcessHttpResponse(); - virtual bool ProcessHttpResponseBody(const BYTE *pucData, UINT size); - virtual bool ProcessHttpRequest(); - - CUpDownClient *m_client; -}; - - -/////////////////////////////////////////////////////////////////////////////// -// CPeerCacheDownSocket - -class CPeerCacheDownSocket : public CPeerCacheSocket -{ - DECLARE_DYNCREATE(CPeerCacheDownSocket) - -public: - explicit CPeerCacheDownSocket(CUpDownClient *pClient = NULL); - - virtual void OnClose(int nErrorCode); - -protected: - virtual ~CPeerCacheDownSocket(); - virtual void DetachFromClient(); - - virtual bool ProcessHttpResponse(); - virtual bool ProcessHttpResponseBody(const BYTE *pucData, UINT uSize); - virtual bool ProcessHttpRequest(); -}; - - -/////////////////////////////////////////////////////////////////////////////// -// CPeerCacheUpSocket - -class CPeerCacheUpSocket : public CPeerCacheSocket -{ - DECLARE_DYNCREATE(CPeerCacheUpSocket) - -public: - explicit CPeerCacheUpSocket(CUpDownClient *pClient = NULL); - - virtual void OnClose(int nErrorCode); - virtual void OnSend(int nErrorCode); - -protected: - virtual ~CPeerCacheUpSocket(); - virtual void DetachFromClient(); - - virtual bool ProcessHttpResponse(); - virtual bool ProcessHttpResponseBody(const BYTE *pucData, UINT size); - virtual bool ProcessHttpRequest(); -}; diff --git a/srchybrid/PerfLog.cpp b/srchybrid/PerfLog.cpp index d7f455f0..04736e52 100644 --- a/srchybrid/PerfLog.cpp +++ b/srchybrid/PerfLog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Pinger.cpp b/srchybrid/Pinger.cpp index 28a0e9fa..07222d9c 100644 --- a/srchybrid/Pinger.cpp +++ b/srchybrid/Pinger.cpp @@ -82,7 +82,7 @@ * implement both approaches. * * Example code and ideas used from (credits go to articles authors): -* http://tangentsoft.net/wskfaq/examples/rawping.html +* https://tangentsoft.net/wskfaq/examples/rawping.html * http://www.cs.concordia.ca/~teaching/comp445/labs/webpage/ch16.htm * http://www.networksorcery.com/enp/protocol/icmp.htm * diff --git a/srchybrid/Pinger.h b/srchybrid/Pinger.h index 69e531ab..a98e4fa6 100644 --- a/srchybrid/Pinger.h +++ b/srchybrid/Pinger.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Preferences.cpp b/srchybrid/Preferences.cpp index 47bea7c9..248783e4 100644 --- a/srchybrid/Preferences.cpp +++ b/srchybrid/Preferences.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "stdafx.h" #include #include @@ -47,9 +46,9 @@ static char THIS_FILE[] = __FILE__; #endif -#define SHAREDDIRS _T("shareddir.dat") +#define SHAREDDIRS _T("shareddir.dat") +LPCTSTR const strPreferencesDat = _T("preferences.dat"); LPCTSTR const strDefaultToolbar = _T("0099010203040506070899091011"); - CPreferences thePrefs; CString CPreferences::m_astrDefaultDirs[13]; @@ -149,10 +148,8 @@ uint64 CPreferences::sesUpData_EMULECOMPAT; uint64 CPreferences::sesUpData_SHAREAZA; uint64 CPreferences::cumUpDataPort_4662; uint64 CPreferences::cumUpDataPort_OTHER; -uint64 CPreferences::cumUpDataPort_PeerCache; uint64 CPreferences::sesUpDataPort_4662; uint64 CPreferences::sesUpDataPort_OTHER; -uint64 CPreferences::sesUpDataPort_PeerCache; uint64 CPreferences::cumUpData_File; uint64 CPreferences::cumUpData_Partfile; uint64 CPreferences::sesUpData_File; @@ -189,10 +186,8 @@ uint64 CPreferences::sesDownData_SHAREAZA; uint64 CPreferences::sesDownData_URL; uint64 CPreferences::cumDownDataPort_4662; uint64 CPreferences::cumDownDataPort_OTHER; -uint64 CPreferences::cumDownDataPort_PeerCache; uint64 CPreferences::sesDownDataPort_4662; uint64 CPreferences::sesDownDataPort_OTHER; -uint64 CPreferences::sesDownDataPort_PeerCache; float CPreferences::cumConnAvgDownRate; float CPreferences::cumConnMaxAvgDownRate; float CPreferences::cumConnMaxDownRate; @@ -440,18 +435,13 @@ bool CPreferences::m_bKeepUnavailableFixedSharedDirs; CStringList CPreferences::shareddir_list; CStringList CPreferences::addresses_list; CString CPreferences::m_strFileCommentsFilePath; -Preferences_Ext_Struct* CPreferences::prefsExt; +Preferences_Ext_Struct *CPreferences::prefsExt; WORD CPreferences::m_wWinVer; CArray CPreferences::catArr; UINT CPreferences::m_nWebMirrorAlertLevel; bool CPreferences::m_bRunAsUser; bool CPreferences::m_bPreferRestrictedOverUser; bool CPreferences::m_bUseOldTimeRemaining; -time_t CPreferences::m_uPeerCacheLastSearch; -bool CPreferences::m_bPeerCacheWasFound; -bool CPreferences::m_bPeerCacheEnabled; -uint16 CPreferences::m_nPeerCachePort; -bool CPreferences::m_bPeerCacheShow; bool CPreferences::m_bOpenPortsOnStartUp; int CPreferences::m_byLogLevel; @@ -502,6 +492,14 @@ LPCTSTR CPreferences::GetConfigFile() return theApp.m_pszProfileName; } +void CPreferences::MovePreferences(EDefaultDirectory eSrc, LPCTSTR const sFile, const CString &dst) +{ + const CString &src(GetMuleDirectory(eSrc)); + const CString &pathTxt(src + sFile); + if (::PathFileExists(pathTxt)) + ::MoveFile(pathTxt, dst + sFile); +} + void CPreferences::Init() { //srand((unsigned)time(NULL)); // we need random numbers sometimes @@ -523,22 +521,18 @@ void CPreferences::Init() ff.Close(); /////////////////////////////////////////////////////////////////////////// - // Move 'downloads.txt/bak' files from application and/or data-base directory + // Move 'downloads.txt/bak' files from application and/or database directory // into 'config' directory // - const CString &sDBdir(GetMuleDirectory(EMULE_DATABASEDIR)); - if (::PathFileExists(sDBdir + _T("downloads.txt"))) - ::MoveFile(sDBdir + _T("downloads.txt"), sConfDir + _T("downloads.txt")); - if (::PathFileExists(sDBdir + _T("downloads.bak"))) - ::MoveFile(sDBdir + _T("downloads.bak"), sConfDir + _T("downloads.bak")); - const CString &sEXEdir(GetMuleDirectory(EMULE_EXECUTABLEDIR)); - if (::PathFileExists(sEXEdir + _T("downloads.txt"))) - ::MoveFile(sEXEdir + _T("downloads.txt"), sConfDir + _T("downloads.txt")); - if (::PathFileExists(sEXEdir + _T("downloads.bak"))) - ::MoveFile(sEXEdir + _T("downloads.bak"), sConfDir + _T("downloads.bak")); + static LPCTSTR const strDownloadsTxt = _T("downloads.txt"); + static LPCTSTR const strDownloadsBak = _T("downloads.bak"); + MovePreferences(EMULE_DATABASEDIR, strDownloadsTxt, sConfDir); + MovePreferences(EMULE_EXECUTABLEDIR, strDownloadsTxt, sConfDir); + MovePreferences(EMULE_DATABASEDIR, strDownloadsBak, sConfDir); + MovePreferences(EMULE_EXECUTABLEDIR, strDownloadsBak, sConfDir); // load preferences.dat or set standard values - CString strFullPath(sConfDir + _T("preferences.dat")); + CString strFullPath(sConfDir + strPreferencesDat); FILE *preffile = _tfsopen(strFullPath, _T("rb"), _SH_DENYWR); LoadPreferences(); @@ -762,7 +756,6 @@ void CPreferences::SaveStats(int bBackUp) ini.WriteUInt64(_T("DownData_URL"), GetCumDownData_URL()); ini.WriteUInt64(_T("DownDataPort_4662"), GetCumDownDataPort_4662()); ini.WriteUInt64(_T("DownDataPort_OTHER"), GetCumDownDataPort_OTHER()); - ini.WriteUInt64(_T("DownDataPort_PeerCache"), GetCumDownDataPort_PeerCache()); ini.WriteUInt64(_T("DownOverheadTotal"), theStats.GetDownDataOverheadFileRequest() + theStats.GetDownDataOverheadSourceExchange() @@ -800,7 +793,6 @@ void CPreferences::SaveStats(int bBackUp) ini.WriteUInt64(_T("UpData_SHAREAZA"), GetCumUpData_SHAREAZA()); ini.WriteUInt64(_T("UpDataPort_4662"), GetCumUpDataPort_4662()); ini.WriteUInt64(_T("UpDataPort_OTHER"), GetCumUpDataPort_OTHER()); - ini.WriteUInt64(_T("UpDataPort_PeerCache"), GetCumUpDataPort_PeerCache()); ini.WriteUInt64(_T("UpData_File"), GetCumUpData_File()); ini.WriteUInt64(_T("UpData_Partfile"), GetCumUpData_Partfile()); @@ -1024,10 +1016,6 @@ void CPreferences::Add2SessionTransferData(UINT uClientID, UINT uClientPort, BOO case 4662: sesUpDataPort_4662 += bytes; break; - case (UINT)-1: - sesUpDataPort_PeerCache += bytes; - break; - //case (UINT)-2: default: sesUpDataPort_OTHER += bytes; } @@ -1079,12 +1067,6 @@ void CPreferences::Add2SessionTransferData(UINT uClientID, UINT uClientPort, BOO case 4662: sesDownDataPort_4662 += bytes; break; - case (UINT)-1: - sesDownDataPort_PeerCache += bytes; - break; - //case (UINT)-2: - // sesDownDataPort_URL += bytes; - // break; default: sesDownDataPort_OTHER += bytes; break; @@ -1139,7 +1121,6 @@ void CPreferences::ResetCumulativeStatistics() cumUpData_SHAREAZA = 0; cumUpDataPort_4662 = 0; cumUpDataPort_OTHER = 0; - cumUpDataPort_PeerCache = 0; cumDownCompletedFiles = 0; cumDownSuccessfulSessions = 0; cumDownFailedSessions = 0; @@ -1157,7 +1138,6 @@ void CPreferences::ResetCumulativeStatistics() cumDownData_URL = 0; cumDownDataPort_4662 = 0; cumDownDataPort_OTHER = 0; - cumDownDataPort_PeerCache = 0; cumConnAvgDownRate = 0; cumConnMaxAvgDownRate = 0; cumConnMaxDownRate = 0; @@ -1267,7 +1247,6 @@ bool CPreferences::LoadStats(int loadBackUp) // Load cumulative port breakdown stats for sent bytes cumUpDataPort_4662 = ini.GetUInt64(_T("UpDataPort_4662")); cumUpDataPort_OTHER = ini.GetUInt64(_T("UpDataPort_OTHER")); - cumUpDataPort_PeerCache = ini.GetUInt64(_T("UpDataPort_PeerCache")); // Load cumulative source breakdown stats for sent bytes cumUpData_File = ini.GetUInt64(_T("UpData_File")); @@ -1297,7 +1276,6 @@ bool CPreferences::LoadStats(int loadBackUp) // Load cumulative port breakdown stats for received bytes cumDownDataPort_4662 = ini.GetUInt64(_T("DownDataPort_4662")); cumDownDataPort_OTHER = ini.GetUInt64(_T("DownDataPort_OTHER")); - cumDownDataPort_PeerCache = ini.GetUInt64(_T("DownDataPort_PeerCache")); // Load stats for cumulative connection data cumConnAvgDownRate = ini.GetFloat(_T("ConnAvgDownRate")); @@ -1383,7 +1361,6 @@ bool CPreferences::LoadStats(int loadBackUp) sesUpData_SHAREAZA = 0; sesUpDataPort_4662 = 0; sesUpDataPort_OTHER = 0; - sesUpDataPort_PeerCache = 0; sesDownData_EDONKEY = 0; sesDownData_EDONKEYHYBRID = 0; @@ -1395,7 +1372,6 @@ bool CPreferences::LoadStats(int loadBackUp) sesDownData_URL = 0; sesDownDataPort_4662 = 0; sesDownDataPort_OTHER = 0; - sesDownDataPort_PeerCache = 0; sesDownSuccessfulSessions = 0; sesDownFailedSessions = 0; @@ -1438,7 +1414,7 @@ bool CPreferences::Save() { static LPCTSTR const stmp = _T(".tmp"); const CString &sConfDir(GetMuleDirectory(EMULE_CONFIGDIR)); - const CString &strPrefPath(sConfDir + _T("preferences.dat")); + const CString &strPrefPath(sConfDir + strPreferencesDat); bool error; FILE *preffile = _tfsopen(strPrefPath + stmp, _T("wb"), _SH_DENYWR); //keep contents @@ -1457,24 +1433,22 @@ bool CPreferences::Save() SaveStats(); const CString &strSharesPath(sConfDir + SHAREDDIRS); - CStdioFile sdirfile; - if (sdirfile.Open(strSharesPath + stmp, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite | CFile::typeBinary)) { + CStdioFile file; + if (file.Open(strSharesPath + stmp, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite | CFile::typeBinary)) { try { - // write Unicode byte order mark 0xFEFF - static const WORD wBOM = u'\xFEFF'; //UTF-16LE - sdirfile.Write(&wBOM, sizeof wBOM); + // write UTF-16LE byte order mark 0xFEFF + static const WORD wBOM = u'\xFEFF'; + file.Write(&wBOM, sizeof wBOM); for (POSITION pos = shareddir_list.GetHeadPosition(); pos != NULL;) { - sdirfile.WriteString(shareddir_list.GetNext(pos)); - sdirfile.Write(_T("\r\n"), 2 * sizeof(TCHAR)); + file.WriteString(shareddir_list.GetNext(pos)); + file.Write(_T("\r\n"), 2 * sizeof(TCHAR)); } - sdirfile.Close(); + file.Close(); error |= (MoveFileEx(strSharesPath + stmp, strSharesPath, MOVEFILE_REPLACE_EXISTING) == 0); - } catch (CFileException *ferror) { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*ferror, buffer, _countof(buffer)); + } catch (CFileException *ex) { if (thePrefs.GetVerbose()) - AddDebugLogLine(true, _T("Failed to save %s - %s"), (LPCTSTR)strSharesPath, buffer); - ferror->Delete(); + AddDebugLogLine(true, _T("Failed to save %s%s"), (LPCTSTR)strSharesPath, (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } else error = true; @@ -1826,14 +1800,6 @@ void CPreferences::SavePreferences() ini.WriteString(_T("HTTPSCertificate"), m_sWebHttpsCertificate); ini.WriteString(_T("HTTPSKey"), m_sWebHttpsKey); - - /////////////////////////////////////////////////////////////////////////// - // Section: "PeerCache" - // - ini.WriteInt(_T("LastSearch"), (int)m_uPeerCacheLastSearch, _T("PeerCache")); - ini.WriteBool(_T("Found"), m_bPeerCacheWasFound); - ini.WriteInt(_T("PCPort"), m_nPeerCachePort); - /////////////////////////////////////////////////////////////////////////// // Section: "UPnP" // @@ -2421,15 +2387,6 @@ void CPreferences::LoadPreferences() m_sWebHttpsCertificate = ini.GetString(_T("HTTPSCertificate"), _T("")); m_sWebHttpsKey = ini.GetString(_T("HTTPSKey"), _T("")); - /////////////////////////////////////////////////////////////////////////// - // Section: "PeerCache" - // - m_uPeerCacheLastSearch = ini.GetInt(_T("LastSearch"), 0, _T("PeerCache")); - m_bPeerCacheWasFound = ini.GetBool(_T("Found"), false); - m_bPeerCacheEnabled = ini.GetBool(_T("EnabledDeprecated"), false); - m_nPeerCachePort = (uint16)ini.GetInt(_T("PCPort"), 0); - m_bPeerCacheShow = ini.GetBool(_T("Show"), false); - /////////////////////////////////////////////////////////////////////////// // Section: "UPnP" // @@ -2463,9 +2420,6 @@ UINT CPreferences::GetDefaultMaxConperFive() case _WINVER_95_: case _WINVER_ME_: return MAXCON5WIN9X; - //case _WINVER_2K_: - //case _WINVER_XP_: - // return MAXCONPER5SEC; default: return MAXCONPER5SEC; } @@ -2751,8 +2705,8 @@ UINT CPreferences::GetWebMirrorAlertLevel() bool CPreferences::IsRunAsUserEnabled() { switch (GetWindowsVersion()) { - case _WINVER_XP_: case _WINVER_2K_: + case _WINVER_XP_: case _WINVER_2003_: return m_bRunAsUser && m_nCurrentUserDirMode == 2; } @@ -2905,7 +2859,6 @@ CString CPreferences::GetDefaultDirectory(EDefaultDirectory eDirectory, bool bCr // Get executable starting directory which was our default till Vista TCHAR tchBuffer[MAX_PATH]; ::GetModuleFileName(NULL, tchBuffer, _countof(tchBuffer)); - tchBuffer[_countof(tchBuffer) - 1] = _T('\0'); LPTSTR pszFileName = _tcsrchr(tchBuffer, _T('\\')) + 1; *pszFileName = _T('\0'); m_astrDefaultDirs[EMULE_EXECUTABLEDIR] = tchBuffer; diff --git a/srchybrid/Preferences.h b/srchybrid/Preferences.h index 124cd08a..ab8d3d6d 100644 --- a/srchybrid/Preferences.h +++ b/srchybrid/Preferences.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -43,13 +43,13 @@ enum SMTPauth: byte { AUTH_NONE, AUTH_PLAIN, - AUTH_LOGIN - /* AUTH_GSSAPI, + AUTH_LOGIN /*, + AUTH_GSSAPI, AUTH_DIGEST, AUTH_MD5, AUTH_CRAM, AUTH_OAUTH1, - AUTH_OAUTH2 */ + AUTH_OAUTH2 */ }; @@ -146,6 +146,7 @@ class CPreferences static LPCSTR m_pszBindAddrA; static LPCWSTR m_pszBindAddrW; + static void MovePreferences(EDefaultDirectory eSrc, LPCTSTR const sFile, const CString &dst); public: static CString strNick; // ZZ:UploadSpeedSense --> @@ -253,11 +254,9 @@ class CPreferences // Cumulative port breakdown stats for sent bytes... static uint64 cumUpDataPort_4662; static uint64 cumUpDataPort_OTHER; - static uint64 cumUpDataPort_PeerCache; // Session port breakdown stats for sent bytes... static uint64 sesUpDataPort_4662; static uint64 sesUpDataPort_OTHER; - static uint64 sesUpDataPort_PeerCache; // Cumulative source breakdown stats for sent bytes... static uint64 cumUpData_File; @@ -308,11 +307,9 @@ class CPreferences // Cumulative port breakdown stats for received bytes... static uint64 cumDownDataPort_4662; static uint64 cumDownDataPort_OTHER; - static uint64 cumDownDataPort_PeerCache; // Session port breakdown stats for received bytes... static uint64 sesDownDataPort_4662; static uint64 sesDownDataPort_OTHER; - static uint64 sesDownDataPort_PeerCache; // Saved stats for cumulative connection data... static float cumConnAvgDownRate; @@ -610,13 +607,6 @@ class CPreferences static bool m_bUseOldTimeRemaining; - // PeerCache - static time_t m_uPeerCacheLastSearch; - static uint16 m_nPeerCachePort; - static bool m_bPeerCacheWasFound; - static bool m_bPeerCacheEnabled; - static bool m_bPeerCacheShow; - // Firewall settings static bool m_bOpenPortsOnStartUp; @@ -844,19 +834,15 @@ class CPreferences // Cumulative port breakdown stats for sent bytes... static uint64 GetUpTotalPortData() { return GetCumUpDataPort_4662() - + GetCumUpDataPort_OTHER() - + GetCumUpDataPort_PeerCache(); } + + GetCumUpDataPort_OTHER(); } static uint64 GetCumUpDataPort_4662() { return cumUpDataPort_4662 + sesUpDataPort_4662; } static uint64 GetCumUpDataPort_OTHER() { return cumUpDataPort_OTHER + sesUpDataPort_OTHER; } - static uint64 GetCumUpDataPort_PeerCache() { return cumUpDataPort_PeerCache + sesUpDataPort_PeerCache; } // Session port breakdown stats for sent bytes... static uint64 GetUpSessionPortData() { return sesUpDataPort_4662 - + sesUpDataPort_OTHER - + sesUpDataPort_PeerCache; } + + sesUpDataPort_OTHER; } static uint64 GetUpDataPort_4662() { return sesUpDataPort_4662; } static uint64 GetUpDataPort_OTHER() { return sesUpDataPort_OTHER; } - static uint64 GetUpDataPort_PeerCache() { return sesUpDataPort_PeerCache; } // Cumulative DS breakdown stats for sent bytes... static uint64 GetUpTotalDataFile() { return GetCumUpData_File() + GetCumUpData_Partfile(); } @@ -905,19 +891,15 @@ class CPreferences // Cumulative port breakdown stats for received bytes... static uint64 GetDownTotalPortData() { return GetCumDownDataPort_4662() - + GetCumDownDataPort_OTHER() - + GetCumDownDataPort_PeerCache(); } + + GetCumDownDataPort_OTHER(); } static uint64 GetCumDownDataPort_4662() { return cumDownDataPort_4662 + sesDownDataPort_4662; } static uint64 GetCumDownDataPort_OTHER() { return cumDownDataPort_OTHER + sesDownDataPort_OTHER; } - static uint64 GetCumDownDataPort_PeerCache() { return cumDownDataPort_PeerCache + sesDownDataPort_PeerCache; } // Session port breakdown stats for received bytes... static uint64 GetDownSessionDataPort() { return sesDownDataPort_4662 - + sesDownDataPort_OTHER - + sesDownDataPort_PeerCache; } + + sesDownDataPort_OTHER; } static uint64 GetDownDataPort_4662() { return sesDownDataPort_4662; } static uint64 GetDownDataPort_OTHER() { return sesDownDataPort_OTHER; } - static uint64 GetDownDataPort_PeerCache() { return sesDownDataPort_PeerCache; } // Saved stats for cumulative connection data static float GetConnAvgDownRate() { return cumConnAvgDownRate; } @@ -1340,16 +1322,6 @@ class CPreferences static bool IsRunAsUserEnabled(); static bool IsPreferingRestrictedOverUser() { return m_bPreferRestrictedOverUser; } - // PeerCache - static bool IsPeerCacheDownloadEnabled() { return (m_bPeerCacheEnabled && !IsClientCryptLayerRequested()); } - static time_t GetPeerCacheLastSearch() { return m_uPeerCacheLastSearch; } - static bool WasPeerCacheFound() { return m_bPeerCacheWasFound; } - static void SetPeerCacheLastSearch(time_t dwLastSearch) { m_uPeerCacheLastSearch = dwLastSearch; } - static void SetPeerCacheWasFound(bool bFound) { m_bPeerCacheWasFound = bFound; } - static uint16 GetPeerCachePort() { return m_nPeerCachePort; } - static void SetPeerCachePort(uint16 nPort) { m_nPeerCachePort = nPort; } - static bool GetPeerCacheShow() { return m_bPeerCacheShow; } - // Verbose log options static bool GetEnableVerboseOptions() { return m_bEnableVerboseOptions; } static bool GetVerbose() { return m_bVerbose; } @@ -1399,7 +1371,7 @@ class CPreferences static void SetRememberDownloadedFiles(bool nv) { m_bRememberDownloadedFiles = nv; } static void SetRememberCancelledFiles(bool nv) { m_bRememberCancelledFiles = nv; } // mail notifier - static const EmailSettings &GetEmailSettings() { return m_email; }; + static const EmailSettings &GetEmailSettings() { return m_email; } static void SetEmailSettings(const EmailSettings &settings) { m_email = settings; } static bool IsNotifierSendMailEnabled() { return m_email.bSendMail; } @@ -1413,12 +1385,10 @@ class CPreferences static void SetAllocCompleteMode(bool in) { m_bAllocFull = in; } // encryption - static bool IsClientCryptLayerSupported() { return m_bCryptLayerSupported; } - static bool IsClientCryptLayerRequested() { return IsClientCryptLayerSupported() && m_bCryptLayerRequested; } - static bool IsClientCryptLayerRequired() { return IsClientCryptLayerRequested() && m_bCryptLayerRequired; } - static bool IsClientCryptLayerRequiredStrict() { return false; } // not even incoming test connections will be answered - static bool IsServerCryptLayerUDPEnabled() { return IsClientCryptLayerSupported(); } - static bool IsServerCryptLayerTCPRequested() { return IsClientCryptLayerRequested(); } + static bool IsCryptLayerEnabled() { return m_bCryptLayerSupported; } + static bool IsCryptLayerPreferred() { return IsCryptLayerEnabled() && m_bCryptLayerRequested; } + static bool IsCryptLayerRequired() { return IsCryptLayerPreferred() && m_bCryptLayerRequired; } + static bool IsCryptLayerRequiredStrict() { return false; } // not even incoming test connections will be answered static uint32 GetKadUDPKey() { return m_dwKadUDPKey; } static uint8 GetCryptTCPPaddingLength() { return m_byCryptTCPPaddingLength; } diff --git a/srchybrid/PreferencesDlg.cpp b/srchybrid/PreferencesDlg.cpp index a750500b..5a6486f4 100644 --- a/srchybrid/PreferencesDlg.cpp +++ b/srchybrid/PreferencesDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Preview.cpp b/srchybrid/Preview.cpp index 002f5412..168a50cc 100644 --- a/srchybrid/Preview.cpp +++ b/srchybrid/Preview.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -59,12 +59,11 @@ BOOL CPreviewThread::Run() { try { const CString srcName(m_pPartfile->GetFileName()); - LPCTSTR const pExt = _tcsrchr(srcName, _T('.')); CString strPreviewName(m_pPartfile->GetTmpPath()); - strPreviewName.AppendFormat(_T("%s_preview%s"), (LPCTSTR)srcName.Left(5), (pExt ? pExt : _T(""))); - strPreviewName.Format(_T("%s%s-rec.tmp"), (LPCTSTR)m_pPartfile->GetTmpPath(), (LPCTSTR)m_pPartfile->GetFileName().Left(5)); + strPreviewName.AppendFormat(_T("%s_preview%s"), (LPCTSTR)srcName.Left(5), ::PathFindExtension(srcName)); bool bRet = m_pPartfile->CopyPartFile(m_aFilled, strPreviewName); + m_pPartfile->m_bPreviewing = false; m_aFilled.RemoveAll(); if (!bRet) return FALSE; @@ -108,9 +107,9 @@ BOOL CPreviewThread::Run() ::CloseHandle(SE.hProcess); } CFile::Remove(strPreviewName); - } catch (CFileException *error) { + } catch (CFileException *ex) { m_pPartfile->m_bPreviewing = false; - error->Delete(); + ex->Delete(); } return TRUE; } diff --git a/srchybrid/Preview.h b/srchybrid/Preview.h index 3e2126ea..e7c7409b 100644 --- a/srchybrid/Preview.h +++ b/srchybrid/Preview.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/PreviewDlg.cpp b/srchybrid/PreviewDlg.cpp index 28705923..ff77c31b 100644 --- a/srchybrid/PreviewDlg.cpp +++ b/srchybrid/PreviewDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2003-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2003-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -46,9 +46,7 @@ PreviewDlg::PreviewDlg(CWnd *pParent /*=NULL*/) PreviewDlg::~PreviewDlg() { - for (int i = _countof(m_icons); --i >= 0;) - if (m_icons[i]) - VERIFY(::DestroyIcon(m_icons[i])); + DestroyIconsArr(m_icons, _countof(m_icons)); } void PreviewDlg::DoDataExchange(CDataExchange *pDX) diff --git a/srchybrid/PreviewDlg.h b/srchybrid/PreviewDlg.h index efc54253..433a3a3d 100644 --- a/srchybrid/PreviewDlg.h +++ b/srchybrid/PreviewDlg.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2003-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2003-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Quantize.cpp b/srchybrid/Quantize.cpp index 97102019..58575d32 100644 --- a/srchybrid/Quantize.cpp +++ b/srchybrid/Quantize.cpp @@ -74,7 +74,7 @@ BOOL CQuantizer::ProcessImage(HANDLE hImage) void CQuantizer::AddColor(NODE **ppNode, BYTE r, BYTE g, BYTE b, BYTE a, UINT nColorBits, UINT nLevel, UINT *pLeafCount, NODE **pReducibleNodes) { - static const BYTE mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; + static BYTE const mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; // If the node doesn't exist, create it. if (*ppNode == NULL) diff --git a/srchybrid/Quantize.h b/srchybrid/Quantize.h index ecffb0ec..39246571 100644 --- a/srchybrid/Quantize.h +++ b/srchybrid/Quantize.h @@ -49,11 +49,11 @@ class CQuantizer virtual ~CQuantizer(); BOOL ProcessImage(HANDLE hImage); UINT GetColorCount() const; - void SetColorTable(RGBQUAD* prgb); + void SetColorTable(RGBQUAD *prgb); protected: void AddColor(NODE **ppNode, BYTE r, BYTE g, BYTE b, BYTE a, UINT nColorBits, UINT nLevel, UINT *pLeafCount, NODE **pReducibleNodes); - void* CreateNode(UINT nLevel, UINT nColorBits, UINT* pLeafCount, NODE **pReducibleNodes); + void* CreateNode(UINT nLevel, UINT nColorBits, UINT *pLeafCount, NODE **pReducibleNodes); void DeleteTree(NODE **ppNode); static void ReduceTree(UINT nColorBits, UINT *pLeafCount, NODE **pReducibleNodes); static void GetPaletteColors(NODE *pTree, RGBQUAD *prgb, UINT *pIndex, UINT *pSum); diff --git a/srchybrid/QueueListCtrl.cpp b/srchybrid/QueueListCtrl.cpp index 5959aa74..14c20a87 100644 --- a/srchybrid/QueueListCtrl.cpp +++ b/srchybrid/QueueListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/QueueListCtrl.h b/srchybrid/QueueListCtrl.h index 077ef046..9452f78d 100644 --- a/srchybrid/QueueListCtrl.h +++ b/srchybrid/QueueListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/RARFile.cpp b/srchybrid/RARFile.cpp index 281310a7..1c0eefbe 100644 --- a/srchybrid/RARFile.cpp +++ b/srchybrid/RARFile.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -24,6 +24,9 @@ static char THIS_FILE[] = __FILE__; #endif +LPCTSTR CRARFile::sUnrar_download = _T("Download latest version of '") + UNRAR_DLL_NAME + _T("' from https://www.rarlab.com and copy the DLL into eMule installation folder."); CRARFile::CRARFile() : m_hLibUnRar(NULL) @@ -45,7 +48,7 @@ CRARFile::~CRARFile() bool CRARFile::InitUnRarLib() { if (m_hLibUnRar == NULL) { - m_hLibUnRar = LoadLibrary(_T("unrar.dll")); + m_hLibUnRar = LoadLibrary(UNRAR_DLL_NAME); if (m_hLibUnRar) { (FARPROC&)m_pfnRAROpenArchiveEx = GetProcAddress(m_hLibUnRar, "RAROpenArchiveEx"); (FARPROC&)m_pfnRARCloseArchive = GetProcAddress(m_hLibUnRar, "RARCloseArchive"); @@ -63,7 +66,7 @@ bool CRARFile::InitUnRarLib() } if (m_hLibUnRar == NULL) - LogWarning(LOG_STATUSBAR, _T("Failed to initialize UNRAR.DLL. Download latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder.")); + LogWarning(LOG_STATUSBAR, _T("Failed to initialize ") UNRAR_DLL_NAME _T(". %s"), sUnrar_download); return m_hLibUnRar != NULL; } @@ -139,7 +142,7 @@ bool CRARFile::Extract(LPCTSTR pszDstFilePath) const } catch (...) { return false; } - return (iProcessFileResult == 0); + return !iProcessFileResult; } bool CRARFile::Skip() const @@ -155,5 +158,5 @@ bool CRARFile::Skip() const } catch (...) { return false; } - return (iProcessFileResult == 0); + return !iProcessFileResult; } \ No newline at end of file diff --git a/srchybrid/RARFile.h b/srchybrid/RARFile.h index fabbe71e..2a43331c 100644 --- a/srchybrid/RARFile.h +++ b/srchybrid/RARFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2005-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2005-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -16,30 +16,36 @@ //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #pragma once -#define ERAR_END_ARCHIVE 10 -#define ERAR_NO_MEMORY 11 -#define ERAR_BAD_DATA 12 -#define ERAR_BAD_ARCHIVE 13 -#define ERAR_UNKNOWN_FORMAT 14 -#define ERAR_EOPEN 15 -#define ERAR_ECREATE 16 -#define ERAR_ECLOSE 17 -#define ERAR_EREAD 18 -#define ERAR_EWRITE 19 -#define ERAR_SMALL_BUF 20 -#define ERAR_UNKNOWN 21 +#define ERAR_END_ARCHIVE 10 +#define ERAR_NO_MEMORY 11 +#define ERAR_BAD_DATA 12 +#define ERAR_BAD_ARCHIVE 13 +#define ERAR_UNKNOWN_FORMAT 14 +#define ERAR_EOPEN 15 +#define ERAR_ECREATE 16 +#define ERAR_ECLOSE 17 +#define ERAR_EREAD 18 +#define ERAR_EWRITE 19 +#define ERAR_SMALL_BUF 20 +#define ERAR_UNKNOWN 21 -#define RAR_OM_LIST 0 -#define RAR_OM_EXTRACT 1 +#define RAR_OM_LIST 0 +#define RAR_OM_EXTRACT 1 -#define RAR_SKIP 0 -#define RAR_TEST 1 -#define RAR_EXTRACT 2 +#define RAR_SKIP 0 +#define RAR_TEST 1 +#define RAR_EXTRACT 2 -#define RAR_VOL_ASK 0 -#define RAR_VOL_NOTIFY 1 +#define RAR_VOL_ASK 0 +#define RAR_VOL_NOTIFY 1 -#define RAR_DLL_VERSION 4 +#define RAR_DLL_VERSION 4 + +#ifdef _WIN64 +#define UNRAR_DLL_NAME _T("unrar64.dll") +#else +#define UNRAR_DLL_NAME _T("unrar.dll") +#endif #pragma pack(push, 1) struct RAROpenArchiveDataEx @@ -95,6 +101,8 @@ class CRARFile bool Extract(LPCTSTR pszDstFilePath) const; bool Skip() const; + static LPCTSTR sUnrar_download; + protected: CString m_strArchiveFilePath; HMODULE m_hLibUnRar; diff --git a/srchybrid/Resource.h b/srchybrid/Resource.h index 5fcc8e9c..737e046c 100644 --- a/srchybrid/Resource.h +++ b/srchybrid/Resource.h @@ -1208,7 +1208,7 @@ #define IDS_NEWMSG 1266 #define IDS_PREF_STARTNEXTFILECATONLY 1267 #define IDS_LOG_ULDL_EVENTS 1268 -#define IDS_PEERCACHE_ENABLED 1269 +//#define IDS_PEERCACHE_ENABLED 1269 #define IDS_IRC_EMULEPROTO_ALLOWADDFRIEND 1270 #define IDS_SOURCESWAPBLOCKED 1271 #define IDS_TRICKLING 1272 @@ -1240,9 +1240,9 @@ #define IDS_WIZ_STARTWITHWINDOWS 1298 #define IDS_KAD_WAITCBK 1299 #define IDS_KAD_TOOMANDYKADLKPS 1300 -#define IDS_PCDS_CLIENTWAIT 1301 -#define IDS_PCDS_CACHEWAIT 1302 -#define IDS_CACHE 1303 +//#define IDS_PCDS_CLIENTWAIT 1301 +//#define IDS_PCDS_CACHEWAIT 1302 +//#define IDS_CACHE 1303 #define IDS_INDEXED 1304 #define IDS_KADINFO_SRC 1305 #define IDS_KADINFO_KEYW 1306 @@ -1656,7 +1656,7 @@ #define IDC_TEMPFILES 2144 #define IDC_WIZ_APPLY_BUTTON 2149 #define IDC_WIZ_CANCEL_BUTTON 2153 -#define IDC_UNCLIST 2155 +//#define IDC_UNCLIST 2155 #define IDC_PORT 2162 #define IDC_APPLY 2164 #define IDC_UPLOAD_CAP 2166 @@ -2121,7 +2121,7 @@ #define IDC_STATIC133x 2743 #define IDC_CDIDENT 2744 #define IDC_UNCADD 2745 -#define IDC_UNCREM 2746 +//#define IDC_UNCREM 2746 #define IDC_SEC_MISC 2747 #define IDC_SEC_OBFUSCATIONBOX 2748 #define IDC_MMPASSWORDFIELD 2749 diff --git a/srchybrid/RichEditCtrlX.cpp b/srchybrid/RichEditCtrlX.cpp index 271ebeaa..e7f0c0d0 100644 --- a/srchybrid/RichEditCtrlX.cpp +++ b/srchybrid/RichEditCtrlX.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -268,7 +268,7 @@ void CRichEditCtrlX::UpdateSyntaxColoring() psz = pszEnd + 1; } else { bool bFoundKeyword = false; - for (int k = 0; k < m_astrKeywords.GetCount(); ++k) { + for (INT_PTR k = 0; k < m_astrKeywords.GetCount(); ++k) { const CString &rstrKeyword(m_astrKeywords[k]); int iKwLen = rstrKeyword.GetLength(); if (_tcsncmp(psz, rstrKeyword, iKwLen) == 0 && (psz[iKwLen] == _T('\0') || _tcschr(m_strSeparators, psz[iKwLen]) != NULL)) { diff --git a/srchybrid/RichEditStream.cpp b/srchybrid/RichEditStream.cpp index ede43d59..176fe989 100644 --- a/srchybrid/RichEditStream.cpp +++ b/srchybrid/RichEditStream.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/SHAHashSet.cpp b/srchybrid/SHAHashSet.cpp index aa5f7cca..267a51b3 100644 --- a/srchybrid/SHAHashSet.cpp +++ b/srchybrid/SHAHashSet.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "shahashset.h" #include "opcodes.h" @@ -722,21 +721,17 @@ bool CAICHRecoveryHashSet::SaveHashSet() if (!lockKnown2Met.Lock(SEC2MS(5))) return false; - CString fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + KNOWN2_MET_FILENAME); CSafeFile file; - CFileException fexp; - if (!file.Open(fullpath, CFile::modeCreate | CFile::modeReadWrite | CFile::modeNoTruncate | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - theApp.QueueLogLine(true, _T("%s"), (LPCTSTR)strError); - } + CFileException fex; + if (!file.Open(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + KNOWN2_MET_FILENAME + , CFile::modeCreate | CFile::modeReadWrite | CFile::modeNoTruncate | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone, &fex)) + { + if (fex.m_cause != CFileException::fileNotFound) + theApp.QueueLogLine(true, _T("%s%s"), _T("Failed to load ") KNOWN2_MET_FILENAME, (LPCTSTR)CExceptionStrDash(fex)); return false; } + //::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { - //::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); if (file.GetLength() <= 0) file.WriteUInt8(KNOWN2_MET_VERSION); else if (file.ReadUInt8() != KNOWN2_MET_VERSION) @@ -774,15 +769,12 @@ bool CAICHRecoveryHashSet::SaveHashSet() theApp.QueueDebugLogLine(false, _T("Successfully saved AICH Hashset, %u Hashes + 1 Masterhash written"), nHashCount); file.Flush(); file.Close(); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) theApp.QueueLogLine(true, GetResString(IDS_ERR_MET_BAD), KNOWN2_MET_FILENAME); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - theApp.QueueLogLine(true, GetResString(IDS_ERR_SERVERMET_UNKNOWN), buffer); - } - error->Delete(); + else + theApp.QueueLogLine(true, GetResString(IDS_ERR_SERVERMET_UNKNOWN), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); FreeHashSet(); return false; } @@ -801,21 +793,18 @@ bool CAICHRecoveryHashSet::LoadHashSet() ASSERT(0); return false; } - CString fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + KNOWN2_MET_FILENAME); + CSafeFile file; - CFileException fexp; - if (!file.Open(fullpath, CFile::modeCreate | CFile::modeRead | CFile::modeNoTruncate | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - theApp.QueueLogLine(true, _T("%s"), (LPCTSTR)strError); - } + CFileException fex; + if (!file.Open(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + KNOWN2_MET_FILENAME + , CFile::modeCreate | CFile::modeRead | CFile::modeNoTruncate | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyNone, &fex)) + { + if (fex.m_cause != CFileException::fileNotFound) + theApp.QueueLogLine(true, _T("%s%s"), _T("Failed to load ") KNOWN2_MET_FILENAME, (LPCTSTR)CExceptionStrDash(fex)); return false; } + //::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { - //::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); uint8 header = file.ReadUInt8(); if (header != KNOWN2_MET_VERSION) AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName()); @@ -881,15 +870,12 @@ bool CAICHRecoveryHashSet::LoadHashSet() file.Seek(nHashCount * (LONGLONG)HASHSIZE, CFile::current); } theApp.QueueDebugLogLine(true, _T("Failed to load HashSet: HashSet not found!")); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) theApp.QueueLogLine(true, GetResString(IDS_ERR_MET_BAD), KNOWN2_MET_FILENAME); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - theApp.QueueLogLine(true, GetResString(IDS_ERR_SERVERMET_UNKNOWN), buffer); - } - error->Delete(); + else + theApp.QueueLogLine(true, GetResString(IDS_ERR_SERVERMET_UNKNOWN), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); } return false; } @@ -972,7 +958,7 @@ void CAICHRecoveryHashSet::UntrustedHashReceived(const CAICHHash &Hash, uint32 d INT_PTR nSigningIPsTotal = 0; // unique clients who send us a hash INT_PTR nMostTrustedPos = -1; // the hash which most clients send us INT_PTR nMostTrustedIPs = 0; - for (int i = 0; i < m_aUntrustedHashes.GetCount(); ++i) { + for (INT_PTR i = 0; i < m_aUntrustedHashes.GetCount(); ++i) { const INT_PTR signings = m_aUntrustedHashes[i].m_adwIpsSigning.GetCount(); nSigningIPsTotal += signings; if (signings > nMostTrustedIPs) { diff --git a/srchybrid/SHAHashSet.h b/srchybrid/SHAHashSet.h index 77aeb367..c172e146 100644 --- a/srchybrid/SHAHashSet.h +++ b/srchybrid/SHAHashSet.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -15,7 +15,6 @@ //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - /* SHA hashset basically exists of 1 Tree for all Parts (9.28MB) + n Trees for all blocks (180KB) while n is the number of Parts. @@ -63,7 +62,6 @@ Version 2 of AICH also supports 32bit identifiers to support large files, check */ - #pragma once #define HASHSIZE 20u diff --git a/srchybrid/SMTPdialog.cpp b/srchybrid/SMTPdialog.cpp index 471d9a92..7d9b42ee 100644 --- a/srchybrid/SMTPdialog.cpp +++ b/srchybrid/SMTPdialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/SafeFile.cpp b/srchybrid/SafeFile.cpp index 6efcb6c3..c87e620d 100644 --- a/srchybrid/SafeFile.cpp +++ b/srchybrid/SafeFile.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/SafeFile.h b/srchybrid/SafeFile.h index 0ce5ceed..46749e9a 100644 --- a/srchybrid/SafeFile.h +++ b/srchybrid/SafeFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -21,8 +21,6 @@ namespace Kademlia class CUInt128; }; -#define MAX_CFEXP_ERRORMSG (MAX_PATH + 256) - enum EUTF8str : uint8 { UTF8strNone, // convert Unicode string to locale dependent MBCS diff --git a/srchybrid/Scanner.cpp b/srchybrid/Scanner.cpp index 2fb96235..92462633 100644 --- a/srchybrid/Scanner.cpp +++ b/srchybrid/Scanner.cpp @@ -1257,14 +1257,11 @@ YY_RULE_SETUP // as any other string term. It even can get combined with other search terms and operators // within one search tree. CString strError; - try - { + try { CED2KLink *pLink = CED2KLink::CreateLinkFromUrl(CString(yytext)); - if (pLink && pLink->GetKind() == CED2KLink::kFile) - { + if (pLink && pLink->GetKind() == CED2KLink::kFile) { CED2KFileLink *pFileLink = pLink->GetFileLink(); - if (pFileLink) - { + if (pFileLink) { yylval.pstr = new CStringA; yylval.pstr->Format("ed2k::%S", (LPCTSTR)md4str(pFileLink->GetHashKey())); delete pLink; @@ -1272,9 +1269,7 @@ YY_RULE_SETUP } } delete pLink; - } - catch (const CString &strEd2kLinkError) - { + } catch (const CString &strEd2kLinkError) { strError = strEd2kLinkError; } if (strError.IsEmpty()) diff --git a/srchybrid/Scanner.l b/srchybrid/Scanner.l index 488bea0b..c52f7d06 100644 --- a/srchybrid/Scanner.l +++ b/srchybrid/Scanner.l @@ -336,7 +336,7 @@ number {num1}|{num2} BEGIN(INITIAL); yylval.pstr = new CStringA(yytext); return TOK_STRING; - } + } "\"" { int l = 128; diff --git a/srchybrid/Scheduler.cpp b/srchybrid/Scheduler.cpp index c3eeec82..838abc01 100644 --- a/srchybrid/Scheduler.cpp +++ b/srchybrid/Scheduler.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -76,10 +76,10 @@ void CScheduler::SaveToFile() CIni ini(thePrefs.GetConfigFile(), _T("Scheduler")); ini.WriteInt(_T("Count"), (int)GetCount()); - for (int i = 0; i < GetCount(); ++i) { + for (INT_PTR i = 0; i < GetCount(); ++i) { Schedule_Struct *schedule = theApp.scheduler->GetSchedule(i); CString temp; - temp.Format(_T("Schedule#%i"), i); + temp.Format(_T("Schedule#%i"), (int)i); ini.WriteString(_T("Title"), schedule->title, temp); ini.WriteInt(_T("Day"), schedule->day); ini.WriteInt(_T("StartTime"), (int)schedule->time); @@ -128,41 +128,23 @@ int CScheduler::Check(bool forcecheck) m_iLastCheckedMinute = tNow.GetMinute(); theApp.scheduler->RestoreOriginals(); - for (int si = 0; si < theApp.scheduler->GetCount(); ++si) { - const Schedule_Struct *schedule = theApp.scheduler->GetSchedule(si); + for (INT_PTR i = 0; i < theApp.scheduler->GetCount(); ++i) { + const Schedule_Struct *schedule = theApp.scheduler->GetSchedule(i); if (!schedule->actions[0] || !schedule->enabled) continue; - // check day of week + // check the day of the week if (schedule->day != DAY_DAILY) { - int dow = tNow.GetDayOfWeek(); + UINT dow = (UINT)tNow.GetDayOfWeek(); switch (schedule->day) { case DAY_MO: - if (dow != 2) - continue; - break; case DAY_DI: - if (dow != 3) - continue; - break; case DAY_MI: - if (dow != 4) - continue; - break; case DAY_DO: - if (dow != 5) - continue; - break; case DAY_FR: - if (dow != 6) - continue; - break; case DAY_SA: - if (dow != 7) - continue; - break; case DAY_SO: - if (dow != 1) + if ((schedule->day % 7) + 1 != dow) continue; break; case DAY_MO_FR: @@ -192,7 +174,7 @@ int CScheduler::Check(bool forcecheck) continue; } // OK, lets do the actions of this schedule - ActivateSchedule(si, schedule->time2 == 0); + ActivateSchedule(i, schedule->time2 == 0); } return -1; diff --git a/srchybrid/Scheduler.h b/srchybrid/Scheduler.h index 545de9db..f541841d 100644 --- a/srchybrid/Scheduler.h +++ b/srchybrid/Scheduler.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -82,6 +82,6 @@ class CScheduler UINT original_sources; private: - CArray schedulelist; int m_iLastCheckedMinute; + CArray schedulelist; }; \ No newline at end of file diff --git a/srchybrid/SearchDlg.cpp b/srchybrid/SearchDlg.cpp index da09b034..adc16c2d 100644 --- a/srchybrid/SearchDlg.cpp +++ b/srchybrid/SearchDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -28,7 +28,6 @@ static char THIS_FILE[] = __FILE__; #endif - #define IDBAR_SEARCH_PARAMS (AFX_IDW_CONTROLBAR_FIRST + 32 + 1) // do NOT change that ID, if not absolutely needed (it is stored by MFC in the bar profile!) #define SEARCH_PARAMS_PROFILE _T("SearchFrmBarState") @@ -48,7 +47,7 @@ CSearchDlg::CSearchDlg() { } -BOOL CSearchDlg::Create(CWnd *pParent) +BOOL CSearchDlg::CreateWnd(CWnd *pParent) { // *) The initial size of that frame window must not exceed the window size of the // dialog resource template of the client window (the search results window). @@ -68,6 +67,10 @@ int CSearchDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) context.m_pCurrentDoc = NULL; context.m_pNewViewClass = RUNTIME_CLASS(CSearchResultsWnd); context.m_pNewDocTemplate = NULL; +#ifdef _DEBUG + CFrameDoc dummy; + context.m_pCurrentDoc = &dummy; +#endif m_pwndResults = static_cast(CreateView(&context)); m_wndParams.m_searchdlg = m_pwndResults; m_pwndResults->ModifyStyle(WS_BORDER, 0); @@ -122,26 +125,6 @@ void CSearchDlg::OnSetFocus(CWnd *pOldWnd) m_wndParams.SetFocus(); } -void CSearchDlg::SaveAllSettings() -{ - m_wndParams.SaveSettings(); -} - -void CSearchDlg::ResetHistory() -{ - m_wndParams.ResetHistory(); -} - -BOOL CSearchDlg::IsSearchParamsWndVisible() const -{ - return m_wndParams.IsWindowVisible(); -} - -void CSearchDlg::OpenParametersWnd() -{ - ShowControlBar(&m_wndParams, TRUE, TRUE); -} - void CSearchDlg::DockParametersWnd() { if (m_wndParams.IsFloating()) { @@ -230,24 +213,14 @@ bool CSearchDlg::DoNewEd2kSearch(SSearchParams *pParams) return m_pwndResults->DoNewEd2kSearch(pParams); } -void CSearchDlg::ProcessEd2kSearchLinkRequest(const CString &strSearchTerm) -{ - m_wndParams.ProcessEd2kSearchLinkRequest(strSearchTerm); -} - void CSearchDlg::DeleteAllSearches() { m_pwndResults->DeleteAllSearches(); } -bool CSearchDlg::CanDeleteSearch() const -{ - return m_pwndResults->CanDeleteSearch(); -} - -bool CSearchDlg::CanDeleteAllSearches() const +bool CSearchDlg::CanDeleteSearches() const { - return m_pwndResults->CanDeleteAllSearches(); + return m_pwndResults->CanDeleteSearches(); } void CSearchDlg::DeleteSearch(uint32 nSearchID) @@ -265,7 +238,7 @@ void CSearchDlg::DownloadSelected() m_pwndResults->DownloadSelected(); } -CClosableTabCtrl& CSearchDlg::GetSearchSelector() +CClosableTabCtrl& CSearchDlg::GetSearchSelector() const { return m_pwndResults->searchselect; } diff --git a/srchybrid/SearchDlg.h b/srchybrid/SearchDlg.h index c9b6a910..993d5f65 100644 --- a/srchybrid/SearchDlg.h +++ b/srchybrid/SearchDlg.h @@ -13,10 +13,10 @@ class CSearchDlg : public CFrameWnd DECLARE_DYNCREATE(CSearchDlg) public: - CSearchDlg(); // protected constructor used by dynamic creation + CSearchDlg(); // constructor used by dynamic creation CSearchResultsWnd *m_pwndResults; - BOOL Create(CWnd *pParent); + BOOL CreateWnd(CWnd *pParent); void Localize(); void CreateMenus(); @@ -28,7 +28,7 @@ class CSearchDlg : public CFrameWnd void CancelEd2kSearch(); void CancelKadSearch(UINT uSearchID); void SetNextSearchID(uint32 uNextID); - void ProcessEd2kSearchLinkRequest(const CString &strSearchTerm); + void ProcessEd2kSearchLinkRequest(const CString &strSearchTerm) { m_wndParams.ProcessEd2kSearchLinkRequest(strSearchTerm); } bool CanSearchRelatedFiles() const; void SearchRelatedFiles(CPtrList &listFiles); @@ -36,8 +36,7 @@ class CSearchDlg : public CFrameWnd void DownloadSelected(); void DownloadSelected(bool bPaused); - bool CanDeleteSearch() const; - bool CanDeleteAllSearches() const; + bool CanDeleteSearches() const; void DeleteSearch(uint32 nSearchID); void DeleteAllSearches(); @@ -46,18 +45,18 @@ class CSearchDlg : public CFrameWnd bool CreateNewTab(SSearchParams *pParams, bool bActiveIcon = true); SSearchParams* GetSearchParamsBySearchID(uint32 nSearchID); - CClosableTabCtrl& GetSearchSelector(); + CClosableTabCtrl& GetSearchSelector() const; int GetSelectedCat(); void UpdateCatTabs(); - void SaveAllSettings(); - void ResetHistory(); + void SaveAllSettings() { m_wndParams.SaveSettings(); } + void ResetHistory() { m_wndParams.ResetHistory(); } void SetToolTipsDelay(UINT uDelay); void DeleteAllSearchListCtrlItems(); - BOOL IsSearchParamsWndVisible() const; - void OpenParametersWnd(); + BOOL IsSearchParamsWndVisible() const { return m_wndParams.IsWindowVisible(); } + void OpenParametersWnd() { ShowControlBar(&m_wndParams, TRUE, TRUE); } void DockParametersWnd(); void UpdateSearch(CSearchFile *pSearchFile); diff --git a/srchybrid/SearchFile.cpp b/srchybrid/SearchFile.cpp index 72c49b69..9353a39c 100644 --- a/srchybrid/SearchFile.cpp +++ b/srchybrid/SearchFile.cpp @@ -1,6 +1,6 @@ // parts of this file are based on work from pan One (http://home-3.tiscali.nl/~meost/pms/) //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -113,9 +113,9 @@ IMPLEMENT_DYNAMIC(CSearchFile, CAbstractFile) CSearchFile::CSearchFile(const CSearchFile *copyfrom) : CAbstractFile(copyfrom) + , m_list_childcount() , m_bPreviewPossible() , m_list_bExpanded() - , m_list_childcount() { CSearchFile::UpdateFileRatingCommentAvail(); @@ -153,16 +153,16 @@ CSearchFile::CSearchFile(CFileDataIO &in_data, bool bOptUTF8, uint32 nSearchID, , m_bKademlia(bKademlia) , m_bServerUDPAnswer(bServerUDPAnswer) , m_flags() + , m_nSearchID(nSearchID) , m_nSources() , m_nCompleteSources() - , m_nSearchID(nSearchID) , m_nKadPublishInfo() , m_nSpamRating() - , m_bPreviewPossible() - , m_list_bExpanded() , m_list_childcount() , m_list_parent() , m_eKnown(NotDetermined) + , m_bPreviewPossible() + , m_list_bExpanded() { m_FileIdentifier.SetMD4Hash(in_data); m_nClientID = in_data.ReadUInt32(); @@ -173,6 +173,16 @@ CSearchFile::CSearchFile(CFileDataIO &in_data, bool bOptUTF8, uint32 nSearchID, m_nClientID = 0; m_nClientPort = 0; } + + m_nClientServerIP = nServerIP; + m_nClientServerPort = nServerPort; + if (m_nClientServerIP && m_nClientServerPort) { + SServer server(m_nClientServerIP, m_nClientServerPort, bServerUDPAnswer); + server.m_uAvail = GetIntTagValue(FT_SOURCES); + AddServer(server); + } + m_pszDirectory = pszDirectory ? _tcsdup(pszDirectory) : NULL; + uint32 tagcount = in_data.ReadUInt32(); // NSERVER2.EXE (lugdunum v16.38 patched for Win32) returns the ClientIP+Port of the client which offered that // file, even if that client has not filled the according fields in the OP_OFFERFILES packet with its IP+Port. @@ -234,6 +244,10 @@ CSearchFile::CSearchFile(CFileDataIO &in_data, bool bOptUTF8, uint32 nSearchID, case FT_COMPLETE_SOURCES: if (tag->IsInt()) m_nCompleteSources = tag->GetInt(); + break; + case FT_FOLDERNAME: + if (!bKademlia && !m_pszDirectory && tag->IsStr() && !tag->GetStr().IsEmpty()) + m_pszDirectory = _tcsdup(tag->GetStr()); } m_taglist.Add(tag); } @@ -249,7 +263,7 @@ CSearchFile::CSearchFile(CFileDataIO &in_data, bool bOptUTF8, uint32 nSearchID, // but, in no case, we will use the received file type when adding this search result to the download queue, to avoid // that we are using 'wrong' file types in part files. (this has to be handled when creating the part files) const CString &rstrFileType(GetStrTagValue(FT_FILETYPE)); - CSearchFile::SetFileName(GetStrTagValue(FT_FILENAME), false, rstrFileType.IsEmpty(), true); + SetAFileName(GetStrTagValue(FT_FILENAME), false, rstrFileType.IsEmpty(), true); uint64 ui64FileSize = 0; CTag *pTagFileSize = GetTag(FT_FILESIZE); @@ -276,15 +290,6 @@ CSearchFile::CSearchFile(CFileDataIO &in_data, bool bOptUTF8, uint32 nSearchID, CSearchFile::SetFileType(strDetailFileType.IsEmpty() ? rstrFileType : strDetailFileType); } else CSearchFile::SetFileType(rstrFileType); - - m_nClientServerIP = nServerIP; - m_nClientServerPort = nServerPort; - if (m_nClientServerIP && m_nClientServerPort) { - SServer server(m_nClientServerIP, m_nClientServerPort, bServerUDPAnswer); - server.m_uAvail = GetIntTagValue(FT_SOURCES); - AddServer(server); - } - m_pszDirectory = pszDirectory ? _tcsdup(pszDirectory) : NULL; } CSearchFile::~CSearchFile() @@ -299,8 +304,10 @@ void CSearchFile::StoreToFile(CFileDataIO &rFile) const rFile.WriteHash16(m_FileIdentifier.GetMD4Hash()); rFile.WriteUInt32(m_nClientID); rFile.WriteUInt16(m_nClientPort); + bool bHasDirectory = m_pszDirectory && *m_pszDirectory; uint32 nTagCount = (uint32)m_taglist.GetCount(); nTagCount += static_cast(m_FileIdentifier.HasAICHHash()); + nTagCount += static_cast(bHasDirectory); rFile.WriteUInt32(nTagCount); for (INT_PTR pos = 0; pos < m_taglist.GetCount(); ++pos) { @@ -314,6 +321,8 @@ void CSearchFile::StoreToFile(CFileDataIO &rFile) const CTag aichtag(FT_AICH_HASH, m_FileIdentifier.GetAICHHash().GetString()); aichtag.WriteNewEd2kTag(rFile); } + if (bHasDirectory) + CTag(FT_FOLDERNAME, m_pszDirectory).WriteNewEd2kTag(rFile); } void CSearchFile::UpdateFileRatingCommentAvail(bool bForceUpdate) diff --git a/srchybrid/SearchFile.h b/srchybrid/SearchFile.h index 1907ba8b..b06de6ad 100644 --- a/srchybrid/SearchFile.h +++ b/srchybrid/SearchFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -175,14 +175,14 @@ class CSearchFile : public CAbstractFile byte noshow : 1; //bit #0 - do not display in GUI lists byte nowrite : 1; //bit #1 - do not save this entry } m_flags; + uint32 m_nSearchID; uint32 m_nSources; uint32 m_nCompleteSources; + uint32 m_nKadPublishInfo; uint32 m_nClientID; - uint16 m_nClientPort; - uint32 m_nSearchID; uint32 m_nClientServerIP; uint16 m_nClientServerPort; - uint32 m_nKadPublishInfo; + uint16 m_nClientPort; CSimpleArray m_aClients; CSimpleArray m_aServers; CSimpleArray m_listImages; @@ -192,11 +192,11 @@ class CSearchFile : public CAbstractFile uint32 m_nSpamRating; // GUI helpers - bool m_bPreviewPossible; - bool m_list_bExpanded; UINT m_list_childcount; CSearchFile *m_list_parent; EKnownType m_eKnown; + bool m_bPreviewPossible; + bool m_list_bExpanded; }; bool IsValidSearchResultClientIPPort(uint32 nIP, uint16 nPort); \ No newline at end of file diff --git a/srchybrid/SearchList.cpp b/srchybrid/SearchList.cpp index 69ebe4a4..7d4726e6 100644 --- a/srchybrid/SearchList.cpp +++ b/srchybrid/SearchList.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -43,6 +43,19 @@ static char THIS_FILE[] = __FILE__; #endif +namespace +{ + bool CFileOpenD(CFile &file, LPCTSTR lpszFileName, UINT nOpenFlags, LPCTSTR lpszMsg) + { + CFileException ex; + if (!file.Open(lpszFileName, nOpenFlags, &ex)) { + if (ex.m_cause != CFileException::fileNotFound) + DebugLogError(_T("%s%s"), lpszMsg, (LPCTSTR)CExceptionStrDash(ex)); + return false; + } + return true; + } +} #define SPAMFILTER_FILENAME _T("SearchSpam.met") #define STOREDSEARCHES_FILENAME _T("StoredSearches.met") @@ -113,6 +126,7 @@ void CSearchList::ShowResults(uint32 nSearchID) } } + outputwnd->UpdateTabHeader(nSearchID); outputwnd->SetUpdateMode(bCurUpdateMode); outputwnd->SetRedraw(true); } @@ -204,6 +218,8 @@ UINT CSearchList::ProcessSearchAnswer(const uchar *in_packet, uint32 size toadd->SetPreviewPossible(sender.GetPreviewSupport() && ED2KFT_VIDEO == GetED2KFileTypeID(toadd->GetFileName())); AddToList(toadd, true); } + if (outputwnd) + outputwnd->UpdateTabHeader(uSearchID); if (pbMoreResultsAvailable) *pbMoreResultsAvailable = false; @@ -244,6 +260,8 @@ UINT CSearchList::ProcessSearchAnswer(const uchar *in_packet, uint32 size, bool } AddToList(toadd, false); } + if (outputwnd) + outputwnd->UpdateTabHeader(m_nCurED2KSearchID); if (pbMoreResultsAvailable) *pbMoreResultsAvailable = false; @@ -311,6 +329,9 @@ UINT CSearchList::ProcessUDPSearchAnswer(CFileDataIO &packet, bool bOptUTF8, uin } AddToList(toadd, false, nServerIP); + if (outputwnd) + outputwnd->UpdateTabHeader(m_nCurED2KSearchID); + return GetED2KResultCount(); } @@ -565,7 +586,7 @@ bool CSearchList::AddToList(CSearchFile *toadd, bool bClientResponse, uint32 dwF } if (bestEntry) { parent->SetFileSize(bestEntry->GetFileSize()); - parent->SetFileName(bestEntry->GetFileName()); + parent->SetAFileName(bestEntry->GetFileName()); parent->SetFileType(bestEntry->GetFileType()); parent->SetSourceCount(uAllChildrenSourceCount); parent->SetCompleteSourceCount(uAllChildrenCompleteSourceCount); @@ -621,7 +642,7 @@ bool CSearchList::AddToList(CSearchFile *toadd, bool bClientResponse, uint32 dwF // add the 'Availability' of this new search result entry to the total search result count for this search AddResultCount(toadd->GetSearchID(), toadd->GetFileHash(), uAvail, toadd->IsConsideredSpam()); - // add parent in GUI + // add to parent in GUI if (outputwnd) outputwnd->AddResult(toadd); @@ -783,6 +804,8 @@ void CSearchList::KademliaSearchKeyword(uint32 nSearchID, const Kademlia::CUInt1 } else if (raAICHHashes.GetCount() > 1) DEBUG_ONLY(DebugLog(_T("Received multiple (%u) AICH hashes for search result %s, ignoring AICH"), raAICHHashes.GetCount(), (LPCTSTR)tempFile->GetFileName())); AddToList(tempFile); + if (outputwnd) + outputwnd->UpdateTabHeader(nSearchID); } else DebugLogWarning(_T("Kad Searchresult failed sanitize check against search query, ignoring. (%s)"), name); } @@ -1229,21 +1252,16 @@ void CSearchList::LoadSpamFilter() m_bSpamFilterLoaded = true; - const CString &fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + SPAMFILTER_FILENAME); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(fullpath, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") SPAMFILTER_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - DebugLogError(_T("%s"), (LPCTSTR)strError); - } + if (!CFileOpenD(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + SPAMFILTER_FILENAME + , CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to load ") SPAMFILTER_FILENAME)) + { return; } - ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { uint8 header = file.ReadUInt8(); if (header != MET_HEADER_I64TAGS) { @@ -1324,15 +1342,12 @@ void CSearchList::LoadSpamFilter() , (unsigned)m_aui64KnownSpamSizes.GetCount() , (unsigned)m_astrKnownSpamNames.GetCount() , (unsigned)m_astrKnownSimilarSpamNames.GetCount()); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) DebugLogError(_T("Failed to load searchspam.met, corrupt")); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - DebugLogError(_T("Failed to load searchspam.met, %s"), buffer); - } - error->Delete(); + else + DebugLogError(_T("Failed to load searchspam.met%s"), (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } @@ -1341,38 +1356,34 @@ void CSearchList::SaveSpamFilter() if (!m_bSpamFilterLoaded) return; - const CString &fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + SPAMFILTER_FILENAME); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(fullpath, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") SPAMFILTER_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - DebugLogError(_T("%s"), (LPCTSTR)strError); - } + if (!CFileOpenD(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + SPAMFILTER_FILENAME + , CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to load ") SPAMFILTER_FILENAME)) + { return; } + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { uint32 nCount = 0; file.WriteUInt8(MET_HEADER_I64TAGS); file.WriteUInt32(nCount); - for (int i = 0; i < m_astrKnownSpamNames.GetCount(); ++i) { + for (INT_PTR i = 0; i < m_astrKnownSpamNames.GetCount(); ++i) { CTag tag(SP_FILEFULLNAME, m_astrKnownSpamNames[i]); tag.WriteNewEd2kTag(file, UTF8strOptBOM); ++nCount; } - for (int i = 0; i < m_astrKnownSimilarSpamNames.GetCount(); ++i) { + for (INT_PTR i = 0; i < m_astrKnownSimilarSpamNames.GetCount(); ++i) { CTag tag(SP_FILESIMILARNAME, m_astrKnownSimilarSpamNames[i]); tag.WriteNewEd2kTag(file, UTF8strOptBOM); ++nCount; } - for (int i = 0; i < m_aui64KnownSpamSizes.GetCount(); ++i) { + for (INT_PTR i = 0; i < m_aui64KnownSpamSizes.GetCount(); ++i) { CTag tag(SP_FILESIZE, m_aui64KnownSpamSizes[i], true); tag.WriteNewEd2kTag(file); ++nCount; @@ -1407,31 +1418,24 @@ void CSearchList::SaveSpamFilter() file.WriteUInt32(nCount); file.Close(); DebugLog(_T("Stored searchspam.met, wrote %u records"), nCount); - } catch (CFileException *error) { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - DebugLogError(_T("Failed to save searchspam.met, %s"), buffer); - error->Delete(); + } catch (CFileException *ex) { + DebugLogError(_T("Failed to save searchspam.met%s"), (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } void CSearchList::StoreSearches() { // store open searches on shutdown to restore them on the next startup - const CString &fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + STOREDSEARCHES_FILENAME); - CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(fullpath, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") STOREDSEARCHES_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - DebugLogError(_T("%s"), (LPCTSTR)strError); - } + if (!CFileOpenD(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + STOREDSEARCHES_FILENAME + , CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to save ") STOREDSEARCHES_FILENAME)) + { return; } + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { file.WriteUInt8(MET_HEADER_I64TAGS); @@ -1464,32 +1468,25 @@ void CSearchList::StoreSearches() file.Close(); DebugLog(_T("Stored %u open search(es) for restoring on next start"), nCount); - } catch (CFileException *error) { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - DebugLogError(_T("Failed to save %s, %s"), STOREDSEARCHES_FILENAME, buffer); - error->Delete(); + } catch (CFileException *ex) { + DebugLogError(_T("Failed to save %s%s"), STOREDSEARCHES_FILENAME, (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } void CSearchList::LoadSearches() { ASSERT(m_listFileLists.IsEmpty()); - const CString &fullpath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + STOREDSEARCHES_FILENAME); CSafeBufferedFile file; - CFileException fexp; - if (!file.Open(fullpath, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - if (fexp.m_cause != CFileException::fileNotFound) { - CString strError(_T("Failed to load ") STOREDSEARCHES_FILENAME _T(" file")); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - DebugLogError(_T("%s"), (LPCTSTR)strError); - } + if (!CFileOpenD(file + , thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + STOREDSEARCHES_FILENAME + , CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite + , _T("Failed to load ") STOREDSEARCHES_FILENAME)) + { return; } - ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { uint8 header = file.ReadUInt8(); if (header != MET_HEADER_I64TAGS) { @@ -1519,11 +1516,14 @@ void CSearchList::LoadSearches() } else ASSERT(0); //failed to create tab - // fill the list with stored results - for (uint32 nFileCount = file.ReadUInt32(); nFileCount-- > 0;) { + // fill the list using stored data + for (uint32 nFileCount = file.ReadUInt32(); nFileCount > 0; --nFileCount) { CSearchFile *toadd = new CSearchFile(file, true, pParams->dwSearchID, 0, 0, NULL, pParams->eType == SearchTypeKademlia); AddToList(toadd, pParams->bClientSharedFiles); } + if (outputwnd) + outputwnd->UpdateTabHeader(pParams->dwSearchID); + if (bDeleteParams) delete pParams; } @@ -1531,16 +1531,9 @@ void CSearchList::LoadSearches() // adjust the starting values for search IDs to avoid reused IDs in loaded searches Kademlia::CSearchManager::SetNextSearchID(++nID); theApp.emuledlg->searchwnd->SetNextSearchID(0x80000000u + nID); - } catch (CFileException *error) { - LPCTSTR sErr; - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - if (error->m_cause == CFileException::endOfFile) - sErr = _T("corrupt"); - else { - sErr = buffer; - GetExceptionMessage(*error, buffer, _countof(buffer)); - } - DebugLogError(_T("Failed to load %s, %s"), STOREDSEARCHES_FILENAME, sErr); - error->Delete(); + } catch (CFileException *ex) { + DebugLogError(_T("Failed to load %s%s"), STOREDSEARCHES_FILENAME + , (ex->m_cause == CFileException::endOfFile) ? _T(" - corrupt") : (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } \ No newline at end of file diff --git a/srchybrid/SearchList.h b/srchybrid/SearchList.h index 15e926bc..667e51d7 100644 --- a/srchybrid/SearchList.h +++ b/srchybrid/SearchList.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -118,20 +118,20 @@ class CSearchList CSearchListCtrl *outputwnd; CString m_strResultFileType; - uint32 m_nCurED2KSearchID; - // spam filter typedef CMap CSpammerIPMap; typedef CMap CUDPServerRecordMap; - CStringArray m_astrSpamCheckCurSearchExp; - CStringArray m_astrKnownSpamNames; - CStringArray m_astrKnownSimilarSpamNames; - CSpammerIPMap m_mapKnownSpamServerIPs; - CSpammerIPMap m_mapKnownSpamSourcesIPs; - CMap m_mapKnownSpamHashes; - CArray m_aui64KnownSpamSizes; - CArray m_aCurED2KSentRequestsIPs; - CArray m_aCurED2KSentReceivedIPs; - CUDPServerRecordMap m_mUDPServerRecords; - bool m_bSpamFilterLoaded; + CMap m_mapKnownSpamHashes; + CSpammerIPMap m_mapKnownSpamServerIPs; + CSpammerIPMap m_mapKnownSpamSourcesIPs; + CUDPServerRecordMap m_mUDPServerRecords; + CStringArray m_astrSpamCheckCurSearchExp; + CStringArray m_astrKnownSpamNames; + CStringArray m_astrKnownSimilarSpamNames; + CArray m_aui64KnownSpamSizes; + CArray m_aCurED2KSentRequestsIPs; + CArray m_aCurED2KSentReceivedIPs; + + uint32 m_nCurED2KSearchID; + bool m_bSpamFilterLoaded; }; \ No newline at end of file diff --git a/srchybrid/SearchListCtrl.cpp b/srchybrid/SearchListCtrl.cpp index 01dfea04..06b00ec2 100644 --- a/srchybrid/SearchListCtrl.cpp +++ b/srchybrid/SearchListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -330,7 +330,7 @@ void CSearchListCtrl::Localize() CString strRes(GetResString(IDS_SEARCHAVAIL)); if (thePrefs.IsExtControlsEnabled()) strRes.AppendFormat(_T(" (%s)"), (LPCTSTR)GetResString(IDS_DL_SOURCES)); //modify "availability" header - hdi.pszText = const_cast((LPCTSTR)strRes); + hdi.pszText = (LPTSTR)(LPCTSTR)strRes; GetHeaderCtrl()->SetItem(2, &hdi); CreateMenus(); @@ -338,35 +338,9 @@ void CSearchListCtrl::Localize() void CSearchListCtrl::AddResult(const CSearchFile *toshow) { - bool bFilterActive = !theApp.emuledlg->searchwnd->m_pwndResults->m_astrFilter.IsEmpty(); - bool bItemFiltered = bFilterActive && IsFilteredOut(toshow); - - // update tab-counter for the given searchfile - CClosableTabCtrl &searchselect = theApp.emuledlg->searchwnd->GetSearchSelector(); - TCITEM ti; - ti.mask = TCIF_PARAM; - for (int iItem = searchselect.GetItemCount(); --iItem >= 0;) - if (searchselect.GetItem(iItem, &ti) && ti.lParam != NULL) { - const SSearchParams* pSearchParams = reinterpret_cast(ti.lParam); - if (pSearchParams->dwSearchID == toshow->GetSearchID()) { - UINT iAvailResults = searchlist->GetFoundFiles(toshow->GetSearchID()); - CString strTabLabel(pSearchParams->strSearchTitle); - if (bFilterActive) { - int iFilteredResult = GetItemCount() + static_cast(!bItemFiltered); - strTabLabel.AppendFormat(_T(" (%i/%u)"), iFilteredResult, iAvailResults); - } else - strTabLabel.AppendFormat(_T(" (%u)"), iAvailResults); - DupAmpersand(strTabLabel); - ti.pszText = const_cast((LPCTSTR)strTabLabel); - ti.mask = TCIF_TEXT; - searchselect.SetItem(iItem, &ti); - if (searchselect.GetCurSel() != iItem) - searchselect.HighlightItem(iItem); - break; - } - } - - if (bItemFiltered || toshow->GetSearchID() != m_nResultsID) + if (toshow->GetSearchID() != m_nResultsID) + return; + if (!theApp.emuledlg->searchwnd->m_pwndResults->m_astrFilter.IsEmpty() && IsFilteredOut(toshow)) return; // Turn off updates @@ -432,17 +406,39 @@ void CSearchListCtrl::UpdateSearch(CSearchFile *toupdate) } } -bool CSearchListCtrl::IsComplete(const CSearchFile *pFile, UINT uSources) const +void CSearchListCtrl::UpdateTabHeader(uint32 nResultsID) { - int iComplete = pFile->IsComplete(uSources, pFile->GetCompleteSourceCount()); - - if (iComplete < 0) // '< 0' ... unknown - return true; // treat 'unknown' as complete + CClosableTabCtrl &searchselect = theApp.emuledlg->searchwnd->GetSearchSelector(); - if (iComplete > 0) // '> 0' ... we know it's complete - return true; + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int iItem = searchselect.GetItemCount(); --iItem >= 0;) + if (searchselect.GetItem(iItem, &ti) && ti.lParam != NULL) { + const SSearchParams* pSearchParams = reinterpret_cast(ti.lParam); + if (pSearchParams->dwSearchID == nResultsID) { + UINT iAvailResults = searchlist->GetFoundFiles(nResultsID); + CString strTabLabel(pSearchParams->strSearchTitle); + if (theApp.emuledlg->searchwnd->m_pwndResults->m_astrFilter.IsEmpty()) + strTabLabel.AppendFormat(_T(" (%u)"), iAvailResults); + else + strTabLabel.AppendFormat(_T(" (%i/%u)"), GetItemCount(), iAvailResults); + DupAmpersand(strTabLabel); + ti.pszText = const_cast((LPCTSTR)strTabLabel); + ti.mask = TCIF_TEXT; + searchselect.SetItem(iItem, &ti); + if (searchselect.GetCurSel() != iItem) + searchselect.HighlightItem(iItem); + break; + } + } +} - return false; // '= 0' ... we know it's not complete +bool CSearchListCtrl::IsComplete(const CSearchFile *pFile, UINT uSources) const +{ + // '< 0' ... unknown; treat 'unknown' as complete + // '> 0' ... complete + // '= 0' ... not complete + return pFile->IsComplete(uSources, pFile->GetCompleteSourceCount()) != 0; } CString CSearchListCtrl::GetCompleteSourcesDisplayString(const CSearchFile *pFile, UINT uSources, bool *pbComplete) const @@ -497,7 +493,7 @@ void CSearchListCtrl::RemoveResult(const CSearchFile *toremove) void CSearchListCtrl::ShowResults(uint32 nResultsID) { - if (m_nResultsID != 0 && nResultsID != m_nResultsID) { + if (nResultsID != m_nResultsID) { // store the current state CSortSelectionState *pCurState = new CSortSelectionState(); for (POSITION pos = GetFirstSelectedItemPosition(); pos != NULL;) @@ -513,7 +509,7 @@ void CSearchListCtrl::ShowResults(uint32 nResultsID) // recover stored state CSortSelectionState *pNewState; - if (nResultsID != 0 && nResultsID != m_nResultsID && m_mapSortSelectionStates.Lookup(nResultsID, pNewState)) { + if (nResultsID != m_nResultsID && m_mapSortSelectionStates.Lookup(nResultsID, pNewState)) { m_mapSortSelectionStates.RemoveKey(nResultsID); // sort order @@ -521,9 +517,9 @@ void CSearchListCtrl::ShowResults(uint32 nResultsID) SortItems(SortProc, MAKELONG(pNewState->m_nSortItem, !pNewState->m_bSortAscending)); // fill in the items m_nResultsID = nResultsID; - searchlist->ShowResults(m_nResultsID); + searchlist->ShowResults(nResultsID); // set stored selectionstates - for (int i = (int)pNewState->m_aSelectedItems.GetCount(); --i >= 0;) + for (INT_PTR i = pNewState->m_aSelectedItems.GetCount(); --i >= 0;) SetItemState(pNewState->m_aSelectedItems[i], LVIS_SELECTED, LVIS_SELECTED); if (pNewState->m_nScrollPosition > 0) { @@ -535,7 +531,7 @@ void CSearchListCtrl::ShowResults(uint32 nResultsID) delete pNewState; } else { m_nResultsID = nResultsID; - searchlist->ShowResults(m_nResultsID); + searchlist->ShowResults(nResultsID); } } @@ -705,8 +701,8 @@ void CSearchListCtrl::OnContextMenu(CWnd*, CPoint point) m_SearchFileMenu.EnableMenuItem(MP_GETED2KLINK, iSelected > 0 ? MF_ENABLED : MF_GRAYED); m_SearchFileMenu.EnableMenuItem(MP_GETHTMLED2KLINK, iSelected > 0 ? MF_ENABLED : MF_GRAYED); m_SearchFileMenu.EnableMenuItem(MP_REMOVESELECTED, iSelected > 0 ? MF_ENABLED : MF_GRAYED); - m_SearchFileMenu.EnableMenuItem(MP_REMOVE, theApp.emuledlg->searchwnd->CanDeleteSearch() ? MF_ENABLED : MF_GRAYED); - m_SearchFileMenu.EnableMenuItem(MP_REMOVEALL, theApp.emuledlg->searchwnd->CanDeleteAllSearches() ? MF_ENABLED : MF_GRAYED); + m_SearchFileMenu.EnableMenuItem(MP_REMOVE, theApp.emuledlg->searchwnd->CanDeleteSearches() ? MF_ENABLED : MF_GRAYED); + m_SearchFileMenu.EnableMenuItem(MP_REMOVEALL, theApp.emuledlg->searchwnd->CanDeleteSearches() ? MF_ENABLED : MF_GRAYED); m_SearchFileMenu.EnableMenuItem(MP_SEARCHRELATED, iSelected > 0 && theApp.emuledlg->searchwnd->CanSearchRelatedFiles() ? MF_ENABLED : MF_GRAYED); UINT uInsertedMenuItem = 0; if (iToPreview == 1) { @@ -972,7 +968,7 @@ void CSearchListCtrl::OnLvnGetInfoTip(LPNMHDR pNMHDR, LRESULT *pResult) , (LPCTSTR)GetResString(IDS_FD_SIZE), (LPCTSTR)CastItoXBytes((uint64)file->GetFileSize())); const CArray &tags = file->GetTags(); - for (int i = 0; i < tags.GetCount(); ++i) { + for (INT_PTR i = 0; i < tags.GetCount(); ++i) { const CTag *tag = tags[i]; if (tag) { CString strTag; @@ -1083,7 +1079,7 @@ void CSearchListCtrl::OnLvnGetInfoTip(LPNMHDR pNMHDR, LRESULT *pResult) } const CSimpleArray &aClients = file->GetClients(); - for (int i = 0; i < aClients.GetSize(); ++i) { + for (INT_PTR i = 0; i < aClients.GetSize(); ++i) { uint32 uClientIP = aClients[i].m_nIP; uint32 uServerIP = aClients[i].m_nServerIP; CString strSource; @@ -1104,7 +1100,7 @@ void CSearchListCtrl::OnLvnGetInfoTip(LPNMHDR pNMHDR, LRESULT *pResult) if (file->GetServers().GetSize()) { const CSimpleArray &aServers = file->GetServers(); - for (int i = 0; i < aServers.GetSize(); ++i) { + for (INT_PTR i = 0; i < aServers.GetSize(); ++i) { uint32 uServerIP = aServers[i].m_nIP; CString strServer; if (i == 0) diff --git a/srchybrid/SearchListCtrl.h b/srchybrid/SearchListCtrl.h index 1c983ca7..f986a4b7 100644 --- a/srchybrid/SearchListCtrl.h +++ b/srchybrid/SearchListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -67,6 +67,7 @@ class CSearchListCtrl : public CMuleListCtrl, public CListCtrlItemWalk void ClearResultViewState(uint32 nResultsID); void NoTabs() { m_nResultsID = 0; } void UpdateSearch(CSearchFile *toupdate); + void UpdateTabHeader(uint32 nResultsID); EFileSizeFormat GetFileSizeFormat() const { return m_eFileSizeFormat; } void SetFileSizeFormat(EFileSizeFormat eFormat); diff --git a/srchybrid/SearchParamsWnd.cpp b/srchybrid/SearchParamsWnd.cpp index 7083ab0f..cae53ecf 100644 --- a/srchybrid/SearchParamsWnd.cpp +++ b/srchybrid/SearchParamsWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -324,9 +324,9 @@ void CSearchParamsWnd::OnSize(UINT nType, int cx, int cy) } */ - int iWidthOpts = rcClient.right - (rcClient.left + m_rcOpts.left); HDWP hdwp = BeginDeferWindowPos(12); if (hdwp) { + int iWidthOpts = rcClient.right - (rcClient.left + m_rcOpts.left); const UINT uFlags = SWP_NOZORDER | SWP_NOACTIVATE; hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_MSTATIC3), NULL, rcClient.left + m_rcNameLbl.left, rcClient.top + m_rcNameLbl.top, m_rcNameLbl.Width(), m_rcNameLbl.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlName, NULL, rcClient.left + m_rcName.left, rcClient.top + m_rcName.top, m_rcName.Width(), m_rcName.Height(), uFlags); @@ -750,13 +750,12 @@ void CSearchParamsWnd::OnBnClickedSearchReset() void CSearchParamsWnd::OnSysCommand(UINT nID, LPARAM lParam) { - if (nID == SC_KEYMENU) - if (lParam == EMULE_HOTMENU_ACCEL) - theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); - else - theApp.emuledlg->SendMessage(WM_SYSCOMMAND, nID, lParam); - else + if ((nID & 0xFFF0) != SC_KEYMENU) CDialogBar::OnSysCommand(nID, lParam); + else if (lParam == EMULE_HOTMENU_ACCEL) + theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); + else + theApp.emuledlg->SendMessage(WM_SYSCOMMAND, nID, lParam); } void CSearchParamsWnd::SetParameters(const SSearchParams *pParams) diff --git a/srchybrid/SearchResultsWnd.cpp b/srchybrid/SearchResultsWnd.cpp index 727b2ac0..b38a55f5 100644 --- a/srchybrid/SearchResultsWnd.cpp +++ b/srchybrid/SearchResultsWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -87,6 +87,7 @@ BEGIN_MESSAGE_MAP(CSearchResultsWnd, CResizableFormView) ON_BN_CLICKED(IDC_SDOWNLOAD, OnBnClickedDownloadSelected) ON_BN_CLICKED(IDC_CLEARALL, OnBnClickedClearAll) ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelChangeTab) + ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, OnSelChangingTab) ON_MESSAGE(UM_CLOSETAB, OnCloseTab) ON_MESSAGE(UM_DBLCLICKTAB, OnDblClickTab) ON_WM_DESTROY() @@ -312,16 +313,15 @@ void CSearchResultsWnd::OnTimer(UINT_PTR nIDEvent) void CSearchResultsWnd::SetSearchResultsIcon(uint32 uSearchID, int iImage) { - for (int i = searchselect.GetItemCount(); --i >= 0;) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem(i, &item) && item.lParam != NULL && reinterpret_cast(item.lParam)->dwSearchID == uSearchID) { - item.mask = TCIF_IMAGE; - item.iImage = iImage; - searchselect.SetItem(i, &item); + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = searchselect.GetItemCount(); --i >= 0;) + if (searchselect.GetItem(i, &ti) && ti.lParam != NULL && reinterpret_cast(ti.lParam)->dwSearchID == uSearchID) { + ti.mask = TCIF_IMAGE; + ti.iImage = iImage; + searchselect.SetItem(i, &ti); break; } - } } void CSearchResultsWnd::SetActiveSearchResultsIcon(uint32 uSearchID) @@ -356,12 +356,12 @@ void CSearchResultsWnd::SetInactiveSearchResultsIcon(uint32 uSearchID) SSearchParams* CSearchResultsWnd::GetSearchResultsParams(uint32 uSearchID) const { - for (int i = searchselect.GetItemCount(); --i >= 0;) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem(i, &item) && item.lParam != NULL && reinterpret_cast(item.lParam)->dwSearchID == uSearchID) - return reinterpret_cast(item.lParam); - } + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = searchselect.GetItemCount(); --i >= 0;) + if (searchselect.GetItem(i, &ti) && ti.lParam != NULL && reinterpret_cast(ti.lParam)->dwSearchID == uSearchID) + return reinterpret_cast(ti.lParam); + return NULL; } @@ -370,10 +370,10 @@ void CSearchResultsWnd::CancelSearch(uint32 uSearchID) if (uSearchID == 0) { int iCurSel = searchselect.GetCurSel(); if (iCurSel >= 0) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem(iCurSel, &item) && item.lParam != NULL) - uSearchID = reinterpret_cast(item.lParam)->dwSearchID; + TCITEM ti; + ti.mask = TCIF_PARAM; + if (searchselect.GetItem(iCurSel, &ti) && ti.lParam != NULL) + uSearchID = reinterpret_cast(ti.lParam)->dwSearchID; } } if (uSearchID == 0) @@ -440,9 +440,9 @@ void CSearchResultsWnd::SearchCancelled(uint32 uSearchID) int iSel = searchselect.GetCurSel(); if (iSel >= 0) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem(iSel, &item) && item.lParam != NULL && uSearchID == reinterpret_cast(item.lParam)->dwSearchID) { + TCITEM ti; + ti.mask = TCIF_PARAM; + if (searchselect.GetItem(iSel, &ti) && ti.lParam != NULL && uSearchID == reinterpret_cast(ti.lParam)->dwSearchID) { const CWnd *pWndFocus = GetFocus(); m_pwndParams->m_ctlCancel.EnableWindow(FALSE); if (pWndFocus && pWndFocus->m_hWnd == m_pwndParams->m_ctlCancel.m_hWnd) @@ -537,7 +537,7 @@ void CSearchResultsWnd::DownloadSelected(bool bPaused) // create new DL queue entry with all properties of parent (e.g. already received sources!) // but with the filename of the selected listview item. CSearchFile tempFile(parent); - tempFile.SetFileName(sel_file->GetFileName()); + tempFile.SetAFileName(sel_file->GetFileName()); tempFile.SetStrTagValue(FT_FILENAME, sel_file->GetFileName()); theApp.downloadqueue->AddSearchToDownload(&tempFile, bPaused, GetSelectedCat()); @@ -729,7 +729,7 @@ void ParsedSearchExpression(const CSearchExpr &expr) int iOpNot = 0; int iNonDefTags = 0; //CStringA strDbg; - for (int i = 0; i < expr.m_aExpr.GetCount(); ++i) { + for (INT_PTR i = 0; i < expr.m_aExpr.GetCount(); ++i) { const CSearchAttr &rSearchAttr(expr.m_aExpr[i]); const CStringA &rstr(rSearchAttr.m_str); if (rstr == SEARCHOPTOK_AND) { @@ -789,7 +789,7 @@ void ParsedSearchExpression(const CSearchExpr &expr) // the same or even better if we ask the node which indexes the rare keyword "oxymoronaccelerator", so we try to rearrange // keywords and generally assume that the longer keywords are rarer if (thePrefs.GetRearrangeKadSearchKeywords() && !s_strCurKadKeywordA.IsEmpty()) { - for (int i = 0; i < expr.m_aExpr.GetCount(); ++i) { + for (INT_PTR i = 0; i < expr.m_aExpr.GetCount(); ++i) { const CStringA &cs(expr.m_aExpr[i].m_str); if ( cs != SEARCHOPTOK_AND && cs != s_strCurKadKeywordA @@ -804,7 +804,7 @@ void ParsedSearchExpression(const CSearchExpr &expr) } CStringA strAndTerms; - for (int i = 0; i < expr.m_aExpr.GetCount(); ++i) { + for (INT_PTR i = 0; i < expr.m_aExpr.GetCount(); ++i) { const CStringA &cs(expr.m_aExpr[i].m_str); if (cs != SEARCHOPTOK_AND) { ASSERT(expr.m_aExpr[i].m_iTag == FT_FILENAME); @@ -1018,7 +1018,7 @@ bool GetSearchPacket(CSafeMemFile &data, SSearchParams *pParams, bool bTargetSup } } //TRACE(_T("Parsed search expr:\n")); - //for (int i = 0; i < s_SearchExpr.m_aExpr.GetCount(); ++i){ + //for (INT_PTR i = 0; i < s_SearchExpr.m_aExpr.GetCount(); ++i){ // TRACE(_T("%hs"), s_SearchExpr.m_aExpr[i]); // TRACE(_T(" %s\n"), (LPCTSTR)DbgGetHexDump((uchar*)(LPCSTR)s_SearchExpr.m_aExpr[i], s_SearchExpr.m_aExpr[i].GetLength()*sizeof(CHAR))); //} @@ -1076,8 +1076,8 @@ bool GetSearchPacket(CSafeMemFile &data, SSearchParams *pParams, bool bTargetSup DebugLog(_T("Search Expr: %s"), (LPCTSTR)s_strSearchTree); } - for (int j = 0; j < s_SearchExpr.m_aExpr.GetCount(); ++j) { - const CSearchAttr &rSearchAttr(s_SearchExpr.m_aExpr[j]); + for (INT_PTR i = 0; i < s_SearchExpr.m_aExpr.GetCount(); ++i) { + const CSearchAttr &rSearchAttr(s_SearchExpr.m_aExpr[i]); const CStringA &rstrA(rSearchAttr.m_str); if (rstrA == SEARCHOPTOK_AND) target.WriteBooleanAND(); @@ -1348,37 +1348,37 @@ bool CSearchResultsWnd::DoNewKadSearch(SSearchParams *pParams) bool CSearchResultsWnd::CreateNewTab(SSearchParams *pParams, bool bActiveIcon) { - for (int i = searchselect.GetItemCount(); --i >= 0;) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem(i, &item) && item.lParam != NULL && reinterpret_cast(item.lParam)->dwSearchID == pParams->dwSearchID) + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = searchselect.GetItemCount(); --i >= 0;) + if (searchselect.GetItem(i, &ti) && ti.lParam != NULL && reinterpret_cast(ti.lParam)->dwSearchID == pParams->dwSearchID) return false; - } // add a new tab - TCITEM newitem; if (pParams->strExpression.IsEmpty()) pParams->strExpression += _T('-'); - newitem.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; - newitem.lParam = (LPARAM)pParams; + ti.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; + ti.lParam = (LPARAM)pParams; pParams->strSearchTitle = (pParams->strSpecialTitle.IsEmpty() ? pParams->strExpression : pParams->strSpecialTitle); CString strTcLabel(pParams->strSearchTitle); DupAmpersand(strTcLabel); - newitem.pszText = const_cast((LPCTSTR)strTcLabel); - newitem.cchTextMax = 0; + ti.pszText = const_cast((LPCTSTR)strTcLabel); + ti.cchTextMax = 0; if (pParams->bClientSharedFiles) - newitem.iImage = sriClient; + ti.iImage = sriClient; else if (pParams->eType == SearchTypeKademlia) - newitem.iImage = bActiveIcon ? sriKadActice : sriKad; + ti.iImage = bActiveIcon ? sriKadActice : sriKad; else if (pParams->eType == SearchTypeEd2kGlobal) - newitem.iImage = bActiveIcon ? sriGlobalActive : sriGlobal; + ti.iImage = bActiveIcon ? sriGlobalActive : sriGlobal; else { ASSERT(pParams->eType == SearchTypeEd2kServer); - newitem.iImage = bActiveIcon ? sriServerActive : sriServer; + ti.iImage = bActiveIcon ? sriServerActive : sriServer; } - int itemnr = searchselect.InsertItem(INT_MAX, &newitem); + int itemnr = searchselect.InsertItem(INT_MAX, &ti); if (!searchselect.IsWindowVisible()) ShowSearchSelector(true); + LRESULT lResult; + OnSelChangingTab(NULL, &lResult); searchselect.SetCurSel(itemnr); searchlistctrl.ShowResults(pParams->dwSearchID); return true; @@ -1386,30 +1386,25 @@ bool CSearchResultsWnd::CreateNewTab(SSearchParams *pParams, bool bActiveIcon) void CSearchResultsWnd::DeleteSelectedSearch() { - if (CanDeleteSearch()) { + if (CanDeleteSearches()) { int iFocus = searchselect.GetCurFocus(); - TCITEM item; - item.mask = TCIF_PARAM; - if (iFocus >= 0 && searchselect.GetItem(iFocus, &item) && item.lParam != NULL) - DeleteSearch(reinterpret_cast(item.lParam)->dwSearchID); + TCITEM ti; + ti.mask = TCIF_PARAM; + if (iFocus >= 0 && searchselect.GetItem(iFocus, &ti) && ti.lParam != NULL) + DeleteSearch(reinterpret_cast(ti.lParam)->dwSearchID); } } -bool CSearchResultsWnd::CanDeleteSearch() const -{ - return (searchselect.GetItemCount() > 0); -} - #pragma warning(push) #pragma warning(disable:4701) // potentially uninitialized local variable 'item' used void CSearchResultsWnd::DeleteSearch(uint32 uSearchID) { Kademlia::CSearchManager::StopSearch(uSearchID, false); - TCITEM item; - item.mask = TCIF_PARAM; + TCITEM ti; + ti.mask = TCIF_PARAM; int i = searchselect.GetItemCount(); - while (--i >= 0 && !(searchselect.GetItem(i, &item) && item.lParam != NULL && reinterpret_cast(item.lParam)->dwSearchID == uSearchID)); + while (--i >= 0 && !(searchselect.GetItem(i, &ti) && ti.lParam != NULL && reinterpret_cast(ti.lParam)->dwSearchID == uSearchID)); if (i < 0) return; @@ -1427,7 +1422,7 @@ void CSearchResultsWnd::DeleteSearch(uint32 uSearchID) // delete search tab int iCurSel = searchselect.GetCurSel(); searchselect.DeleteItem(i); - delete reinterpret_cast(item.lParam); + delete reinterpret_cast(ti.lParam); int iTabItems = searchselect.GetItemCount(); if (iTabItems > 0) { @@ -1441,10 +1436,10 @@ void CSearchResultsWnd::DeleteSearch(uint32 uSearchID) if (iCurSel == CB_ERR) // if still error iCurSel = searchselect.SetCurSel(0); if (iCurSel != CB_ERR) { - item.mask = TCIF_PARAM; - if (searchselect.GetItem(iCurSel, &item) && item.lParam != NULL) { + ti.mask = TCIF_PARAM; + if (searchselect.GetItem(iCurSel, &ti) && ti.lParam != NULL) { searchselect.HighlightItem(iCurSel, FALSE); - ShowResults(reinterpret_cast(item.lParam)); + ShowResults(reinterpret_cast(ti.lParam)); } } } else @@ -1452,24 +1447,19 @@ void CSearchResultsWnd::DeleteSearch(uint32 uSearchID) } #pragma warning(pop) -bool CSearchResultsWnd::CanDeleteAllSearches() const -{ - return (searchselect.GetItemCount() > 0); -} - void CSearchResultsWnd::DeleteAllSearches() { CancelEd2kSearch(); - for (int i = searchselect.GetItemCount(); --i >= 0;) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem(i, &item) && item.lParam != NULL) { - const SSearchParams *params = reinterpret_cast(item.lParam); + TCITEM ti; + ti.mask = TCIF_PARAM; + for (int i = searchselect.GetItemCount(); --i >= 0;) + if (searchselect.GetItem(i, &ti) && ti.lParam != NULL) { + const SSearchParams *params = reinterpret_cast(ti.lParam); Kademlia::CSearchManager::StopSearch(params->dwSearchID, false); delete params; } - } + NoTabItems(); } @@ -1518,11 +1508,38 @@ void CSearchResultsWnd::OnSelChangeTab(LPNMHDR, LRESULT *pResult) CWaitCursor curWait; // this may take a while int cur_sel = searchselect.GetCurSel(); if (cur_sel >= 0) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem(cur_sel, &item) && item.lParam != NULL) { + TCITEM ti; + ti.mask = TCIF_PARAM; + if (searchselect.GetItem(cur_sel, &ti) && ti.lParam != NULL) { searchselect.HighlightItem(cur_sel, FALSE); - ShowResults(reinterpret_cast(item.lParam)); + ShowResults(reinterpret_cast(ti.lParam)); + } + } + *pResult = 0; +} + +void CSearchResultsWnd::OnSelChangingTab(LPNMHDR, LRESULT *pResult) +{ + if (!m_astrFilter.IsEmpty()) { + int cur_sel = searchselect.GetCurSel(); + if (cur_sel >= 0) { + CString strTabLabel; + TCITEM ti; + ti.cchTextMax = 512; + ti.pszText = strTabLabel.GetBuffer(ti.cchTextMax); + ti.mask = TCIF_TEXT; + bool b = searchselect.GetItem(cur_sel, &ti); + strTabLabel.ReleaseBuffer(); + if (b) { + int i = strTabLabel.ReverseFind(_T('/')); + int j = strTabLabel.ReverseFind(_T('(')); + if (j >= 0 && i > j) { + strTabLabel.Delete(j + 1, i - j); + DupAmpersand(strTabLabel); + ti.pszText = const_cast((LPCTSTR)strTabLabel); + searchselect.SetItem(cur_sel, &ti); + } + } } } *pResult = 0; @@ -1530,10 +1547,10 @@ void CSearchResultsWnd::OnSelChangeTab(LPNMHDR, LRESULT *pResult) LRESULT CSearchResultsWnd::OnCloseTab(WPARAM wParam, LPARAM) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem((int)wParam, &item) && item.lParam != NULL) { - uint32 uSearchID = reinterpret_cast(item.lParam)->dwSearchID; + TCITEM ti; + ti.mask = TCIF_PARAM; + if (searchselect.GetItem((int)wParam, &ti) && ti.lParam != NULL) { + uint32 uSearchID = reinterpret_cast(ti.lParam)->dwSearchID; if (!m_cancelled && uSearchID == m_nEd2kSearchID) CancelEd2kSearch(); DeleteSearch(uSearchID); @@ -1543,18 +1560,13 @@ LRESULT CSearchResultsWnd::OnCloseTab(WPARAM wParam, LPARAM) LRESULT CSearchResultsWnd::OnDblClickTab(WPARAM wParam, LPARAM) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem((int)wParam, &item) && item.lParam != NULL) - m_pwndParams->SetParameters(reinterpret_cast(item.lParam)); + TCITEM ti; + ti.mask = TCIF_PARAM; + if (searchselect.GetItem((int)wParam, &ti) && ti.lParam != NULL) + m_pwndParams->SetParameters(reinterpret_cast(ti.lParam)); return TRUE; } -int CSearchResultsWnd::GetSelectedCat() -{ - return m_cattabs.GetCurSel(); -} - void CSearchResultsWnd::UpdateCatTabs() { int oldsel = m_cattabs.GetCurSel(); @@ -1597,12 +1609,11 @@ void CSearchResultsWnd::ShowSearchSelector(bool visible) void CSearchResultsWnd::OnDestroy() { - for (INT_PTR i = searchselect.GetItemCount(); --i >= 0;) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem((int)i, &item)) - delete reinterpret_cast(item.lParam); - } + TCITEM ti; + ti.mask = TCIF_PARAM; + for (INT_PTR i = searchselect.GetItemCount(); --i >= 0;) + if (searchselect.GetItem((int)i, &ti)) + delete reinterpret_cast(ti.lParam); CResizableFormView::OnDestroy(); } @@ -1636,13 +1647,12 @@ void CSearchResultsWnd::OnBnClickedOpenParamsWnd() void CSearchResultsWnd::OnSysCommand(UINT nID, LPARAM lParam) { - if (nID == SC_KEYMENU) { - if (lParam == EMULE_HOTMENU_ACCEL) - theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); - else - theApp.emuledlg->SendMessage(WM_SYSCOMMAND, nID, lParam); - } else + if ((nID & 0xFFF0) != SC_KEYMENU) __super::OnSysCommand(nID, lParam); + else if (lParam == EMULE_HOTMENU_ACCEL) + theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); + else + theApp.emuledlg->SendMessage(WM_SYSCOMMAND, nID, lParam); } bool CSearchResultsWnd::CanSearchRelatedFiles() const @@ -1756,10 +1766,10 @@ LRESULT CSearchResultsWnd::OnChangeFilter(WPARAM wParam, LPARAM lParam) int iCurSel = searchselect.GetCurSel(); if (iCurSel >= 0) { - TCITEM item; - item.mask = TCIF_PARAM; - if (searchselect.GetItem(iCurSel, &item) && item.lParam != NULL) - ShowResults(reinterpret_cast(item.lParam)); + TCITEM ti; + ti.mask = TCIF_PARAM; + if (searchselect.GetItem(iCurSel, &ti) && ti.lParam != NULL) + ShowResults(reinterpret_cast(ti.lParam)); } return 0; } diff --git a/srchybrid/SearchResultsWnd.h b/srchybrid/SearchResultsWnd.h index c22a262e..c50f219d 100644 --- a/srchybrid/SearchResultsWnd.h +++ b/srchybrid/SearchResultsWnd.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -96,15 +96,14 @@ class CSearchResultsWnd : public CResizableFormView void DownloadSelected(); void DownloadSelected(bool bPaused); - bool CanDeleteSearch() const; - bool CanDeleteAllSearches() const; + bool CanDeleteSearches() const { return (searchselect.GetItemCount() > 0); }; void DeleteSearch(uint32 uSearchID); void DeleteAllSearches(); void DeleteSelectedSearch(); bool CreateNewTab(SSearchParams *pParams, bool bActiveIcon = true); void ShowSearchSelector(bool visible); - int GetSelectedCat(); + int GetSelectedCat() { return m_cattabs.GetCurSel(); } void UpdateCatTabs(); SSearchParams* GetSearchResultsParams(uint32 uSearchID) const; @@ -149,6 +148,7 @@ class CSearchResultsWnd : public CResizableFormView DECLARE_MESSAGE_MAP() afx_msg void OnDblClkSearchList(LPNMHDR, LRESULT *pResult); afx_msg void OnSelChangeTab(LPNMHDR, LRESULT *pResult); + afx_msg void OnSelChangingTab(LPNMHDR, LRESULT *pResult); afx_msg LRESULT OnCloseTab(WPARAM wParam, LPARAM); afx_msg LRESULT OnDblClickTab(WPARAM wParam, LPARAM); afx_msg void OnDestroy(); diff --git a/srchybrid/SecRunAsUser.cpp b/srchybrid/SecRunAsUser.cpp index 40ef7df9..8ca8aa50 100644 --- a/srchybrid/SecRunAsUser.cpp +++ b/srchybrid/SecRunAsUser.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2004-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2004-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/SecRunAsUser.h b/srchybrid/SecRunAsUser.h index 63078726..3216946d 100644 --- a/srchybrid/SecRunAsUser.h +++ b/srchybrid/SecRunAsUser.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2004-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2004-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include #include diff --git a/srchybrid/SendMail.cpp b/srchybrid/SendMail.cpp index b3252145..ba78f294 100644 --- a/srchybrid/SendMail.cpp +++ b/srchybrid/SendMail.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -26,14 +26,14 @@ #include #include -#include "mbedtls/build_info.h" -#include "mbedtls/platform.h" #include "mbedtls/base64.h" +#include "mbedtls/ctr_drbg.h" #include "mbedtls/error.h" #include "mbedtls/net_sockets.h" -#include "mbedtls/ssl.h" -#include "mbedtls/entropy.h" -#include "mbedtls/ctr_drbg.h" +#include "mbedtls/platform.h" +#include "mbedtls/ssl_cache.h" +#include "mbedtls/ssl_cookie.h" +#include "mbedtls/ssl_ticket.h" #include "mbedtls/x509.h" #ifdef _DEBUG @@ -160,12 +160,13 @@ bool encoded_word(const CString &src, CStringA &dst) return true; } -static int do_handshake(mbedtls_ssl_context *ssl) +static int do_handshake(mbedtls_ssl_context *ssl, LPCTSTR *pmsg) { - for (int ret; (ret = mbedtls_ssl_handshake(ssl)) != 0;) + int ret; + while ((ret = mbedtls_ssl_handshake(ssl)) != 0) if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { - DebugLogWarning(LOG_DONTNOTIFY, _T("SSL/TLS handshake failed: %d"), ret); - return -1; + *pmsg = _T("mbedtls_ssl_handshake"); + return ret; } uint32_t flags = mbedtls_ssl_get_verify_result(ssl); @@ -266,24 +267,37 @@ void CNotifierMailThread::sendmail() static const unsigned char pers[] = "eMule_mail"; CStringA sBodyA, sReceiverA, sSenderA, sServerA, sTmpA, sBufA; - mbedtls_net_context server_fd; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; + mbedtls_net_context server_fd; + mbedtls_pk_context pkey; mbedtls_ssl_context ssl; mbedtls_ssl_config conf; - mbedtls_pk_context pkey; + mbedtls_ssl_cache_context cache; + mbedtls_ssl_cookie_ctx cookie_ctx; + mbedtls_ssl_ticket_context ticket_ctx; + LPCTSTR pmsg = NULL; + int ret; mbedtls_threading_set_alt(threading_mutex_init_alt, threading_mutex_free_alt, threading_mutex_lock_alt, threading_mutex_unlock_alt); mbedtls_net_init(&server_fd); mbedtls_ssl_init(&ssl); mbedtls_ssl_config_init(&conf); - mbedtls_pk_init(&pkey); mbedtls_ctr_drbg_init(&ctr_drbg); mbedtls_entropy_init(&entropy); + mbedtls_pk_init(&pkey); + mbedtls_ssl_cache_init(&cache); + mbedtls_ssl_ticket_init(&ticket_ctx); + mbedtls_ssl_cookie_init(&cookie_ctx); + ret = (int)psa_crypto_init(); + if (ret) { //PSA_SUCCESS is 0 + pmsg = _T("psa_crypto_init"); + goto exit; + } - int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, pers, sizeof pers -1); + ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, pers, sizeof pers -1); if (ret != 0) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Seeding the random number generator failed: %d"), ret); + pmsg = _T("mbedtls_ctr_drbg_seed"); goto exit; } @@ -297,23 +311,31 @@ void CNotifierMailThread::sendmail() ret = mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT); if (ret != 0) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Seting SSL/TLS defaults failed: %d"), ret); + pmsg = _T("mbedtls_ssl_config_defaults"); goto exit; } mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_OPTIONAL); - mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg); - ret = mbedtls_ssl_setup(&ssl, &conf); if (ret != 0) { - DebugLogWarning(LOG_DONTNOTIFY, _T("SSL/TLS setup failed: %d"), ret); + pmsg = _T("mbedtls_ssl_setup"); goto exit; } + mbedtls_ssl_conf_session_cache(&conf, &cache, mbedtls_ssl_cache_get, mbedtls_ssl_cache_set); + ret = mbedtls_ssl_ticket_setup(&ticket_ctx, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_CIPHER_AES_256_GCM, 86400); + if (ret != 0) { + pmsg = _T("mbedtls_ssl_ticket_setup"); + goto exit; + } + mbedtls_ssl_conf_session_tickets_cb(&conf, mbedtls_ssl_ticket_write, mbedtls_ssl_ticket_parse, &ticket_ctx); + mbedtls_ssl_conf_new_session_tickets(&conf, 1); + mbedtls_ssl_conf_tls13_key_exchange_modes(&conf, MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_ALL); + ret = mbedtls_ssl_set_hostname(&ssl, sServerA); if (ret != 0) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Set hostname failed: %d"), ret); + pmsg = _T("mbedtls_ssl_set_hostname"); goto exit; } @@ -324,19 +346,20 @@ void CNotifierMailThread::sendmail() switch (m_mail.uTLS) { case MODE_SSL_TLS: - if (do_handshake(&ssl) != 0) + ret = do_handshake(&ssl, &pmsg); + if (ret) goto exit; ret = write_ssl(&ssl, NULL, 0); if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Get header from server failed: %d"), ret); + pmsg = _T("write_ssl"); goto failed; } sBufA.Format("EHLO %s\r\n", hostname); ret = write_ssl(&ssl, sBufA, sBufA.GetLength()); //250 if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Write EHLO failed: %d"), ret); + pmsg = _T("write_txt (EHLO hostname)"); goto failed; } break; @@ -344,14 +367,14 @@ void CNotifierMailThread::sendmail() default: //MODE_NONE ret = write_txt(&server_fd, NULL, 0); //220 if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Get greetings from server failed: %d"), ret); + pmsg = _T("write_txt (greetings)"); goto exit; } sBufA.Format("EHLO %s\r\n", hostname); ret = write_txt(&server_fd, sBufA, sBufA.GetLength()); //250 if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Send EHLO failed: %d"), ret); + pmsg = _T("write_txt (EHLO)"); goto exit; } if (m_mail.uTLS == MODE_NONE) @@ -359,61 +382,64 @@ void CNotifierMailThread::sendmail() ret = write_txt(&server_fd, "STARTTLS\r\n", sizeof("STARTTLS\r\n")); //220 if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Send STARTTLS failed: %d"), ret); + pmsg = _T("write_txt (STARTTLS)"); goto exit; } - if (do_handshake(&ssl) != 0) + ret = do_handshake(&ssl, &pmsg); + if (ret) goto exit; } size_t n; unsigned char base[1024]; + n = sprintf((char*)base, "%s\n", mbedtls_ssl_get_ciphersuite(&ssl)); + switch (m_mail.uAuth) { case AUTH_PLAIN: sTmpA.Format("%c%s%c%s", '\0', (LPCSTR)((CStringA)m_mail.sUser), '\0', (LPCSTR)(CStringA(m_mail.sPass))); ret = mbedtls_base64_encode(base, sizeof base, &n, (unsigned char*)(LPCSTR)sTmpA, sTmpA.GetLength()); if (ret != 0) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Plain ID to base64 failed: %d"), ret); + pmsg = _T("mbedtls_base64_encode (plain ID)"); goto failed; } sTmpA.Format("AUTH PLAIN %s\r\n", base); ret = write_data(&ssl, sTmpA); //235 if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("AUTH PLAIN failed: %d"), ret); + pmsg = _T("write_data (AUTH PLAIN)"); goto failed; } break; case AUTH_LOGIN: ret = write_data(&ssl, "AUTH LOGIN\r\n"); //334 if (ret > 0 && ret < 200 || ret > 399) { - DebugLogWarning(LOG_DONTNOTIFY, _T("AUTH LOGIN failed: %d"), ret); + pmsg = _T("write_data (AUTH LOGIN)"); goto failed; } sTmpA = (CStringA)m_mail.sUser; ret = mbedtls_base64_encode(base, sizeof base, &n, (unsigned char*)(LPCSTR)sTmpA, sTmpA.GetLength()); if (ret != 0) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Login to base64 failed: %d"), ret); + pmsg = _T("mbedtls_base64_encode (login)"); goto failed; } sBufA.Format("%s\r\n", base); ret = write_data(&ssl, sBufA); //334 if (ret > 0 && ret < 300 || ret > 399) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Send login failed: %d"), ret); + pmsg = _T("write_data (login)"); goto failed; } sTmpA = (CStringA)m_mail.sPass; ret = mbedtls_base64_encode(base, sizeof base, &n, (unsigned char*)(LPCSTR)sTmpA, sTmpA.GetLength()); if (ret != 0) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Password to base64 failed: %d"), ret); + pmsg = _T("mbedtls_base64_encode (password)"); goto failed; } sBufA.Format("%s\r\n", base); ret = write_data(&ssl, sBufA); //235 if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Send password failed: %d"), ret); + pmsg = _T("write_data (password)"); goto failed; } } @@ -422,7 +448,7 @@ void CNotifierMailThread::sendmail() sBufA.Format("MAIL FROM:<%s>\r\n", (LPCSTR)sSenderA); ret = write_data(&ssl, sBufA); //250 if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Send MAIL FROM failed: %d"), ret); + pmsg = _T("write_data (MAIL FROM)"); goto failed; } @@ -430,13 +456,13 @@ void CNotifierMailThread::sendmail() sBufA.Format("RCPT TO:<%s>\r\n", (LPCSTR)sReceiverA); ret = write_data(&ssl, sBufA); //250 251 if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Send RCPT TO failed: %d"), ret); + pmsg = _T("write_data (RCPT TO)"); goto failed; } ret = write_data(&ssl, "DATA\r\n"); //354 250 if (ret > 0 && ret < 200 || ret > 399) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Write DATA failed: %d"), ret); + pmsg = _T("write_data (DATA)"); goto failed; } @@ -482,24 +508,30 @@ void CNotifierMailThread::sendmail() ret = write_data(&ssl, sBufA); if (ret > 0 && ret < 200 || ret > 299) { - DebugLogWarning(LOG_DONTNOTIFY, _T("Write content failed: %d"), ret); + pmsg = _T("write_data"); goto failed; } ret = write_data(&ssl, "QUIT\r\n"); //221 if (ret > 0 && ret < 200 || ret > 299) - DebugLogWarning(LOG_DONTNOTIFY, _T("Send QUIT failed: %d"), ret); + pmsg = _T("write_data (QUIT)"); failed: mbedtls_ssl_close_notify(&ssl); exit: mbedtls_net_free(&server_fd); + mbedtls_ssl_cookie_free(&cookie_ctx); + mbedtls_ssl_ticket_free(&ticket_ctx); + mbedtls_ssl_cache_free(&cache); + mbedtls_psa_crypto_free(); mbedtls_pk_free(&pkey); - mbedtls_ssl_free(&ssl); - mbedtls_ssl_config_free(&conf); - mbedtls_ctr_drbg_free(&ctr_drbg); mbedtls_entropy_free(&entropy); + mbedtls_ctr_drbg_free(&ctr_drbg); + mbedtls_ssl_config_free(&conf); + mbedtls_ssl_free(&ssl); + if (pmsg) + DebugLogError(_T("Error: %s returned -0x%04x - %s"), pmsg, -ret, (LPCTSTR)SSLerror(ret)); } int CNotifierMailThread::write_data(mbedtls_ssl_context *ssl, const char *buf) diff --git a/srchybrid/Server.cpp b/srchybrid/Server.cpp index be3438b3..a733c7a6 100644 --- a/srchybrid/Server.cpp +++ b/srchybrid/Server.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Server.h b/srchybrid/Server.h index 7ca39b8c..75d5c124 100644 --- a/srchybrid/Server.h +++ b/srchybrid/Server.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -167,7 +167,7 @@ class CServer private: void init(); - TCHAR ipfull[3+1+3+1+3+1+3+1]; // 16 + TCHAR ipfull[3+1+3+1+3+1+3+1]; // 16, null terminated CString m_strDescription; CString m_strName; CString m_strDynIP; diff --git a/srchybrid/ServerConnect.cpp b/srchybrid/ServerConnect.cpp index 294feedf..bf4b9142 100644 --- a/srchybrid/ServerConnect.cpp +++ b/srchybrid/ServerConnect.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -26,7 +26,6 @@ #include "ServerList.h" #include "Server.h" #include "ListenSocket.h" -#include "SafeFile.h" #include "Packets.h" #include "SharedFileList.h" #include "emuleDlg.h" @@ -43,11 +42,11 @@ static char THIS_FILE[] = __FILE__; void CServerConnect::TryAnotherConnectionRequest() { - if (connectionattempts.GetCount() < (thePrefs.IsSafeServerConnectEnabled() ? 1 : 2)) { + if (connectionattempts.GetCount() < 2 - static_cast(thePrefs.IsSafeServerConnectEnabled())) { CServer *next_server = theApp.serverlist->GetNextServer(m_bTryObfuscated); if (next_server == NULL) { if (connectionattempts.IsEmpty()) { - if (m_bTryObfuscated && !thePrefs.IsClientCryptLayerRequired()) { + if (m_bTryObfuscated && !thePrefs.IsCryptLayerRequired()) { // try all servers on the non-obfuscated port next m_bTryObfuscated = false; ConnectToAnyServer(0, true, true, true); @@ -69,14 +68,14 @@ void CServerConnect::TryAnotherConnectionRequest() } } -void CServerConnect::ConnectToAnyServer(UINT startAt, bool prioSort, bool isAuto, bool bNoCrypt) +void CServerConnect::ConnectToAnyServer(INT_PTR startAt, bool prioSort, bool isAuto, bool bNoCrypt) { StopConnectionTry(); Disconnect(); connecting = true; singleconnecting = false; theApp.emuledlg->ShowConnectionState(); - m_bTryObfuscated = thePrefs.IsServerCryptLayerTCPRequested() && !bNoCrypt; + m_bTryObfuscated = thePrefs.IsCryptLayerPreferred() && !bNoCrypt; // Barry - Only auto-connect to static server option if (thePrefs.GetAutoConnectToStaticServersOnly() && isAuto) { @@ -185,11 +184,11 @@ void CServerConnect::ConnectionEstablished(CServerSocket *sender) tagVersion.WriteTagToFile(data); uint32 dwCryptFlags = 0; - if (thePrefs.IsClientCryptLayerSupported()) + if (thePrefs.IsCryptLayerEnabled()) dwCryptFlags |= SRVCAP_SUPPORTCRYPT; - if (thePrefs.IsClientCryptLayerRequested()) + if (thePrefs.IsCryptLayerPreferred()) dwCryptFlags |= SRVCAP_REQUESTCRYPT; - if (thePrefs.IsClientCryptLayerRequired()) + if (thePrefs.IsCryptLayerRequired()) dwCryptFlags |= SRVCAP_REQUIRECRYPT; CTag tagFlags(CT_SERVER_FLAGS, SRVCAP_ZLIB | SRVCAP_NEWTAGS | SRVCAP_LARGEFILES | SRVCAP_UNICODE | dwCryptFlags); @@ -241,6 +240,7 @@ void CServerConnect::ConnectionEstablished(CServerSocket *sender) CServer *pServer = theApp.serverlist->GetServerByAddress(cserver->GetAddress(), cserver->GetPort()); if (pServer) { if (sender->IsObfusicating() && !pServer->SupportsObfuscationTCP()) { + pServer->SetTCPFlags(cserver->GetTCPFlags() | SRV_TCPFLG_TCPOBFUSCATION); pServer->SetObfuscationPortTCP(cserver->GetObfuscationPortTCP()); if (!pServer->SupportsObfuscationUDP()) pServer->SetObfuscationPortUDP(cserver->GetObfuscationPortUDP()); @@ -328,7 +328,7 @@ void CServerConnect::ConnectionFailed(CServerSocket *sender) // If possible, use the "next" server. int iPosInList = theApp.serverlist->GetPositionOfServer(pServer); if (iPosInList >= 0) - m_uStartAutoConnectPos = (UINT)((iPosInList + 1) % theApp.serverlist->GetServerCount()); + m_uStartAutoConnectPos = (iPosInList + 1) % theApp.serverlist->GetServerCount(); } VERIFY((m_idRetryTimer = ::SetTimer(NULL, 0, SEC2MS(CS_RETRYCONNECTTIME), RetryConnectTimer)) != 0); if (thePrefs.GetVerbose() && !m_idRetryTimer) @@ -360,7 +360,7 @@ void CServerConnect::ConnectionFailed(CServerSocket *sender) if (!connecting) break; if (singleconnecting) { - if (pServer != NULL && sender->IsServerCryptEnabledConnection() && !thePrefs.IsClientCryptLayerRequired()) { + if (pServer != NULL && sender->IsServerCryptEnabledConnection() && !thePrefs.IsCryptLayerRequired()) { // try reconnecting without obfuscation ConnectToServer(pServer, false, true); break; @@ -393,7 +393,7 @@ VOID CALLBACK CServerConnect::RetryConnectTimer(HWND /*hWnd*/, UINT /*nMsg*/, UI _this->StopConnectionTry(); if (_this->IsConnected()) return; - if (_this->m_uStartAutoConnectPos >= (UINT)theApp.serverlist->GetServerCount()) + if (_this->m_uStartAutoConnectPos >= theApp.serverlist->GetServerCount()) _this->m_uStartAutoConnectPos = 0; _this->ConnectToAnyServer(_this->m_uStartAutoConnectPos, true, true); } @@ -457,7 +457,7 @@ CServerConnect::CServerConnect() , connectedsocket() , m_idRetryTimer() , m_uStartAutoConnectPos() - , max_simcons(thePrefs.IsSafeServerConnectEnabled() ? 1 : 2) + , max_simcons(2 - static_cast(thePrefs.IsSafeServerConnectEnabled())) , connecting() , singleconnecting() , connected() diff --git a/srchybrid/ServerConnect.h b/srchybrid/ServerConnect.h index e19abcb7..4e9fbab3 100644 --- a/srchybrid/ServerConnect.h +++ b/srchybrid/ServerConnect.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -46,8 +46,8 @@ class CServerConnect void ConnectionFailed(CServerSocket *sender); void ConnectionEstablished(CServerSocket *sender); - void ConnectToAnyServer() { ConnectToAnyServer(0, true, true); } - void ConnectToAnyServer(UINT startAt, bool prioSort = false, bool isAuto = true, bool bNoCrypt = false); + void ConnectToAnyServer() { ConnectToAnyServer(0, true, true, false); } + void ConnectToAnyServer(INT_PTR startAt, bool prioSort = false, bool isAuto = true, bool bNoCrypt = false); void ConnectToServer(CServer *server, bool multiconnect = false, bool bNoCrypt = false); void StopConnectionTry(); static VOID CALLBACK RetryConnectTimer(HWND hWnd, UINT nMsg, UINT_PTR nId, DWORD dwTime) noexcept; @@ -85,8 +85,8 @@ class CServerConnect CServerSocket *connectedsocket; CUDPSocket *udpsocket; UINT_PTR m_idRetryTimer; + INT_PTR m_uStartAutoConnectPos; uint32 m_nLocalIP; - UINT m_uStartAutoConnectPos; uint8 max_simcons; bool connecting; bool singleconnecting; diff --git a/srchybrid/ServerList.cpp b/srchybrid/ServerList.cpp index 7fd8d1b0..e2d223f5 100644 --- a/srchybrid/ServerList.cpp +++ b/srchybrid/ServerList.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -49,11 +49,10 @@ CServerList::CServerList() : serverpos() , searchserverpos() , statserverpos() - , servercount() , delservercount() + , m_nLastSaved(::GetTickCount()) , version() { - m_nLastSaved = ::GetTickCount(); } CServerList::~CServerList() @@ -131,15 +130,10 @@ bool CServerList::AddServerMetToList(const CString &strFile, bool bMerge) } CSafeBufferedFile servermet; - CFileException fexp; - if (!servermet.Open(strFile, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - if (!bMerge) { - CString strError(GetResString(IDS_ERR_LOADSERVERMET)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - } + CFileException fex; + if (!servermet.Open(strFile, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fex)) { + if (!bMerge) + LogError(LOG_STATUSBAR, _T("%s%s"), (LPCTSTR)GetResString(IDS_ERR_LOADSERVERMET), (LPCTSTR)CExceptionStrDash(fex)); return false; } ::setvbuf(servermet.m_pStream, NULL, _IOFBF, 16384); @@ -193,15 +187,12 @@ bool CServerList::AddServerMetToList(const CString &strFile, bool bMerge) else AddLogLine(true, GetResString(IDS_SERVERSADDED), iAddCount, fservercount - iAddCount); servermet.Close(); - } catch (CFileException *error) { - if (error->m_cause == CFileException::endOfFile) + } catch (CFileException *ex) { + if (ex->m_cause == CFileException::endOfFile) LogError(LOG_STATUSBAR, GetResString(IDS_ERR_BADSERVERLIST)); - else { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR_SERVERMET), buffer); - } - error->Delete(); + else + LogError(LOG_STATUSBAR, GetResString(IDS_ERR_FILEERROR_SERVERMET), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); } theApp.emuledlg->serverwnd->serverlistctrl.SetRedraw(true); theApp.emuledlg->serverwnd->serverlistctrl.Visible(); @@ -279,20 +270,20 @@ void CServerList::ServerStats() } //srand((unsigned)tNow); ping_server->SetRealLastPingedTime(tNow); // this is not used to calculate the next ping, but only to ensure a minimum delay for premature pings - if (!ping_server->GetCryptPingReplyPending() && tNow >= ping_server->GetLastPingedTime() + UDPSERVSTATREASKTIME && theApp.GetPublicIP() && thePrefs.IsServerCryptLayerUDPEnabled()) { + if (!ping_server->GetCryptPingReplyPending() && tNow >= ping_server->GetLastPingedTime() + UDPSERVSTATREASKTIME && theApp.GetPublicIP() && thePrefs.IsCryptLayerEnabled()) { // we try an obfuscated ping first and wait 20 seconds for an answer // if it doesn't respond, we don't count it as an error but continue with a normal ping ping_server->SetCryptPingReplyPending(true); uint32 nPacketLen = 4 + (uint8)(rand() & 0xf); // max padding 15 bytes BYTE *pRawPacket = new BYTE[nPacketLen]; - uint32 dwChallenge = (rand() << 17) | (rand() << 2) | (rand() & 0x03); - if (dwChallenge == 0) - dwChallenge = 1; - PokeUInt32(pRawPacket, dwChallenge); + uint32 uChallenge = (rand() << 17) | (rand() << 2) | (rand() & 0x03); + if (uChallenge == 0) + uChallenge = 1; + PokeUInt32(pRawPacket, uChallenge); for (uint32 i = 4; i < nPacketLen; ++i) // fill up the remaining bytes with random data pRawPacket[i] = (uint8)rand(); - ping_server->SetChallenge(dwChallenge); + ping_server->SetChallenge(uChallenge); ping_server->SetLastPinged(::GetTickCount()); ping_server->SetLastPingedTime(tNow - UDPSERVSTATREASKTIME + 20); // give it 20 seconds to respond @@ -301,14 +292,15 @@ void CServerList::ServerStats() theStats.AddUpDataOverheadServer(nPacketLen); theApp.serverconnect->SendUDPPacket(NULL, ping_server, true, ping_server->GetPort() + 12, pRawPacket, nPacketLen); - } else if (ping_server->GetCryptPingReplyPending() || theApp.GetPublicIP() == 0 || !thePrefs.IsServerCryptLayerUDPEnabled()) { + } else if (ping_server->GetCryptPingReplyPending() || theApp.GetPublicIP() == 0 || !thePrefs.IsCryptLayerEnabled()) { // our obfuscated ping request was not answered; assume the server doesn't support obfuscation - // continue with a normal request - if (ping_server->GetCryptPingReplyPending() && thePrefs.IsServerCryptLayerUDPEnabled()) - DEBUG_ONLY(DebugLog(_T("CryptPing failed for server %s"), (LPCTSTR)ping_server->GetListName())); - else if (thePrefs.IsServerCryptLayerUDPEnabled()) - DEBUG_ONLY(DebugLog(_T("CryptPing skipped because our public IP is unknown to server %s"), (LPCTSTR)ping_server->GetListName())); + if (thePrefs.IsCryptLayerEnabled()) + if (ping_server->GetCryptPingReplyPending()) + DEBUG_ONLY(DebugLog(_T("CryptPing failed for server %s"), (LPCTSTR)ping_server->GetListName())); + else + DEBUG_ONLY(DebugLog(_T("CryptPing skipped because our public IP is unknown to server %s"), (LPCTSTR)ping_server->GetListName())); + // continue with an unencrypted request ping_server->SetCryptPingReplyPending(false); Packet *packet = new Packet(OP_GLOBSERVSTATREQ, 4); uint32 uChallenge = 0x55AA0000 + GetRandomUInt16(); @@ -455,9 +447,8 @@ void CServerList::GetUserSortedServers() CServerListCtrl &serverListCtrl = theApp.emuledlg->serverwnd->serverlistctrl; ASSERT(serverListCtrl.GetItemCount() == list.GetCount()); list.RemoveAll(); - int iServers = serverListCtrl.GetItemCount(); - for (int i = 0; i < iServers; ++i) - list.AddTail(reinterpret_cast(serverListCtrl.GetItemData(i))); + for (int i = serverListCtrl.GetItemCount(); --i >= 0;) + list.AddHead(reinterpret_cast(serverListCtrl.GetItemData(i))); } #ifdef _DEBUG @@ -471,66 +462,56 @@ void CServerList::Dump() } #endif -void CServerList::SetServerPosition(UINT newPosition) +void CServerList::SetServerPosition(INT_PTR newPosition) { - if (newPosition < (UINT)list.GetCount()) - serverpos = newPosition; - else - serverpos = 0; + serverpos = (newPosition < list.GetCount()) ? newPosition : 0; } -CServer* CServerList::GetNextServer(bool bOnlyObfuscated) +CServer* CServerList::GetNextServer(bool bTryObfuscated) { - if (serverpos >= (UINT)list.GetCount()) - return NULL; - - CServer *nextserver = NULL; - for (int i = 0; !nextserver && i < list.GetCount(); ++i) { + for (INT_PTR i = 0; max(i, serverpos) < list.GetCount(); ++i) { POSITION posIndex = list.FindIndex(serverpos); - if (posIndex == NULL) { // check if search position is still valid (could be corrupted by server delete operation) + if (posIndex == NULL) { //server delete operation could invalidate search position posIndex = list.GetHeadPosition(); serverpos = 0; } - ++serverpos; - if (!bOnlyObfuscated || reinterpret_cast(list.GetAt(posIndex))->SupportsObfuscationTCP()) - nextserver = list.GetAt(posIndex); - else if (serverpos >= (UINT)list.GetCount()) - return NULL; + + CServer *nextserver = list.GetAt(posIndex); + if (!bTryObfuscated || nextserver->SupportsObfuscationTCP() || !nextserver->TriedCrypt()) + return nextserver; } - return nextserver; + return NULL; } CServer* CServerList::GetNextSearchServer() { - CServer *nextserver = NULL; - for (int i = 0; !nextserver && i < list.GetCount(); ++i) { + for (INT_PTR i = 0; i < list.GetCount(); ++i) { POSITION posIndex = list.FindIndex(searchserverpos); - if (posIndex == NULL) { // check if search position is still valid (could be corrupted by server delete operation) + if (posIndex == NULL) { //server delete operation could invalidate search position posIndex = list.GetHeadPosition(); searchserverpos = 0; } - nextserver = list.GetAt(posIndex); - if (++searchserverpos >= (UINT)list.GetCount()) + if (++searchserverpos >= list.GetCount()) searchserverpos = 0; + return list.GetAt(posIndex); } - return nextserver; + return NULL; } CServer* CServerList::GetNextStatServer() { - CServer *nextserver = NULL; - for (int i = 0; !nextserver && i < list.GetCount(); ++i) { + for (INT_PTR i = 0; i < list.GetCount(); ++i) { POSITION posIndex = list.FindIndex(statserverpos); - if (posIndex == NULL) { // check if search position is still valid (could be corrupted by server delete operation) + if (posIndex == NULL) { //server delete operation could invalidate search position posIndex = list.GetHeadPosition(); statserverpos = 0; } - nextserver = list.GetAt(posIndex); - if (++statserverpos >= (UINT)list.GetCount()) + if (++statserverpos >= list.GetCount()) statserverpos = 0; + return list.GetAt(posIndex); } - return nextserver; + return NULL; } CServer* CServerList::GetSuccServer(const CServer *lastserver) const @@ -584,9 +565,9 @@ CServer* CServerList::GetServerByIPUDP(uint32 nIP, uint16 nUDPPort, bool bObfusc for (POSITION pos = list.GetHeadPosition(); pos != NULL;) { CServer *s = list.GetNext(pos); if (s->GetIP() == nIP - && nUDPPort == s->GetPort() + 4 + && (nUDPPort == s->GetPort() + 4 || (bObfuscationPorts - && (nUDPPort == s->GetObfuscationPortUDP() || nUDPPort == s->GetPort() + 12))) + && (nUDPPort == s->GetObfuscationPortUDP() || nUDPPort == s->GetPort() + 12)))) { return s; } @@ -603,171 +584,158 @@ bool CServerList::SaveServermetToFile() const CString &curservermet(sConfDir + SERVER_MET_FILENAME); const CString &newservermet(curservermet + _T(".new")); - CSafeBufferedFile servermet; - CFileException fexp; - if (!servermet.Open(newservermet, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - CString strError(GetResString(IDS_ERR_SAVESERVERMET)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(fexp, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); + CSafeBufferedFile file; + if (!CFileOpen(file, newservermet + , CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite + , GetResString(IDS_ERR_SAVESERVERMET))) + { return false; } - ::setvbuf(servermet.m_pStream, NULL, _IOFBF, 16384); + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { - servermet.WriteUInt8(0xE0); + file.WriteUInt8(0xE0); INT_PTR fservercount = list.GetCount(); - servermet.WriteUInt32((uint32)fservercount); + file.WriteUInt32((uint32)fservercount); - for (INT_PTR j = 0; j < fservercount; ++j) { - const CServer *nextserver = GetServerAt(j); + for (INT_PTR i = 0; i < fservercount; ++i) { + const CServer *nextserver = GetServerAt(i); // don't write potentially outdated IPs of dynIP-servers - servermet.WriteUInt32(nextserver->HasDynIP() ? 0 : nextserver->GetIP()); - servermet.WriteUInt16(nextserver->GetPort()); + file.WriteUInt32(nextserver->HasDynIP() ? 0 : nextserver->GetIP()); + file.WriteUInt16(nextserver->GetPort()); UINT uTagCount = 0; - ULONGLONG uTagCountFilePos = servermet.GetPosition(); - servermet.WriteUInt32(uTagCount); + ULONGLONG uTagCountFilePos = file.GetPosition(); + file.WriteUInt32(uTagCount); if (!nextserver->GetListName().IsEmpty()) { CTag servername(ST_SERVERNAME, nextserver->GetListName()); - servername.WriteTagToFile(servermet, UTF8strOptBOM); + servername.WriteTagToFile(file, UTF8strOptBOM); ++uTagCount; } if (!nextserver->GetDynIP().IsEmpty()) { CTag serverdynip(ST_DYNIP, nextserver->GetDynIP()); - serverdynip.WriteTagToFile(servermet, UTF8strOptBOM); + serverdynip.WriteTagToFile(file, UTF8strOptBOM); ++uTagCount; } if (!nextserver->GetDescription().IsEmpty()) { CTag serverdesc(ST_DESCRIPTION, nextserver->GetDescription()); - serverdesc.WriteTagToFile(servermet, UTF8strOptBOM); + serverdesc.WriteTagToFile(file, UTF8strOptBOM); ++uTagCount; } if (nextserver->GetFailedCount()) { CTag serverfail(ST_FAIL, nextserver->GetFailedCount()); - serverfail.WriteTagToFile(servermet); + serverfail.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetPreference() != SRV_PR_NORMAL) { CTag serverpref(ST_PREFERENCE, nextserver->GetPreference()); - serverpref.WriteTagToFile(servermet); + serverpref.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetUsers()) { CTag serveruser("users", nextserver->GetUsers()); - serveruser.WriteTagToFile(servermet); + serveruser.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetFiles()) { CTag serverfiles("files", nextserver->GetFiles()); - serverfiles.WriteTagToFile(servermet); + serverfiles.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetPing()) { CTag serverping(ST_PING, nextserver->GetPing()); - serverping.WriteTagToFile(servermet); + serverping.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetLastPingedTime() > 0) { CTag serverlastp(ST_LASTPING, nextserver->GetLastPingedTime()); - serverlastp.WriteTagToFile(servermet); + serverlastp.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetMaxUsers()) { CTag servermaxusers(ST_MAXUSERS, nextserver->GetMaxUsers()); - servermaxusers.WriteTagToFile(servermet); + servermaxusers.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetSoftFiles()) { CTag softfiles(ST_SOFTFILES, nextserver->GetSoftFiles()); - softfiles.WriteTagToFile(servermet); + softfiles.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetHardFiles()) { CTag hardfiles(ST_HARDFILES, nextserver->GetHardFiles()); - hardfiles.WriteTagToFile(servermet); + hardfiles.WriteTagToFile(file); ++uTagCount; } if (!nextserver->GetVersion().IsEmpty()) { // as long as we don't receive an integer version tag from the local server (TCP) we store it as string CTag tversion(ST_VERSION, nextserver->GetVersion()); - tversion.WriteTagToFile(servermet, UTF8strOptBOM); + tversion.WriteTagToFile(file, UTF8strOptBOM); ++uTagCount; } if (nextserver->GetUDPFlags()) { CTag tagUDPFlags(ST_UDPFLAGS, nextserver->GetUDPFlags()); - tagUDPFlags.WriteTagToFile(servermet); + tagUDPFlags.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetLowIDUsers()) { CTag tagLowIDUsers(ST_LOWIDUSERS, nextserver->GetLowIDUsers()); - tagLowIDUsers.WriteTagToFile(servermet); + tagLowIDUsers.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetServerKeyUDP(true)) { CTag tagServerKeyUDP(ST_UDPKEY, nextserver->GetServerKeyUDP(true)); - tagServerKeyUDP.WriteTagToFile(servermet); + tagServerKeyUDP.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetServerKeyUDPIP()) { CTag tagServerKeyUDPIP(ST_UDPKEYIP, nextserver->GetServerKeyUDPIP()); - tagServerKeyUDPIP.WriteTagToFile(servermet); + tagServerKeyUDPIP.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetObfuscationPortTCP()) { CTag tagObfuscationPortTCP(ST_TCPPORTOBFUSCATION, nextserver->GetObfuscationPortTCP()); - tagObfuscationPortTCP.WriteTagToFile(servermet); + tagObfuscationPortTCP.WriteTagToFile(file); ++uTagCount; } if (nextserver->GetObfuscationPortUDP()) { CTag tagObfuscationPortUDP(ST_UDPPORTOBFUSCATION, nextserver->GetObfuscationPortUDP()); - tagObfuscationPortUDP.WriteTagToFile(servermet); + tagObfuscationPortUDP.WriteTagToFile(file); ++uTagCount; } - servermet.Seek(uTagCountFilePos, CFile::begin); - servermet.WriteUInt32(uTagCount); - servermet.SeekToEnd(); - } - - if (thePrefs.GetCommitFiles() >= 2 || (thePrefs.GetCommitFiles() >= 1 && theApp.IsClosing())) { - servermet.Flush(); // flush file stream buffers to disk buffers - if (_commit(_fileno(servermet.m_pStream)) != 0) // commit disk buffers to disk - AfxThrowFileException(CFileException::hardIO, ::GetLastError(), servermet.GetFileName()); + file.Seek(uTagCountFilePos, CFile::begin); + file.WriteUInt32(uTagCount); + file.SeekToEnd(); } - servermet.Close(); + CommitAndClose(file); MoveFileEx(curservermet, sConfDir + _T("server_met.old"), MOVEFILE_REPLACE_EXISTING); MoveFileEx(newservermet, curservermet, MOVEFILE_REPLACE_EXISTING); - } catch (CFileException *error) { - CString strError(GetResString(IDS_ERR_SAVESERVERMET2)); - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (GetExceptionMessage(*error, szError, _countof(szError))) - strError.AppendFormat(_T(" - %s"), szError); - LogError(LOG_STATUSBAR, _T("%s"), (LPCTSTR)strError); - error->Delete(); + } catch (CFileException *ex) { + LogError(LOG_STATUSBAR, _T("%s%s"), (LPCTSTR)GetResString(IDS_ERR_SAVESERVERMET2), (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); return false; } return true; @@ -923,7 +891,7 @@ void CServerList::RemoveDuplicatesByIP(const CServer *pExceptThis) void CServerList::CheckForExpiredUDPKeys() { - if (!thePrefs.IsServerCryptLayerUDPEnabled()) + if (!thePrefs.IsCryptLayerEnabled()) return; uint32 cKeysTotal = 0; diff --git a/srchybrid/ServerList.h b/srchybrid/ServerList.h index d80131f1..0d1683eb 100644 --- a/srchybrid/ServerList.h +++ b/srchybrid/ServerList.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -46,15 +46,15 @@ class CServerList INT_PTR GetServerCount() const { return list.GetCount(); } CServer* GetServerAt(INT_PTR pos) const { return list.GetAt(list.FindIndex(pos)); } CServer* GetSuccServer(const CServer *lastserver) const; - CServer* GetNextServer(bool bOnlyObfuscated); + CServer* GetNextServer(bool bTryObfuscated); CServer* GetServerByAddress(LPCTSTR address, uint16 port) const; CServer* GetServerByIP(uint32 nIP) const; CServer* GetServerByIPTCP(uint32 nIP, uint16 nTCPPort) const; CServer* GetServerByIPUDP(uint32 nIP, uint16 nUDPPort, bool bObfuscationPorts = true) const; int GetPositionOfServer(const CServer *pServer) const; - void SetServerPosition(UINT newPosition); - UINT GetServerPostion() const { return serverpos; } + void SetServerPosition(INT_PTR newPosition); + INT_PTR GetServerPostion() const { return serverpos; } void ResetSearchServerPos() { searchserverpos = 0; } CServer* GetNextSearchServer(); @@ -78,11 +78,10 @@ class CServerList private: CTypedPtrList list; - DWORD m_nLastSaved; - UINT serverpos; - UINT searchserverpos; - UINT statserverpos; - UINT servercount; + INT_PTR serverpos; + INT_PTR searchserverpos; + INT_PTR statserverpos; UINT delservercount; + DWORD m_nLastSaved; uint8 version; }; \ No newline at end of file diff --git a/srchybrid/ServerListCtrl.cpp b/srchybrid/ServerListCtrl.cpp index d56942ad..7f6cc06a 100644 --- a/srchybrid/ServerListCtrl.cpp +++ b/srchybrid/ServerListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -397,16 +397,16 @@ BOOL CServerListCtrl::OnCommand(WPARAM wParam, LPARAM) int iItem = GetNextSelectedItem(pos); if (iItem > -1) { const CServer *pServer = reinterpret_cast(GetItemData(iItem)); - if (!thePrefs.IsClientCryptLayerRequired() || pServer->SupportsObfuscationTCP() || !pServer->TriedCrypt()) + if (!thePrefs.IsCryptLayerRequired() || pServer->SupportsObfuscationTCP() || !pServer->TriedCrypt()) theApp.serverlist->MoveServerDown(pServer); } } - theApp.serverconnect->ConnectToAnyServer((UINT)(theApp.serverlist->GetServerCount() - GetSelectedCount()), false, false); + theApp.serverconnect->ConnectToAnyServer(theApp.serverlist->GetServerCount() - GetSelectedCount(), false, false); } else { int iItem = GetNextItem(-1, LVIS_SELECTED | LVIS_FOCUSED); if (iItem > -1) { const CServer *pServer = reinterpret_cast(GetItemData(iItem)); - if (!thePrefs.IsClientCryptLayerRequired() || pServer->SupportsObfuscationTCP() || !pServer->TriedCrypt()) + if (!thePrefs.IsCryptLayerRequired() || pServer->SupportsObfuscationTCP() || !pServer->TriedCrypt()) theApp.serverconnect->ConnectToServer(reinterpret_cast(GetItemData(iItem))); } } diff --git a/srchybrid/ServerSocket.cpp b/srchybrid/ServerSocket.cpp index 58726e33..f390abdb 100644 --- a/srchybrid/ServerSocket.cpp +++ b/srchybrid/ServerSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -259,10 +259,10 @@ bool CServerSocket::ProcessPacket(const BYTE *packet, uint32 size, uint8 opcode) const LoginAnswer_Struct *la = reinterpret_cast(packet); // save TCP flags in 'cur_server' - CServer *pServer; + uint32 dwFlags = 0; if (cur_server) { if (size >= sizeof(LoginAnswer_Struct) + 4) { - uint32 dwFlags = PeekUInt32(packet + sizeof(LoginAnswer_Struct)); + dwFlags = PeekUInt32(packet + sizeof(LoginAnswer_Struct)); if (thePrefs.GetDebugServerTCPLevel() > 0) { CString strInfo; strInfo.Format(_T(" TCP Flags=0x%08x"), dwFlags); @@ -285,21 +285,23 @@ bool CServerSocket::ProcessPacket(const BYTE *packet, uint32 size, uint8 opcode) strInfo.AppendFormat(_T(" TCP_Obfscation=1")); Debug(_T("%s\n"), (LPCTSTR)strInfo); } - cur_server->SetTCPFlags(dwFlags); - } else - cur_server->SetTCPFlags(0); + } + if (IsObfusicating()) + dwFlags |= SRV_TCPFLG_TCPOBFUSCATION; + cur_server->SetTCPFlags(dwFlags); - // copy TCP flags into the server in the server list - pServer = theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort()); + // copy TCP flags into the entry in the server list + CServer *pServer = theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort()); if (pServer) { - if (IsObfusicating()) + if (IsObfusicating()) { pServer->SetTriedCrypt(false); - pServer->SetTCPFlags(cur_server->GetTCPFlags()); + if (!pServer->GetObfuscationPortTCP()) //obfuscated connection with the default port + pServer->SetObfuscationPortTCP(pServer->GetPort()); + } + pServer->SetTCPFlags(dwFlags); } - } else { - pServer = NULL; + } else ASSERT(0); - } uint32 dwServerReportedIP; if (size >= 16) { @@ -356,8 +358,6 @@ bool CServerSocket::ProcessPacket(const BYTE *packet, uint32 size, uint8 opcode) if (thePrefs.GetDebugServerTCPLevel() > 0) Debug(_T("ServerMsg - OP_SearchResult\n")); CServer *cur_srv = (serverconnect) ? serverconnect->GetCurrentServer() : NULL; - //CServer *pServer = cur_srv ? theApp.serverlist->GetServerByAddress(cur_srv->GetAddress(), cur_srv->GetPort()) : NULL; - //(void)pServer; bool bMoreResultsAvailable; UINT uSearchResults = theApp.searchlist->ProcessSearchAnswer(packet, size, true/*pServer ? pServer->GetUnicodeSupport() : false*/, cur_srv ? cur_srv->GetIP() : 0, cur_srv ? cur_srv->GetPort() : (uint16)0, &bMoreResultsAvailable); theApp.emuledlg->searchwnd->LocalEd2kSearchEnd(uSearchResults, bMoreResultsAvailable); @@ -414,7 +414,6 @@ bool CServerSocket::ProcessPacket(const BYTE *packet, uint32 size, uint8 opcode) break;// throw "Invalid server info received"; } - CServer *pServer = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort()) : NULL; CString strInfo; CSafeMemFile data(packet, size); @@ -432,8 +431,10 @@ bool CServerSocket::ProcessPacket(const BYTE *packet, uint32 size, uint8 opcode) CString strName; CString strDescription; - for (uint32 i = 0; i < nTags; ++i) { - CTag tag(data, pServer ? pServer->GetUnicodeSupport() : false); + CServer *pServer = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort()) : NULL; + bool bUTF8 = pServer ? pServer->GetUnicodeSupport() : false; + for (; nTags; --nTags) { + CTag tag(data, bUTF8); if (tag.GetNameID() == ST_SERVERNAME) { if (tag.IsStr()) { strName = tag.GetStr(); @@ -502,10 +503,10 @@ bool CServerSocket::ProcessPacket(const BYTE *packet, uint32 size, uint8 opcode) DebugHexDump(packet + servers.GetPosition(), uAddData); } } - } catch (CFileException *error) { + } catch (CFileException *ex) { if (thePrefs.GetVerbose()) DebugLogError((LPCTSTR)GetResString(IDS_ERR_BADSERVERLISTRECEIVED)); - error->Delete(); + ex->Delete(); } break; case OP_CALLBACKREQUESTED: @@ -582,33 +583,30 @@ bool CServerSocket::ProcessPacket(const BYTE *packet, uint32 size, uint8 opcode) } return true; - } catch (CFileException *error) { + } catch (CFileException *ex) { if (thePrefs.GetVerbose()) { - TCHAR szError[MAX_CFEXP_ERRORMSG]; - error->m_strFileName = _T("server packet"); - GetExceptionMessage(*error, szError, _countof(szError)); - ProcessPacketError(size, opcode, szError); + ex->m_strFileName = _T("server packet"); + ProcessPacketError(size, opcode, CExceptionStr(*ex)); } ASSERT(0); - error->Delete(); + ex->Delete(); if (opcode == OP_SEARCHRESULT || opcode == OP_FOUNDSOURCES) return true; - } catch (CMemoryException *error) { + } catch (CMemoryException *ex) { ProcessPacketError(size, opcode, _T("CMemoryException")); ASSERT(0); - error->Delete(); + ex->Delete(); if (opcode == OP_SEARCHRESULT || opcode == OP_FOUNDSOURCES) return true; } catch (const CString &error) { ProcessPacketError(size, opcode, error); ASSERT(0); - } #ifndef _DEBUG - catch (...) { + } catch (...) { ProcessPacketError(size, opcode, _T("Unknown exception")); ASSERT(0); - } #endif + } SetConnectionState(CS_DISCONNECTED); return false; @@ -638,7 +636,7 @@ void CServerSocket::ConnectTo(CServer *server, bool bNoCrypt) } cur_server = new CServer(server); - bool bEncrypt = !bNoCrypt && thePrefs.IsServerCryptLayerTCPRequested() && (cur_server->SupportsObfuscationTCP() || !cur_server->TriedCrypt()); + bool bEncrypt = !bNoCrypt && thePrefs.IsCryptLayerPreferred() && (cur_server->SupportsObfuscationTCP() || !cur_server->TriedCrypt()); uint16 nPort; if (bEncrypt) { server->SetTriedCrypt(!server->SupportsObfuscationTCP()); //if no obfuscation support, try only once diff --git a/srchybrid/ServerSocket.h b/srchybrid/ServerSocket.h index 2f52bb78..656f1117 100644 --- a/srchybrid/ServerSocket.h +++ b/srchybrid/ServerSocket.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ServerWnd.cpp b/srchybrid/ServerWnd.cpp index e238935d..595952eb 100644 --- a/srchybrid/ServerWnd.cpp +++ b/srchybrid/ServerWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -173,27 +173,27 @@ BOOL CServerWnd::OnInitDialog() static_cast(GetDlgItem(IDC_SPORT))->SetLimitText(5); SetDlgItemText(IDC_SPORT, _T("4661")); - TCITEM newitem; + TCITEM ti; CString name(GetResString(IDS_SV_SERVERINFO)); DupAmpersand(name); - newitem.mask = TCIF_TEXT | TCIF_IMAGE; - newitem.pszText = const_cast((LPCTSTR)name); - newitem.iImage = 1; - VERIFY(StatusSelector.InsertItem(StatusSelector.GetItemCount(), &newitem) == PaneServerInfo); + ti.mask = TCIF_TEXT | TCIF_IMAGE; + ti.pszText = const_cast((LPCTSTR)name); + ti.iImage = 1; + VERIFY(StatusSelector.InsertItem(StatusSelector.GetItemCount(), &ti) == PaneServerInfo); name = GetResString(IDS_SV_LOG); DupAmpersand(name); - newitem.mask = TCIF_TEXT | TCIF_IMAGE; - newitem.pszText = const_cast((LPCTSTR)name); - newitem.iImage = 0; - VERIFY(StatusSelector.InsertItem(StatusSelector.GetItemCount(), &newitem) == PaneLog); + ti.mask = TCIF_TEXT | TCIF_IMAGE; + ti.pszText = const_cast((LPCTSTR)name); + ti.iImage = 0; + VERIFY(StatusSelector.InsertItem(StatusSelector.GetItemCount(), &ti) == PaneLog); name = SZ_DEBUG_LOG_TITLE; DupAmpersand(name); - newitem.mask = TCIF_TEXT | TCIF_IMAGE; - newitem.pszText = const_cast((LPCTSTR)name); - newitem.iImage = 0; - VERIFY(StatusSelector.InsertItem(StatusSelector.GetItemCount(), &newitem) == PaneVerboseLog); + ti.mask = TCIF_TEXT | TCIF_IMAGE; + ti.pszText = const_cast((LPCTSTR)name); + ti.iImage = 0; + VERIFY(StatusSelector.InsertItem(StatusSelector.GetItemCount(), &ti) == PaneVerboseLog); AddAnchor(IDC_SERVLST_ICO, TOP_LEFT); AddAnchor(IDC_SERVLIST_TEXT, TOP_LEFT); @@ -272,7 +272,7 @@ BOOL CServerWnd::OnInitDialog() // splitter CRect rcSpl(55, 55, 300, 55 + SVWND_SPLITTER_HEIGHT); - m_wndSplitter.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_SERVER); + m_wndSplitter.CreateWnd(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_SERVER); m_wndSplitter.SetDrawBorder(true); InitSplitter(); GetDlgItem(IDC_ED2KCONNECT)->EnableWindow(false); @@ -366,24 +366,24 @@ void CServerWnd::Localize() SetDlgItemText(IDC_LOGRESET, GetResString(IDS_PW_RESET)); m_ctrlMyInfoFrm.SetWindowText(GetResString(IDS_MYINFO)); - TCITEM item; + TCITEM ti; CString name(GetResString(IDS_SV_SERVERINFO)); DupAmpersand(name); - item.mask = TCIF_TEXT; - item.pszText = const_cast((LPCTSTR)name); - StatusSelector.SetItem(PaneServerInfo, &item); + ti.mask = TCIF_TEXT; + ti.pszText = const_cast((LPCTSTR)name); + StatusSelector.SetItem(PaneServerInfo, &ti); name = GetResString(IDS_SV_LOG); DupAmpersand(name); - item.mask = TCIF_TEXT; - item.pszText = const_cast((LPCTSTR)name); - StatusSelector.SetItem(PaneLog, &item); + ti.mask = TCIF_TEXT; + ti.pszText = const_cast((LPCTSTR)name); + StatusSelector.SetItem(PaneLog, &ti); name = SZ_DEBUG_LOG_TITLE; DupAmpersand(name); - item.mask = TCIF_TEXT; - item.pszText = const_cast((LPCTSTR)name); - StatusSelector.SetItem(PaneVerboseLog, &item); + ti.mask = TCIF_TEXT; + ti.pszText = const_cast((LPCTSTR)name); + StatusSelector.SetItem(PaneVerboseLog, &ti); UpdateLogTabSelection(); UpdateControlsState(); @@ -583,18 +583,17 @@ void CServerWnd::UpdateLogTabSelection() void CServerWnd::ToggleDebugWindow() { - int cur_sel = StatusSelector.GetCurSel(); if (thePrefs.GetVerbose() && !debug) { - TCITEM newitem; + TCITEM ti; CString name(SZ_DEBUG_LOG_TITLE); DupAmpersand(name); - newitem.mask = TCIF_TEXT | TCIF_IMAGE; - newitem.pszText = const_cast((LPCTSTR)name); - newitem.iImage = 0; - StatusSelector.InsertItem(StatusSelector.GetItemCount(), &newitem); + ti.mask = TCIF_TEXT | TCIF_IMAGE; + ti.pszText = const_cast((LPCTSTR)name); + ti.iImage = 0; + StatusSelector.InsertItem(StatusSelector.GetItemCount(), &ti); debug = true; } else if (!thePrefs.GetVerbose() && debug) { - if (cur_sel == PaneVerboseLog) { + if (StatusSelector.GetCurSel() == PaneVerboseLog) { StatusSelector.SetCurSel(PaneLog); StatusSelector.SetFocus(); } diff --git a/srchybrid/ServerWnd.h b/srchybrid/ServerWnd.h index a1b4a7ff..99dc5d5f 100644 --- a/srchybrid/ServerWnd.h +++ b/srchybrid/ServerWnd.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ShareableFile.cpp b/srchybrid/ShareableFile.cpp index da8ab35d..8fb8807e 100644 --- a/srchybrid/ShareableFile.cpp +++ b/srchybrid/ShareableFile.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ShareableFile.h b/srchybrid/ShareableFile.h index 3e1a37f1..c0afb16c 100644 --- a/srchybrid/ShareableFile.h +++ b/srchybrid/ShareableFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "abstractfile.h" diff --git a/srchybrid/SharedDirsTreeCtrl.cpp b/srchybrid/SharedDirsTreeCtrl.cpp index f857c71e..9ed47a5a 100644 --- a/srchybrid/SharedDirsTreeCtrl.cpp +++ b/srchybrid/SharedDirsTreeCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -112,8 +112,7 @@ void CSharedDirsTreeCtrl::Initialize(CSharedFilesCtrl *pSharedFilesCtrl) // Win98: Explicitly set to Unicode to receive Unicode notifications. SendMessage(CCM_SETUNICODEFORMAT, TRUE); - //WORD wWinVer = thePrefs.GetWindowsVersion(); - m_bUseIcons = true;/*(wWinVer == _WINVER_2K_ || wWinVer == _WINVER_XP_ || wWinVer == _WINVER_ME_);*/ + m_bUseIcons = true; SetAllIcons(); Localize(); } @@ -739,7 +738,7 @@ void CSharedDirsTreeCtrl::FileSystemTreeAddChildItem(CDirectoryItem *pRoot, cons itInsert.item.mask |= TVIF_PARAM; itInsert.item.lParam = (LPARAM)pti; - CString sName; //temporary storage for display name + SHFILEINFO shFinfo; if (m_bUseIcons) { if (FileSystemTreeIsShared(strDir)) { itInsert.item.stateMask |= TVIS_OVERLAYMASK; @@ -751,27 +750,16 @@ void CSharedDirsTreeCtrl::FileSystemTreeAddChildItem(CDirectoryItem *pRoot, cons if (DRIVE_REMOVABLE <= nType && nType <= DRIVE_RAMDISK) itInsert.item.iImage = nType; - SHFILEINFO shFinfo; shFinfo.szDisplayName[0] = _T('\0'); - if (::SHGetFileInfo(strDir, 0, &shFinfo, sizeof(shFinfo), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME)) { + if (::SHGetFileInfo(strDir, 0, &shFinfo, sizeof(shFinfo), SHGFI_SMALLICON | SHGFI_ICON | SHGFI_OPENICON | SHGFI_DISPLAYNAME)) { itInsert.itemex.iImage = AddSystemIcon(shFinfo.hIcon, shFinfo.iIcon); ::DestroyIcon(shFinfo.hIcon); - if (bTopLevel && shFinfo.szDisplayName[0] != _T('\0')) { - sName = shFinfo.szDisplayName; - itInsert.item.pszText = const_cast((LPCTSTR)sName); - } + if (bTopLevel && shFinfo.szDisplayName[0] != _T('\0')) + itInsert.item.pszText = shFinfo.szDisplayName; } else { - TRACE(_T("Error Getting SystemFileInfo!")); + TRACE(_T("Error getting SystemFileInfo!")); itInsert.itemex.iImage = 0; // :( } - - if (::SHGetFileInfo(strDir, 0, &shFinfo, sizeof(shFinfo), SHGFI_ICON | SHGFI_OPENICON | SHGFI_SMALLICON)) { - itInsert.itemex.iSelectedImage = AddSystemIcon(shFinfo.hIcon, shFinfo.iIcon); - ::DestroyIcon(shFinfo.hIcon); - } else { - TRACE(_T("Error Getting SystemFileInfo!")); - itInsert.itemex.iImage = 0; - } } pti->m_htItem = InsertItem(&itInsert); diff --git a/srchybrid/SharedDirsTreeCtrl.h b/srchybrid/SharedDirsTreeCtrl.h index 1826a5ac..3985d823 100644 --- a/srchybrid/SharedDirsTreeCtrl.h +++ b/srchybrid/SharedDirsTreeCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "TitleMenu.h" @@ -66,7 +65,7 @@ class CSharedDirsTreeCtrl : public CTreeCtrl void SetAllIcons(); CDirectoryItem* GetSelectedFilter() const; - bool IsCreatingTree() const { return m_bCreatingTree; }; + bool IsCreatingTree() const { return m_bCreatingTree; } void Localize(); void EditSharedDirectories(const CDirectoryItem *pDir, bool bAdd, bool bSubDirectories); void Reload(bool bForce = false); diff --git a/srchybrid/SharedFileList.cpp b/srchybrid/SharedFileList.cpp index 76653f96..f1b85aaa 100644 --- a/srchybrid/SharedFileList.cpp +++ b/srchybrid/SharedFileList.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -420,9 +420,9 @@ int CAddFileThread::Run() return 0; } - // Locking that hashing thread is needed because we may create a couple of those threads + // Locking this hashing thread is needed because we may create a few of those threads // at startup when rehashing potentially corrupted downloading part files. - // If all those hash threads would run concurrently, the io-system would be under + // If all those hash threads would run concurrently, the I/O system would be under // very heavy load and slowly progressing CSingleLock hashingLock(&theApp.hashing_mut, TRUE); // hash only one file at a time @@ -706,9 +706,8 @@ bool CSharedFileList::AddFile(CKnownFile *pFile) delete pFile->m_pCollection; pFile->m_pCollection = NULL; } else if (!pFile->m_pCollection->GetCollectionAuthorKeyString().IsEmpty()) { - //If the collection has a key, resetting the file name will - //cause the key to be added into the word list to be stored - //into Kad. + //If the collection has a key, resetting the file name will cause + //the key to be added into the word list to be stored in Kad. pFile->SetFileName(pFile->GetFileName()); //During the initial startup, shared files are not accessible //to SetFileName which will then not call AddKeywords. @@ -1579,32 +1578,25 @@ void CSharedFileList::CheckAndAddSingleFile(const CFileFind &ff) void CSharedFileList::Save() const { const CString &strFullPath(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + SHAREDFILES_FILE); - CStdioFile sdirfile; - if (sdirfile.Open(strFullPath, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite | CFile::typeBinary)) { + CStdioFile file; + if (file.Open(strFullPath, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite | CFile::typeBinary)) { try { // write Unicode byte order mark 0xFEFF static const WORD wBOM = u'\xFEFF'; - sdirfile.Write(&wBOM, sizeof(wBOM)); + file.Write(&wBOM, sizeof(wBOM)); for (POSITION pos = m_liSingleSharedFiles.GetHeadPosition(); pos != NULL;) { - sdirfile.WriteString(m_liSingleSharedFiles.GetNext(pos)); - sdirfile.Write(_T("\r\n"), 2 * sizeof(TCHAR)); + file.WriteString(m_liSingleSharedFiles.GetNext(pos)); + file.Write(_T("\r\n"), 2 * sizeof(TCHAR)); } for (POSITION pos = m_liSingleExcludedFiles.GetHeadPosition(); pos != NULL;) { - sdirfile.WriteString(_T('-') + m_liSingleExcludedFiles.GetNext(pos)); // a '-' prefix means excluded - sdirfile.Write(_T("\r\n"), 2 * sizeof(TCHAR)); - } - if (thePrefs.GetCommitFiles() >= 2 || (thePrefs.GetCommitFiles() >= 1 && theApp.IsClosing())) { - sdirfile.Flush(); // flush file stream buffers to disk buffers - if (_commit(_fileno(sdirfile.m_pStream)) != 0) // commit disk buffers to disk - AfxThrowFileException(CFileException::hardIO, ::GetLastError(), sdirfile.GetFileName()); + file.WriteString(_T('-') + m_liSingleExcludedFiles.GetNext(pos)); // a '-' prefix means excluded + file.Write(_T("\r\n"), 2 * sizeof(TCHAR)); } - sdirfile.Close(); - } catch (CFileException *error) { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - DebugLogError(_T("Failed to save %s - %s"), (LPCTSTR)strFullPath, buffer); - error->Delete(); + CommitAndClose(file); + } catch (CFileException *ex) { + DebugLogError(_T("Failed to save %s%s"), (LPCTSTR)strFullPath, (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } else DebugLogError(_T("Failed to save %s"), (LPCTSTR)strFullPath); @@ -1638,11 +1630,9 @@ void CSharedFileList::LoadSingleSharedFilesList() AddSingleSharedFile(toadd, true); } sdirfile.Close(); - } catch (CFileException *error) { - TCHAR buffer[MAX_CFEXP_ERRORMSG]; - GetExceptionMessage(*error, buffer, _countof(buffer)); - DebugLogError(_T("Failed to load %s - %s"), (LPCTSTR)strFullPath, buffer); - error->Delete(); + } catch (CFileException *ex) { + DebugLogError(_T("Failed to load %s%s"), (LPCTSTR)strFullPath, (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } } else DebugLogError(_T("Failed to load %s"), (LPCTSTR)strFullPath); diff --git a/srchybrid/SharedFileList.h b/srchybrid/SharedFileList.h index 99c4ec53..55553030 100644 --- a/srchybrid/SharedFileList.h +++ b/srchybrid/SharedFileList.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -100,7 +100,7 @@ class CSharedFileList bool GetPopularityRank(const CKnownFile *pFile, uint32 &rnOutSession, uint32 &rnOutTotal) const; CCriticalSection m_mutWriteList; // don't acquire other locks while having this one in the main thread or make sure deadlocks are impossible - static uint8 GetRealPrio(uint8 in) { return (in < 4) ? in + 1 : 0; }; + static uint8 GetRealPrio(uint8 in) { return (in < 4) ? in + 1 : 0; } void ResetPseudoDirNames() { m_mapPseudoDirNames.RemoveAll(); } protected: diff --git a/srchybrid/SharedFilesCtrl.cpp b/srchybrid/SharedFilesCtrl.cpp index 84ac0c86..16743da5 100644 --- a/srchybrid/SharedFilesCtrl.cpp +++ b/srchybrid/SharedFilesCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -1543,7 +1543,7 @@ void CSharedFilesCtrl::AddShareableFiles(const CString &strFromDir) } else { // neither known nor shared, create CShareableFile *pNewTempFile = new CShareableFile(); pNewTempFile->SetFilePath(strFoundFilePath); - pNewTempFile->SetFileName(strFoundFileName); + pNewTempFile->SetAFileName(strFoundFileName); pNewTempFile->SetPath(strFoundDirectory); pNewTempFile->SetFileSize(ullFoundFileSize); uchar aucMD4[MDX_DIGEST_SIZE] = {}; @@ -1628,7 +1628,6 @@ void CSharedFilesCtrl::OnMouseMove(UINT nFlags, CPoint point) if (iItem >= 0) { CRect rcItem; if (GetItemRect(iItem, rcItem, LVIR_BOUNDS)) { - ASSERT(rcItem.PtInRect(point)); rcItem.left += sm_iIconOffset; rcItem.right = rcItem.left + 16; rcItem.top += (rcItem.Height() > 16) ? ((rcItem.Height() - 15) / 2) : 0; diff --git a/srchybrid/SharedFilesCtrl.h b/srchybrid/SharedFilesCtrl.h index 848d5e01..a9bb1a14 100644 --- a/srchybrid/SharedFilesCtrl.h +++ b/srchybrid/SharedFilesCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/SharedFilesWnd.cpp b/srchybrid/SharedFilesWnd.cpp index 5c737e25..20239bff 100644 --- a/srchybrid/SharedFilesWnd.cpp +++ b/srchybrid/SharedFilesWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -110,7 +110,7 @@ BOOL CSharedFilesWnd::OnInitDialog() rcSpl.left = rcSpl.right + SPLITTER_MARGIN; rcSpl.right = rcSpl.left + SPLITTER_WIDTH; - m_wndSplitter.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_SHAREDFILES); + m_wndSplitter.CreateWnd(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_SHAREDFILES); AddAnchor(m_ctlSharedDirTree, TOP_LEFT, BOTTOM_LEFT); AddAnchor(IDC_RELOADSHAREDFILES, TOP_RIGHT); @@ -350,7 +350,7 @@ LRESULT CSharedFilesWnd::OnChangeFilter(WPARAM wParam, LPARAM lParam) bool bFilterDiff = (astrFilter.GetCount() != m_astrFilter.GetCount()); if (!bFilterDiff) - for (int i = (int)astrFilter.GetCount(); --i >= 0;) + for (INT_PTR i = astrFilter.GetCount(); --i >= 0;) if (astrFilter[i] != m_astrFilter[i]) { bFilterDiff = true; break; @@ -544,9 +544,9 @@ CSharedFileDetailsModelessSheet::CSharedFileDetailsModelessSheet() /*LPCTSTR pPshStartPage = m_pPshStartPage; if (m_uInvokePage != 0) pPshStartPage = MAKEINTRESOURCE(m_uInvokePage); - for (int i = (int)m_pages.GetCount(); --i >= 0;) + for (INT_PTR i = m_pages.GetCount(); --i >= 0;) if (GetPage(i)->m_psp.pszTemplate == pPshStartPage) { - m_psh.nStartPage = i; + m_psh.nStartPage = (UINT)i; break; }*/ } diff --git a/srchybrid/SharedFilesWnd.h b/srchybrid/SharedFilesWnd.h index 87367fc8..9a6016c7 100644 --- a/srchybrid/SharedFilesWnd.h +++ b/srchybrid/SharedFilesWnd.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/SmileySelector.cpp b/srchybrid/SmileySelector.cpp index e5c0142a..79aee3a4 100644 --- a/srchybrid/SmileySelector.cpp +++ b/srchybrid/SmileySelector.cpp @@ -1,6 +1,6 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -86,7 +86,7 @@ void CSmileySelector::OnDestroy() CWnd::OnDestroy(); } -BOOL CSmileySelector::Create(CWnd *pWndParent, LPCRECT pRect, CEdit *pwndEdit) +BOOL CSmileySelector::CreateWnd(CWnd *pWndParent, LPCRECT pRect, CEdit *pwndEdit) { m_pwndEdit = pwndEdit; @@ -121,8 +121,8 @@ BOOL CSmileySelector::Create(CWnd *pWndParent, LPCRECT pRect, CEdit *pwndEdit) | TBSTYLE_TOOLTIPS #endif | CCS_NOPARENTALIGN - | CCS_NODIVIDER, - CRect(), this, IDC_SMILEY_TOOLBAR)) + | CCS_NODIVIDER + , CRect(), this, IDC_SMILEY_TOOLBAR)) { return FALSE; } diff --git a/srchybrid/SmileySelector.h b/srchybrid/SmileySelector.h index fa2ff00e..2acc5890 100644 --- a/srchybrid/SmileySelector.h +++ b/srchybrid/SmileySelector.h @@ -1,6 +1,6 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -25,7 +25,7 @@ class CSmileySelector : public CWnd public: CSmileySelector(); - BOOL Create(CWnd *pWndParent, LPCRECT pRect, CEdit *pwndEdit); + BOOL CreateWnd(CWnd *pWndParent, LPCRECT pRect, CEdit *pwndEdit); protected: int m_iBitmaps; diff --git a/srchybrid/SplashScreen.cpp b/srchybrid/SplashScreen.cpp index f99c2cef..3f2013ef 100644 --- a/srchybrid/SplashScreen.cpp +++ b/srchybrid/SplashScreen.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -125,7 +125,7 @@ void CSplashScreen::OnPaint() _tcscpy(lf.lfFaceName, _T("Arial")); font.CreateFontIndirect(&lf); pOldFont = dc.SelectObject(&font); - dc.DrawText(_T("Copyright (C) 2002-2023 Merkur"), &rc, DT_CENTER | DT_NOPREFIX); + dc.DrawText(_T("Copyright (C) 2002-2024 Merkur"), &rc, DT_CENTER | DT_NOPREFIX); if (pOldFont) dc.SelectObject(pOldFont); font.DeleteObject(); diff --git a/srchybrid/SplitterControl.cpp b/srchybrid/SplitterControl.cpp index 59cfa36e..f46dbffd 100644 --- a/srchybrid/SplitterControl.cpp +++ b/srchybrid/SplitterControl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -51,7 +51,7 @@ CSplitterControl::CSplitterControl() { } -void CSplitterControl::Create(DWORD dwStyle, const CRect &rect, CWnd *pParent, UINT nID) +void CSplitterControl::CreateWnd(DWORD dwStyle, const CRect &rect, CWnd *pParent, UINT nID) { CRect rc = rect; dwStyle |= SS_NOTIFY; diff --git a/srchybrid/SplitterControl.h b/srchybrid/SplitterControl.h index c91e510a..424c41c7 100644 --- a/srchybrid/SplitterControl.h +++ b/srchybrid/SplitterControl.h @@ -34,7 +34,7 @@ class CSplitterControl : public CStatic public: CSplitterControl(); - void Create(DWORD dwStyle, const CRect &rect, CWnd *pParent, UINT nID); + void CreateWnd(DWORD dwStyle, const CRect &rect, CWnd *pParent, UINT nID); int GetStyle(); int SetStyle(int nStyle = SPS_VERTICAL); void SetRange(int nMin, int nMax); diff --git a/srchybrid/StatisticFile.cpp b/srchybrid/StatisticFile.cpp index 7ca500b0..1c7c9cc9 100644 --- a/srchybrid/StatisticFile.cpp +++ b/srchybrid/StatisticFile.cpp @@ -1,6 +1,6 @@ // parts of this file are based on work from pan One (http://home-3.tiscali.nl/~meost/pms/) //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/StatisticFile.h b/srchybrid/StatisticFile.h index 836c2e80..9a173719 100644 --- a/srchybrid/StatisticFile.h +++ b/srchybrid/StatisticFile.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Statistics.cpp b/srchybrid/Statistics.cpp index 33845763..ed0e8d06 100644 --- a/srchybrid/Statistics.cpp +++ b/srchybrid/Statistics.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Statistics.h b/srchybrid/Statistics.h index b65e7162..1f6a100c 100644 --- a/srchybrid/Statistics.h +++ b/srchybrid/Statistics.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -147,7 +147,7 @@ class CStatistics static uint64 sessionReceivedBytes; static uint64 sessionSentBytes; - static uint64 sessionSentBytesToFriend; + static uint64 sessionSentBytesToFriend; static uint16 reconnects; static DWORD transferStarttime; static DWORD serverConnectTime; diff --git a/srchybrid/StatisticsDlg.cpp b/srchybrid/StatisticsDlg.cpp index 71741112..5ddad700 100644 --- a/srchybrid/StatisticsDlg.cpp +++ b/srchybrid/StatisticsDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -162,7 +162,7 @@ BOOL CStatisticsDlg::OnInitDialog() GetDlgItem(IDC_SCOPE_D)->GetWindowRect(rcDown); GetDlgItem(IDC_SCOPE_D)->DestroyWindow(); ScreenToClient(rcDown); - m_DownloadOMeter.Create(WS_VISIBLE | WS_CHILD, rcDown, this, IDC_SCOPE_D); + m_DownloadOMeter.CreateWnd(WS_VISIBLE | WS_CHILD, rcDown, this, IDC_SCOPE_D); SetARange(true, thePrefs.GetMaxGraphDownloadRate()); m_DownloadOMeter.SetYUnits(GetResString(IDS_KBYTESPERSEC)); @@ -174,7 +174,7 @@ BOOL CStatisticsDlg::OnInitDialog() // compensate rounding errors due to dialog units, make each of the 3 panes the same height rcUp.top = rcDown.bottom + 4; rcUp.bottom = rcUp.top + rcDown.Height(); - m_UploadOMeter.Create(WS_VISIBLE | WS_CHILD, rcUp, this, IDC_SCOPE_U); + m_UploadOMeter.CreateWnd(WS_VISIBLE | WS_CHILD, rcUp, this, IDC_SCOPE_U); SetARange(false, thePrefs.GetMaxGraphUploadRate(true)); m_UploadOMeter.SetYUnits(GetResString(IDS_KBYTESPERSEC)); @@ -186,7 +186,7 @@ BOOL CStatisticsDlg::OnInitDialog() // compensate rounding errors due to dialog units, make each of the 3 panes the same height rcConn.top = rcUp.bottom + 4; rcConn.bottom = rcConn.top + rcDown.Height(); - m_Statistics.Create(WS_VISIBLE | WS_CHILD, rcConn, this, IDC_STATSSCOPE); + m_Statistics.CreateWnd(WS_VISIBLE | WS_CHILD, rcConn, this, IDC_STATSSCOPE); m_Statistics.SetRanges(0, thePrefs.GetStatsMax()); m_Statistics.autofitYscale = false; // Set the trend ratio of the Active Connections trend in the Connection Statistics scope. @@ -229,7 +229,7 @@ BOOL CStatisticsDlg::OnInitDialog() //vertical splitter CRect rcSpl(rcTree.right, rcW.top + 2, rcTree.right + 4, rcW.bottom - 5); - m_wndSplitterstat.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT); + m_wndSplitterstat.CreateWnd(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT); int PosStatVinitX = rcSpl.left; int PosStatVnewX = thePrefs.GetSplitterbarPositionStat() * rcW.Width() / 100; int maxX = rcW.right - 13; @@ -244,7 +244,7 @@ BOOL CStatisticsDlg::OnInitDialog() //HR splitter rcSpl = { rcDown.left, rcDown.bottom, rcDown.right, rcDown.bottom + 4 }; - m_wndSplitterstat_HR.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT_HR); + m_wndSplitterstat_HR.CreateWnd(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT_HR); int PosStatVinitZ = rcSpl.top; int PosStatVnewZ = thePrefs.GetSplitterbarPositionStat_HR() * rcW.Height() / 100; int maxZ = rcW.bottom - 14; @@ -259,7 +259,7 @@ BOOL CStatisticsDlg::OnInitDialog() //HL splitter rcSpl = { rcUp.left, rcUp.bottom, rcUp.right, rcUp.bottom + 4 }; - m_wndSplitterstat_HL.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT_HL); + m_wndSplitterstat_HL.CreateWnd(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT_HL); int PosStatVinitY = rcSpl.top; int PosStatVnewY = thePrefs.GetSplitterbarPositionStat_HL() * rcW.Height() / 100; int maxY = rcW.bottom - 9; @@ -616,9 +616,9 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) // TRANSFER SECTION if (forceUpdate || m_stattree.IsExpanded(h_transfer)) { - uint32 statGoodSessions = 0; - uint32 statBadSessions = 0; - double percentSessions = 0; + uint32 statGoodSessions; + uint32 statBadSessions; + double percentSessions; // Transfer Ratios if (theStats.sessionReceivedBytes > 0 && theStats.sessionSentBytes > 0) { // Session @@ -735,7 +735,6 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) if (forceUpdate || m_stattree.IsExpanded(hdown_spb)) { uint64 PortDataDefault = thePrefs.GetDownDataPort_4662(); uint64 PortDataOther = thePrefs.GetDownDataPort_OTHER(); - uint64 PortDataPeerCache = thePrefs.GetDownDataPort_PeerCache(); uint64 PortDataTotal = thePrefs.GetDownSessionDataPort(); double percentPortTransferred; @@ -753,13 +752,6 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) percentPortTransferred = 0; sText.Format(_T("%s: %s (%1.1f%%)"), (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataOther), percentPortTransferred); m_stattree.SetItemText(down_spb[i], sText); - ++i; - if (PortDataTotal != 0 && PortDataPeerCache != 0) - percentPortTransferred = 100.0 * PortDataPeerCache / PortDataTotal; - else - percentPortTransferred = 0; - sText.Format(_T("%s: %s (%1.1f%%)"), thePrefs.GetPeerCacheShow() ? _T("PeerCache") : (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataPeerCache), percentPortTransferred); - m_stattree.SetItemText(down_spb[i], sText); } } // Completed Downloads @@ -1001,7 +993,6 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) int i = 0; uint64 PortDataDefault = thePrefs.GetCumDownDataPort_4662(); uint64 PortDataOther = thePrefs.GetCumDownDataPort_OTHER(); - uint64 PortDataPeerCache = thePrefs.GetCumDownDataPort_PeerCache(); uint64 PortDataTotal = thePrefs.GetDownTotalPortData(); double percentPortTransferred; @@ -1019,14 +1010,7 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) percentPortTransferred = 0; sText.Format(_T("%s: %s (%1.1f%%)"), (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataOther), percentPortTransferred); m_stattree.SetItemText(down_tpb[i], sText); - ++i; - - if (PortDataTotal != 0 && PortDataPeerCache != 0) - percentPortTransferred = 100.0 * PortDataPeerCache / PortDataTotal; - else - percentPortTransferred = 0; - sText.Format(_T("%s: %s (%1.1f%%)"), thePrefs.GetPeerCacheShow() ? _T("PeerCache") : (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataPeerCache), percentPortTransferred); - m_stattree.SetItemText(down_tpb[i], sText); + //++i; } } // Set Cum Completed Downloads @@ -1174,11 +1158,6 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) percentPortTransferred = !PortDataTotal ? 0 : 100.0 * PortDataOther / PortDataTotal; sText.Format(_T("%s: %s (%1.1f%%)"), (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataOther), percentPortTransferred); m_stattree.SetItemText(up_spb[i], sText); - ++i; - uint64 PortDataPeerCache = thePrefs.GetUpDataPort_PeerCache(); - percentPortTransferred = !PortDataTotal ? 0 : 100.0 * PortDataPeerCache / PortDataTotal; - sText.Format(_T("%s: %s (%1.1f%%)"), thePrefs.GetPeerCacheShow() ? _T("PeerCache") : (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataPeerCache), percentPortTransferred); - m_stattree.SetItemText(up_spb[i], sText); } // Uploaded Data By Source if (forceUpdate || m_stattree.IsExpanded(hup_ssb)) { @@ -1333,11 +1312,6 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) percentPortTransferred = !PortDataTotal ? 0 : 100.0 * PortDataOther / PortDataTotal; sText.Format(_T("%s: %s (%1.1f%%)"), (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataOther), percentPortTransferred); m_stattree.SetItemText(up_tpb[i], sText); - ++i; - uint64 PortDataPeerCache = thePrefs.GetCumUpDataPort_PeerCache(); - percentPortTransferred = !PortDataTotal ? 0 : 100.0 * PortDataPeerCache / PortDataTotal; - sText.Format(_T("%s: %s (%1.1f%%)"), thePrefs.GetPeerCacheShow() ? _T("PeerCache") : (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataPeerCache), percentPortTransferred); - m_stattree.SetItemText(up_tpb[i], sText); } // Uploaded Data By Source if (forceUpdate || m_stattree.IsExpanded(hup_tsb)) { @@ -1703,7 +1677,6 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) int i = 0; uint64 PortDataDefault = (uint64)(thePrefs.GetCumUpDataPort_4662() * avgModifier[mx]); uint64 PortDataOther = (uint64)(thePrefs.GetCumUpDataPort_OTHER() * avgModifier[mx]); - uint64 PortDataPeerCache = (uint64)(thePrefs.GetCumUpDataPort_PeerCache() * avgModifier[mx]); uint64 PortDataTotal = (uint64)(thePrefs.GetUpTotalPortData() * avgModifier[mx]); double percentPortTransferred = 0; @@ -1718,13 +1691,6 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) percentPortTransferred = 0; sText.Format(_T("%s: %s (%1.1f%%)"), (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataOther), percentPortTransferred); m_stattree.SetItemText(time_aap_up_dp[mx][i], sText); - ++i; - if (PortDataTotal != 0 && PortDataPeerCache != 0) - percentPortTransferred = 100.0 * PortDataPeerCache / PortDataTotal; - else - percentPortTransferred = 0; - sText.Format(_T("%s: %s (%1.1f%%)"), thePrefs.GetPeerCacheShow() ? _T("PeerCache") : (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataPeerCache), percentPortTransferred); - m_stattree.SetItemText(time_aap_up_dp[mx][i], sText); } // Uploaded Data By Source if (forceUpdate || m_stattree.IsExpanded(time_aap_up_hd[mx][2])) { @@ -1891,7 +1857,6 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) int i = 0; uint64 PortDataDefault = (uint64)(thePrefs.GetCumDownDataPort_4662() * avgModifier[mx]); uint64 PortDataOther = (uint64)(thePrefs.GetCumDownDataPort_OTHER() * avgModifier[mx]); - uint64 PortDataPeerCache = (uint64)(thePrefs.GetCumDownDataPort_PeerCache() * avgModifier[mx]); uint64 PortDataTotal = (uint64)(thePrefs.GetDownTotalPortData() * avgModifier[mx]); double percentPortTransferred; @@ -1902,21 +1867,12 @@ void CStatisticsDlg::ShowStatistics(bool forceUpdate) sText.Format(_T("%s: %s (%1.1f%%)"), (LPCTSTR)GetResString(IDS_STATS_PRTDEF), (LPCTSTR)CastItoXBytes(PortDataDefault), percentPortTransferred); m_stattree.SetItemText(time_aap_down_dp[mx][i], sText); ++i; - if (PortDataTotal != 0 && PortDataOther != 0) percentPortTransferred = 100.0 * PortDataOther / PortDataTotal; else percentPortTransferred = 0; sText.Format(_T("%s: %s (%1.1f%%)"), (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataOther), percentPortTransferred); m_stattree.SetItemText(time_aap_down_dp[mx][i], sText); - ++i; - - if (PortDataTotal != 0 && PortDataPeerCache != 0) - percentPortTransferred = 100.0 * PortDataPeerCache / PortDataTotal; - else - percentPortTransferred = 0; - sText.Format(_T("%s: %s (%1.1f%%)"), thePrefs.GetPeerCacheShow() ? _T("PeerCache") : (LPCTSTR)GetResString(IDS_STATS_PRTOTHER), (LPCTSTR)CastItoXBytes(PortDataPeerCache), percentPortTransferred); - m_stattree.SetItemText(time_aap_down_dp[mx][i], sText); } } // Set Cum Completed Downloads diff --git a/srchybrid/StatisticsDlg.h b/srchybrid/StatisticsDlg.h index daae2a05..0ad6b2ea 100644 --- a/srchybrid/StatisticsDlg.h +++ b/srchybrid/StatisticsDlg.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -64,13 +64,13 @@ class CStatisticsDlg : public CResizableDialog CImageList imagelistStatTree; HTREEITEM h_transfer, trans[3]; // Transfer Header and Items HTREEITEM h_upload, h_up_session, up_S[6], h_up_total, up_T[2]; // Uploads Session and Total Items and Headers - HTREEITEM hup_scb, up_scb[7], hup_spb, up_spb[3], hup_ssb, up_ssb[2]; // Session Uploaded Byte Breakdowns - HTREEITEM hup_tcb, up_tcb[7], hup_tpb, up_tpb[3], hup_tsb, up_tsb[2]; // Total Uploaded Byte Breakdowns + HTREEITEM hup_scb, up_scb[7], hup_spb, up_spb[2], hup_ssb, up_ssb[2]; // Session Uploaded Byte Breakdowns + HTREEITEM hup_tcb, up_tcb[7], hup_tpb, up_tpb[2], hup_tsb, up_tsb[2]; // Total Uploaded Byte Breakdowns HTREEITEM hup_soh, up_soh[4], hup_toh, up_toh[4]; // Upline Overhead HTREEITEM up_ssessions[4], up_tsessions[4]; // Breakdown of Upload Sessions HTREEITEM h_download, h_down_session, down_S[8], h_down_total, down_T[6]; // Downloads Session and Total Items and Headers - HTREEITEM hdown_scb, down_scb[8], hdown_spb, down_spb[3]; // Session Downloaded Byte Breakdowns - HTREEITEM hdown_tcb, down_tcb[8], hdown_tpb, down_tpb[3]; // Total Downloaded Byte Breakdowns + HTREEITEM hdown_scb, down_scb[8], hdown_spb, down_spb[2]; // Session Downloaded Byte Breakdowns + HTREEITEM hdown_tcb, down_tcb[8], hdown_tpb, down_tpb[2]; // Total Downloaded Byte Breakdowns HTREEITEM hdown_soh, down_soh[4], hdown_toh, down_toh[4]; // Downline Overhead HTREEITEM down_ssessions[4], down_tsessions[4], down_sources[22]; // Breakdown of Download Sessions and Sources HTREEITEM h_connection, h_conn_session, h_conn_total; // Connection Section Headers @@ -88,9 +88,9 @@ class CStatisticsDlg : public CResizableDialog HTREEITEM h_time, tvitime[2], htime_s, tvitime_s[4], tvitime_st[2], htime_t, tvitime_t[3], tvitime_tt[2]; HTREEITEM htime_aap, time_aaph[3], time_aap_hup[3], time_aap_hdown[3]; HTREEITEM time_aap_up_hd[3][3], time_aap_down_hd[3][2]; - HTREEITEM time_aap_up[3][3], time_aap_up_dc[3][7], time_aap_up_dp[3][3]; + HTREEITEM time_aap_up[3][3], time_aap_up_dc[3][7], time_aap_up_dp[3][2]; HTREEITEM time_aap_up_ds[3][2], time_aap_up_s[3][2], time_aap_up_oh[3][4]; - HTREEITEM time_aap_down[3][7], time_aap_down_dc[3][8], time_aap_down_dp[3][3]; + HTREEITEM time_aap_down[3][7], time_aap_down_dc[3][8], time_aap_down_dp[3][2]; HTREEITEM time_aap_down_s[3][2], time_aap_down_oh[3][4]; HTREEITEM h_total_downloads; diff --git a/srchybrid/StringConversion.cpp b/srchybrid/StringConversion.cpp index a3deb7a2..a5317d58 100644 --- a/srchybrid/StringConversion.cpp +++ b/srchybrid/StringConversion.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/StringConversion.h b/srchybrid/StringConversion.h index 2c342260..b926b58c 100644 --- a/srchybrid/StringConversion.h +++ b/srchybrid/StringConversion.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/TabCtrl.cpp b/srchybrid/TabCtrl.cpp index 53964bb6..0085eb6b 100644 --- a/srchybrid/TabCtrl.cpp +++ b/srchybrid/TabCtrl.cpp @@ -281,22 +281,21 @@ BOOL TabControl::ReorderTab(unsigned int nSrcTab, unsigned int nDstTab) // Remember the current selected tab unsigned int nSelectedTab = GetCurSel(); - // Get information from the tab to move (to be deleted) + // Get information from the tab to be moved or deleted TCHAR sBuffer[256]; - TCITEM item; - item.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT; //| TCIF_STATE; - item.pszText = sBuffer; - item.cchTextMax = _countof(sBuffer); + TCITEM ti; + ti.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT; //| TCIF_STATE; + ti.pszText = sBuffer; + ti.cchTextMax = _countof(sBuffer); - BOOL bOK = GetItem(nSrcTab, &item); - sBuffer[_countof(sBuffer) - 1] = _T('\0'); + BOOL bOK = GetItem(nSrcTab, &ti); ASSERT(bOK); bOK = DeleteItem(nSrcTab); ASSERT(bOK); // Insert it at new location - bOK = InsertItem(nDstTab - static_cast(m_nDstTab > m_nSrcTab), &item); + bOK = InsertItem(nDstTab - static_cast(m_nDstTab > m_nSrcTab), &ti); // Setup new selected tab if (nSelectedTab == nSrcTab) @@ -370,7 +369,6 @@ void TabControl::DrawItem(LPDRAWITEMSTRUCT lpDIS) tci.cchTextMax = _countof(szLabel); if (!GetItem(nTabIndex, &tci)) return; - szLabel[_countof(szLabel) - 1] = _T('\0'); CDC *pDC = CDC::FromHandle(lpDIS->hDC); if (!pDC) diff --git a/srchybrid/TaskbarNotifier.cpp b/srchybrid/TaskbarNotifier.cpp index f141b679..6ff7f975 100644 --- a/srchybrid/TaskbarNotifier.cpp +++ b/srchybrid/TaskbarNotifier.cpp @@ -115,7 +115,7 @@ LRESULT CALLBACK My_AfxWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPara return DefWindowProc(hWnd, nMsg, wParam, lParam); } -int CTaskbarNotifier::Create(CWnd *pWndParent) +int CTaskbarNotifier::CreateWnd(CWnd *pWndParent) { static LPCTSTR const s_szClassName = _T("eMule_TaskbarNotifierWndClass"); ASSERT(pWndParent != NULL); diff --git a/srchybrid/TaskbarNotifier.h b/srchybrid/TaskbarNotifier.h index 3723338f..1bbd7c54 100644 --- a/srchybrid/TaskbarNotifier.h +++ b/srchybrid/TaskbarNotifier.h @@ -52,7 +52,7 @@ class CTaskbarNotifier : public CWnd CTaskbarNotifier(); virtual ~CTaskbarNotifier(); - int Create(CWnd *pWndParent); + int CreateWnd(CWnd *pWndParent); bool LoadConfiguration(LPCTSTR pszFilePath); void Show(LPCTSTR pszCaption, TbnMsg nMsgType, LPCTSTR pszLink, BOOL bAutoClose = TRUE); void ShowLastHistoryMessage(); diff --git a/srchybrid/TextToSpeech.cpp b/srchybrid/TextToSpeech.cpp index e1447cc2..93f4c3d4 100644 --- a/srchybrid/TextToSpeech.cpp +++ b/srchybrid/TextToSpeech.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/TextToSpeech.h b/srchybrid/TextToSpeech.h index 265d732e..e0ba3348 100644 --- a/srchybrid/TextToSpeech.h +++ b/srchybrid/TextToSpeech.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/TitleMenu.cpp b/srchybrid/TitleMenu.cpp index 676a143d..9cd8602e 100644 --- a/srchybrid/TitleMenu.cpp +++ b/srchybrid/TitleMenu.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "stdafx.h" #include "TitleMenu.h" #include "emule.h" @@ -184,15 +183,16 @@ void CTitleMenu::DrawItem(LPDRAWITEMSTRUCT lpDIS) ::SetBkColor(lpDIS->hDC, crOldBk); } else { - CDC *dc = CDC::FromHandle(lpDIS->hDC); - int posY = lpDIS->rcItem.top + ((lpDIS->rcItem.bottom - lpDIS->rcItem.top) - ICONSIZE) / 2; int nIconPos; - if (m_mapMenuIdToIconIdx.Lookup(lpDIS->itemID, nIconPos)) + if (m_mapMenuIdToIconIdx.Lookup(lpDIS->itemID, nIconPos)) { + int posY = lpDIS->rcItem.top + ((lpDIS->rcItem.bottom - lpDIS->rcItem.top) - ICONSIZE) / 2; + CDC *dc = CDC::FromHandle(lpDIS->hDC); if ((lpDIS->itemState & ODS_GRAYED) != 0) DrawMonoIcon(nIconPos, CPoint(lpDIS->rcItem.left, posY), dc); else // Draw the bitmap on the menu. m_ImageList.Draw(dc, nIconPos, CPoint(lpDIS->rcItem.left, posY), ILD_TRANSPARENT); + } } } diff --git a/srchybrid/ToolBarCtrlX.cpp b/srchybrid/ToolBarCtrlX.cpp index 882163ec..fa93c3fa 100644 --- a/srchybrid/ToolBarCtrlX.cpp +++ b/srchybrid/ToolBarCtrlX.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ToolBarCtrlX.h b/srchybrid/ToolBarCtrlX.h index 827b653e..5713ac27 100644 --- a/srchybrid/ToolBarCtrlX.h +++ b/srchybrid/ToolBarCtrlX.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ToolTipCtrlX.cpp b/srchybrid/ToolTipCtrlX.cpp index 82553d05..7dc4f359 100644 --- a/srchybrid/ToolTipCtrlX.cpp +++ b/srchybrid/ToolTipCtrlX.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ToolTipCtrlX.h b/srchybrid/ToolTipCtrlX.h index 06cb5f4b..26210771 100644 --- a/srchybrid/ToolTipCtrlX.h +++ b/srchybrid/ToolTipCtrlX.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/ToolbarWnd.cpp b/srchybrid/ToolbarWnd.cpp index c0712940..c618460f 100644 --- a/srchybrid/ToolbarWnd.cpp +++ b/srchybrid/ToolbarWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "stdafx.h" #include "emule.h" #include "emuledlg.h" @@ -482,7 +481,7 @@ void CToolbarWnd::DelayShow(BOOL bShow) void CToolbarWnd::OnSysCommand(UINT nID, LPARAM lParam) { - if (nID != SC_KEYMENU) + if ((nID & 0xFFF0) != SC_KEYMENU) __super::OnSysCommand(nID, lParam); else if (lParam == EMULE_HOTMENU_ACCEL) theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); diff --git a/srchybrid/ToolbarWnd.h b/srchybrid/ToolbarWnd.h index 1bf0150b..4cc8e1d2 100644 --- a/srchybrid/ToolbarWnd.h +++ b/srchybrid/ToolbarWnd.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "ToolBarCtrlX.h" diff --git a/srchybrid/TransferDlg.cpp b/srchybrid/TransferDlg.cpp index e9ff75c6..778418b5 100644 --- a/srchybrid/TransferDlg.cpp +++ b/srchybrid/TransferDlg.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "stdafx.h" #include "emule.h" #include "emuleDlg.h" @@ -49,7 +48,7 @@ CTransferDlg::CTransferDlg() { } -BOOL CTransferDlg::Create(CWnd *pParent) +BOOL CTransferDlg::CreateWnd(CWnd *pParent) { // *) The initial size of that frame window must not exceed the window size of the // dialog resource template of the client window (the search results window). @@ -70,6 +69,10 @@ int CTransferDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) context.m_pCurrentDoc = NULL; context.m_pNewViewClass = RUNTIME_CLASS(CTransferWnd); context.m_pNewDocTemplate = NULL; +#ifdef _DEBUG + CFrameDoc dummy; + context.m_pCurrentDoc = &dummy; +#endif m_pwndTransfer = static_cast(CreateView(&context)); m_pwndTransfer->ModifyStyle(WS_BORDER, 0); m_pwndTransfer->ModifyStyleEx(WS_EX_CLIENTEDGE, WS_EX_STATICEDGE); @@ -134,14 +137,13 @@ void CTransferDlg::Localize() void CTransferDlg::OnSysCommand(UINT nID, LPARAM lParam) { - if (nID == SC_KEYMENU) { - if (lParam == EMULE_HOTMENU_ACCEL) - theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); - else - theApp.emuledlg->SendMessage(WM_SYSCOMMAND, nID, lParam); - return; - } - CFrameWnd::OnSysCommand(nID, lParam); + if ((nID & 0xFFF0) != SC_KEYMENU) + CFrameWnd::OnSysCommand(nID, lParam); + else if (lParam == EMULE_HOTMENU_ACCEL) + theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); + else + theApp.emuledlg->SendMessage(WM_SYSCOMMAND, nID, lParam); + } BOOL CTransferDlg::PreTranslateMessage(MSG *pMsg) diff --git a/srchybrid/TransferDlg.h b/srchybrid/TransferDlg.h index e7ad9317..4f5eeb7b 100644 --- a/srchybrid/TransferDlg.h +++ b/srchybrid/TransferDlg.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "UploadListCtrl.h" #include "DownloadListCtrl.h" @@ -32,7 +31,7 @@ class CTransferDlg : public CFrameWnd CTransferDlg(); // protected constructor used by dynamic creation CTransferWnd *m_pwndTransfer; - BOOL Create(CWnd *pParent); + BOOL CreateWnd(CWnd *pParent); //Wrappers void Localize(); diff --git a/srchybrid/TransferWnd.cpp b/srchybrid/TransferWnd.cpp index ee3c36a2..07d26bc4 100644 --- a/srchybrid/TransferWnd.cpp +++ b/srchybrid/TransferWnd.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -16,6 +16,7 @@ //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "stdafx.h" #include "emule.h" +#include "emuledlg.h" #include "SearchDlg.h" #include "TransferWnd.h" #include "TransferDlg.h" @@ -23,7 +24,6 @@ #include "ClientList.h" #include "UploadQueue.h" #include "DownloadQueue.h" -#include "emuledlg.h" #include "MenuCmds.h" #include "PartFile.h" #include "CatDialog.h" @@ -84,7 +84,6 @@ END_MESSAGE_MAP() CTransferWnd::CTransferWnd(CWnd* /*pParent =NULL*/) : CResizableFormView(CTransferWnd::IDD) - //, m_pImageList(&CTransferWnd::m_ImageList) , m_pLastMousePoint(POINT{ -1, -1 }) , m_uWnd2(wnd2Uploading) , m_pDragImage() @@ -98,7 +97,6 @@ CTransferWnd::CTransferWnd(CWnd* /*pParent =NULL*/) , downloadlistactive() , m_bLayoutInited() { - //SetImageList(); } CTransferWnd::~CTransferWnd() @@ -1499,7 +1497,7 @@ void CTransferWnd::ShowSplitWindow(bool bReDraw) rcSpl.top = splitpos + WND_SPLITTER_YOFF; rcSpl.bottom = rcSpl.top + WND_SPLITTER_HEIGHT; if (!m_wndSplitter) { - m_wndSplitter.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER); + m_wndSplitter.CreateWnd(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER); m_wndSplitter.SetDrawBorder(true); } else m_wndSplitter.MoveWindow(&rcSpl, TRUE); @@ -1834,11 +1832,10 @@ void CTransferWnd::OnPaint() void CTransferWnd::OnSysCommand(UINT nID, LPARAM lParam) { - if (nID == SC_KEYMENU) { - if (lParam == EMULE_HOTMENU_ACCEL) - theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); - else - theApp.emuledlg->SendMessage(WM_SYSCOMMAND, nID, lParam); - } else + if ((nID & 0xFFF0) != SC_KEYMENU) __super::OnSysCommand(nID, lParam); + else if (lParam == EMULE_HOTMENU_ACCEL) + theApp.emuledlg->SendMessage(WM_COMMAND, IDC_HOTMENU); + else + theApp.emuledlg->SendMessage(WM_SYSCOMMAND, nID, lParam); } \ No newline at end of file diff --git a/srchybrid/TransferWnd.h b/srchybrid/TransferWnd.h index d5cc1436..38a44fd1 100644 --- a/srchybrid/TransferWnd.h +++ b/srchybrid/TransferWnd.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( devs@emule-project.net / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( devs@emule-project.net / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/TrayDialog.cpp b/srchybrid/TrayDialog.cpp index 0d73a891..15254bf3 100644 --- a/srchybrid/TrayDialog.cpp +++ b/srchybrid/TrayDialog.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -254,7 +254,7 @@ void CTrayDialog::OnTimer(UINT_PTR nIDEvent) void CTrayDialog::OnSysCommand(UINT nID, LPARAM lParam) { - if (m_pbMinimizeToTray != NULL && *m_pbMinimizeToTray) { + if (m_pbMinimizeToTray && *m_pbMinimizeToTray) { if ((nID & 0xFFF0) == SC_MINIMIZE) { if (TrayShow()) ShowWindow(SW_HIDE); diff --git a/srchybrid/TreeOptionsCtrl.h b/srchybrid/TreeOptionsCtrl.h index 5efccbf2..28af5641 100644 --- a/srchybrid/TreeOptionsCtrl.h +++ b/srchybrid/TreeOptionsCtrl.h @@ -218,7 +218,7 @@ class CTreeOptionsBrowseButton : public CButton virtual DWORD GetWindowStyle(); virtual int GetWidth(); virtual CString GetCaption(); - COLORREF GetColor() const { return m_Color; }; + COLORREF GetColor() const { return m_Color; } void SetColor(COLORREF color); void GetFontItem(LOGFONT *pLogFont); void SetFontItem(const LOGFONT *pLogFont); @@ -353,11 +353,11 @@ class CTreeOptionsIPAddressCtrl : public CIPAddressCtrl protected: //Misc methods - void SetTreeBuddy(CTreeOptionsCtrl *pTreeCtrl) { m_pTreeCtrl = pTreeCtrl; }; - void SetTreeItem(HTREEITEM hItem) { m_hTreeCtrlItem = hItem; }; + void SetTreeBuddy(CTreeOptionsCtrl *pTreeCtrl) { m_pTreeCtrl = pTreeCtrl; } + void SetTreeItem(HTREEITEM hItem) { m_hTreeCtrlItem = hItem; } virtual DWORD GetWindowStyle(); - DWORD GetIPAddress() const { return m_dwAddress; }; - void SetIPAddress(DWORD dwAddress) { m_dwAddress = dwAddress; }; + DWORD GetIPAddress() const { return m_dwAddress; } + void SetIPAddress(DWORD dwAddress) { m_dwAddress = dwAddress; } virtual BOOL IsRelatedWnd(CWnd *pChild); //{{AFX_VIRTUAL(CTreeOptionsIPAddressCtrl) @@ -450,16 +450,16 @@ class CTreeOptionsCtrl : public CTreeCtrl virtual ~CTreeOptionsCtrl(); //Misc - void SetAutoSelect(BOOL bAutoSelect) { m_bAutoSelect = bAutoSelect; }; - BOOL GetAutoSelect() const { return m_bAutoSelect; }; - void SetImageListResourceIDToUse(UINT nResourceID) { m_nilID = nResourceID; }; - UINT GetImageListResourceIDToUse() const { return m_nilID; }; - void SetToggleOverIconOnly(BOOL bToggle) { m_bToggleOverIconOnly = bToggle; }; - BOOL GetToggleOverIconOnly() const { return m_bToggleOverIconOnly; }; + void SetAutoSelect(BOOL bAutoSelect) { m_bAutoSelect = bAutoSelect; } + BOOL GetAutoSelect() const { return m_bAutoSelect; } + void SetImageListResourceIDToUse(UINT nResourceID) { m_nilID = nResourceID; } + UINT GetImageListResourceIDToUse() const { return m_nilID; } + void SetToggleOverIconOnly(BOOL bToggle) { m_bToggleOverIconOnly = bToggle; } + BOOL GetToggleOverIconOnly() const { return m_bToggleOverIconOnly; } DWORD GetUserItemData(HTREEITEM hItem) const; BOOL SetUserItemData(HTREEITEM hItem, DWORD dwData); - void SetTextSeparator(const CString &sSeparator) { m_sSeparator = sSeparator; }; - const CString& GetTextSeparator() const { return m_sSeparator; }; + void SetTextSeparator(const CString &sSeparator) { m_sSeparator = sSeparator; } + const CString& GetTextSeparator() const { return m_sSeparator; } void Clear(); virtual BOOL DeleteAllItems(); diff --git a/srchybrid/TreeOptionsCtrlEx.cpp b/srchybrid/TreeOptionsCtrlEx.cpp index b041ec3a..0cdc92a7 100644 --- a/srchybrid/TreeOptionsCtrlEx.cpp +++ b/srchybrid/TreeOptionsCtrlEx.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/TreePropSheet.cpp b/srchybrid/TreePropSheet.cpp index 631f9b82..c213454b 100644 --- a/srchybrid/TreePropSheet.cpp +++ b/srchybrid/TreePropSheet.cpp @@ -286,7 +286,6 @@ void CTreePropSheet::RefillPageTree() ti.pszText = strPagePath.GetBuffer(ti.cchTextMax); pTabCtrl->GetItem(nPage, &ti); - ti.pszText[ti.cchTextMax - 1] = _T('\0'); strPagePath.ReleaseBuffer(); // Create an item in the tree for the page diff --git a/srchybrid/TreePropSheet.h b/srchybrid/TreePropSheet.h index 8b145e67..70b1df9e 100644 --- a/srchybrid/TreePropSheet.h +++ b/srchybrid/TreePropSheet.h @@ -182,7 +182,7 @@ class /*AFX_EXT_CLASS*/ CTreePropSheet : public CPropertySheet Returns a pointer to the tree control, when the sheet is in tree view mode, NULL otherwise. */ - CTreeCtrl *GetPageTreeControl() { return m_pwndPageTree; }; + CTreeCtrl* GetPageTreeControl() { return m_pwndPageTree; } // Public helpers public: diff --git a/srchybrid/UDPSocket.cpp b/srchybrid/UDPSocket.cpp index 1d9e2370..f87749d6 100644 --- a/srchybrid/UDPSocket.cpp +++ b/srchybrid/UDPSocket.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -130,7 +130,7 @@ CUDPSocket::~CUDPSocket() bool CUDPSocket::Create() { if (thePrefs.GetServerUDPPort()) { - VERIFY(m_udpwnd.CreateEx(0, AfxRegisterWndClass(0), _T("eMule Async DNS Resolve Socket Wnd #1"), WS_OVERLAPPED, 0, 0, 0, 0, HWND_MESSAGE, NULL)); + VERIFY(m_udpwnd.CreateEx(0, AfxRegisterWndClass(0), _T("eMule Async DNS Resolver Socket #1"), 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, 0)); m_hWndResolveMessage = m_udpwnd.m_hWnd; m_udpwnd.m_pOwner = this; if (CAsyncSocket::Create(thePrefs.GetServerUDPPort() == _UI16_MAX ? 0 : thePrefs.GetServerUDPPort(), SOCK_DGRAM, FD_READ | FD_WRITE, thePrefs.GetBindAddrW())) @@ -157,7 +157,7 @@ void CUDPSocket::OnReceive(int nErrorCode) if (length != SOCKET_ERROR) { int nPayLoadLen = length; CServer *pServer = theApp.serverlist->GetServerByIPUDP(sockAddr.sin_addr.s_addr, ntohs(sockAddr.sin_port), true); - if (pServer != NULL && thePrefs.IsServerCryptLayerUDPEnabled() + if (pServer != NULL && thePrefs.IsCryptLayerEnabled() && ((pServer->GetServerKeyUDP() != 0 && pServer->SupportsObfuscationUDP()) || (pServer->GetCryptPingReplyPending() && pServer->GetChallenge() != 0))) { // TODO @@ -166,8 +166,8 @@ void CUDPSocket::OnReceive(int nErrorCode) dwKey = pServer->GetChallenge(); else dwKey = pServer->GetServerKeyUDP(); - ASSERT(dwKey); + nPayLoadLen = DecryptReceivedServer(buffer, length, &pBuffer, dwKey, sockAddr); if (nPayLoadLen == length) DebugLogWarning(_T("Expected encrypted packet, but received unencrypted from server %s, UDPKey %u, Challenge: %u"), (LPCTSTR)pServer->GetListName(), pServer->GetServerKeyUDP(), pServer->GetChallenge()); @@ -390,6 +390,11 @@ bool CUDPSocket::ProcessPacket(const BYTE *packet, UINT size, UINT opcode, uint3 nUDPObfuscationPort = nTCPObfuscationPort = 0; dwServerUDPKey = 0; } + //Apply default port numbers if short packet had no port data + if (!nTCPObfuscationPort && (uUDPFlags & SRV_UDPFLG_TCPOBFUSCATION)) + nTCPObfuscationPort = pServer->GetPort(); + if (!nUDPObfuscationPort && (uUDPFlags & SRV_UDPFLG_UDPOBFUSCATION)) + nUDPObfuscationPort = pServer->GetPort() + 12; pServer->SetPing(::GetTickCount() - pServer->GetLastPinged()); pServer->SetUserCount(cur_user); @@ -482,7 +487,7 @@ bool CUDPSocket::ProcessPacket(const BYTE *packet, UINT size, UINT opcode, uint3 } else { // A server sent us a new server description packet (including a challenge) although we did not // ask for it. This may happen, if there are multiple servers running on the same machine with - // multiple IPs. If such a server is asked for a description, the server will answer 2 times, + // multiple IPs. If such server is asked for a description, the server will answer 2 times, // but with the same IP. if (thePrefs.GetDebugServerUDPLevel() > 0) @@ -513,27 +518,21 @@ bool CUDPSocket::ProcessPacket(const BYTE *packet, UINT size, UINT opcode, uint3 return false; } return true; - } catch (CFileException *error) { - TCHAR szError[MAX_CFEXP_ERRORMSG]; - error->m_strFileName = _T("server UDP packet"); - if (!GetExceptionMessage(*error, szError, _countof(szError))) - szError[0] = _T('\0'); - ProcessPacketError(size, opcode, nIP, nUDPPort, szError); - error->Delete(); + } catch (CFileException *ex) { + ex->m_strFileName = _T("server UDP packet"); + ProcessPacketError(size, opcode, nIP, nUDPPort, CExceptionStr(*ex)); + ex->Delete(); //ASSERT(0); if (opcode == OP_GLOBSEARCHRES || opcode == OP_GLOBFOUNDSOURCES) return true; - } catch (CMemoryException *error) { - TCHAR szError[MAX_CFEXP_ERRORMSG]; - if (!GetExceptionMessage(*error, szError, _countof(szError))) - szError[0] = _T('\0'); - ProcessPacketError(size, opcode, nIP, nUDPPort, szError); - error->Delete(); + } catch (CMemoryException *ex) { + ProcessPacketError(size, opcode, nIP, nUDPPort, (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); //ASSERT(0); if (opcode == OP_GLOBSEARCHRES || opcode == OP_GLOBFOUNDSOURCES) return true; - } catch (const CString &error) { - ProcessPacketError(size, opcode, nIP, nUDPPort, error); + } catch (const CString &ex) { + ProcessPacketError(size, opcode, nIP, nUDPPort, ex); //ASSERT(0); #ifndef _DEBUG } catch (...) { @@ -748,7 +747,7 @@ void CUDPSocket::SendPacket(Packet *packet, CServer *pServer, uint16 nSpecialPor uint16 nPort = nSpecialPort; if (packet != NULL) { uRawPacketSize = packet->size + 2; - size_t iLen = thePrefs.IsServerCryptLayerUDPEnabled() && pServer->GetServerKeyUDP() && pServer->SupportsObfuscationUDP() + size_t iLen = thePrefs.IsCryptLayerEnabled() && pServer->GetServerKeyUDP() && pServer->SupportsObfuscationUDP() ? EncryptOverheadSize(false) : 0; pRawPacket = new BYTE[uRawPacketSize + iLen]; memcpy(pRawPacket + iLen, packet->GetUDPHeader(), 2); diff --git a/srchybrid/UDPSocket.h b/srchybrid/UDPSocket.h index 5654b575..d887aae2 100644 --- a/srchybrid/UDPSocket.h +++ b/srchybrid/UDPSocket.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/UPnPImpl.cpp b/srchybrid/UPnPImpl.cpp index 0f3527e6..12ff5f04 100644 --- a/srchybrid/UPnPImpl.cpp +++ b/srchybrid/UPnPImpl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "UPnPImpl.h" @@ -25,7 +24,9 @@ static char THIS_FILE[] = __FILE__; #endif CUPnPImpl::CUPnPImpl() - : m_bUPnPPortsForwarded(TRIS_FALSE) + : m_wndResultMessage() + , m_nResultMessageID() + , m_bUPnPPortsForwarded(TRIS_FALSE) , m_nOldTCPPort() , m_nOldTCPWebPort() , m_nOldUDPPort() @@ -33,8 +34,6 @@ CUPnPImpl::CUPnPImpl() , m_nTCPWebPort() , m_nUDPPort() , m_bCheckAndRefresh() - , m_wndResultMessage() - , m_nResultMessageID() { } diff --git a/srchybrid/UPnPImpl.h b/srchybrid/UPnPImpl.h index 3bfd8dd9..62a39226 100644 --- a/srchybrid/UPnPImpl.h +++ b/srchybrid/UPnPImpl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include @@ -35,6 +34,9 @@ enum UPNP_IMPLEMENTATION class CUPnPImpl { + CWnd* m_wndResultMessage; + UINT m_nResultMessageID; + public: CUPnPImpl(); virtual ~CUPnPImpl() = default; @@ -56,22 +58,10 @@ class CUPnPImpl void LateEnableWebServerPort(uint16 nPort); // Add Web Server port to already existing port mapping void SetMessageOnResult(CWnd *cwnd, UINT nMessageID); - TRISTATE ArePortsForwarded() const - { - return m_bUPnPPortsForwarded; - } - uint16 GetUsedTCPPort() const - { - return m_nTCPPort; - } - uint16 GetUsedUDPPort() const - { - return m_nUDPPort; - } - uint16 GetUsedTCPWebPort() const - { - return m_nTCPWebPort; - } + TRISTATE ArePortsForwarded() const { return m_bUPnPPortsForwarded; } + uint16 GetUsedTCPPort() const { return m_nTCPPort; } + uint16 GetUsedUDPPort() const { return m_nUDPPort; } + uint16 GetUsedTCPWebPort() const { return m_nTCPWebPort; } // Implementation protected: @@ -84,41 +74,16 @@ class CUPnPImpl uint16 m_nTCPWebPort; uint16 m_nUDPPort; bool m_bCheckAndRefresh; - -private: - CWnd *m_wndResultMessage; - UINT m_nResultMessageID; }; // Dummy Implementation to be used when no other implementation is available class CUPnPImplNone : public CUPnPImpl { public: - virtual void StartDiscovery(uint16, uint16, uint16) - { - ASSERT(0); - } - - virtual bool CheckAndRefresh() - { - return false; - } - - virtual void StopAsyncFind() - { - } - - virtual void DeletePorts() - { - } - - virtual bool IsReady() - { - return false; - } - - virtual int GetImplementationID() - { - return UPNP_IMPL_NONE; - } + virtual void StartDiscovery(uint16, uint16, uint16) { ASSERT(0); } + virtual bool CheckAndRefresh() { return false; } + virtual void StopAsyncFind() {} + virtual void DeletePorts() {} + virtual bool IsReady() { return false; } + virtual int GetImplementationID() { return UPNP_IMPL_NONE; } }; \ No newline at end of file diff --git a/srchybrid/UPnPImplMiniLib.cpp b/srchybrid/UPnPImplMiniLib.cpp index 700200ae..054f870f 100644 --- a/srchybrid/UPnPImplMiniLib.cpp +++ b/srchybrid/UPnPImplMiniLib.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "emule.h" #include "preferences.h" @@ -41,16 +40,17 @@ static LPCTSTR const sTCP = _T("TCP"); static LPCTSTR const sUDP = _T("UDP"); CUPnPImplMiniLib::CUPnPImplMiniLib() - : m_bSucceededOnce() - , m_pURLs() + : m_pURLs() , m_pIGDData() , m_hThreadHandle() + , m_bSucceededOnce() , m_bAbortDiscovery() { m_nOldUDPPort = 0; m_nOldTCPPort = 0; m_nOldTCPWebPort = 0; m_achLanIP[0] = 0; + m_achWanIP[0] = 0; } CUPnPImplMiniLib::~CUPnPImplMiniLib() @@ -147,7 +147,7 @@ void CUPnPImplMiniLib::DeletePorts(bool bSkipLock) void CUPnPImplMiniLib::StartDiscovery(uint16 nTCPPort, uint16 nUDPPort, uint16 nTCPWebPort) { DebugLog(_T("Using MiniUPnPLib based implementation")); - DebugLog(_T("miniupnpc (c) 2005-2023 Thomas Bernard - http://miniupnp.free.fr/")); + DebugLog(_T("miniupnpc (c) 2005-2024 Thomas Bernard - http://miniupnp.free.fr/")); GetOldPorts(); m_nUDPPort = nUDPPort; m_nTCPPort = nTCPPort; @@ -240,9 +240,11 @@ int CUPnPImplMiniLib::CStartDiscoveryThread::Run() m_pOwner->m_pURLs = new UPNPUrls(); m_pOwner->m_pIGDData = new IGDdatas(); - - m_pOwner->m_achLanIP[0] = 0; - int iResult = UPNP_GetValidIGD(structDeviceList, m_pOwner->m_pURLs, m_pOwner->m_pIGDData, m_pOwner->m_achLanIP, sizeof m_pOwner->m_achLanIP); + *m_pOwner->m_achLanIP = 0; + *m_pOwner->m_achWanIP = 0; + int iResult = UPNP_GetValidIGD(structDeviceList, m_pOwner->m_pURLs, m_pOwner->m_pIGDData + , m_pOwner->m_achLanIP, sizeof m_pOwner->m_achLanIP + , m_pOwner->m_achWanIP, sizeof m_pOwner->m_achWanIP); freeUPNPDevlist(structDeviceList); bool bNotFound = false; switch (iResult) { @@ -250,13 +252,17 @@ int CUPnPImplMiniLib::CStartDiscoveryThread::Run() DebugLog(_T("Found valid IGD : %S"), m_pOwner->m_pURLs->controlURL); break; case 2: - DebugLog(_T("Found a (not connected?) IGD : %S - Trying to continue anyway"), m_pOwner->m_pURLs->controlURL); + DebugLog(_T("Found an IGD with a reserved IP address (%S) : %S"), m_pOwner->m_achWanIP, m_pOwner->m_pURLs->controlURL); + bNotFound = true; break; case 3: - DebugLog(_T("UPnP device found. Is it an IGD ? : %S - Trying to continue anyway"), m_pOwner->m_pURLs->controlURL); + DebugLog(_T("Found a (not connected?) IGD : %S - Trying to continue anyway"), m_pOwner->m_pURLs->controlURL); + break; + case 4: + DebugLog(_T("UPnP device found. Is it an IGD? : %S - Trying to continue anyway"), m_pOwner->m_pURLs->controlURL); break; default: - DebugLog(_T("Found device (igd ?) : %S - Aborting"), m_pOwner->m_pURLs->controlURL != NULL ? m_pOwner->m_pURLs->controlURL : "(none)"); + DebugLog(_T("Found device (IGD?) : %S - Aborting"), m_pOwner->m_pURLs->controlURL != NULL ? m_pOwner->m_pURLs->controlURL : "(none)"); bNotFound = true; } if (bNotFound || m_pOwner->m_pURLs->controlURL == NULL) { @@ -282,12 +288,11 @@ int CUPnPImplMiniLib::CStartDiscoveryThread::Run() if (m_pOwner->m_nTCPWebPort) OpenPort(m_pOwner->m_nTCPWebPort, true, m_pOwner->m_achLanIP, m_pOwner->m_bCheckAndRefresh); // don't fail if only the Web Interface port fails for some reason } - } #if !(defined(_DEBUG) || defined(_BETA) || defined(_DEVBUILD)) - catch (...) { + } catch (...) { DebugLogError(_T("Unknown Exception in CUPnPImplMiniLib::CStartDiscoveryThread::Run()")); - } #endif + } if (!m_pOwner->m_bAbortDiscovery) { // don't send the result on an abort request if (bSucceeded) { m_pOwner->m_bUPnPPortsForwarded = TRIS_TRUE; diff --git a/srchybrid/UPnPImplMiniLib.h b/srchybrid/UPnPImplMiniLib.h index 2eaef385..ad28a6f0 100644 --- a/srchybrid/UPnPImplMiniLib.h +++ b/srchybrid/UPnPImplMiniLib.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -57,13 +57,15 @@ class CUPnPImplMiniLib : public CUPnPImpl void DeletePort(uint16 port, LPCTSTR prot); void GetOldPorts(); void StartThread(); - bool m_bSucceededOnce; - char m_achLanIP[16]; + + static CMutex m_mutBusy; UPNPUrls *m_pURLs; IGDdatas *m_pIGDData; HANDLE m_hThreadHandle; + char m_achLanIP[40]; + char m_achWanIP[40]; - static CMutex m_mutBusy; + bool m_bSucceededOnce; volatile bool m_bAbortDiscovery; }; \ No newline at end of file diff --git a/srchybrid/UPnPImplWinServ.cpp b/srchybrid/UPnPImplWinServ.cpp index f1efb24f..ecc2b633 100644 --- a/srchybrid/UPnPImplWinServ.cpp +++ b/srchybrid/UPnPImplWinServ.cpp @@ -5,7 +5,7 @@ // This file is part of SHAREAZA (www.shareaza.com) // // this file is part of eMule -// Copyright (C)2007-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +// Copyright (C)2007-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -20,7 +20,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "emule.h" #include "preferences.h" diff --git a/srchybrid/UPnPImplWinServ.h b/srchybrid/UPnPImplWinServ.h index cab9d31d..cad1f6f9 100644 --- a/srchybrid/UPnPImplWinServ.h +++ b/srchybrid/UPnPImplWinServ.h @@ -5,7 +5,7 @@ // This file is part of SHAREAZA (www.shareaza.com) // // this file is part of eMule -// Copyright (C)2007-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +// Copyright (C)2007-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -20,7 +20,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "UPnPImpl.h" diff --git a/srchybrid/UPnPImplWrapper.cpp b/srchybrid/UPnPImplWrapper.cpp index 238189a3..fdc64c92 100644 --- a/srchybrid/UPnPImplWrapper.cpp +++ b/srchybrid/UPnPImplWrapper.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "UPnPImplWrapper.h" #include "UPnPImpl.h" diff --git a/srchybrid/UPnPImplWrapper.h b/srchybrid/UPnPImplWrapper.h index 8b176422..8c806f29 100644 --- a/srchybrid/UPnPImplWrapper.h +++ b/srchybrid/UPnPImplWrapper.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once class CUPnPImpl; diff --git a/srchybrid/URLClient.cpp b/srchybrid/URLClient.cpp index 82d7ce06..aa7a1a54 100644 --- a/srchybrid/URLClient.cpp +++ b/srchybrid/URLClient.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -93,16 +93,15 @@ bool CUrlClient::SetUrl(LPCTSTR pszUrl, uint32 nIP) if (!::InternetCrackUrl(szUrl, 0, 0, &Url)) return false; - if (Url.dwSchemeLength == 0 || Url.nScheme != INTERNET_SCHEME_HTTP) // we only support "http://" - return false; - if (Url.dwHostNameLength == 0) // we must know the hostname - return false; - if (Url.dwUserNameLength != 0) // no support for user/password - return false; - if (Url.dwPasswordLength != 0) // no support for user/password - return false; - if (Url.dwUrlPathLength == 0) // we must know the URL path on that host + if (Url.dwSchemeLength == 0 // non-empty URL + || Url.nScheme != INTERNET_SCHEME_HTTP // we only support "http://" + || Url.dwHostNameLength == 0 // we must know the hostname + || Url.dwUserNameLength > 0 // no support for user/password + || Url.dwPasswordLength > 0 // no support for user/password + || Url.dwUrlPathLength == 0) // we must know the URL path on that host + { return false; + } m_strHostA = szHostName; @@ -266,7 +265,7 @@ bool CUrlClient::ProcessHttpDownResponse(const CStringAArray &astrHeaders) bool bNewLocation = false; bool bValidContentRange = false; - for (int i = 1; i < astrHeaders.GetCount(); ++i) { + for (INT_PTR i = 1; i < astrHeaders.GetCount(); ++i) { const CStringA &rstrHdr1 = astrHeaders[i]; if (bExpectData && _strnicmp(rstrHdr1, "Content-Length:", 15) == 0) { uint64 uContentLength = _atoi64((LPCSTR)rstrHdr1 + 15); @@ -381,8 +380,7 @@ void CUpDownClient::ProcessHttpBlockPacket(const BYTE *pucData, UINT uSize) if (cur_block->block->StartOffset <= nStartPos && nStartPos <= cur_block->block->EndOffset) { if (thePrefs.GetDebugClientTCPLevel() > 0) { // NOTE: 'Left' is only accurate in case we have one(!) request block! - void *s = m_pPCDownSocket ? (void*)m_pPCDownSocket : (void*)socket; - Debug(_T("%p Start=%I64u End=%I64u Size=%u Left=%I64u %s\n"), s, nStartPos, nEndPos, uSize, cur_block->block->EndOffset - (nStartPos + uSize) + 1, (LPCTSTR)DbgGetFileInfo(m_reqfile->GetFileHash())); + Debug(_T("%p Start=%I64u End=%I64u Size=%u Left=%I64u %s\n"), (void*)socket, nStartPos, nEndPos, uSize, cur_block->block->EndOffset - (nStartPos + uSize) + 1, (LPCTSTR)DbgGetFileInfo(m_reqfile->GetFileHash())); } m_nLastBlockOffset = nStartPos; @@ -401,7 +399,7 @@ void CUpDownClient::ProcessHttpBlockPacket(const BYTE *pucData, UINT uSize) if (thePrefs.GetDebugClientTCPLevel() > 0) DebugSend("More block requests", this); m_nUrlStartPos = _UI64_MAX; - SendHttpBlockRequests(); + static_cast(this)->SendHttpBlockRequests(); } } // else diff --git a/srchybrid/URLClient.h b/srchybrid/URLClient.h index 6bd1dd03..c9830b97 100644 --- a/srchybrid/URLClient.h +++ b/srchybrid/URLClient.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/UpdownClient.h b/srchybrid/UpdownClient.h index 1a6afc86..bedc710d 100644 --- a/srchybrid/UpdownClient.h +++ b/srchybrid/UpdownClient.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -21,8 +21,6 @@ #include "OtherFunctions.h" class CClientReqSocket; -class CPeerCacheDownSocket; -class CPeerCacheUpSocket; class CFriend; class CPartFile; class CClientCredits; @@ -129,7 +127,7 @@ class CUpDownClient : public CObject bool ExtProtocolAvailable() const { return m_bEmuleProtocol; } bool SupportMultiPacket() const { return m_bMultiPacket; } bool SupportExtMultiPacket() const { return m_fExtMultiPacket; } - bool SupportPeerCache() const { return m_fPeerCache; } + bool SupportPeerCache() const { return m_fPeerCache; } //false bool SupportsLargeFiles() const { return m_fSupportsLargeFiles; } bool SupportsFileIdentifiers() const { return m_fSupportsFileIdent; } bool IsEmuleClient() const { return m_byEmuleVersion != 0; } @@ -229,7 +227,7 @@ class CUpDownClient : public CObject void ClearWaitStartTime(); DWORD GetWaitTime() const { return m_dwUploadTime - GetWaitStartTime(); } bool IsDownloading() const { return (m_eUploadState == US_UPLOADING); } - UINT GetUploadDatarate() const { return m_nUpDatarate; } + UINT GetUploadDatarate() const { return m_nUpDatarate; } UINT GetScore(bool sysvalue, bool isdownloading = false, bool onlybasevalue = false) const; void AddReqBlock(Requested_Block_Struct *reqblock, bool bSignalIOThread); DWORD GetUpStartTime() const { return m_dwUploadTime; } @@ -268,7 +266,7 @@ class CUpDownClient : public CObject uint64 GetPayloadInBuffer() const { return m_addedPayloadQueueSession - m_nCurQueueSessionPayloadUp; } void SetQueueSessionUploadAdded(uint64 uVal) { m_addedPayloadQueueSession = uVal; } - bool ProcessExtendedInfo(CSafeMemFile *data, CKnownFile *tempreqfile); + bool ProcessExtendedInfo(CSafeMemFile &data, CKnownFile *tempreqfile); uint16 GetUpPartCount() const { return m_nUpPartCount; } void DrawUpStatusBar(CDC *dc, const CRect &rect, bool onlygreyrect, bool bFlat) const; bool IsUpPartAvailable(UINT uPart) const { return (m_abyUpPartStatus && uPart < m_nUpPartCount && m_abyUpPartStatus[uPart]); } @@ -297,14 +295,14 @@ class CUpDownClient : public CObject bool AskForDownload(); virtual void SendFileRequest(); void SendStartupLoadReq(); - void ProcessFileInfo(CSafeMemFile *data, CPartFile *file); - void ProcessFileStatus(bool bUdpPacket, CSafeMemFile *data, CPartFile *file); + void ProcessFileInfo(CSafeMemFile &data, CPartFile *file); + void ProcessFileStatus(bool bUdpPacket, CSafeMemFile &data, CPartFile *file); void ProcessHashSet(const uchar *packet, uint32 size, bool bFileIdentifiers); void ProcessAcceptUpload(); bool AddRequestForAnotherFile(CPartFile *file); void CreateBlockRequests(int blockCount); virtual void SendBlockRequests(); - virtual bool SendHttpBlockRequests(); + virtual bool SendHttpBlockRequests() { return false; } virtual void ProcessBlockPacket(const uchar *packet, uint32 size, bool packed, bool bI64Offsets); virtual void ProcessHttpBlockPacket(const BYTE *pucData, UINT uSize); void ClearPendingBlockRequest(const Pending_Block_Struct *pending); @@ -322,7 +320,7 @@ class CUpDownClient : public CObject void UDPReaskFNF(); void UDPReaskForDownload(); bool UDPPacketPending() const { return m_bUDPPending; } - bool IsSourceRequestAllowed() const; + bool IsSourceRequestAllowed() const { return IsSourceRequestAllowed(m_reqfile); } bool IsSourceRequestAllowed(CPartFile *partfile, bool sourceExchangeCheck = false) const; // ZZ:DownloadManager bool IsValidSource() const; @@ -441,45 +439,10 @@ class CUpDownClient : public CObject UINT GetSlotNumber() const { return m_slotNumber; } CEMSocket* GetFileUploadSocket(bool bLog = false); - /////////////////////////////////////////////////////////////////////////// - // PeerCache client - // - bool IsDownloadingFromPeerCache() const; - bool IsUploadingToPeerCache() const; - void SetPeerCacheDownState(EPeerCacheDownState eState); - void SetPeerCacheUpState(EPeerCacheUpState eState); - - int GetHttpSendState() const { return m_iHttpSendState; } - void SetHttpSendState(int iState) { m_iHttpSendState = iState; } - - bool SendPeerCacheFileRequest(); - bool ProcessPeerCacheQuery(const uchar *packet, UINT size); - bool ProcessPeerCacheAnswer(const uchar *packet, UINT size); - bool ProcessPeerCacheAcknowledge(const uchar *packet, UINT size); - void OnPeerCacheDownSocketClosed(int nErrorCode); - bool OnPeerCacheDownSocketTimeout(); - - bool ProcessPeerCacheDownHttpResponse(const CStringAArray &astrHeaders); - bool ProcessPeerCacheDownHttpResponseBody(const BYTE *pucData, UINT uSize); - void ProcessPeerCacheUpHttpResponse(const CStringAArray &astrHeaders); - UINT ProcessPeerCacheUpHttpRequest(const CStringAArray &astrHeaders); - virtual bool ProcessHttpDownResponse(const CStringAArray &astrHeaders); virtual bool ProcessHttpDownResponseBody(const BYTE *pucData, UINT uSize); - CPeerCacheDownSocket *m_pPCDownSocket; - CPeerCacheUpSocket *m_pPCUpSocket; - protected: - int m_iHttpSendState; - uint32 m_uPeerCacheDownloadPushId; - uint32 m_uPeerCacheUploadPushId; - uint32 m_uPeerCacheRemoteIP; - bool m_bPeerCacheDownHit; - bool m_bPeerCacheUpHit; - EPeerCacheDownState m_ePeerCacheDownState; - EPeerCacheUpState m_ePeerCacheUpState; - // base bool ProcessHelloTypePacket(CSafeMemFile &data); void SendHelloTypePacket(CSafeMemFile &data); @@ -524,35 +487,40 @@ class CUpDownClient : public CObject uint8 m_bySupportSecIdent; //--group aligned to int32 uint32 m_dwLastSignatureIP; - CString m_strClientSoftware; - CString m_strModVersion; DWORD m_dwLastSourceRequest; DWORD m_dwLastSourceAnswer; DWORD m_dwLastAskedForSources; uint32 m_uSearchID; int m_iFileListRequested; + + CString m_strClientSoftware; + CString m_strModVersion; CString m_strFileComment; //--group aligned to int32 uint8 m_uFileRating; uint8 m_cMessagesReceived; // count of chatmessages he sent to me uint8 m_cMessagesSent; // count of chatmessages I sent to him - bool m_bMultiPacket; + uint8 m_cCaptchasSent; //--group aligned to int32 - bool m_bUnicodeSupport; - bool m_bBuddyIDValid; uint16 m_nBuddyPort; + bool m_bBuddyIDValid; + bool m_bUnicodeSupport; //--group aligned to int32 - uint8 m_byKadVersion; - uint8 m_cCaptchasSent; - uint32 m_nBuddyIP; DWORD m_dwLastBuddyPingPongTime; uchar m_achBuddyID[MDX_DIGEST_SIZE]; + CString m_strHelloInfo; CString m_strMuleInfo; CString m_strCaptchaChallenge; CString m_strCaptchaPendingMsg; + CTypedPtrList m_WaitingPackets_list; + CList m_DontSwap_list; + + uint8 m_byKadVersion; + bool m_bMultiPacket; + // States EClientSoftware m_clientSoft; EChatState m_eChatstate; @@ -564,14 +532,15 @@ class CUpDownClient : public CObject EChatCaptchaState m_eChatCaptchaState; EConnectingState m_eConnectingState; - CTypedPtrList m_WaitingPackets_list; - CList m_DontSwap_list; - //////////////////////////////////////////////////////////////////////// // Upload // int GetFilePrioAsNumber() const; + bool m_bCollectionUploadSlot; + uint16 m_nUpPartCount; + uint16 m_nUpCompleteSourcesCount; + uint64 m_nTransferredUp; uint64 m_nCurSessionUp; uint64 m_nCurSessionDown; @@ -582,9 +551,6 @@ class CUpDownClient : public CObject UINT m_cAsked; UINT m_slotNumber; uchar requpfileid[MDX_DIGEST_SIZE]; - uint16 m_nUpPartCount; - uint16 m_nUpCompleteSourcesCount; - bool m_bCollectionUploadSlot; typedef struct { @@ -618,28 +584,27 @@ class CUpDownClient : public CObject bool m_bReaskPending; bool m_bUDPPending; bool m_bTransferredDownMini; -// bool m_bHasMatchingAICHHash; - - // Download from URL - CStringA m_strUrlPath; - uint64 m_uReqStart; - uint64 m_uReqEnd; - uint64 m_nUrlStartPos; ////////////////////////////////////////////////////////// // Upload data rate computation // - CList m_AverageUDR_list; UINT m_nUpDatarate; uint64 m_nSumForAvgUpDataRate; + CList m_AverageUDR_list; ////////////////////////////////////////////////////////// // Download data rate computation // + uint64 m_nSumForAvgDownDataRate; CList m_AverageDDR_list; UINT m_nDownDatarate; UINT m_nDownDataRateMS; - uint64 m_nSumForAvgDownDataRate; + + // Download from URL + CStringA m_strUrlPath; + uint64 m_uReqStart; + uint64 m_uReqEnd; + uint64 m_nUrlStartPos; ////////////////////////////////////////////////////////// // GUI helpers @@ -648,10 +613,12 @@ class CUpDownClient : public CObject static CBarShader s_UpStatusBar; CTypedPtrList m_PendingBlocks_list; typedef CMap CFileReaskTimesMap; - CFileReaskTimesMap m_fileReaskTimes; // ZZ:DownloadManager (one re-ask timestamp for each file) - DWORD m_lastRefreshedDLDisplay; - DWORD m_lastRefreshedULDisplay; - DWORD m_random_update_wait; + CFileReaskTimesMap m_fileReaskTimes; // ZZ:DownloadManager (one re-ask timestamp for each file) + DWORD lastSwapForSourceExchangeTick; // ZZ:DownloadManaager + DWORD m_dwLastTriedToConnect; // ZZ:DownloadManager (one re-ask timestamp for each file) + DWORD m_lastRefreshedDLDisplay; + DWORD m_lastRefreshedULDisplay; + DWORD m_random_update_wait; // using bit fields for less important flags, to save some bytes UINT m_fHashsetRequestingMD4 : 1, // we have sent a hashset request to this client in the current connection @@ -682,7 +649,5 @@ class CUpDownClient : public CObject m_fSupportsFileIdent : 1; // 0 bits left UINT m_fHashsetRequestingAICH : 1; // 31 bits left - DWORD lastSwapForSourceExchangeTick; // ZZ:DownloadManaager - DWORD m_dwLastTriedToConnect; // ZZ:DownloadManager (one re-ask timestamp for each file) bool m_bSourceExchangeSwapped; // ZZ:DownloadManager }; \ No newline at end of file diff --git a/srchybrid/UploadBandwidthThrottler.cpp b/srchybrid/UploadBandwidthThrottler.cpp index d8225c13..545a3e1c 100644 --- a/srchybrid/UploadBandwidthThrottler.cpp +++ b/srchybrid/UploadBandwidthThrottler.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -144,7 +144,7 @@ void UploadBandwidthThrottler::AddToStandardList(INT_PTR index, ThrottledFileSoc sendLocker.Unlock(); } // else if (thePrefs.GetVerbose()) -// theApp.AddDebugLogLine(true,"Tried to add NULL socket to UploadBandwidthThrottler Standard list! Prevented."); +// theApp.QueueDebugLogLine(true, " Prevented adding a NULL socket to UploadBandwidthThrottler Standard list!"); } /** @@ -492,7 +492,7 @@ UINT UploadBandwidthThrottler::RunInternal() uint32 minFragSize; uint32 doubleSendSize; if (allowedDataRate < 6 * 1024) - doubleSendSize = minFragSize = 536; // send one packet at a time at very low speeds for a smoother upload + doubleSendSize = minFragSize = 536; // send one packet at a time at very low speeds for smoother upload else { minFragSize = 1300; doubleSendSize = minFragSize * 2; // send two packets at a time so they can share an ACK @@ -500,15 +500,15 @@ UINT UploadBandwidthThrottler::RunInternal() #define TIME_BETWEEN_UPLOAD_LOOPS 1 DWORD sleepTime; - if (allowedDataRate == _UI32_MAX || realBytesToSpend >= 1000 || (allowedDataRate == 0 && nEstiminatedDataRate == 0)) - // we could send at once, but sleep a while to not suck up all CPU + if (allowedDataRate == _UI32_MAX || realBytesToSpend >= 1000 || (allowedDataRate | nEstiminatedDataRate) == 0) + // we could send immediately, but sleep a while to not suck up all CPU sleepTime = TIME_BETWEEN_UPLOAD_LOOPS; else { - if (allowedDataRate == 0) - sleepTime = (DWORD)ceil((doubleSendSize * 1000) / (double)nEstiminatedDataRate); - else - // sleep for just as long as we need to get back to having one byte to send + if (allowedDataRate) + // sleep untill we need to send at least one byte sleepTime = (DWORD)ceil((1000 - realBytesToSpend) / (double)allowedDataRate); + else + sleepTime = (DWORD)ceil((doubleSendSize * SEC2MS(1)) / (double)nEstiminatedDataRate); if (sleepTime < TIME_BETWEEN_UPLOAD_LOOPS) sleepTime = TIME_BETWEEN_UPLOAD_LOOPS; } diff --git a/srchybrid/UploadBandwidthThrottler.h b/srchybrid/UploadBandwidthThrottler.h index e10b55f0..6b733733 100644 --- a/srchybrid/UploadBandwidthThrottler.h +++ b/srchybrid/UploadBandwidthThrottler.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -31,7 +31,7 @@ class UploadBandwidthThrottler : uint64 GetNumberOfSentBytesOverheadSinceLastCallAndReset(); INT_PTR GetHighestNumberOfFullyActivatedSlotsSinceLastCallAndReset(); - INT_PTR GetStandardListSize() { return m_StandardOrder_list.GetCount(); }; + INT_PTR GetStandardListSize() { return m_StandardOrder_list.GetCount(); } void AddToStandardList(INT_PTR index, ThrottledFileSocket *socket); bool RemoveFromStandardList(ThrottledFileSocket *socket); diff --git a/srchybrid/UploadClient.cpp b/srchybrid/UploadClient.cpp index 7bb5330d..9e433ac0 100644 --- a/srchybrid/UploadClient.cpp +++ b/srchybrid/UploadClient.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -29,7 +29,6 @@ #include "PartFile.h" #include "ClientCredits.h" #include "ListenSocket.h" -#include "PeerCacheSocket.h" #include "ServerConnect.h" #include "SafeFile.h" #include "DownloadQueue.h" @@ -233,7 +232,7 @@ uint32 CUpDownClient::GetScore(bool sysvalue, bool isdownloading, bool onlybasev return (uint32)fBaseValue; } -bool CUpDownClient::ProcessExtendedInfo(CSafeMemFile *data, CKnownFile *tempreqfile) +bool CUpDownClient::ProcessExtendedInfo(CSafeMemFile &data, CKnownFile *tempreqfile) { delete[] m_abyUpPartStatus; m_abyUpPartStatus = NULL; @@ -242,7 +241,7 @@ bool CUpDownClient::ProcessExtendedInfo(CSafeMemFile *data, CKnownFile *tempreqf if (GetExtendedRequestsVersion() == 0) return true; - uint16 nED2KUpPartCount = data->ReadUInt16(); + uint16 nED2KUpPartCount = data.ReadUInt16(); if (!nED2KUpPartCount) { m_nUpPartCount = tempreqfile->GetPartCount(); if (!m_nUpPartCount) @@ -257,7 +256,7 @@ bool CUpDownClient::ProcessExtendedInfo(CSafeMemFile *data, CKnownFile *tempreqf m_nUpPartCount = tempreqfile->GetPartCount(); m_abyUpPartStatus = new uint8[m_nUpPartCount]; for (UINT done = 0; done < m_nUpPartCount;) { - uint8 toread = data->ReadUInt8(); + uint8 toread = data.ReadUInt8(); for (UINT i = 0; i < 8; ++i) { m_abyUpPartStatus[done] = (toread >> i) & 1; //We may want to use this for another feature. @@ -270,7 +269,7 @@ bool CUpDownClient::ProcessExtendedInfo(CSafeMemFile *data, CKnownFile *tempreqf } if (GetExtendedRequestsVersion() > 1) { uint16 nCompleteCountLast = GetUpCompleteSourcesCount(); - uint16 nCompleteCountNew = data->ReadUInt16(); + uint16 nCompleteCountNew = data.ReadUInt16(); SetUpCompleteSourcesCount(nCompleteCountNew); if (nCompleteCountLast != nCompleteCountNew) tempreqfile->UpdatePartsInfo(); @@ -431,27 +430,13 @@ void CUpDownClient::UpdateUploadingStatisticsData() uint32 sentBytesPartFile = 0; CEMSocket *sock = GetFileUploadSocket(); - if (sock && (m_ePeerCacheUpState != PCUS_WAIT_CACHE_REPLY)) { - UINT uUpStatsPort; - if (m_pPCUpSocket && IsUploadingToPeerCache()) { - uUpStatsPort = UINT_MAX; - - // Check if file data has been sent via the normal socket since the last call. - uint64 sentBytesCompleteFileNormalSocket = socket->GetSentBytesCompleteFileSinceLastCallAndReset(); - uint64 sentBytesPartFileNormalSocket = socket->GetSentBytesPartFileSinceLastCallAndReset(); - - if (thePrefs.GetVerbose() && (sentBytesCompleteFileNormalSocket + sentBytesPartFileNormalSocket > 0)) { - AddDebugLogLine(false, _T("Sent file data via normal socket when in PC mode. Bytes: %I64i."), sentBytesCompleteFileNormalSocket + sentBytesPartFileNormalSocket); - } - } else - uUpStatsPort = GetUserPort(); - + if (sock) { // Extended statistics information based on which client software and which port we sent this data to... // This also updates the grand total for sent bytes, etc. And where this data came from. sentBytesCompleteFile = (uint32)sock->GetSentBytesCompleteFileSinceLastCallAndReset(); sentBytesPartFile = (uint32)sock->GetSentBytesPartFileSinceLastCallAndReset(); - thePrefs.Add2SessionTransferData(GetClientSoft(), uUpStatsPort, false, true, sentBytesCompleteFile, (IsFriend() && GetFriendSlot())); - thePrefs.Add2SessionTransferData(GetClientSoft(), uUpStatsPort, true, true, sentBytesPartFile, (IsFriend() && GetFriendSlot())); + thePrefs.Add2SessionTransferData(GetClientSoft(), GetUserPort(), false, true, sentBytesCompleteFile, (IsFriend() && GetFriendSlot())); + thePrefs.Add2SessionTransferData(GetClientSoft(), GetUserPort(), true, true, sentBytesPartFile, (IsFriend() && GetFriendSlot())); m_nTransferredUp += sentBytesCompleteFile + sentBytesPartFile; credits->AddUploaded(sentBytesCompleteFile + sentBytesPartFile, GetIP()); @@ -715,11 +700,6 @@ bool CUpDownClient::GetFriendSlot() const CEMSocket* CUpDownClient::GetFileUploadSocket(bool bLog) { - if (m_pPCUpSocket && (IsUploadingToPeerCache() || m_ePeerCacheUpState == PCUS_WAIT_CACHE_REPLY)) { - if (bLog && thePrefs.GetVerbose()) - AddDebugLogLine(false, _T("%s got peercache socket."), (LPCTSTR)DbgGetClientInfo()); - return m_pPCUpSocket; - } if (bLog && thePrefs.GetVerbose()) AddDebugLogLine(false, _T("%s got normal socket."), (LPCTSTR)DbgGetClientInfo()); return socket; diff --git a/srchybrid/UploadDiskIOThread.cpp b/srchybrid/UploadDiskIOThread.cpp index 0f1ae103..76b567eb 100644 --- a/srchybrid/UploadDiskIOThread.cpp +++ b/srchybrid/UploadDiskIOThread.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,8 +14,8 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" +#include #include "updownclient.h" #include "uploaddiskiothread.h" #include "emule.h" @@ -29,7 +29,6 @@ #include "listensocket.h" #include "packets.h" #include "Statistics.h" -#include "PeerCacheSocket.h" #include "UploadBandwidthThrottler.h" #include "zlib/zlib.h" @@ -42,16 +41,22 @@ static char THIS_FILE[] = __FILE__; #define SLOT_COMPRESSION_DATARATE (1000 * 1024) // Data rate for a single client from which we start to check if we need to disable compression #define BIGBUFFER_MINDATARATE (75 * 1024) +#define RUN_STOP 0 +#define RUN_IDLE 1 +#define RUN_WORK 2 +#define WAKEUP ((ULONG_PTR)(~0)) + IMPLEMENT_DYNCREATE(CUploadDiskIOThread, CWinThread) CUploadDiskIOThread::CUploadDiskIOThread() : m_eventThreadEnded(FALSE, TRUE) , m_hPort() - , m_bRun() - , m_bSignalThrottler() #ifdef _DEBUG , dbgDataReadPending() #endif + , m_Run(RUN_STOP) + , m_bNewData() + , m_bSignalThrottler() { ASSERT(theApp.uploadqueue != NULL); AfxBeginThread(RunProc, (LPVOID)this); @@ -59,8 +64,7 @@ CUploadDiskIOThread::CUploadDiskIOThread() CUploadDiskIOThread::~CUploadDiskIOThread() { - ASSERT(!m_hPort); - ASSERT(!m_bRun); + ASSERT(!m_hPort && !m_Run); } UINT AFX_CDECL CUploadDiskIOThread::RunProc(LPVOID pParam) @@ -72,7 +76,7 @@ UINT AFX_CDECL CUploadDiskIOThread::RunProc(LPVOID pParam) void CUploadDiskIOThread::EndThread() { - m_bRun = false; + m_Run = RUN_STOP; PostQueuedCompletionStatus(m_hPort, 0, 0, NULL); m_eventThreadEnded.Lock(); } @@ -86,38 +90,41 @@ UINT CUploadDiskIOThread::RunInternal() DWORD dwRead = 0; ULONG_PTR completionKey = 0; OverlappedRead_Struct *pCurIO = NULL; - m_bRun = true; - while (m_bRun + m_Run = RUN_IDLE; + while (m_Run && ::GetQueuedCompletionStatus(m_hPort, &dwRead, &completionKey, (LPOVERLAPPED*)&pCurIO, INFINITE) && completionKey) { + m_Run = RUN_WORK; //start new I/O CCriticalSection *pcsUploadListRead = NULL; const CUploadingPtrList &rUploadList = theApp.uploadqueue->GetUploadListTS(&pcsUploadListRead); pcsUploadListRead->Lock(); for (POSITION pos = rUploadList.GetHeadPosition(); pos != NULL;) StartCreateNextBlockPackage(rUploadList.GetNext(pos)); + InterlockedExchange8(&m_bNewData, 0); pcsUploadListRead->Unlock(); //completed I/O do { if (!completionKey) break; - if (completionKey != (ULONG_PTR)(~0)) //wake up call + if (completionKey != WAKEUP) //ignore wakeups ReadCompletionRoutine(dwRead, pCurIO); } while (::GetQueuedCompletionStatus(m_hPort, &dwRead, &completionKey, (LPOVERLAPPED*)&pCurIO, 0)); - //thread termination - if (!completionKey) // && !dwRead && !pCurIO) + if (!completionKey) //thread termination break; - + m_Run = RUN_IDLE; // if we have put a new data on any socket, tell the throttler if (m_bSignalThrottler && theApp.uploadBandwidthThrottler != NULL) { theApp.uploadBandwidthThrottler->NewUploadDataAvailable(); m_bSignalThrottler = false; } + if (InterlockedExchange8(&m_bNewData, 0) && m_listPendingIO.IsEmpty()) + PostQueuedCompletionStatus(m_hPort, 0, WAKEUP, NULL); } - m_bRun = false; //set non-running state in case of an I/O port error + m_Run = RUN_STOP; //Improper termination of asynchronous I/O follows... //close file handles to release the I/O completion port @@ -133,18 +140,18 @@ UINT CUploadDiskIOThread::RunInternal() bool CUploadDiskIOThread::AssociateFile(CKnownFile *pFile) { - ASSERT(m_hPort && m_bRun); + ASSERT(m_hPort && m_Run); if (pFile && pFile->m_hRead == INVALID_HANDLE_VALUE && !pFile->bNoNewReads) { CString fullname = (pFile->IsPartFile()) ? RemoveFileExtension(static_cast(pFile)->GetFullName()) : pFile->GetFilePath(); pFile->m_hRead = ::CreateFile(fullname, GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (pFile->m_hRead == INVALID_HANDLE_VALUE) { - DebugLogError(_T("Failed to open \"%s\" for overlapped read: %s"), (LPCTSTR)fullname, (LPCTSTR)GetErrorMessage(::GetLastError(), 1)); + theApp.QueueDebugLogLineEx(LOG_ERROR, _T("Failed to open \"%s\" for overlapped read: %s"), (LPCTSTR)fullname, (LPCTSTR)GetErrorMessage(::GetLastError(), 1)); return false; } if (m_hPort != ::CreateIoCompletionPort(pFile->m_hRead, m_hPort, (ULONG_PTR)pFile, 0)) { - DebugLogError(_T("Failed to associate \"%s\" with reading IOCP: %s"), (LPCTSTR)fullname, (LPCTSTR)GetErrorMessage(::GetLastError(), 1)); + theApp.QueueDebugLogLineEx(LOG_ERROR, _T("Failed to associate \"%s\" with reading IOCP: %s"), (LPCTSTR)fullname, (LPCTSTR)GetErrorMessage(::GetLastError(), 1)); DissociateFile(pFile); return false; } @@ -170,12 +177,8 @@ void CUploadDiskIOThread::StartCreateNextBlockPackage(UploadingToClient_Struct * // (so pUploadClientStruct and its members are safe in terms of not getting deleted/changed) CUpDownClient *pClient = pUploadClientStruct->m_pClient; CClientReqSocket *pSock = pClient->socket; - if (pSock == NULL - || !pSock->IsConnected() - || (pClient->IsUploadingToPeerCache() && pClient->m_pPCUpSocket == NULL)) - { + if (pSock == NULL || !pSock->IsConnected()) return; - } // now also get a lock on the Block lists CSingleLock lockBlockLists(&pUploadClientStruct->m_csBlockListsLock, TRUE); @@ -259,13 +262,11 @@ void CUploadDiskIOThread::StartCreateNextBlockPackage(UploadingToClient_Struct * pUploadClientStruct->m_DoneBlocks_list.AddHead(pUploadClientStruct->m_BlockRequests_queue.RemoveHead()); } return; //no errors - } catch (const CString &error) { - theApp.QueueDebugLogLineEx(LOG_ERROR, GetResString(IDS_ERR_CLIENTERRORED), pClient->GetUserName(), (LPCTSTR)error); - } catch (CFileException *e) { - TCHAR szError[MAX_PATH + 256]; - GetExceptionMessage(*e, szError, _countof(szError)); - theApp.QueueDebugLogLineEx(LOG_ERROR, _T("Failed to create upload package for %s - %s"), pClient->GetUserName(), szError); - e->Delete(); + } catch (const CString &ex) { + theApp.QueueDebugLogLineEx(LOG_ERROR, GetResString(IDS_ERR_CLIENTERRORED), pClient->GetUserName(), (LPCTSTR)ex); + } catch (CFileException *ex) { + theApp.QueueDebugLogLineEx(LOG_ERROR, _T("Failed to create upload package for %s%s"), pClient->GetUserName(), (LPCTSTR)CExceptionStrDash(*ex)); + ex->Delete(); } pUploadClientStruct->m_bIOError = true; // will let remove this client from the list in the main thread } @@ -281,7 +282,7 @@ void CUploadDiskIOThread::ReadCompletionRoutine(DWORD dwRead, const OverlappedRe --pOvRead->pFile->nInUse; CKnownFile *pKnownFile = pOvRead->pFile; - if (m_bRun) { + if (m_Run) { m_listPendingIO.RemoveAt(pOvRead->pos); bool bReadError = !dwRead; if (bReadError) @@ -309,13 +310,10 @@ void CUploadDiskIOThread::ReadCompletionRoutine(DWORD dwRead, const OverlappedRe // just to be sure there is no chance of a deadlock (now or in future version, also it doesn't cost us much) CPacketList packetsList; CUpDownClient *pClient = pStruct->m_pClient; - bool bPeerCache = pClient->IsUploadingToPeerCache(); - CClientReqSocket *pSocket = bPeerCache ? pClient->m_pPCUpSocket : pClient->socket; - if (pSocket && (bPeerCache || pSocket->IsConnected())) { + CClientReqSocket *pSocket = pClient->socket; + if (pSocket && pSocket->IsConnected()) { // Try to use compression whenever possible (see CreatePackedPackets notes) - if (bPeerCache) - CreatePeerCachePackets(*pOvRead, packetsList); - else if (pKnownFile->bCompress) + if (pKnownFile->bCompress) CreatePackedPackets(*pOvRead, packetsList); else CreateStandardPackets(*pOvRead, packetsList); @@ -474,60 +472,11 @@ void CUploadDiskIOThread::CreatePackedPackets(const OverlappedRead_Struct &Overl delete[] output; } -// not tested for the new threaded upload, if we ever use the PeerCache code again, take a look before -void CUploadDiskIOThread::CreatePeerCachePackets(const OverlappedRead_Struct &OverlappedRead, CPacketList &rOutPacketList) -{ - byte *pbyData = OverlappedRead.pBuffer; - uint64 uFileSize = (uint64)OverlappedRead.pFile->GetFileSize(); - bool bIsPartFile = OverlappedRead.pFile->IsPartFile(); - uint32 togo = (uint32)(OverlappedRead.uEndOffset - OverlappedRead.uStartOffset); - CUpDownClient *pClient = OverlappedRead.pUploadClientStruct->m_pClient; - ASSERT(uFileSize); - - while (togo) { - uint32 nPacketSize = (togo < 13000) ? togo : 10240u; - togo -= nPacketSize; - - CSafeMemFile dataHttp(nPacketSize + 512); //additional space for an http header - if (pClient->GetHttpSendState() == 0) { - CStringA str; - str.Format("HTTP/1.0 206\r\n" - "Content-Range: bytes %I64u-%I64u/%I64u\r\n" - "Content-Type: application/octet-stream\r\n" - "Content-Length: %u\r\n" - "Server: eMule/%S\r\n" - "\r\n" - , OverlappedRead.uStartOffset, OverlappedRead.uEndOffset - 1, uFileSize - , (unsigned)(OverlappedRead.uEndOffset - OverlappedRead.uStartOffset) - , (LPCTSTR)theApp.m_strCurVersionLong); - - dataHttp.Write((LPCSTR)str, str.GetLength()); - theStats.AddUpDataOverheadFileRequest((uint32)dataHttp.GetLength()); - - pClient->SetHttpSendState(1); - /*if (thePrefs.GetDebugClientTCPLevel() > 0) { - DebugSend("PeerCache-HTTP", this, pucMD4FileHash); - Debug(_T(" %hs\n"), str); - }*/ - } - dataHttp.Write(pbyData, nPacketSize); - pbyData += nPacketSize; - - /*if (thePrefs.GetDebugClientTCPLevel() > 1) { - DebugSend("PeerCache-HTTP data", this, GetUploadFileID()); - Debug(_T(" Start=%I64u End=%I64u Size=%u\n"), startpos, endpos, nPacketSize); - }*/ - - char *pRawPacketData = (char*)dataHttp.Detach(); - CRawPacket *packet = new CRawPacket(pRawPacketData, (UINT)dataHttp.GetLength(), bIsPartFile); - packet->uStatsPayLoad = nPacketSize; - rOutPacketList.AddTail(packet); - free(pRawPacketData); - } -} - void CUploadDiskIOThread::WakeUpCall() { - if (m_bRun) - PostQueuedCompletionStatus(m_hPort, 0, (ULONG_PTR)(~0), NULL); + //pending I/O makes posting unnecessary + if (m_Run == RUN_IDLE && m_listPendingIO.IsEmpty()) + PostQueuedCompletionStatus(m_hPort, 0, WAKEUP, NULL); + else + InterlockedExchange8(&m_bNewData, 1); } \ No newline at end of file diff --git a/srchybrid/UploadDiskIOThread.h b/srchybrid/UploadDiskIOThread.h index ebc53d5e..8a236b19 100644 --- a/srchybrid/UploadDiskIOThread.h +++ b/srchybrid/UploadDiskIOThread.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once class Packet; @@ -44,7 +43,7 @@ class CUploadDiskIOThread : public CWinThread CUploadDiskIOThread& operator=(const CUploadDiskIOThread&) = delete; void EndThread(); //completionkey == 0 - void WakeUpCall(); //completionkey == (ULONG_PTR)(~0) + void WakeUpCall(); //completionkey == WAKEUP static void DissociateFile(CKnownFile *pFile); private: @@ -57,16 +56,16 @@ class CUploadDiskIOThread : public CWinThread void ReadCompletionRoutine(DWORD dwRead, const OverlappedRead_Struct *pOvRead); static void CreatePackedPackets(const OverlappedRead_Struct &OverlappedRead, CPacketList &rOutPacketList); - static void CreatePeerCachePackets(const OverlappedRead_Struct &OverlappedRead, CPacketList &rOutPacketList); static void CreateStandardPackets(const OverlappedRead_Struct &OverlappedRead, CPacketList &rOutPacketList); CEvent m_eventThreadEnded; CTypedPtrList m_listPendingIO; HANDLE m_hPort; - volatile bool m_bRun; - bool m_bSignalThrottler; #ifdef _DEBUG uint64 dbgDataReadPending; #endif + volatile char m_Run; //0 - not running; 1 - idle; 2 - processing + volatile char m_bNewData; + bool m_bSignalThrottler; }; \ No newline at end of file diff --git a/srchybrid/UploadListCtrl.cpp b/srchybrid/UploadListCtrl.cpp index a6e53748..12333cec 100644 --- a/srchybrid/UploadListCtrl.cpp +++ b/srchybrid/UploadListCtrl.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/UploadListCtrl.h b/srchybrid/UploadListCtrl.h index 563803f0..51dca59d 100644 --- a/srchybrid/UploadListCtrl.h +++ b/srchybrid/UploadListCtrl.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/UploadQueue.cpp b/srchybrid/UploadQueue.cpp index f5ebedbf..83e654cd 100644 --- a/srchybrid/UploadQueue.cpp +++ b/srchybrid/UploadQueue.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -54,9 +54,9 @@ static char THIS_FILE[] = __FILE__; #endif -static uint32 counter, sec, statsave; +static uint32 i1sec, i2sec, i5sec, i60sec; static UINT s_uSaveStatistics = 0; -static uint32 igraph, istats, i2Secs; +static uint32 igraph, istats; #define HIGHSPEED_UPLOADRATE_START (500*1024) #define HIGHSPEED_UPLOADRATE_END (300*1024) @@ -81,12 +81,12 @@ CUploadQueue::CUploadQueue() , m_dwLastResortedUploadSlots() , m_bStatisticsWaitingListDirty(true) { - VERIFY((h_timer = ::SetTimer(NULL, 0, 100, UploadTimer)) != 0); + VERIFY((h_timer = ::SetTimer(NULL, 0, SEC2MS(1)/10, UploadTimer)) != 0); if (thePrefs.GetVerbose() && !h_timer) AddDebugLogLine(true, _T("Failed to create 'upload queue' timer - %s"), (LPCTSTR)GetErrorMessage(::GetLastError())); - counter = 0; - statsave = 0; - i2Secs = 0; + i1sec = 0; + i60sec = 0; + i2sec = 0; } CUploadQueue::~CUploadQueue() @@ -332,7 +332,7 @@ void CUploadQueue::Process() // does not have access to the client's download rate if (cur_client->GetUploadDatarate() > 100 * 1024) { CEMSocket *sock = cur_client->GetFileUploadSocket(); - if (sock && (cur_client->m_ePeerCacheUpState != PCUS_WAIT_CACHE_REPLY)) + if (sock) sock->UseBigSendBuffer(); } @@ -393,10 +393,9 @@ bool CUploadQueue::AcceptNewClient(bool addOnNextConnect) const return AcceptNewClient(curUploadSlots); } +// check if we can allow a new client to start downloading from us bool CUploadQueue::AcceptNewClient(INT_PTR curUploadSlots) const { - // check if we can allow a new client to start downloading from us - if (curUploadSlots < max(MIN_UP_CLIENTS_ALLOWED, 4)) return true; if (curUploadSlots >= MAX_UP_CLIENTS_ALLOWED) @@ -408,7 +407,6 @@ bool CUploadQueue::AcceptNewClient(INT_PTR curUploadSlots) const else MaxSpeed = thePrefs.GetMaxUpload(); uint32 TargetRate = GetTargetClientDataRate(false); - if (curUploadSlots >= (INT_PTR)(datarate / GetTargetClientDataRate(true)) || curUploadSlots >= (INT_PTR)(MaxSpeed * 1024 / TargetRate)) return false; @@ -481,17 +479,6 @@ bool CUploadQueue::ForceNewClient(bool allowEmptyWaitingQueue) if ((uint32)curUploadSlots < nMaxSlots) return true; } -/* - if (m_iHighestNumberOfFullyActivatedSlotsSinceLastCall > uploadinglist.GetCount()) { - // uploadThrottler requests another slot. If throttler says it needs another slot, we will allow more slots - // than what we require ourself. Never allow more slots than to give each slot high enough average transfer speed, though (checked above). - //if (thePrefs.GetLogUlDlEvents() && !waitinglist.IsEmpty()) - // AddDebugLogLine(false, _T("UploadQueue: Added new slot since throttler needs it. m_iHighestNumberOfFullyActivatedSlotsSinceLastCall: %i uploadinglist.GetCount(): %i tick: %i"), m_iHighestNumberOfFullyActivatedSlotsSinceLastCall, uploadinglist.GetCount(), ::GetTickCount()); - return true; - } - //nope - return false; -*/ return m_iHighestNumberOfFullyActivatedSlotsSinceLastCall > uploadinglist.GetCount(); } @@ -734,10 +721,9 @@ bool CUploadQueue::RemoveFromUploadQueue(CUpDownClient *client, LPCTSTR pszReaso m_csUploadListMainThrdWriteOtherThrdsRead.Unlock(); delete curClientStruct; // m_csBlockListsLock.Lock(); - //if (thePrefs.GetLogUlDlEvents() && !theApp.uploadBandwidthThrottler->RemoveFromStandardList(client->socket) && !theApp.uploadBandwidthThrottler->RemoveFromStandardList((CClientReqSocket*)client->m_pPCUpSocket))) + //if (thePrefs.GetLogUlDlEvents() && !theApp.uploadBandwidthThrottler->RemoveFromStandardList(client->socket)) // AddDebugLogLine(false, _T("UploadQueue: Didn't find socket to delete. Address: 0x%x"), client->socket); theApp.uploadBandwidthThrottler->RemoveFromStandardList(client->socket); - theApp.uploadBandwidthThrottler->RemoveFromStandardList((CClientReqSocket*)client->m_pPCUpSocket); if (client->GetSessionUp() > 0) { ++successfullupcount; @@ -915,10 +901,10 @@ VOID CALLBACK CUploadQueue::UploadTimer(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR / } // one second - if (++counter >= 10) { - counter = 0; + if (++i1sec >= 10) { + i1sec = 0; - // try to use different time intervals here to not create any disk-IO bottlenecks by saving all files at once + // try to use different time intervals here to avoid disk I/O congestion by saving all files at once theApp.clientcredits->Process(); // 13 minutes theApp.serverlist->Process(); // 17 minutes theApp.knownfiles->Process(); // 11 minutes @@ -946,8 +932,8 @@ VOID CALLBACK CUploadQueue::UploadTimer(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR / theApp.serverconnect->CheckForTimeout(); // 2 seconds - if (++i2Secs >= 2) { - i2Secs = 0; + if (++i2sec >= 2) { + i2sec = 0; // Update connection stats... theStats.UpdateConnectionStats(theApp.uploadqueue->GetDatarate() / 1024.0f, theApp.downloadqueue->GetDatarate() / 1024.0f); @@ -988,13 +974,13 @@ VOID CALLBACK CUploadQueue::UploadTimer(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR / theApp.emuledlg->ShowTransferRate(true); // *** 5 seconds ********************************************** - if (++sec >= 5) { + if (++i5sec >= 5) { #ifdef _DEBUG if (thePrefs.m_iDbgHeap > 0 && !AfxCheckMemory()) AfxDebugBreak(); #endif - sec = 0; + i5sec = 0; theApp.listensocket->Process(); theApp.OnlineSig(); // Added By Bouc7 if (!theApp.emuledlg->IsTrayIconToFlash()) @@ -1020,8 +1006,8 @@ VOID CALLBACK CUploadQueue::UploadTimer(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR / } // *** 60 seconds ********************************************* - if (++statsave >= 60) { - statsave = 0; + if (++i60sec >= 60) { + i60sec = 0; if (thePrefs.GetWSIsEnabled()) theApp.webserver->UpdateSessionCount(); @@ -1038,7 +1024,7 @@ VOID CALLBACK CUploadQueue::UploadTimer(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR / } } - // need more accuracy here. don't rely on the 'sec' and 'statsave' helpers. + // need more accuracy here; do not rely on the 'i5sec' and 'i60sec' helpers. thePerfLog.LogSamples(); } CATCH_DFLT_EXCEPTIONS(_T("CUploadQueue::UploadTimer")) @@ -1063,7 +1049,7 @@ void CUploadQueue::UpdateDatarates() { // Calculate average data rate const DWORD curTick = ::GetTickCount(); - if (curTick >= m_lastCalculatedDataRateTick + 500) { + if (curTick >= m_lastCalculatedDataRateTick + (SEC2MS(1) / 2)) { m_lastCalculatedDataRateTick = curTick; if (average_dr_list.GetCount() >= 2 && average_tick_list.GetTail() > average_tick_list.GetHead()) { @@ -1079,40 +1065,6 @@ uint32 CUploadQueue::GetToNetworkDatarate() const return (datarate > friendDatarate) ? datarate - friendDatarate : 0; } -void CUploadQueue::ReSortUploadSlots(bool force) -{ - const DWORD curTick = ::GetTickCount(); - if (force || curTick >= m_dwLastResortedUploadSlots + SEC2MS(10)) { - m_dwLastResortedUploadSlots = curTick; - - theApp.uploadBandwidthThrottler->Pause(true); - - CUploadingPtrList tempUploadinglist; - - // Remove all clients from uploading list and store in tempList - m_csUploadListMainThrdWriteOtherThrdsRead.Lock(); - while (!uploadinglist.IsEmpty()) { - // Get and remove the client from upload list. - UploadingToClient_Struct *pCurClientStruct = uploadinglist.RemoveHead(); - const CUpDownClient *cur_client = pCurClientStruct->m_pClient; - - // Remove the found Client from UploadBandwidthThrottler - theApp.uploadBandwidthThrottler->RemoveFromStandardList(cur_client->socket); - theApp.uploadBandwidthThrottler->RemoveFromStandardList((CClientReqSocket*)cur_client->m_pPCUpSocket); - - tempUploadinglist.AddTail(pCurClientStruct); - } - - // Remove one at a time from temp list and reinsert in correct position in uploading list - while (!tempUploadinglist.IsEmpty()) - InsertInUploadingList(tempUploadinglist.RemoveHead(), true); - - m_csUploadListMainThrdWriteOtherThrdsRead.Unlock(); - - theApp.uploadBandwidthThrottler->Pause(false); - } -} - uint32 CUploadQueue::GetWaitingUserForFileCount(const CSimpleArray &raFiles, bool bOnlyIfChanged) { if (bOnlyIfChanged && !m_bStatisticsWaitingListDirty) diff --git a/srchybrid/UploadQueue.h b/srchybrid/UploadQueue.h index 9772dd62..70158308 100644 --- a/srchybrid/UploadQueue.h +++ b/srchybrid/UploadQueue.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -90,7 +90,6 @@ class CUploadQueue uint32 GetAverageUpTime() const; CUpDownClient* FindBestClientInQueue(); - void ReSortUploadSlots(bool force = false); CUpDownClientPtrList waitinglist; diff --git a/srchybrid/UserMsgs.h b/srchybrid/UserMsgs.h index 3804442c..fb7d8e1c 100644 --- a/srchybrid/UserMsgs.h +++ b/srchybrid/UserMsgs.h @@ -24,7 +24,7 @@ enum EUserWndMessages UM_VERSIONCHECK_RESPONSE, //+11 // PC - UM_PEERCACHE_RESPONSE, //+12 + UM_PEERCACHE_RESPONSE, //+12 - defunct UM_CLOSETAB, //+13 UM_QUERYTAB, diff --git a/srchybrid/Version.cpp b/srchybrid/Version.cpp index 8cd1363f..c4c0ec84 100644 --- a/srchybrid/Version.cpp +++ b/srchybrid/Version.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/Version.h b/srchybrid/Version.h index 4e893c00..3496a780 100644 --- a/srchybrid/Version.h +++ b/srchybrid/Version.h @@ -31,8 +31,8 @@ // not used for any checks in the program #define VERSION_MJR 0 #define VERSION_MIN 70 -#define VERSION_UPDATE 0 -#define VERSION_BUILD 9 +#define VERSION_UPDATE 1 +#define VERSION_BUILD 5 #ifdef _M_X64 #define VERSION_X64 _T(" x64") #else diff --git a/srchybrid/VisualStylesXP.h b/srchybrid/VisualStylesXP.h index a0399076..4446d70c 100644 --- a/srchybrid/VisualStylesXP.h +++ b/srchybrid/VisualStylesXP.h @@ -33,7 +33,7 @@ class CVisualStylesXP DWORD dwTextFlags, LPCRECT pBoundingRect, LPRECT pExtentRect); static HRESULT GetThemeTextMetrics(HTHEME hTheme, HDC hdc, - int iPartId, int iStateId, TEXTMETRIC* ptm); + int iPartId, int iStateId, TEXTMETRIC *ptm); static HRESULT GetThemeBackgroundRegion(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pRect, HRGN *pRegion); static HRESULT HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, diff --git a/srchybrid/WebServer.cpp b/srchybrid/WebServer.cpp index f5e2c377..b3f6efa7 100644 --- a/srchybrid/WebServer.cpp +++ b/srchybrid/WebServer.cpp @@ -1293,7 +1293,7 @@ CString CWebServer::_GetServerList(const ThreadData &Data) HTTPProcessData.Replace(_T("[Ping]"), _T("")); else { CString sPing; - sPing.Format(_T("%lu"), cur_srv.nServerPing); + sPing.Format(_T("%u"), cur_srv.nServerPing); HTTPProcessData.Replace(_T("[Ping]"), sPing); } @@ -3410,7 +3410,7 @@ CString CWebServer::_GetPreferences(const ThreadData &Data) m_sTestURL.Format(PORTTESTURL, thePrefs.GetPort(), thePrefs.GetUDPPort(), thePrefs.GetLanguageID()); // the portcheck will need to do an obfuscated callback too if obfuscation is requested, so we have to provide our userhash so it can create the key - if (thePrefs.IsClientCryptLayerRequested()) + if (thePrefs.IsCryptLayerPreferred()) m_sTestURL.AppendFormat(_T("&obfuscated_test=%s"), (LPCTSTR)md4str(thePrefs.GetUserHash())); Out.Replace(_T("[CONNECTIONTESTLINK]"), _SpecialChars(m_sTestURL)); @@ -3418,10 +3418,10 @@ CString CWebServer::_GetPreferences(const ThreadData &Data) CString sT; - sT.Format(_T("%u"), thePrefs.GetMaxDownload() == UNLIMITED ? 0 : thePrefs.GetMaxDownload()); + sT.Format(_T("%u"), thePrefs.GetMaxDownload() == UNLIMITED ? 0u : thePrefs.GetMaxDownload()); Out.Replace(_T("[MaxDownVal]"), sT); - sT.Format(_T("%u"), thePrefs.GetMaxUpload() == UNLIMITED ? 0 : thePrefs.GetMaxUpload()); + sT.Format(_T("%u"), thePrefs.GetMaxUpload() == UNLIMITED ? 0u : thePrefs.GetMaxUpload()); Out.Replace(_T("[MaxUpVal]"), sT); sT.Format(_T("%u"), thePrefs.GetMaxGraphDownloadRate()); @@ -3649,7 +3649,7 @@ CString CWebServer::_GetDownloadGraph(const ThreadData &Data, const CString &fil if (i > lastindex && lastcolor < _countof(styles_active)) Out.AppendFormat(pThis->m_Templates.sProgressbarImgs, barcolours[lastcolor], i - lastindex); lastcolor = (BYTE)(s_ChunkBar[i] - '0'); - ASSERT(lastcolor >= 0 && lastcolor <= 9); + ASSERT(lastcolor <= 9); lastindex = i; } } diff --git a/srchybrid/WebSocket.cpp b/srchybrid/WebSocket.cpp index 5138fb90..9de8786f 100644 --- a/srchybrid/WebSocket.cpp +++ b/srchybrid/WebSocket.cpp @@ -8,12 +8,13 @@ #include "Log.h" #include "TLSthreading.h" -#include "mbedtls/entropy.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/error.h" #include "mbedtls/net_sockets.h" -#include "mbedtls/ssl_cache.h" #include "mbedtls/sha1.h" +#include "mbedtls/ssl_cache.h" +#include "mbedtls/ssl_cookie.h" +#include "mbedtls/ssl_ticket.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -28,9 +29,10 @@ mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_config conf; mbedtls_x509_crt srvcert; -mbedtls_x509_crt cachain; mbedtls_pk_context pkey; mbedtls_ssl_cache_context cache; +mbedtls_ssl_cookie_ctx cookie_ctx; +mbedtls_ssl_ticket_context ticket_ctx; typedef struct { @@ -121,7 +123,7 @@ void CWebSocket::OnReceived(void *pData, DWORD dwSize, const in_addr inad) // try to find now the 'Content-Length' header for (dwPos = 0; dwPos < m_dwHttpHeaderLen;) { // Elandal: pPtr is actually a char*, not a void* - char *pPtr = (char*)memchr(m_pBuf + dwPos, '\n', m_dwHttpHeaderLen - dwPos); + char *pPtr = (char*)memchr(&m_pBuf[dwPos], '\n', m_dwHttpHeaderLen - dwPos); if (!pPtr) break; // Elandal: And thus now the pointer subtraction works as it should @@ -129,11 +131,11 @@ void CWebSocket::OnReceived(void *pData, DWORD dwSize, const in_addr inad) // check this header static const char szMatch[] = "content-length"; - if (!_strnicmp(m_pBuf + dwPos, szMatch, (sizeof szMatch) - 1)) { - dwPos += (sizeof szMatch) - 1; - pPtr = (char*)memchr(m_pBuf + dwPos, ':', m_dwHttpHeaderLen - dwPos); + if (!_strnicmp(&m_pBuf[dwPos], szMatch, sizeof szMatch - 1)) { + dwPos += sizeof szMatch - 1; + pPtr = (char*)memchr(&m_pBuf[dwPos], ':', m_dwHttpHeaderLen - dwPos); if (pPtr) - m_dwHttpContentLen = atol(pPtr + 1); + m_dwHttpContentLen = atol(&pPtr[1]); break; } @@ -321,7 +323,7 @@ UINT AFX_CDECL WebSocketAcceptedFunc(LPVOID pD) } HANDLE pWait[] = {hEvent, s_hTerminate}; - while (WAIT_OBJECT_0 == ::WaitForMultipleObjects(2, pWait, FALSE, INFINITE)) { + while (WAIT_OBJECT_0 == ::WaitForMultipleObjects(DWORD(_countof(pWait)), pWait, FALSE, INFINITE)) { while (stWebSocket.m_bValid) { WSANETWORKEVENTS stEvents; if (WSAEnumNetworkEvents(hSocket, NULL, &stEvents)) @@ -456,14 +458,14 @@ UINT AFX_CDECL WebSocketListeningFunc(LPVOID pThis) if (INVALID_SOCKET == hAccepted) break; - if (!thePrefs.GetAllowedRemoteAccessIPs().IsEmpty()) { - bool bAllowedIP = false; - for (int i = 0; i < thePrefs.GetAllowedRemoteAccessIPs().GetCount(); ++i) { + bool bAllowedIP = thePrefs.GetAllowedRemoteAccessIPs().IsEmpty(); + if (!bAllowedIP) { + for (INT_PTR i = thePrefs.GetAllowedRemoteAccessIPs().GetCount(); --i >= 0;) if (their_addr.sin_addr.s_addr == thePrefs.GetAllowedRemoteAccessIPs()[i]) { bAllowedIP = true; break; } - } + if (!bAllowedIP) { LogWarning(_T("Web Interface: Rejected connection attempt from %s"), (LPCTSTR)ipstr(their_addr.sin_addr.s_addr)); VERIFY(!closesocket(hAccepted)); @@ -503,25 +505,36 @@ int StartSSL() if (!thePrefs.GetWebUseHttps()) return 0; //success mbedtls_threading_set_alt(threading_mutex_init_alt, threading_mutex_free_alt, threading_mutex_lock_alt, threading_mutex_unlock_alt); - mbedtls_ssl_cache_init(&cache); - mbedtls_x509_crt_init(&srvcert); - mbedtls_x509_crt_init(&cachain); mbedtls_ssl_config_init(&conf); mbedtls_ctr_drbg_init(&ctr_drbg); mbedtls_entropy_init(&entropy); - int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (unsigned char*)pers, strlen(pers)); - if (!ret) { - ret = mbedtls_x509_crt_parse_file(&srvcert, thePrefs.GetWebCertPath()); + mbedtls_x509_crt_init(&srvcert); + mbedtls_pk_init(&pkey); + mbedtls_ssl_cache_init(&cache); + mbedtls_ssl_ticket_init(&ticket_ctx); + mbedtls_ssl_cookie_init(&cookie_ctx); + int ret = (int)psa_crypto_init(); + if (!ret) { // PSA_SUCCESS is 0 + ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (unsigned char*)pers, strlen(pers)); if (!ret) { - mbedtls_pk_init(&pkey); - ret = mbedtls_pk_parse_keyfile(&pkey, thePrefs.GetWebKeyPath(), NULL, mbedtls_ctr_drbg_random, &ctr_drbg); + ret = mbedtls_x509_crt_parse_file(&srvcert, thePrefs.GetWebCertPath()); if (!ret) { - ret = mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_SERVER, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT); + ret = mbedtls_pk_parse_keyfile(&pkey, thePrefs.GetWebKeyPath(), NULL, mbedtls_ctr_drbg_random, &ctr_drbg); if (!ret) { - mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg); - mbedtls_ssl_conf_session_cache(&conf, &cache, mbedtls_ssl_cache_get, mbedtls_ssl_cache_set); - mbedtls_ssl_conf_ca_chain(&conf, &cachain, NULL); - ret = mbedtls_ssl_conf_own_cert(&conf, &srvcert, &pkey); + ret = mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_SERVER, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT); + if (!ret) { + mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg); + mbedtls_ssl_conf_session_cache(&conf, &cache, mbedtls_ssl_cache_get, mbedtls_ssl_cache_set); + ret = mbedtls_ssl_ticket_setup(&ticket_ctx, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_CIPHER_AES_256_GCM, 86400); + if (!ret) { + mbedtls_ssl_conf_session_tickets_cb(&conf, mbedtls_ssl_ticket_write, mbedtls_ssl_ticket_parse, &ticket_ctx); + mbedtls_ssl_conf_new_session_tickets(&conf, 1); + mbedtls_ssl_conf_tls13_key_exchange_modes(&conf, MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_ALL); + //mbedtls_ssl_conf_legacy_renegotiation(&conf, MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION); //default + //mbedtls_ssl_conf_renegotiation(&conf, MBEDTLS_SSL_RENEGOTIATION_DISABLED); //default + ret = mbedtls_ssl_conf_own_cert(&conf, &srvcert, &pkey); + } + } } } } @@ -539,11 +552,14 @@ int StartSSL() void StopSSL() { if (thePrefs.GetWebUseHttps()) { - mbedtls_x509_crt_free(&srvcert); - mbedtls_pk_free(&pkey); + mbedtls_ssl_cookie_free(&cookie_ctx); + mbedtls_ssl_ticket_free(&ticket_ctx); mbedtls_ssl_cache_free(&cache); - mbedtls_ctr_drbg_free(&ctr_drbg); + mbedtls_pk_free(&pkey); + mbedtls_psa_crypto_free(); + mbedtls_x509_crt_free(&srvcert); mbedtls_entropy_free(&entropy); + mbedtls_ctr_drbg_free(&ctr_drbg); mbedtls_ssl_config_free(&conf); } } diff --git a/srchybrid/WebSocket.h b/srchybrid/WebSocket.h index 083ab741..040e98f1 100644 --- a/srchybrid/WebSocket.h +++ b/srchybrid/WebSocket.h @@ -1,6 +1,5 @@ #pragma once -#include "mbedtls/build_info.h" #include "mbedtls/ssl.h" class CWebServer; diff --git a/srchybrid/Wizard.cpp b/srchybrid/Wizard.cpp index 0ebeb848..a8b0a393 100644 --- a/srchybrid/Wizard.cpp +++ b/srchybrid/Wizard.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License diff --git a/srchybrid/emule.rc b/srchybrid/emule.rc index a310cbdf..874ca455 100644 --- a/srchybrid/emule.rc +++ b/srchybrid/emule.rc @@ -323,18 +323,16 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION CAPTION "Directories" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - EDITTEXT IDC_INCFILES,11,13,210,12,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_SELINCDIR,210,7,14,14 - EDITTEXT IDC_TEMPFILES,11,45,200,12,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_SELTEMPDIR,196,39,14,14 - CONTROL "",IDC_SHARESELECTOR,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | TVS_CHECKBOXES | TVS_INFOTIP | WS_BORDER | WS_TABSTOP,10,76,211,110 - CONTROL "",IDC_UNCLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,10,190,195,43 - PUSHBUTTON "+",IDC_UNCADD,208,190,14,13,BS_CENTER - PUSHBUTTON "-",IDC_UNCREM,208,220,14,13,BS_CENTER GROUPBOX "Incoming Files",IDC_INCOMING_FRM,4,2,223,30 - GROUPBOX "Temporary Files",IDC_TEMP_FRM,4,34,223,29 + EDITTEXT IDC_INCFILES,11,13,210,12,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_SELINCDIR,208,7,14,14 + GROUPBOX "Temporary Files",IDC_TEMP_FRM,4,34,223,30 + EDITTEXT IDC_TEMPFILES,11,45,198,12,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_SELTEMPDIR,194,39,14,14 + PUSHBUTTON "+",IDC_SELTEMPDIRADD,210,45,11,12,BS_CENTER GROUPBOX "Shared Directories (Ctrl-Click includes subdirectories)",IDC_SHARED_FRM,4,65,223,172 - PUSHBUTTON "+",IDC_SELTEMPDIRADD,212,45,11,12,BS_CENTER + CONTROL "",IDC_SHARESELECTOR,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | TVS_CHECKBOXES | TVS_INFOTIP | WS_BORDER | WS_TABSTOP,11,77,209,136 + PUSHBUTTON "Add UNC share",IDC_UNCADD,10,218,64,14,BS_CENTER END IDD_PPG_CONNECTION DIALOGEX 0, 0, 231, 228 @@ -688,7 +686,7 @@ BEGIN PUSHBUTTON "Reload",IDC_RELOADFILTER,119,23,50,12 PUSHBUTTON "Edit",IDC_EDITFILTER,171,23,50,12 LTEXT "Update from URL: (filter.dat- or PeerGuardian-format)",IDC_STATIC_UPDATEFROM,11,37,202,8 - EDITTEXT IDC_UPDATEURL,11,47,160,12,ES_AUTOHSCROLL + EDITTEXT IDC_UPDATEURL,11,47,163,12,ES_AUTOHSCROLL PUSHBUTTON "v",IDC_DD,174,47,11,12,BS_CENTER PUSHBUTTON "Load",IDC_LOADURL,186,47,35,12 GROUPBOX "See My Shared Files/Directories",IDC_SEEMYSHARE_FRM,4,69,223,26 @@ -2643,7 +2641,8 @@ BEGIN IDS_IRC_PRIVMESSAGE "Private Message" IDS_WEB_REMOTE_LINK_ADDED "Link added: " IDS_WEB_REMOTE_LINK_NOT_ADDED "Link not added. Wrong password." - IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Download parts needed for preview first" + //IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Download parts needed for preview first" + IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Increase priority for preview parts" IDS_IRC_KICK "Kick" IDS_IRC_SLAP "Slap" IDS_IRC_JOIN "Join" @@ -2695,7 +2694,7 @@ BEGIN IDS_NEWMSG "New Message from '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Only in same category" IDS_LOG_ULDL_EVENTS "Log upload/download events" - IDS_PEERCACHE_ENABLED "Your ISP supports the PeerCache technology, enabling cache downloads!" +// IDS_PEERCACHE_ENABLED "Your ISP supports the PeerCache technology, enabling cache downloads!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Allow others to add you as a friend" IDS_SOURCESWAPBLOCKED "Swap blocked" IDS_TRICKLING "Standby" @@ -3396,9 +3395,9 @@ BEGIN IDS_WIZ_STARTWITHWINDOWS "Enable this so that eMule will run when you start windows." IDS_KAD_WAITCBK "Wait Callback Kad" IDS_KAD_TOOMANDYKADLKPS "Too Many Kad Lookups" - IDS_PCDS_CLIENTWAIT "ClientWait" - IDS_PCDS_CACHEWAIT "CacheWait" - IDS_CACHE "Cache" +// IDS_PCDS_CLIENTWAIT "ClientWait" +// IDS_PCDS_CACHEWAIT "CacheWait" +// IDS_CACHE "Cache" IDS_INDEXED "Indexed" IDS_KADINFO_SRC "\tSource: %u\r\n" IDS_KADINFO_KEYW "\tKeyword: %u\r\n" diff --git a/srchybrid/emule.sln b/srchybrid/emule.sln index e70267d3..53bbf7d4 100644 --- a/srchybrid/emule.sln +++ b/srchybrid/emule.sln @@ -22,7 +22,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "id3lib", "..\id3lib\libprj\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "..\libpng\projects\visualc\libpng.vcxproj", "{E27AB0B5-84CC-47E8-8F43-34C4F3FDA71E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbedTLS", "..\mbedtls\visualc\VS2013\mbedTLS.vcxproj", "{46CF2D25-6A36-4189-B59C-E4815388E554}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbedTLS", "..\mbedtls\visualc\VS2017\mbedTLS.vcxproj", "{46CF2D25-6A36-4189-B59C-E4815388E554}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniupnpc", "..\miniupnpc\msvc\miniupnpc.vcxproj", "{D28CE435-CB33-4BAE-8A52-C6EF915956F5}" EndProject diff --git a/srchybrid/emule.vcxproj b/srchybrid/emule.vcxproj index 6a78f475..de6ea7e8 100644 --- a/srchybrid/emule.vcxproj +++ b/srchybrid/emule.vcxproj @@ -61,7 +61,7 @@ - .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\crypto\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.22621.0\um\;$(UniversalCRTSdkDir)Include\10.0.22621.0\shared; + .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\tf-psa-crypto\include;..\mbedtls\tf-psa-crypto\drivers\builtin\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.26100.0\um\;$(UniversalCRTSdkDir)Include\10.0.26100.0\shared; /Zc:throwingNew EnableFastChecks true @@ -72,7 +72,7 @@ EnableAllWarnings - ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\$(Configuration)\cryptlib.lib;..\cximage\$(Platform)\$(Configuration)\cximage.lib;..\id3lib\libprj\$(Platform)\$(Configuration)\id3lib.lib;..\libpng\projects\visualc\$(Platform)\$(Configuration)\libpng.lib;..\mbedtls\visualc\vs2013\$(Platform)\$(Configuration)\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\$(Configuration)\miniupnpc.lib;..\resizablelib\$(Platform)\$(Configuration)\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\$(Configuration)\zlib.lib;%(AdditionalDependencies) + ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\$(Configuration)\cryptlib.lib;..\cximage\$(Platform)\$(Configuration)\cximage.lib;..\id3lib\libprj\$(Platform)\$(Configuration)\id3lib.lib;..\libpng\projects\visualc\$(Platform)\$(Configuration)\libpng.lib;..\mbedtls\visualc\vs2017\$(Platform)\$(Configuration)\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\$(Configuration)\miniupnpc.lib;..\resizablelib\$(Platform)\$(Configuration)\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\$(Configuration)\zlib.lib;%(AdditionalDependencies) /safeseh gdiplus.dll;msimg32.dll;oleacc.dll;ws2_32.dll;%(DelayLoadDLLs) mpr.lib;rasapi32.lib;secur32.lib;sensapi.lib;vfw32.lib;%(IgnoreSpecificDefaultLibraries) @@ -87,7 +87,7 @@ - .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\crypto\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.22621.0\um\;$(UniversalCRTSdkDir)Include\10.0.22621.0\shared; + .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\tf-psa-crypto\include;..\mbedtls\tf-psa-crypto\drivers\builtin\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.26100.0\um\;$(UniversalCRTSdkDir)Include\10.0.26100.0\shared; /Zc:throwingNew EnableFastChecks true @@ -98,13 +98,11 @@ EnableAllWarnings - ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\$(Configuration)\cryptlib.lib;..\cximage\$(Platform)\$(Configuration)\cximage.lib;..\id3lib\libprj\$(Platform)\$(Configuration)\id3lib.lib;..\libpng\projects\visualc\$(Platform)\$(Configuration)\libpng.lib;..\mbedtls\visualc\vs2013\$(Platform)\$(Configuration)\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\$(Configuration)\miniupnpc.lib;..\resizablelib\$(Platform)\$(Configuration)\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\$(Configuration)\zlib.lib;%(AdditionalDependencies) + ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\$(Configuration)\cryptlib.lib;..\cximage\$(Platform)\$(Configuration)\cximage.lib;..\id3lib\libprj\$(Platform)\$(Configuration)\id3lib.lib;..\libpng\projects\visualc\$(Platform)\$(Configuration)\libpng.lib;..\mbedtls\visualc\vs2017\$(Platform)\$(Configuration)\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\$(Configuration)\miniupnpc.lib;..\resizablelib\$(Platform)\$(Configuration)\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\$(Configuration)\zlib.lib;%(AdditionalDependencies) gdiplus.dll;msimg32.dll;oleacc.dll;ws2_32.dll;%(DelayLoadDLLs) mpr.lib;rasapi32.lib;secur32.lib;sensapi.lib;vfw32.lib;%(IgnoreSpecificDefaultLibraries) false Windows - - res/$(TargetName)$(Platform).manifest %(AdditionalManifestFiles) @@ -113,7 +111,7 @@ - .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\crypto\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.22621.0\um\;$(UniversalCRTSdkDir)Include\10.0.22621.0\shared; + .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\tf-psa-crypto\include;..\mbedtls\tf-psa-crypto\drivers\builtin\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.26100.0\um\;$(UniversalCRTSdkDir)Include\10.0.26100.0\shared; /Zc:throwingNew true true @@ -123,7 +121,7 @@ EnableAllWarnings - ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\$(Configuration)\cryptlib.lib;..\cximage\$(Platform)\$(Configuration)\cximage.lib;..\id3lib\libprj\$(Platform)\$(Configuration)\id3lib.lib;..\libpng\projects\visualc\$(Platform)\$(Configuration)\libpng.lib;..\mbedtls\visualc\vs2013\$(Platform)\$(Configuration)\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\$(Configuration)\miniupnpc.lib;..\resizablelib\$(Platform)\$(Configuration)\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\$(Configuration)\zlib.lib;%(AdditionalDependencies) + ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\$(Configuration)\cryptlib.lib;..\cximage\$(Platform)\$(Configuration)\cximage.lib;..\id3lib\libprj\$(Platform)\$(Configuration)\id3lib.lib;..\libpng\projects\visualc\$(Platform)\$(Configuration)\libpng.lib;..\mbedtls\visualc\vs2017\$(Platform)\$(Configuration)\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\$(Configuration)\miniupnpc.lib;..\resizablelib\$(Platform)\$(Configuration)\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\$(Configuration)\zlib.lib;%(AdditionalDependencies) /safeseh gdiplus.dll;msimg32.dll;oleacc.dll;ws2_32.dll;%(DelayLoadDLLs) true @@ -139,7 +137,7 @@ - .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\crypto\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.22621.0\um\;$(UniversalCRTSdkDir)Include\10.0.22621.0\shared; + .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\tf-psa-crypto\include;..\mbedtls\tf-psa-crypto\drivers\builtin\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.26100.0\um\;$(UniversalCRTSdkDir)Include\10.0.26100.0\shared; /Zc:throwingNew true true @@ -149,7 +147,7 @@ EnableAllWarnings - ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\$(Configuration)\cryptlib.lib;..\cximage\$(Platform)\$(Configuration)\cximage.lib;..\id3lib\libprj\$(Platform)\$(Configuration)\id3lib.lib;..\libpng\projects\visualc\$(Platform)\$(Configuration)\libpng.lib;..\mbedtls\visualc\vs2013\$(Platform)\$(Configuration)\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\$(Configuration)\miniupnpc.lib;..\resizablelib\$(Platform)\$(Configuration)\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\$(Configuration)\zlib.lib;%(AdditionalDependencies) + ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\$(Configuration)\cryptlib.lib;..\cximage\$(Platform)\$(Configuration)\cximage.lib;..\id3lib\libprj\$(Platform)\$(Configuration)\id3lib.lib;..\libpng\projects\visualc\$(Platform)\$(Configuration)\libpng.lib;..\mbedtls\visualc\vs2017\$(Platform)\$(Configuration)\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\$(Configuration)\miniupnpc.lib;..\resizablelib\$(Platform)\$(Configuration)\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\$(Configuration)\zlib.lib;%(AdditionalDependencies) gdiplus.dll;msimg32.dll;oleacc.dll;ws2_32.dll;%(DelayLoadDLLs) mpr.lib;rasapi32.lib;secur32.lib;sensapi.lib;vfw32.lib;%(IgnoreSpecificDefaultLibraries) true @@ -163,7 +161,7 @@ - .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\crypto\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.22621.0\um\;$(UniversalCRTSdkDir)Include\10.0.22621.0\shared; + .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\tf-psa-crypto\include;..\mbedtls\tf-psa-crypto\drivers\builtin\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.26100.0\um\;$(UniversalCRTSdkDir)Include\10.0.26100.0\shared; /Zc:throwingNew EnableFastChecks true @@ -174,7 +172,7 @@ EnableAllWarnings - ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\Debug\cryptlib.lib;..\cximage\$(Platform)\Debug\cximage.lib;..\id3lib\libprj\$(Platform)\Debug\id3lib.lib;..\libpng\projects\visualc\$(Platform)\Debug\libpng.lib;..\mbedtls\visualc\vs2013\$(Platform)\Debug\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\Debug\miniupnpc.lib;..\resizablelib\$(Platform)\Debug\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\Debug\zlib.lib;%(AdditionalDependencies) + ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\Debug\cryptlib.lib;..\cximage\$(Platform)\Debug\cximage.lib;..\id3lib\libprj\$(Platform)\Debug\id3lib.lib;..\libpng\projects\visualc\$(Platform)\Debug\libpng.lib;..\mbedtls\visualc\vs2017\$(Platform)\Debug\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\Debug\miniupnpc.lib;..\resizablelib\$(Platform)\Debug\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\Debug\zlib.lib;%(AdditionalDependencies) /safeseh gdiplus.dll;msimg32.dll;oleacc.dll;ws2_32.dll;%(DelayLoadDLLs) mpr.lib;rasapi32.lib;secur32.lib;sensapi.lib;vfw32.lib;%(IgnoreSpecificDefaultLibraries) @@ -189,7 +187,7 @@ - .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\crypto\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.22621.0\um\;$(UniversalCRTSdkDir)Include\10.0.22621.0\shared; + .;..;..\id3lib\include;..\mbedtls\include;..\mbedtls\tf-psa-crypto\include;..\mbedtls\tf-psa-crypto\drivers\builtin\include;$(VC_ATLMFC_SourcePath);$(UniversalCRTSdkDir)Include\10.0.26100.0\um\;$(UniversalCRTSdkDir)Include\10.0.26100.0\shared; /Zc:throwingNew EnableFastChecks true @@ -200,7 +198,7 @@ EnableAllWarnings - ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\Debug\cryptlib.lib;..\cximage\$(Platform)\Debug\cximage.lib;..\id3lib\libprj\$(Platform)\Debug\id3lib.lib;..\libpng\projects\visualc\$(Platform)\Debug\libpng.lib;..\mbedtls\visualc\vs2013\$(Platform)\Debug\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\Debug\miniupnpc.lib;..\resizablelib\$(Platform)\Debug\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\Debug\zlib.lib;%(AdditionalDependencies) + ADSIId.lib;crypt32.lib;iphlpapi.lib;version.lib;winmm.lib;ws2_32.lib;..\cryptopp\$(Platform)\Debug\cryptlib.lib;..\cximage\$(Platform)\Debug\cximage.lib;..\id3lib\libprj\$(Platform)\Debug\id3lib.lib;..\libpng\projects\visualc\$(Platform)\Debug\libpng.lib;..\mbedtls\visualc\vs2017\$(Platform)\Debug\mbedtls.lib;..\miniupnpc\msvc\$(Platform)\Debug\miniupnpc.lib;..\resizablelib\$(Platform)\Debug\resizablelib.lib;..\zlib\contrib\vstudio\vc\$(Platform)\Debug\zlib.lib;%(AdditionalDependencies) gdiplus.dll;msimg32.dll;oleacc.dll;ws2_32.dll;%(DelayLoadDLLs) mpr.lib;rasapi32.lib;secur32.lib;sensapi.lib;vfw32.lib;%(IgnoreSpecificDefaultLibraries) false @@ -360,8 +358,6 @@ - - @@ -514,7 +510,6 @@ - @@ -656,8 +651,6 @@ - - diff --git a/srchybrid/emule_site_config.h b/srchybrid/emule_site_config.h index a4227dca..8078febb 100644 --- a/srchybrid/emule_site_config.h +++ b/srchybrid/emule_site_config.h @@ -12,14 +12,12 @@ #ifdef XP_BUILD #define _WIN32_WINNT _WIN32_WINNT_WINXP #define NTDDI_VERSION NTDDI_WINXP -#define XP_NOEXCEPT noexcept -#else //XP_BUILD +#endif //XP_BUILD #if _MSC_VER<1937 //before VS2022 17.7 -#define XP_NOEXCEPT noexcept +#define NOEXCEPT noexcept #else -#define XP_NOEXCEPT +#define NOEXCEPT #endif -#endif //XP_BUILD ////////////////////////////////////////////////////////////////////////////// // Visual Studio 2003 diff --git a/srchybrid/kademlia/io/DataIO.cpp b/srchybrid/kademlia/io/DataIO.cpp index 562769b2..8b04b267 100644 --- a/srchybrid/kademlia/io/DataIO.cpp +++ b/srchybrid/kademlia/io/DataIO.cpp @@ -334,8 +334,8 @@ void CDataIO::WriteTag(const CKadTag &Tag) case TAGTYPE_BSOB: WriteBsob(Tag.GetBsob(), Tag.GetBsobSize()); } - } catch (CIOException *ioe) { - AddDebugLogLine(false, _T("Exception in CDataIO:writeTag (IO Error(%i))"), ioe->m_iCause); + } catch (CIOException *ex) { + AddDebugLogLine(false, _T("Exception in CDataIO:writeTag (IO Error(%i))"), ex->m_iCause); throw; } catch (...) { AddDebugLogLine(false, _T("Exception in CDataIO:writeTag")); diff --git a/srchybrid/kademlia/io/IOException.cpp b/srchybrid/kademlia/io/IOException.cpp index 0da09f1d..678175a5 100644 --- a/srchybrid/kademlia/io/IOException.cpp +++ b/srchybrid/kademlia/io/IOException.cpp @@ -44,7 +44,7 @@ CIOException::CIOException(int iCause) { m_iCause = iCause; } - +/* BOOL CIOException::GetErrorMessage(LPTSTR lpszError, UINT uMaxError, PUINT pnHelpContext) const { static LPCTSTR const sMsg = _T("ONLY AVAILABLE WITH EMULE INTEGRATION"); @@ -57,3 +57,4 @@ BOOL CIOException::GetErrorMessage(LPTSTR lpszError, UINT uMaxError, PUINT pnHel return TRUE; } +*/ \ No newline at end of file diff --git a/srchybrid/kademlia/io/IOException.h b/srchybrid/kademlia/io/IOException.h index fb76b5c3..a7bab13d 100644 --- a/srchybrid/kademlia/io/IOException.h +++ b/srchybrid/kademlia/io/IOException.h @@ -37,8 +37,8 @@ namespace Kademlia { public: explicit CIOException(int iCause = ERR_SUCCESS); - - BOOL GetErrorMessage(LPTSTR lpszError, UINT uMaxError, PUINT pnHelpContext = NULL) const; + //not used; causes C4266 warnings + //BOOL GetErrorMessage(LPTSTR lpszError, UINT uMaxError, PUINT pnHelpContext = NULL) const; int m_iCause; }; } \ No newline at end of file diff --git a/srchybrid/kademlia/kademlia/Entry.cpp b/srchybrid/kademlia/kademlia/Entry.cpp index 7474b209..965f23a1 100644 --- a/srchybrid/kademlia/kademlia/Entry.cpp +++ b/srchybrid/kademlia/kademlia/Entry.cpp @@ -453,17 +453,17 @@ void CKeyEntry::MergeIPsAndFilenames(CKeyEntry *pFromEntry) RecalcualteTrustValue(); } delete pNewAICHHash; - /*//DEBUG_ONLY( + /*DEBUG_ONLY( DebugLog(_T("Kad: EntryTrack: Indexed Keyword, Refresh: %s, Current Publisher: %s, Total Publishers: %u, Total different Names: %u,TrustValue: %.2f, file: %s"), (bRefresh ? _T("Yes") : _T("No")), (LPCTSTR)ipstr(htonl(m_uIP)), m_pliPublishingIPs->GetCount(), m_listFileNames.GetCount(), m_fTrustValue, m_uSourceID.ToHexString()); - //);*/ - /*if (m_aAICHHashes.GetCount() == 1) { + ); + if (m_aAICHHashes.GetCount() == 1) { DebugLog(_T("Kad: EntryTrack: Indexed Keyword, Refresh: %s, Current Publisher: %s, Total Publishers: %u, Total different Names: %u,TrustValue: %.2f, file: %s, AICH Hash: %s, Popularity: %u"), (bRefresh ? _T("Yes") : _T("No")), (LPCTSTR)ipstr(htonl(m_uIP)), m_pliPublishingIPs->GetCount(), m_listFileNames.GetCount(), m_fTrustValue, m_uSourceID.ToHexString(), m_aAICHHashes[0].GetString(), m_anAICHHashPopularity[0]); } else if (m_aAICHHashes.GetCount() > 1) { DebugLog(_T("Kad: EntryTrack: Indexed Keyword, Refresh: %s, Current Publisher: %s, Total Publishers: %u, Total different Names: %u,TrustValue: %.2f, file: %s, AICH Hash: %u - dumping"), (bRefresh ? _T("Yes") : _T("No")), (LPCTSTR)ipstr(htonl(m_uIP)), m_pliPublishingIPs->GetCount(), m_listFileNames.GetCount(), m_fTrustValue, m_uSourceID.ToHexString(), m_aAICHHashes.GetCount()); - for (int i = 0; i < m_aAICHHashes.GetCount(); ++i) + for (INT_PTR i = 0; i < m_aAICHHashes.GetCount(); ++i) DebugLog(_T("Hash: %s, Popularity: %u"), m_aAICHHashes[i].GetString(), m_anAICHHashPopularity[i]); }*/ } @@ -584,7 +584,7 @@ void CKeyEntry::ReadPublishTrackingDataFromFile(CDataIO *pData, bool bIncludesAI ASSERT(m_anAICHHashPopularity.IsEmpty()); if (bIncludesAICH) { CAICHHash hash; - for (UINT i = pData->ReadUInt16(); i-- > 0;) { //hash count + for (uint32 i = pData->ReadUInt16(); i > 0; --i) { //hash count pData->ReadArray(hash.GetRawHash(), CAICHHash::GetHashSize()); m_aAICHHashes.Add(hash); m_anAICHHashPopularity.Add(0); @@ -636,7 +636,7 @@ void CKeyEntry::ReadPublishTrackingDataFromFile(CDataIO *pData, bool bIncludesAI DebugLog(_T("Loaded 1 AICH Hash (%s, publishers %u of %u) for file %s"), (LPCTSTR)m_aAICHHashes[0].GetString(), m_anAICHHashPopularity[0], m_pliPublishingIPs->GetCount(), (LPCTSTR)m_uSourceID.ToHexString()); else if (m_aAICHHashes.GetCount() > 1) { DebugLogWarning(_T("Loaded multiple (%u) AICH Hashes for file %s, dumping..."), m_aAICHHashes.GetCount(), (LPCTSTR)m_uSourceID.ToHexString()); - for (int i = 0; i < m_aAICHHashes.GetCount(); ++i) + for (INT_PTR i = 0; i < m_aAICHHashes.GetCount(); ++i) DebugLog(_T("%s - %u out of %u publishers"), (LPCTSTR)m_aAICHHashes[i].GetString(), m_anAICHHashPopularity[i], m_pliPublishingIPs->GetCount()); } //if (GetTrustValue() < 1.0f) @@ -666,8 +666,8 @@ void CKeyEntry::WriteTagListWithPublishInfo(CDataIO *pData) WriteTagListInc(pData, nAdditionalTags); // write the standard tag list but increase the tag count by the count we want to add // here we add a tag including how many publishers this entry has, the trust value and how many different names are known - // this is supposed to get used in later versions as an indicator for the user how valid this result is (of course this tag - // alone cannot be trusted 100%, because we could be a bad node, but it's a part of the puzzle) + // this is supposed to get used in later versions as an indicator for the user how valid this result is (of course, tag + // alone cannot be trusted 100%, because it could be a bad node, but it's a part of the riddle) uint32 uTrust = (uint16)(GetTrustValue() * 100); uint32 uPublishers = (uint32)(m_pliPublishingIPs->GetCount() % 256); uint32 uNames = (uint32)(m_listFileNames.GetCount() % 256); @@ -675,13 +675,13 @@ void CKeyEntry::WriteTagListWithPublishInfo(CDataIO *pData) uint32 uTagValue = (uNames << 24) | (uPublishers << 16) | (uTrust << 0); pData->WriteTag(CKadTagUInt(TAG_PUBLISHINFO, uTagValue)); - // Last but not least the AICH Hash tag, containing all reported (hopefully, exactly 1) AICH hashes + // Last but not least: the AICH Hash tag, containing all reported (hopefully, exactly 1) AICH hashes // for this file together with the count of publishers who reported it if (!m_aAICHHashes.IsEmpty()) { CSafeMemFile fileAICHTag(100); uint8 byCount = 0; // get count of AICH tags with popularity > 0 - for (int i = 0; i < m_aAICHHashes.GetCount(); ++i) { + for (INT_PTR i = 0; i < m_aAICHHashes.GetCount(); ++i) { byCount += static_cast(m_anAICHHashPopularity[i] > 0); // bsob tags in kad are limited to 255 bytes, so no more than 12 AICH hashes can be written // that shouldn't be an issue however, as the normal AICH hash count is 1, if we have more than @@ -715,7 +715,7 @@ void CKeyEntry::WriteTagListWithPublishInfo(CDataIO *pData) uint16 CKeyEntry::AddRemoveAICHHash(const CAICHHash &hash, bool bAdd) { ASSERT(m_aAICHHashes.GetCount() == m_anAICHHashPopularity.GetCount()); - for (int i = (int)m_aAICHHashes.GetCount(); --i >= 0;) + for (INT_PTR i = m_aAICHHashes.GetCount(); --i >= 0;) if (m_aAICHHashes[i] == hash) { if (bAdd) ++m_anAICHHashPopularity[i]; diff --git a/srchybrid/kademlia/kademlia/Entry.h b/srchybrid/kademlia/kademlia/Entry.h index 3c4e3e23..7a61a2ce 100644 --- a/srchybrid/kademlia/kademlia/Entry.h +++ b/srchybrid/kademlia/kademlia/Entry.h @@ -23,7 +23,6 @@ what all it does, can cause great harm to the network if released in mass form. Any mod that changes anything within the Kademlia side will not be allowed to advertise their client on the eMule forum. */ - #pragma once #include "shahashset.h" #include "kademlia/kademlia/Tag.h" diff --git a/srchybrid/kademlia/kademlia/Indexed.cpp b/srchybrid/kademlia/kademlia/Indexed.cpp index f418cb95..c398d072 100644 --- a/srchybrid/kademlia/kademlia/Indexed.cpp +++ b/srchybrid/kademlia/kademlia/Indexed.cpp @@ -239,9 +239,9 @@ CIndexed::~CIndexed() AddDebugLogLine(false, _T("Wrote %u source, %u keyword, and %u load entries"), uTotalSource, uTotalKey, uTotalLoad); - } catch (CIOException *ioe) { - AddDebugLogLine(false, _T("Exception in CIndexed::~CIndexed (IO error(%i))"), ioe->m_iCause); - ioe->Delete(); + } catch (CIOException *ex) { + AddDebugLogLine(false, _T("Exception in CIndexed::~CIndexed (IO error(%i))"), ex->m_iCause); + ex->Delete(); } catch (...) { AddDebugLogLine(false, _T("Exception in CIndexed::~CIndexed")); } @@ -1047,9 +1047,9 @@ int CIndexed::CLoadDataThread::Run() } else DebugLogWarning(_T("Unable to load Kad file: %s"), (LPCTSTR)m_sSourceFileName); } - } catch (CIOException *ioe) { - AddDebugLogLine(false, _T("CIndexed::CLoadDataThread::Run (IO error(%i))"), ioe->m_iCause); - ioe->Delete(); + } catch (CIOException *ex) { + AddDebugLogLine(false, _T("CIndexed::CLoadDataThread::Run (IO error(%i))"), ex->m_iCause); + ex->Delete(); } catch (...) { AddDebugLogLine(false, _T("Exception in CIndexed::CLoadDataThread::Run")); ASSERT(0); diff --git a/srchybrid/kademlia/kademlia/Kademlia.cpp b/srchybrid/kademlia/kademlia/Kademlia.cpp index 68d50b8e..8522dc5a 100644 --- a/srchybrid/kademlia/kademlia/Kademlia.cpp +++ b/srchybrid/kademlia/kademlia/Kademlia.cpp @@ -139,15 +139,13 @@ void CKademlia::Start(CPrefs *pPrefs) m_pInstance->m_pUDPListener = new CKademliaUDPListener(); // Mark Kad as running state. m_bRunning = true; - } catch (CException *e) { + } catch (CException *ex) { // Although this has never been an issue, maybe some code needs // to be created here just in case things go real bad. But if things // went real bad, the entire client most likely is in bad shape, so this may // not be something to worry about as the client most likely will crap out anyway. - TCHAR err[512]; - GetExceptionMessage(*e, err, 512); - AddDebugLogLine(false, _T("%s"), err); - e->Delete(); + AddDebugLogLine(false, _T("%s"), (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); } } @@ -504,7 +502,7 @@ bool CKademlia::FindIPByNodeID(CKadClientSearcher &rRequester, const uchar *pach return CSearchManager::FindNodeSpecial(CUInt128(pachNodeID), &rRequester); } -void CKademlia::CancelClientSearch(CKadClientSearcher &rFromRequester) +void CKademlia::CancelClientSearch(const CKadClientSearcher &rFromRequester) { if (m_pInstance == NULL || GetUDPListener() == NULL) { ASSERT(0); diff --git a/srchybrid/kademlia/kademlia/Kademlia.h b/srchybrid/kademlia/kademlia/Kademlia.h index 31693d45..514e9e32 100644 --- a/srchybrid/kademlia/kademlia/Kademlia.h +++ b/srchybrid/kademlia/kademlia/Kademlia.h @@ -79,7 +79,7 @@ namespace Kademlia static bool FindNodeIDByIP(CKadClientSearcher &rRequester, uint32 dwIP, uint16 nTCPPort, uint16 nUDPPort); static bool FindIPByNodeID(CKadClientSearcher &rRequester, const uchar *pachNodeID); - static void CancelClientSearch(CKadClientSearcher &rFromRequester); + static void CancelClientSearch(const CKadClientSearcher &rFromRequester); static _ContactList s_liBootstrapList; diff --git a/srchybrid/kademlia/kademlia/Prefs.cpp b/srchybrid/kademlia/kademlia/Prefs.cpp index a57970d6..e82234d3 100644 --- a/srchybrid/kademlia/kademlia/Prefs.cpp +++ b/srchybrid/kademlia/kademlia/Prefs.cpp @@ -33,7 +33,6 @@ their client on the eMule forum. #include "preferences.h" #include "emule.h" #include "emuledlg.h" -#include "SafeFile.h" #include "serverlist.h" #include "Log.h" #include "MD5Sum.h" @@ -97,24 +96,24 @@ void CPrefs::Init(LPCTSTR szFilename) void CPrefs::ReadFile() { + CSafeBufferedFile file; + if (!file.Open(m_sFilename, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, NULL)) + return; + + ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); try { - CSafeBufferedFile file; - CFileException fexp; - if (file.Open(m_sFilename, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); - m_uIP = file.ReadUInt32(); - file.ReadUInt16(); - file.ReadUInt128(m_uClientID); - // get rid of invalid kad IDs which may have been stored by older versions - if (m_uClientID == 0) - m_uClientID.SetValueRandom(); - file.Close(); - } + m_uIP = file.ReadUInt32(); + file.ReadUInt16(); + file.ReadUInt128(m_uClientID); + // get rid of invalid kad IDs which may have been stored by older versions + if (m_uClientID == 0) + m_uClientID.SetValueRandom(); + file.Close(); } catch (CException *ex) { ASSERT(0); ex->Delete(); } catch (...) { - TRACE("Exception in CPrefs::readFile\n"); + TRACE("Exception in CPrefs::ReadFile\n"); } } @@ -122,8 +121,7 @@ void CPrefs::WriteFile() { try { CSafeBufferedFile file; - CFileException fexp; - if (file.Open(m_sFilename, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { + if (file.Open(m_sFilename, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, NULL)) { ::setvbuf(file.m_pStream, NULL, _IOFBF, 16384); file.WriteUInt32(m_uIP); file.WriteUInt16(0); //This is no longer used. @@ -135,7 +133,7 @@ void CPrefs::WriteFile() ASSERT(0); ex->Delete(); } catch (...) { - TRACE("Exception in CPrefs::writeFile\n"); + TRACE("Exception in CPrefs::WriteFile\n"); } } diff --git a/srchybrid/kademlia/kademlia/Search.cpp b/srchybrid/kademlia/kademlia/Search.cpp index 9a06282c..6aab71f9 100644 --- a/srchybrid/kademlia/kademlia/Search.cpp +++ b/srchybrid/kademlia/kademlia/Search.cpp @@ -1,6 +1,6 @@ /* Copyright (C)2003 Barry Dunne (https://www.emule-project.net) -Copyright (C)2004-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +Copyright (C)2004-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1135,9 +1135,9 @@ void CSearch::ProcessResultKeyword(const CUInt128 &uAnswer, TagList &rlistInfo, aAICHHashes.Add(CAICHHash(fileAICHTag)); } } - } catch (CFileException *pError) { + } catch (CFileException *ex) { DebugLogError(_T("ProcessResultKeyword: Corrupt or invalid TAG_KADAICHHASHRESULT received - ip: %s)"), (LPCTSTR)ipstr(htonl(uFromIP))); - pError->Delete(); + ex->Delete(); aAICHHashPopularity.RemoveAll(); aAICHHashes.RemoveAll(); } @@ -1275,9 +1275,9 @@ void CSearch::SendFindValue(CContact *pContact, bool bReAskMore) } } else ASSERT(0); - } catch (CIOException *ioe) { - AddDebugLogLine(false, _T("Exception in CSearch::SendFindValue (IO error(%i))"), ioe->m_iCause); - ioe->Delete(); + } catch (CIOException *ex) { + AddDebugLogLine(false, _T("Exception in CSearch::SendFindValue (IO error(%i))"), ex->m_iCause); + ex->Delete(); } catch (...) { AddDebugLogLine(false, _T("Exception in CSearch::SendFindValue")); } @@ -1417,9 +1417,9 @@ void CSearch::PreparePacketForTags(CByteIO *byIO, CKnownFile *pFile, uint8 byTar //If we get here, bad things happened. Will fix this later if it is a real issue. ASSERT(0); } - } catch (CIOException *ioe) { - AddDebugLogLine(false, _T("Exception in CSearch::PreparePacketForTags (IO error(%i))"), ioe->m_iCause); - ioe->Delete(); + } catch (CIOException *ex) { + AddDebugLogLine(false, _T("Exception in CSearch::PreparePacketForTags (IO error(%i))"), ex->m_iCause); + ex->Delete(); } catch (...) { AddDebugLogLine(false, _T("Exception in CSearch::PreparePacketForTags")); } diff --git a/srchybrid/kademlia/kademlia/Search.h b/srchybrid/kademlia/kademlia/Search.h index 1df39209..76d74b5d 100644 --- a/srchybrid/kademlia/kademlia/Search.h +++ b/srchybrid/kademlia/kademlia/Search.h @@ -46,25 +46,25 @@ namespace Kademlia { friend class CSearchManager; public: - uint32 GetSearchID() const { return m_uSearchID; }; - uint32 GetSearchType() const { return m_uType; }; + uint32 GetSearchID() const { return m_uSearchID; } + uint32 GetSearchType() const { return m_uType; } void SetSearchType(uint32 uVal); - void SetTargetID(const CUInt128 &uVal) { m_uTarget = uVal; }; - CUInt128 GetTarget() const { return m_uTarget; }; + void SetTargetID(const CUInt128 &uVal) { m_uTarget = uVal; } + const CUInt128& GetTarget() const { return m_uTarget; } uint32 GetAnswers() const; - uint32 GetKadPacketSent() const { return m_uKadPacketSent; }; - uint32 GetRequestAnswer() const { return m_uTotalRequestAnswers; }; + uint32 GetKadPacketSent() const { return m_uKadPacketSent; } + uint32 GetRequestAnswer() const { return m_uTotalRequestAnswers; } uint32 GetNodeLoad() const; - uint32 GetNodeLoadResponse() const { return m_uTotalLoadResponses; }; - uint32 GetNodeLoadTotal() const { return m_uTotalLoad; }; - const CStringW& GetGUIName() const; + uint32 GetNodeLoadResponse() const { return m_uTotalLoadResponses; } + uint32 GetNodeLoadTotal() const { return m_uTotalLoad; } + const CStringW& GetGUIName() const; void SetGUIName(LPCWSTR sGUIName); void SetSearchTermData(uint32 uSearchTermDataSize, LPBYTE pucSearchTermsData); static CString GetTypeName(uint32 uType); void AddFileID(const CUInt128 &uID); static void PreparePacketForTags(CByteIO *byIO, CKnownFile *pFile, uint8 byTargetKadVersion); - bool Stoping() const { return m_bStoping; }; + bool Stoping() const { return m_bStoping; } void UpdateNodeLoad(uint8 uLoad); CKadClientSearcher* GetNodeSpecialSearchRequester() const { return pNodeSpecialSearchRequester; } diff --git a/srchybrid/kademlia/kademlia/SearchManager.cpp b/srchybrid/kademlia/kademlia/SearchManager.cpp index d19e90e5..dd365740 100644 --- a/srchybrid/kademlia/kademlia/SearchManager.cpp +++ b/srchybrid/kademlia/kademlia/SearchManager.cpp @@ -30,7 +30,6 @@ their client on the eMule forum. #include "stdafx.h" #include "resource.h" -#include "SafeFile.h" #include "Log.h" #include "emule.h" #include "emuledlg.h" @@ -146,15 +145,13 @@ CSearch* CSearchManager::PrepareFindKeywords(LPCWSTR szKeyword, UINT uSearchTerm return pSearch; } } - } catch (CIOException *ioe) { - strError.Format(_T("IO-Exception in %hs: Error %i"), __FUNCTION__, ioe->m_iCause); - ioe->Delete(); - } catch (CFileException *e) { - TCHAR szError[MAX_CFEXP_ERRORMSG]; - e->m_strFileName = _T("search packet"); - GetExceptionMessage(*e, szError, _countof(szError)); - strError.Format(_T("Exception in %hs: %s"), __FUNCTION__, szError); - e->Delete(); + } catch (CIOException *ex) { + strError.Format(_T("IO-Exception in %hs: Error %i"), __FUNCTION__, ex->m_iCause); + ex->Delete(); + } catch (CFileException *ex) { + ex->m_strFileName = _T("search packet"); + strError.Format(_T("Exception in %hs: %s"), __FUNCTION__, (LPCTSTR)CExceptionStr(*ex)); + ex->Delete(); } catch (const CString&) { delete pSearch; throw; @@ -198,9 +195,9 @@ CSearch* CSearchManager::PrepareLookup(uint32 uType, bool bStart, const CUInt128 pSearch->Go(); } return pSearch; - } catch (CIOException *ioe) { - AddDebugLogLine(false, _T("Exception in CSearchManager::PrepareLookup (IO error(%i))"), ioe->m_iCause); - ioe->Delete(); + } catch (CIOException *ex) { + AddDebugLogLine(false, _T("Exception in CSearchManager::PrepareLookup (IO error(%i))"), ex->m_iCause); + ex->Delete(); } catch (...) { AddDebugLogLine(false, _T("Exception in CSearchManager::PrepareLookup")); } diff --git a/srchybrid/kademlia/kademlia/Tag.h b/srchybrid/kademlia/kademlia/Tag.h index 79f77903..c5725084 100644 --- a/srchybrid/kademlia/kademlia/Tag.h +++ b/srchybrid/kademlia/kademlia/Tag.h @@ -81,7 +81,7 @@ namespace Kademlia return __ascii_stricmp(GetString(), psz); } - friend bool operator==(const CKadTagNameString& str1, LPCSTR const psz2) noexcept + friend bool operator==(const CKadTagNameString &str1, LPCSTR const psz2) noexcept { return (str1.Compare(psz2) == 0); } diff --git a/srchybrid/kademlia/kademlia/UDPFirewallTester.cpp b/srchybrid/kademlia/kademlia/UDPFirewallTester.cpp index c9a9d99f..2863df00 100644 --- a/srchybrid/kademlia/kademlia/UDPFirewallTester.cpp +++ b/srchybrid/kademlia/kademlia/UDPFirewallTester.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "stdafx.h" #include "kademlia/kademlia/UDPFirewallTester.h" #include "kademlia/kademlia/Kademlia.h" diff --git a/srchybrid/kademlia/kademlia/UDPFirewallTester.h b/srchybrid/kademlia/kademlia/UDPFirewallTester.h index bd5cd38f..49f9fd45 100644 --- a/srchybrid/kademlia/kademlia/UDPFirewallTester.h +++ b/srchybrid/kademlia/kademlia/UDPFirewallTester.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "kademlia/utils/UInt128.h" #include "kademlia/utils/KadUDPKey.h" diff --git a/srchybrid/kademlia/net/KademliaUDPListener.cpp b/srchybrid/kademlia/net/KademliaUDPListener.cpp index 0e4a892b..1c0981a3 100644 --- a/srchybrid/kademlia/net/KademliaUDPListener.cpp +++ b/srchybrid/kademlia/net/KademliaUDPListener.cpp @@ -1,6 +1,6 @@ /* Copyright (C)2003 Barry Dunne (https://www.emule-project.net) -Copyright (C)2007-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +Copyright (C)2007-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) This program is free software; you can redistribute it and/or @@ -1062,10 +1062,10 @@ void CKademliaUDPListener::Process_KADEMLIA2_SEARCH_KEY_REQ(const byte *pbyPacke CUInt128 uTarget; fileIO.ReadUInt128(uTarget); uint16 uStartPosition = fileIO.ReadUInt16(); - bool uRestrictive = ((uStartPosition & 0x8000) != 0); - uStartPosition &= 0x7FFF; + bool bRestrictive = ((uStartPosition & 0x8000) != 0); + uStartPosition &= ~0x8000; SSearchTerm *pSearchTerms = NULL; - if (uRestrictive) { + if (bRestrictive) { try { #if defined(_DEBUG) || defined(USE_DEBUG_DEVICE) s_pstrDbgSearchExpr = (thePrefs.GetDebugServerSearchesLevel() > 0) ? new CString() : NULL; @@ -1884,7 +1884,7 @@ void CKademliaUDPListener::SendPacket(const byte *pbyData, uint32 uLenData, uint AddTrackedOutPacket(uDestinationHost, pbyData[1]); theApp.clientudp->SendPacket(pPacket, ntohl(uDestinationHost), uDestinationPort, true , (uCryptTargetID != NULL) ? uCryptTargetID->GetData() : NULL - , true, targetUDPKey.GetKeyValue(theApp.GetPublicIP(false))); + , true, targetUDPKey.GetKeyValue(theApp.GetPublicIP())); } void CKademliaUDPListener::SendPacket(const byte *pbyData, uint32 uLenData, byte byOpcode, uint32 uDestinationHost, uint16 uDestinationPort, const CKadUDPKey &targetUDPKey, const CUInt128 *uCryptTargetID) @@ -1900,7 +1900,7 @@ void CKademliaUDPListener::SendPacket(const byte *pbyData, uint32 uLenData, byte AddTrackedOutPacket(uDestinationHost, byOpcode); theApp.clientudp->SendPacket(pPacket, ntohl(uDestinationHost), uDestinationPort, true , (uCryptTargetID != NULL) ? uCryptTargetID->GetData() : NULL - , true, targetUDPKey.GetKeyValue(theApp.GetPublicIP(false))); + , true, targetUDPKey.GetKeyValue(theApp.GetPublicIP())); } void CKademliaUDPListener::SendPacket(CSafeMemFile &pbyData, byte byOpcode, uint32 uDestinationHost, uint16 uDestinationPort, const CKadUDPKey &targetUDPKey, const CUInt128 *uCryptTargetID) @@ -1913,7 +1913,7 @@ void CKademliaUDPListener::SendPacket(CSafeMemFile &pbyData, byte byOpcode, uint AddTrackedOutPacket(uDestinationHost, byOpcode); theApp.clientudp->SendPacket(pPacket, htonl(uDestinationHost), uDestinationPort, true , (uCryptTargetID != NULL) ? uCryptTargetID->GetData() : NULL - , true, targetUDPKey.GetKeyValue(theApp.GetPublicIP(false))); + , true, targetUDPKey.GetKeyValue(theApp.GetPublicIP())); } bool CKademliaUDPListener::FindNodeIDByIP(CKadClientSearcher *pRequester, uint32 dwIP, uint16 nTCPPort, uint16 nUDPPort) diff --git a/srchybrid/kademlia/net/PacketTracking.cpp b/srchybrid/kademlia/net/PacketTracking.cpp index 300d3418..dd67ceda 100644 --- a/srchybrid/kademlia/net/PacketTracking.cpp +++ b/srchybrid/kademlia/net/PacketTracking.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "stdafx.h" #include "clientlist.h" #include "emule.h" diff --git a/srchybrid/kademlia/net/PacketTracking.h b/srchybrid/kademlia/net/PacketTracking.h index 81179f90..09d807c1 100644 --- a/srchybrid/kademlia/net/PacketTracking.h +++ b/srchybrid/kademlia/net/PacketTracking.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "kademlia/utils/UInt128.h" diff --git a/srchybrid/kademlia/routing/Contact.cpp b/srchybrid/kademlia/routing/Contact.cpp index e7128103..1e5df115 100644 --- a/srchybrid/kademlia/routing/Contact.cpp +++ b/srchybrid/kademlia/routing/Contact.cpp @@ -60,11 +60,15 @@ CContact::~CContact() CContact::CContact() : m_uClientID() - , m_cUDPKey() + , m_tExpires() + , m_uInUse() , m_uIp() + , m_uNetIp() , m_uTcpPort() , m_uUdpPort() , m_uVersion() + , m_byType(3) + , m_bGuiRefs() , m_bIPVerified() { InitContact(); @@ -73,11 +77,18 @@ CContact::CContact() CContact::CContact(const CUInt128 &uClientID, uint32 uIp, uint16 uUdpPort, uint16 uTcpPort, uint8 uVersion, const CKadUDPKey &cUDPKey, bool bIPVerified) : m_uClientID(uClientID) , m_cUDPKey(cUDPKey) + , m_tExpires() + , m_uInUse() , m_uIp(uIp) + , m_uNetIp(htonl(uIp)) , m_uTcpPort(uTcpPort) , m_uUdpPort(uUdpPort) , m_uVersion(uVersion) + , m_byType(3) + , m_bGuiRefs() , m_bIPVerified(bIPVerified) + , m_bReceivedHelloPacket() + , m_bBootstrapContact() { CKademlia::GetPrefs()->GetKadID(m_uDistance); m_uDistance.Xor(uClientID); @@ -87,11 +98,18 @@ CContact::CContact(const CUInt128 &uClientID, uint32 uIp, uint16 uUdpPort, uint1 CContact::CContact(const CUInt128 &uClientID, uint32 uIp, uint16 uUdpPort, uint16 uTcpPort, const CUInt128 &uTarget, uint8 uVersion, const CKadUDPKey &cUDPKey, bool bIPVerified) : m_uClientID(uClientID) , m_cUDPKey(cUDPKey) + , m_tExpires() + , m_uInUse() , m_uIp(uIp) + , m_uNetIp(htonl(uIp)) , m_uTcpPort(uTcpPort) , m_uUdpPort(uUdpPort) , m_uVersion(uVersion) + , m_byType(3) + , m_bGuiRefs() , m_bIPVerified(bIPVerified) + , m_bReceivedHelloPacket() + , m_bBootstrapContact() { m_uDistance.SetValue(uTarget); m_uDistance.Xor(uClientID); @@ -103,41 +121,29 @@ void CContact::Copy(const CContact &fromContact) ASSERT(!fromContact.m_bGuiRefs); // don't do this, if this is needed at some point, the code has to be adjusted before m_uClientID = fromContact.m_uClientID; m_uDistance = fromContact.m_uDistance; - m_uNetIp = fromContact.m_uNetIp; - m_uIp = fromContact.m_uIp; - m_uTcpPort = fromContact.m_uTcpPort; - m_uUdpPort = fromContact.m_uUdpPort; - m_uInUse = fromContact.m_uInUse; + m_cUDPKey = fromContact.m_cUDPKey; m_tLastTypeSet = fromContact.m_tLastTypeSet; m_tExpires = fromContact.m_tExpires; m_tCreated = fromContact.m_tCreated; - m_byType = fromContact.m_byType; + m_uInUse = fromContact.m_uInUse; + m_uIp = fromContact.m_uIp; + m_uNetIp = fromContact.m_uNetIp; + m_uTcpPort = fromContact.m_uTcpPort; + m_uUdpPort = fromContact.m_uUdpPort; m_uVersion = fromContact.m_uVersion; + m_byType = fromContact.m_byType; m_bGuiRefs = false; m_bIPVerified = fromContact.m_bIPVerified; - m_cUDPKey = fromContact.m_cUDPKey; m_bReceivedHelloPacket = fromContact.m_bReceivedHelloPacket; m_bBootstrapContact = fromContact.m_bBootstrapContact; } void CContact::InitContact() { - m_byType = 3; - m_tExpires = 0; m_tCreated = m_tLastTypeSet = time(NULL); - m_bGuiRefs = false; - m_uInUse = 0; - m_uNetIp = htonl(m_uIp); - m_bReceivedHelloPacket = false; - m_bBootstrapContact = false; } -void CContact::GetClientID(CUInt128 &uId) const -{ - uId.SetValue(m_uClientID); -} - -void CContact::GetClientID(CString &sId) const +void Kademlia::CContact::GetClientID(CString &sId) const { m_uClientID.ToHexString(sId); } @@ -149,32 +155,12 @@ void CContact::SetClientID(const CUInt128 &uClientID) m_uDistance.Xor(uClientID); } -void CContact::GetDistance(CUInt128 &uDistance) const -{ - uDistance.SetValue(m_uDistance); -} - -void CContact::GetDistance(CString &sDistance) const +void Kademlia::CContact::GetDistance(CString &sDistance) const { m_uDistance.ToBinaryString(sDistance); } -CUInt128 CContact::GetDistance() const -{ - return m_uDistance; -} - -uint32 CContact::GetIPAddress() const -{ - return m_uIp; -} - -uint32 CContact::GetNetIP() const -{ - return m_uNetIp; -} - -void CContact::GetIPAddress(CString &sIp) const +void Kademlia::CContact::GetIPAddress(CString &sIp) const { CMiscUtils::IPAddressToString(m_uIp, sIp); } @@ -188,41 +174,16 @@ void CContact::SetIPAddress(uint32 uIp) } } -uint16 CContact::GetTCPPort() const -{ - return m_uTcpPort; -} - void CContact::GetTCPPort(CString &sPort) const { sPort.Format(_T("%hu"), m_uTcpPort); } -void CContact::SetTCPPort(uint16 uPort) -{ - m_uTcpPort = uPort; -} - -uint16 CContact::GetUDPPort() const -{ - return m_uUdpPort; -} - void CContact::GetUDPPort(CString &sPort) const { sPort.Format(_T("%hu"), m_uUdpPort); } -void CContact::SetUDPPort(uint16 uPort) -{ - m_uUdpPort = uPort; -} - -byte CContact::GetType() const -{ - return m_byType; -} - void CContact::CheckingType() { if (time(NULL) - m_tLastTypeSet >= 10 && m_byType < 4) { @@ -243,7 +204,7 @@ void CContact::UpdateType() break; case 1: m_byType = 1; - m_tExpires = tNow + (unsigned)HR2S(1.5); + m_tExpires = tNow + (time_t)HR2S(1.5); break; default: m_byType = 0; @@ -274,80 +235,10 @@ void Kademlia::CContact::Expire() //mark contact for removal m_tExpires = 1; //the smallest non-zero } -CUInt128 CContact::GetClientID() const -{ - return m_uClientID; -} - -bool CContact::GetGuiRefs() const -{ - return m_bGuiRefs; -} - -void CContact::SetGuiRefs(bool bRefs) -{ - m_bGuiRefs = bRefs; -} - -bool CContact::InUse() const -{ - return (m_uInUse > 0); -} - -void CContact::IncUse() -{ - ++m_uInUse; -} - void CContact::DecUse() { if (m_uInUse) --m_uInUse; else ASSERT(0); -} - -time_t CContact::GetCreatedTime() const -{ - return m_tCreated; -} - -time_t CContact::GetExpireTime() const -{ - return m_tExpires; -} - -time_t CContact::GetLastTypeSet() const -{ - return m_tLastTypeSet; -} - -uint8 CContact::GetVersion() const -{ - return m_uVersion; -} - -void CContact::SetVersion(uint8 uVersion) -{ - m_uVersion = uVersion; -} - -CKadUDPKey CContact::GetUDPKey() const -{ - return m_cUDPKey; -} - -void CContact::SetUDPKey(const CKadUDPKey &cUDPKey) -{ - m_cUDPKey = cUDPKey; -} - -bool CContact::IsIpVerified() const -{ - return m_bIPVerified; -} - -void CContact::SetIpVerified(bool bIPVerified) -{ - m_bIPVerified = bIPVerified; } \ No newline at end of file diff --git a/srchybrid/kademlia/routing/Contact.h b/srchybrid/kademlia/routing/Contact.h index 2ecaa6f9..1098e975 100644 --- a/srchybrid/kademlia/routing/Contact.h +++ b/srchybrid/kademlia/routing/Contact.h @@ -49,53 +49,53 @@ namespace Kademlia CContact(); CContact(const CUInt128 &uClientID, uint32 uIp, uint16 uUdpPort, uint16 uTcpPort, uint8 uVersion, const CKadUDPKey &cUDPKey, bool bIPVerified); CContact(const CUInt128 &uClientID, uint32 uIp, uint16 uUdpPort, uint16 uTcpPort, const CUInt128 &uTarget, uint8 uVersion, const CKadUDPKey &cUDPKey, bool bIPVerified); - CContact(const CContact &k1) { Copy(k1); } - CContact& operator=(const CContact &k1) { Copy(k1); return *this; } + CContact(const CContact &k1) { Copy(k1); } + CContact& operator=(const CContact &k1) { Copy(k1); return *this; } - void GetClientID(CUInt128 &uId) const; - CUInt128 GetClientID() const; + void GetClientID(CUInt128 &uId) const { uId.SetValue(m_uClientID); } + CUInt128 GetClientID() const { return m_uClientID; } void GetClientID(CString &sId) const; void SetClientID(const CUInt128 &uClientID); - void GetDistance(CUInt128 &uDistance) const; + void GetDistance(CUInt128 &uDistance) const { uDistance.SetValue(m_uDistance); } void GetDistance(CString &sDistance) const; - CUInt128 GetDistance() const; - uint32 GetIPAddress() const; - uint32 GetNetIP() const; + CUInt128 GetDistance() const { return m_uDistance; } + uint32 GetIPAddress() const { return m_uIp; } + uint32 GetNetIP() const { return m_uNetIp; } void GetIPAddress(CString &sIp) const; void SetIPAddress(uint32 uIp); - uint16 GetTCPPort() const; + uint16 GetTCPPort() const { return m_uTcpPort; } void GetTCPPort(CString &sPort) const; - void SetTCPPort(uint16 uPort); - uint16 GetUDPPort() const; + void SetTCPPort(uint16 uPort) { m_uTcpPort = uPort; } + uint16 GetUDPPort() const { return m_uUdpPort; } void GetUDPPort(CString &sPort) const; - void SetUDPPort(uint16 uPort); - byte GetType() const; + void SetUDPPort(uint16 uPort) { m_uUdpPort = uPort; } + byte GetType() const { return m_byType; } void UpdateType(); void CheckingType(); - bool GetGuiRefs() const; - void SetGuiRefs(bool bRefs); - bool InUse() const; - void IncUse(); + bool GetGuiRefs() const { return m_bGuiRefs; } + void SetGuiRefs(bool bRefs) { m_bGuiRefs = bRefs; } + bool InUse() const { return (m_uInUse > 0); } + void IncUse() { ++m_uInUse; } void DecUse(); - uint8 GetVersion() const; - void SetVersion(uint8 uVersion); - time_t GetCreatedTime() const; - time_t GetExpireTime() const; - time_t GetLastTypeSet() const; + uint8 GetVersion() const { return m_uVersion; } + void SetVersion(uint8 uVersion) { m_uVersion = uVersion; } + time_t GetCreatedTime() const { return m_tCreated; } + time_t GetExpireTime() const { return m_tExpires; } + time_t GetLastTypeSet() const { return m_tLastTypeSet; } time_t GetLastSeen() const; void Expire(); - bool GetReceivedHelloPacket() const { return m_bReceivedHelloPacket; } - void SetReceivedHelloPacket() { m_bReceivedHelloPacket = true; } + bool GetReceivedHelloPacket() const { return m_bReceivedHelloPacket; } + void SetReceivedHelloPacket() { m_bReceivedHelloPacket = true; } - CKadUDPKey GetUDPKey() const; - void SetUDPKey(const CKadUDPKey &cUDPKey); - bool IsIpVerified() const; - void SetIpVerified(bool bIPVerified); + CKadUDPKey GetUDPKey() const { return m_cUDPKey; } + void SetUDPKey(const CKadUDPKey &cUDPKey) { m_cUDPKey = cUDPKey; } + bool IsIpVerified() const { return m_bIPVerified; } + void SetIpVerified(bool bIPVerified) { m_bIPVerified = bIPVerified; } // bootstrapcontact functions only used for GUI - bool IsBootstrapContact() const { return m_bBootstrapContact; } - void SetBootstrapContact() { m_bBootstrapContact = true; } + bool IsBootstrapContact() const { return m_bBootstrapContact; } + void SetBootstrapContact() { m_bBootstrapContact = true; } private: void InitContact(); // Common var initialization goes here diff --git a/srchybrid/kademlia/routing/RoutingBin.cpp b/srchybrid/kademlia/routing/RoutingBin.cpp index 7ca2e84c..88fd6612 100644 --- a/srchybrid/kademlia/routing/RoutingBin.cpp +++ b/srchybrid/kademlia/routing/RoutingBin.cpp @@ -215,11 +215,11 @@ void CRoutingBin::GetClosestTo(uint32 uMaxType, const CUInt128 &uTarget, uint32 if (bEmptyFirst) rmapResult.clear(); - // Return 0 since we have no entries. - if (m_listEntries.empty()) + // Return empty since we have no entries. + if (m_listEntries.empty() || !uMaxRequired) return; - // First put results in sort order for uTarget so we can insert them correctly. + // First put results in sorted by uTarget order so we can insert them correctly. // We don't care about max results at this time. for (ContactList::const_iterator itContact = m_listEntries.begin(); itContact != m_listEntries.end(); ++itContact) if ((*itContact)->GetType() <= uMaxType && (*itContact)->IsIpVerified()) { @@ -233,13 +233,14 @@ void CRoutingBin::GetClosestTo(uint32 uMaxType, const CUInt128 &uTarget, uint32 // Remove any extra results by least wanted first. while (rmapResult.size() > uMaxRequired) { + ContactMap::const_iterator it = --rmapResult.end(); // Dec in use count. if (bInUse) - (--rmapResult.end())->second->DecUse(); + it->second->DecUse(); // remove from results - rmapResult.erase(--rmapResult.end()); + rmapResult.erase(it); } - // Return result count to the caller. + // Return result to the caller. } void CRoutingBin::AdjustGlobalTracking(uint32 uIP, bool bIncrease) diff --git a/srchybrid/kademlia/routing/RoutingZone.cpp b/srchybrid/kademlia/routing/RoutingZone.cpp index 475bf38e..7b3aa4a5 100644 --- a/srchybrid/kademlia/routing/RoutingZone.cpp +++ b/srchybrid/kademlia/routing/RoutingZone.cpp @@ -1,6 +1,6 @@ /* Copyright (C)2003 Barry Dunne (https://www.emule-project.net) -Copyright (C)2007-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +Copyright (C)2007-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -167,92 +167,96 @@ void CRoutingZone::ReadFile(const CString &strSpecialNodesdate) ASSERT(0); return; } + CSafeBufferedFile file; + if (!file.Open(strSpecialNodesdate.IsEmpty() ? m_sFilename : strSpecialNodesdate, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, NULL)) { + DebugLogWarning(_T("Unable to read Kad file: %s"), (LPCTSTR)m_sFilename); + return; + } // Read in the saved contact list. try { - CSafeBufferedFile file; - CFileException fexp; - if (file.Open(strSpecialNodesdate.IsEmpty() ? m_sFilename : strSpecialNodesdate, CFile::modeRead | CFile::osSequentialScan | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - ::setvbuf(file.m_pStream, NULL, _IOFBF, 32768); - - // Get how many contacts in the saved list. - // NOTE: Older clients put the number of contacts here. - // Newer clients always have 0 here to prevent older clients from reading it. - uint32 uNumContacts = file.ReadUInt32(); - uint32 uVersion = 0; - if (uNumContacts == 0) { - if (file.GetLength() >= 8) { - uVersion = file.ReadUInt32(); - if (uVersion == 3) { - uint32 nBoostrapEdition = file.ReadUInt32(); - if (nBoostrapEdition == 1) { - // this is a special bootstrap-only nodes.dat, handle it in a separate reading function - ReadBootstrapNodesDat(file); - file.Close(); - return; - } + ::setvbuf(file.m_pStream, NULL, _IOFBF, 32768); + + // Get how many contacts in the saved list. + // NOTE: Older clients put the number of contacts here. + // Newer clients always have 0 here to prevent older clients from reading it. + uint32 uNumContacts = file.ReadUInt32(); + uint32 uVersion = 0; + if (uNumContacts == 0) { + if (file.GetLength() >= 8) { + uVersion = file.ReadUInt32(); + if (uVersion == 3) { + uint32 nBoostrapEdition = file.ReadUInt32(); + if (nBoostrapEdition == 1) { + // this is a special bootstrap-only nodes.dat, handle it in a separate reading function + ReadBootstrapNodesDat(file); + file.Close(); + return; } - if (uVersion >= 1 && uVersion <= 3) // those version we know, others we ignore - uNumContacts = file.ReadUInt32(); + } + if (uVersion >= 1 && uVersion <= 3) // those version we know, others we ignore + uNumContacts = file.ReadUInt32(); + } else + AddDebugLogLine(false, GetResString(IDS_ERR_KADCONTACTS)); + } + if (uNumContacts != 0 && uNumContacts * 25ull <= (file.GetLength() - file.GetPosition())) { + // Hide contact list in the GUI + theApp.emuledlg->kademliawnd->StopUpdateContacts(); + + bool bDoHaveVerifiedContacts = false; + uint32 uValidContacts = 0; + CUInt128 uID; + while (uNumContacts--) { + file.ReadUInt128(uID); + uint32 uIP = file.ReadUInt32(); + uint16 uUDPPort = file.ReadUInt16(); + uint16 uTCPPort = file.ReadUInt16(); + + byte byType; + uint8 uContactVersion; + if (uVersion >= 1) { + byType = 0; + uContactVersion = file.ReadUInt8(); + } else { + byType = file.ReadUInt8(); + uContactVersion = 0; + } + + bool bVerified; + CKadUDPKey kadUDPKey; + if (uVersion >= 2) { + kadUDPKey.ReadFromFile(file); + bVerified = file.ReadUInt8() != 0; + if (bVerified) + bDoHaveVerifiedContacts = true; } else - AddDebugLogLine(false, GetResString(IDS_ERR_KADCONTACTS)); - } - if (uNumContacts != 0 && uNumContacts * 25ull <= (file.GetLength() - file.GetPosition())) { - // Hide contact list in the GUI - theApp.emuledlg->kademliawnd->StopUpdateContacts(); - - bool bDoHaveVerifiedContacts = false; - uint32 uValidContacts = 0; - CUInt128 uID; - while (uNumContacts--) { - file.ReadUInt128(uID); - uint32 uIP = file.ReadUInt32(); - uint16 uUDPPort = file.ReadUInt16(); - uint16 uTCPPort = file.ReadUInt16(); - byte byType = 0; - - uint8 uContactVersion = 0; - if (uVersion >= 1) - uContactVersion = file.ReadUInt8(); - else - byType = file.ReadUInt8(); - - CKadUDPKey kadUDPKey; - bool bVerified = false; - if (uVersion >= 2) { - kadUDPKey.ReadFromFile(file); - bVerified = file.ReadUInt8() != 0; - if (bVerified) - bDoHaveVerifiedContacts = true; - } - // IP Appears valid - if (byType < 4) { - uint32 uhostIP = htonl(uIP); - if (IsGoodIPPort(uhostIP, uUDPPort)) { - if (theApp.ipfilter->IsFiltered(uhostIP)) { - if (thePrefs.GetLogFilteredIPs()) - AddDebugLogLine(false, _T("Ignored kad contact (IP=%s:%u)--read known.dat -- - IP filter (%s)"), (LPCTSTR)ipstr(uhostIP), uUDPPort, (LPCTSTR)theApp.ipfilter->GetLastHit()); - } else if (uUDPPort == 53 && uContactVersion <= KADEMLIA_VERSION5_48a) { /*No DNS Port without encryption*/ - if (thePrefs.GetLogFilteredIPs()) - AddDebugLogLine(false, _T("Ignored kad contact (IP=%s:%u)--read known.dat"), (LPCTSTR)ipstr(uhostIP), uUDPPort); - } else { - // This was not a dead contact, Inc counter if add was successful - if (AddUnfiltered(uID, uIP, uUDPPort, uTCPPort, uContactVersion, kadUDPKey, bVerified, false, true, false)) - ++uValidContacts; - } + bVerified = false; + // IP Appears valid + if (byType < 4) { + uint32 uhostIP = htonl(uIP); + if (IsGoodIPPort(uhostIP, uUDPPort)) { + if (theApp.ipfilter->IsFiltered(uhostIP)) { + if (thePrefs.GetLogFilteredIPs()) + AddDebugLogLine(false, _T("Ignored kad contact (IP=%s:%u)--read nodes.dat -- - IP filter (%s)"), (LPCTSTR)ipstr(uhostIP), uUDPPort, (LPCTSTR)theApp.ipfilter->GetLastHit()); + } else if (uUDPPort == 53 && uContactVersion <= KADEMLIA_VERSION5_48a) { /*No DNS Port without encryption*/ + if (thePrefs.GetLogFilteredIPs()) + AddDebugLogLine(false, _T("Ignored kad contact (IP=%s:%u)--read nodes.dat"), (LPCTSTR)ipstr(uhostIP), uUDPPort); + } else { + // This was not a dead contact, Inc counter if add was successful + if (AddUnfiltered(uID, uIP, uUDPPort, uTCPPort, uContactVersion, kadUDPKey, bVerified, false, true, false)) + ++uValidContacts; } } } - AddLogLine(false, GetResString(IDS_KADCONTACTSREAD), uValidContacts); - if (!bDoHaveVerifiedContacts) { - DebugLogWarning(_T("No verified contacts found in nodes.dat - might be an old file version. Setting all contacts verified for this time to speed up Kad bootstrapping")); - SetAllContactsVerified(); - } } - file.Close(); - } else - DebugLogWarning(_T("Unable to read Kad file: %s"), (LPCTSTR)m_sFilename); - } catch (CFileException *e) { - e->Delete(); + AddLogLine(false, GetResString(IDS_KADCONTACTSREAD), uValidContacts); + if (!bDoHaveVerifiedContacts) { + DebugLogWarning(_T("No verified contacts found in nodes.dat - might be an old file version. Setting all contacts verified for this time to speed up Kad bootstrapping")); + SetAllContactsVerified(); + } + } + file.Close(); + } catch (CFileException *ex) { + ex->Delete(); DebugLogError(_T("CFileException in CRoutingZone::readFile")); } // Show contact list in GUI @@ -294,7 +298,7 @@ void CRoutingZone::ReadBootstrapNodesDat(CFileDataIO &file) } else if (uContactVersion > 1) { // only kad2 nodes // we want 50 nodes closest to our own ID (provides randomness between different users and // gives good chances to bootstrap with close Nodes as a nice start for our routing table) - CUInt128 uDistance = uMe; + CUInt128 uDistance(uMe); uDistance.Xor(uID); ++uValidContacts; // don't bother if we already have 50 and the farthest distance is smaller than this contact @@ -342,40 +346,39 @@ void CRoutingZone::WriteFile() DebugLogWarning(_T("Skipped storing nodes.dat, because we have an unfinished bootstrap of the nodes.dat version and no contacts in our routing table")); return; } + + CSafeBufferedFile file; + if (!file.Open(m_sFilename, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, NULL)) { + DebugLogError(_T("Unable to store Kad file: %s"), (LPCTSTR)m_sFilename); + return; + } + // Write the saved contact list. try { - // Write a saved contact list. - CSafeBufferedFile file; - CFileException fexp; - if (file.Open(m_sFilename, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - ::setvbuf(file.m_pStream, NULL, _IOFBF, 32768); - - // The bootstrap method gets a very nice sample of contacts to save. - ContactArray listContacts; - GetBootstrapContacts(listContacts, 200); - // Start file with 0 to prevent older clients from reading it. - file.WriteUInt32(0); - // Now tag it with a version which happens to be 2 (1 till 0.48a). - file.WriteUInt32(2); - // file.WriteUInt32(0) // if we would use version >=3, this would mean that this is a normal nodes.dat - file.WriteUInt32((uint32)listContacts.size()); - for (ContactArray::const_iterator itContact = listContacts.begin(); itContact != listContacts.end(); ++itContact) { - CUInt128 uID; - const CContact &rContact(**itContact); - rContact.GetClientID(uID); - file.WriteUInt128(uID); - file.WriteUInt32(rContact.GetIPAddress()); - file.WriteUInt16(rContact.GetUDPPort()); - file.WriteUInt16(rContact.GetTCPPort()); - file.WriteUInt8(rContact.GetVersion()); - rContact.GetUDPKey().StoreToFile(file); - file.WriteUInt8(static_cast(rContact.IsIpVerified())); - } - file.Close(); - AddDebugLogLine(false, _T("Wrote %ld contact%s to file."), listContacts.size(), ((listContacts.size() == 1) ? _T("") : _T("s"))); - } else - DebugLogError(_T("Unable to store Kad file: %s"), (LPCTSTR)m_sFilename); - } catch (CFileException *e) { - e->Delete(); + ::setvbuf(file.m_pStream, NULL, _IOFBF, 32768); + + // The bootstrap method gets a very nice sample of contacts to save. + ContactArray listContacts; + GetBootstrapContacts(listContacts, 200); + // Start file with 0 to prevent older clients from reading it. + file.WriteUInt32(0); + // Now tag it with a version which happens to be 2 (1 till 0.48a). + file.WriteUInt32(2); + // file.WriteUInt32(0) // if we would use version >=3, this would mean that this is a normal nodes.dat + file.WriteUInt32((uint32)listContacts.size()); + for (ContactArray::const_iterator itContact = listContacts.begin(); itContact != listContacts.end(); ++itContact) { + const CContact &contact(**itContact); + file.WriteUInt128(contact.GetClientID()); + file.WriteUInt32(contact.GetIPAddress()); + file.WriteUInt16(contact.GetUDPPort()); + file.WriteUInt16(contact.GetTCPPort()); + file.WriteUInt8(contact.GetVersion()); + contact.GetUDPKey().StoreToFile(file); + file.WriteUInt8(static_cast(contact.IsIpVerified())); + } + file.Close(); + AddDebugLogLine(false, _T("Wrote %ld contact%s to file."), listContacts.size(), ((listContacts.size() == 1) ? _T("") : _T("s"))); + } catch (CFileException *ex) { + ex->Delete(); AddDebugLogLine(false, _T("CFileException in CRoutingZone::writeFile")); } } @@ -384,48 +387,46 @@ void CRoutingZone::DbgWriteBootstrapFile() { #ifdef _BOOTSTRAPNODESDAT DebugLogWarning(_T("Writing special bootstrap nodes.dat - not intended for normal use")); + CSafeBufferedFile file; + if (!file.Open(m_sFilename, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, NULL)) { + DebugLogError(_T("Unable to store bootstrap file: %s"), (LPCTSTR)m_sFilename); + return; + } + // Write the saved contact list. try { - // Write a saved contact list. - CUInt128 uID; - CSafeBufferedFile file; - CFileException fexp; - if (file.Open(m_sFilename, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary | CFile::shareDenyWrite, &fexp)) { - ::setvbuf(file.m_pStream, NULL, _IOFBF, 32768); - - // The bootstrap method gets a very nice sample of contacts to save. - ContactMap mapContacts; - CUInt128 uRandom(CUInt128(0ul), 0); - CUInt128 uDistance = uRandom; - uDistance.Xor(uMe); - GetClosestTo(2, uRandom, uDistance, 1200, mapContacts, false, false); - // filter out Kad1 nodes - for (ContactMap::const_iterator itContactMap = mapContacts.begin(); itContactMap != mapContacts.end();) { - ContactMap::const_iterator itCurContactMap = itContactMap++; - const CContact *pContact = itCurContactMap->second; - if (pContact->GetVersion() <= 1) - mapContacts.erase(itCurContactMap); - } - // Start file with 0 to prevent older clients from reading it. - file.WriteUInt32(0); - // Now tag it with a version which happens to be 2 (1 till 0.48a). - file.WriteUInt32(3); - file.WriteUInt32(1); // if we would use version >=3, this would mean that this is not a normal nodes.dat - file.WriteUInt32((uint32)mapContacts.size()); - for (ContactMap::const_iterator itContactMap = mapContacts.begin(); itContactMap != mapContacts.end(); ++itContactMap) { - const CContact *pContact = itContactMap->second; - pContact->GetClientID(uID); - file.WriteUInt128(uID); - file.WriteUInt32(pContact->GetIPAddress()); - file.WriteUInt16(pContact->GetUDPPort()); - file.WriteUInt16(pContact->GetTCPPort()); - file.WriteUInt8(pContact->GetVersion()); - } - file.Close(); - AddDebugLogLine(false, _T("Wrote %ld contact to bootstrap file."), mapContacts.size()); - } else - DebugLogError(_T("Unable to store Kad file: %s"), (LPCTSTR)m_sFilename); - } catch (CFileException *e) { - e->Delete(); + ::setvbuf(file.m_pStream, NULL, _IOFBF, 32768); + ContactMap mapContacts; + // filter out Kad1 nodes and null IDs + for (ContactMap::const_iterator itContactMap = mapContacts.begin(); itContactMap != mapContacts.end();) { + ContactMap::const_iterator itCurContactMap = itContactMap++; + const CContact *pContact = itCurContactMap->second; + if (pContact->GetClientID() == 0 || pContact->GetVersion() < KADEMLIA_VERSION2_47a) + mapContacts.erase(itCurContactMap); + } + + // The bootstrap method gets a very nice sample of contacts to save. + CUInt128 uRandom(CUInt128(0ul), 0); + CUInt128 uDistance = uRandom; + uDistance.Xor(uMe); + GetClosestTo(2, uRandom, uDistance, 1200, mapContacts, false, false); + // Start file with 0 to prevent older clients from reading it. + file.WriteUInt32(0); + // Now tag it with a version which happens to be 2 (1 till 0.48a). + file.WriteUInt32(3); + file.WriteUInt32(1); // if we would use version >=3, this would mean that this is not a normal nodes.dat + file.WriteUInt32((uint32)mapContacts.size()); + for (ContactMap::const_iterator itContactMap = mapContacts.begin(); itContactMap != mapContacts.end(); ++itContactMap) { + const CContact &contact = *itContactMap->second; + file.WriteUInt128(contact.GetClientID()); + file.WriteUInt32(contact.GetIPAddress()); + file.WriteUInt16(contact.GetUDPPort()); + file.WriteUInt16(contact.GetTCPPort()); + file.WriteUInt8(contact.GetVersion()); + } + file.Close(); + AddDebugLogLine(false, _T("Wrote %ld contact to bootstrap file."), mapContacts.size()); + } catch (CFileException *ex) { + ex->Delete(); AddDebugLogLine(false, _T("CFileException in CRoutingZone::writeFile")); } #endif @@ -493,8 +494,8 @@ bool CRoutingZone::Add(CContact *pContact, bool &bUpdate, bool &bOutIPVerified) CContact *pContactUpdate = m_pBin->GetContact(pContact->GetClientID()); if (pContactUpdate) { if (bUpdate) { - if (pContactUpdate->GetUDPKey().GetKeyValue(theApp.GetPublicIP(false)) != 0 - && pContactUpdate->GetUDPKey().GetKeyValue(theApp.GetPublicIP(false)) != pContact->GetUDPKey().GetKeyValue(theApp.GetPublicIP(false))) + if (pContactUpdate->GetUDPKey().GetKeyValue(theApp.GetPublicIP()) != 0 + && pContactUpdate->GetUDPKey().GetKeyValue(theApp.GetPublicIP()) != pContact->GetUDPKey().GetKeyValue(theApp.GetPublicIP())) { // if our existing contact has a UDPSender-Key (which should be the case for all > = 0.49a clients) // except if our IP has changed recently, we demand that the key is the same as the key we received @@ -502,7 +503,7 @@ bool CRoutingZone::Add(CContact *pContact, bool &bUpdate, bool &bOutIPVerified) // hijack this entry DebugLogWarning(_T("Kad: Sender (%s) tried to update contact entry but failed to provide the proper sender key (Sent Empty: %s) for the entry (%s) - denying update") , (LPCTSTR)ipstr(pContact->GetNetIP()) - , pContact->GetUDPKey().GetKeyValue(theApp.GetPublicIP(false)) == 0 ? _T("Yes") : _T("No") + , pContact->GetUDPKey().GetKeyValue(theApp.GetPublicIP()) == 0 ? _T("Yes") : _T("No") , (LPCTSTR)ipstr(pContactUpdate->GetNetIP())); bUpdate = false; } else if (pContactUpdate->GetVersion() >= KADEMLIA_VERSION1_46c && pContactUpdate->GetVersion() < KADEMLIA_VERSION6_49aBETA @@ -530,7 +531,7 @@ bool CRoutingZone::Add(CContact *pContact, bool &bUpdate, bool &bOutIPVerified) #ifdef _DEBUG // just for outlining, get removed anyway //debug logging stuff - remove later - if (pContact->GetUDPKey().GetKeyValue(theApp.GetPublicIP(false)) == 0) { + if (pContact->GetUDPKey().GetKeyValue(theApp.GetPublicIP()) == 0) { if (pContact->GetVersion() >= KADEMLIA_VERSION6_49aBETA && pContact->GetType() < 2) AddDebugLogLine(DLP_LOW, false, _T("Updating > 0.49a + type < 2 contact without valid key stored %s"), (LPCTSTR)ipstr(pContact->GetNetIP())); } else @@ -610,9 +611,9 @@ CContact* CRoutingZone::GetRandomContact(uint32 nMaxType, uint32 nMinKadVersion) if (IsLeaf()) return m_pBin->GetRandomContact(nMaxType, nMinKadVersion); - uint32 nZone = rand() & 1; + int nZone = rand() & 1; CContact *pContact = m_pSubZones[nZone]->GetRandomContact(nMaxType, nMinKadVersion); - return (pContact != NULL) ? pContact : m_pSubZones[static_cast(nZone != 1)]->GetRandomContact(nMaxType, nMinKadVersion); + return (pContact != NULL) ? pContact : m_pSubZones[nZone ^ 1]->GetRandomContact(nMaxType, nMinKadVersion); } void CRoutingZone::GetClosestTo(uint32 uMaxType, const CUInt128 &uTarget, const CUInt128 &uDistance, uint32 uMaxRequired, ContactMap &rmapResult, bool bEmptyFirst, bool bInUse) const @@ -728,11 +729,6 @@ uint32 CRoutingZone::Consolidate() return uMergeCount; } -bool CRoutingZone::IsLeaf() const -{ - return (m_pBin != NULL); -} - CRoutingZone* CRoutingZone::GenSubZone(int iSide) { CUInt128 uNewIndex(m_uZoneIndex); @@ -749,11 +745,6 @@ void CRoutingZone::StartTimer() CKademlia::AddEvent(this); } -void CRoutingZone::StopTimer() -{ - CKademlia::RemoveEvent(this); -} - bool CRoutingZone::OnBigTimer() { if (IsLeaf() && (m_uZoneIndex < KK || m_uLevel < KBASE || m_pBin->GetRemaining() >= (K*.8))) { @@ -772,7 +763,7 @@ uint32 CRoutingZone::EstimateCount() if (!IsLeaf()) return 0; if (m_uLevel < KBASE) - return (uint32)(pow(2.0F, (int)m_uLevel)*K); + return (uint32)(pow(2.0f, (int)m_uLevel) * K); CRoutingZone *pCurZone = m_pSuperZone->m_pSuperZone->m_pSuperZone; // Find out how full this part of the tree is. float fModify = pCurZone->GetNumContacts() / (K * 2.0f); @@ -816,7 +807,7 @@ void CRoutingZone::OnSmallTimer() m_pBin->GetEntries(listEntries); for (ContactArray::const_iterator itContact = listEntries.begin(); itContact != listEntries.end(); ++itContact) { pContact = *itContact; - if (pContact->GetType() == 4) { + if (pContact->GetType() == 4) if (((pContact->m_tExpires > 0) && (pContact->m_tExpires <= tNow))) { if (!pContact->InUse()) { m_pBin->RemoveContact(pContact); @@ -824,17 +815,17 @@ void CRoutingZone::OnSmallTimer() } continue; } - } + if (pContact->m_tExpires == 0) pContact->m_tExpires = tNow; } pContact = m_pBin->GetOldest(); - if (pContact != NULL) { + if (pContact != NULL) if (pContact->m_tExpires >= tNow || pContact->GetType() == 4) { m_pBin->PushToBottom(pContact); pContact = NULL; } - } + if (pContact != NULL) { pContact->CheckingType(); if (pContact->GetVersion() >= KADEMLIA_VERSION6_49aBETA) { @@ -898,13 +889,11 @@ uint32 CRoutingZone::GetBootstrapContacts(ContactArray &rlistResult, uint32 uMax try { ContactArray top; TopDepth(LOG_BASE_EXPONENT, top); - if (!top.empty()) { - for (ContactArray::const_iterator itContact = top.begin(); itContact != top.end(); ++itContact) { + if (!top.empty()) + for (ContactArray::const_iterator itContact = top.begin(); uRetVal < uMaxRequired && itContact != top.end(); ++itContact) { rlistResult.push_back(*itContact); - if (++uRetVal >= uMaxRequired) - break; + ++uRetVal; } - } } catch (...) { AddDebugLogLine(false, _T("Exception in CRoutingZone::getBoostStrapContacts")); } @@ -938,21 +927,19 @@ void CRoutingZone::SetAllContactsVerified() bool CRoutingZone::IsAcceptableContact(const CContact *pToCheck) const { - // Check if we know a contact with the same ID or IP but not matching IP/ID and other limitations, similar checks like when adding a node to the table except allowing duplicates - // we use this to check KADEMLIA_RES routing answers on searches + // Check if we know a contact with the same ID or IP but not matching IP/ID and other limitations + // This is similar to adding a node to the table except alloweding duplicates + // We use this to check KADEMLIA_RES routing answers on searches if (pToCheck->GetVersion() < KADEMLIA_VERSION2_47a) // No Kad1 Contacts allowed return false; CContact *pDuplicate = GetContact(pToCheck->GetClientID()); if (pDuplicate != NULL) { - if (pDuplicate->IsIpVerified() - && (pDuplicate->GetIPAddress() != pToCheck->GetIPAddress() || pDuplicate->GetUDPPort() != pToCheck->GetUDPPort())) - { - // already existing verified node with different IP - return false; - } - return true; // node exists already in our routing table, that's fine + //false - a verified node with different IP exists + //true - node exists already in our routing table, that's fine + return !pDuplicate->IsIpVerified() + || (pDuplicate->GetIPAddress() == pToCheck->GetIPAddress() && pDuplicate->GetUDPPort() == pToCheck->GetUDPPort()); } - // if the node is not yet known, check if we out IP limitations would hit + // if the node is not yet known, check if IP limitations would hit #ifdef _DEBUG return CRoutingBin::CheckGlobalIPLimits(pToCheck->GetIPAddress(), pToCheck->GetUDPPort(), true); #else diff --git a/srchybrid/kademlia/routing/RoutingZone.h b/srchybrid/kademlia/routing/RoutingZone.h index 34ad00e7..d9718ebf 100644 --- a/srchybrid/kademlia/routing/RoutingZone.h +++ b/srchybrid/kademlia/routing/RoutingZone.h @@ -91,7 +91,7 @@ namespace Kademlia void DbgWriteBootstrapFile(); void WriteFile(); - bool IsLeaf() const; + bool IsLeaf() const { return (m_pBin != NULL); } bool CanSplit() const; // Returns all contacts from this zone tree that are no deeper than *depth* from the current zone. void TopDepth(int iDepth, ContactArray &listResult, bool bEmptyFirst = true); @@ -100,7 +100,7 @@ namespace Kademlia void RandomBin(ContactArray &listResult, bool bEmptyFirst = true); void Split(); void StartTimer(); - void StopTimer(); + void StopTimer() { CKademlia::RemoveEvent(this); } void RandomLookup(); void SetAllContactsVerified(); /** diff --git a/srchybrid/kademlia/utils/KadClientSearcher.h b/srchybrid/kademlia/utils/KadClientSearcher.h index 637af63f..8f189495 100644 --- a/srchybrid/kademlia/utils/KadClientSearcher.h +++ b/srchybrid/kademlia/utils/KadClientSearcher.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once // Interface class for non-kad classes which want to do client searches namespace Kademlia diff --git a/srchybrid/kademlia/utils/KadUDPKey.h b/srchybrid/kademlia/utils/KadUDPKey.h index 30aedd48..bf65a2e3 100644 --- a/srchybrid/kademlia/utils/KadUDPKey.h +++ b/srchybrid/kademlia/utils/KadUDPKey.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "SafeFile.h" diff --git a/srchybrid/kademlia/utils/LookupHistory.cpp b/srchybrid/kademlia/utils/LookupHistory.cpp index 18ed8466..7f23dee2 100644 --- a/srchybrid/kademlia/utils/LookupHistory.cpp +++ b/srchybrid/kademlia/utils/LookupHistory.cpp @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2010-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2010-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #include "StdAfx.h" #include "emule.h" #include "kademlia/kademlia/search.h" diff --git a/srchybrid/kademlia/utils/LookupHistory.h b/srchybrid/kademlia/utils/LookupHistory.h index 1c5e9ff8..4d1289ec 100644 --- a/srchybrid/kademlia/utils/LookupHistory.h +++ b/srchybrid/kademlia/utils/LookupHistory.h @@ -1,5 +1,5 @@ //this file is part of eMule -//Copyright (C)2002-2023 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) +//Copyright (C)2002-2024 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / https://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License @@ -14,7 +14,6 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - #pragma once #include "kademlia/routing/Maps.h" #include "kademlia/kademlia/Tag.h" diff --git a/srchybrid/lang/ar_AE.rc b/srchybrid/lang/ar_AE.rc index 8b688fce..6f3ee5d3 100644 --- a/srchybrid/lang/ar_AE.rc +++ b/srchybrid/lang/ar_AE.rc @@ -819,7 +819,7 @@ BEGIN IDS_NEWMSG "رسالة جديدة من '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "فقط في نفس الجدول" IDS_LOG_ULDL_EVENTS "رفع\تحميل حدث" - IDS_PEERCACHE_ENABLED "شركة الانترنت الخاصة بك تدعم تقنية البييركاشي, السماح بتحميل الكاشي!" +// IDS_PEERCACHE_ENABLED "شركة الانترنت الخاصة بك تدعم تقنية البييركاشي, السماح بتحميل الكاشي!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "اسمح للمستخدم باضافتك كصديق." IDS_SOURCESWAPBLOCKED "التبادل حجز" IDS_TRICKLING "الوقوف دون حدث" @@ -1607,9 +1607,9 @@ BEGIN "فعل هذا الاختيار لبدأ ايمول عند بدأ الويندوز. [معطل تلقائياً]" IDS_KAD_WAITCBK "انتظر الرد من Kad " IDS_KAD_TOOMANDYKADLKPS "بحوث Kad كثيرة" - IDS_PCDS_CLIENTWAIT "انتظار العميل" - IDS_PCDS_CACHEWAIT "انتظار الكاتشي" - IDS_CACHE "وhjad" +// IDS_PCDS_CLIENTWAIT "انتظار العميل" +// IDS_PCDS_CACHEWAIT "انتظار الكاتشي" +// IDS_CACHE "وhjad" IDS_INDEXED "جدول" IDS_KADINFO_SRC "\tمصدر: %u\r\n" IDS_KADINFO_KEYW "\tمفتاح الكلمة: %u\r\n" diff --git a/srchybrid/lang/ar_AE.vcxproj b/srchybrid/lang/ar_AE.vcxproj index 44e9e626..d7f26275 100644 --- a/srchybrid/lang/ar_AE.vcxproj +++ b/srchybrid/lang/ar_AE.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/ba_BA.rc b/srchybrid/lang/ba_BA.rc index 1716840b..770ed17a 100644 --- a/srchybrid/lang/ba_BA.rc +++ b/srchybrid/lang/ba_BA.rc @@ -1552,7 +1552,7 @@ BEGIN IDS_NEWMSG "'%s' (IP:%s)-ren mezu berria" IDS_PREF_STARTNEXTFILECATONLY "kategoria berdinean soilik" IDS_LOG_ULDL_EVENTS "Igoera/Jaitsiera gertaerak log fitxategian gorde" - IDS_PEERCACHE_ENABLED "Zure Interneterako Zerbitzu Hornitzaileak (ISP) PeerCache onartzen du, cache-a aktibatuta!" +// IDS_PEERCACHE_ENABLED "Zure Interneterako Zerbitzu Hornitzaileak (ISP) PeerCache onartzen du, cache-a aktibatuta!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Erabiltzaileak baimendu lagun bezala gehitu zaitzaten." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Lehenik eta behin, aurrikuspenerako beharrezko zatiak jaitsi" END @@ -1594,9 +1594,9 @@ BEGIN "eMule exekutatu Windows hasterakoan. (Jatorriz desaktibatuta)" IDS_KAD_WAITCBK "Kad erantzuna itxaroten" IDS_KAD_TOOMANDYKADLKPS "Kad bilaketa gehiegi" - IDS_PCDS_CLIENTWAIT "Bezeroaren itxaronaldia" - IDS_PCDS_CACHEWAIT "Cache-aren itxaronaldia" - IDS_CACHE "Cache-a" +// IDS_PCDS_CLIENTWAIT "Bezeroaren itxaronaldia" +// IDS_PCDS_CACHEWAIT "Cache-aren itxaronaldia" +// IDS_CACHE "Cache-a" IDS_INDEXED "Indexatuta" IDS_KADINFO_SRC "\tIturria: %u\r\n" IDS_KADINFO_KEYW "\tHitz Gakoa: %u\r\n" diff --git a/srchybrid/lang/ba_BA.vcxproj b/srchybrid/lang/ba_BA.vcxproj index cd44b4c8..ae31b7cf 100644 --- a/srchybrid/lang/ba_BA.vcxproj +++ b/srchybrid/lang/ba_BA.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/bg_BG.rc b/srchybrid/lang/bg_BG.rc index 0adf8dfa..2b0d8397 100644 --- a/srchybrid/lang/bg_BG.rc +++ b/srchybrid/lang/bg_BG.rc @@ -819,7 +819,7 @@ BEGIN IDS_NEWMSG "Съобщение от '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "само в същата категория" IDS_LOG_ULDL_EVENTS "Отчет за качване/сваляне" - IDS_PEERCACHE_ENABLED "Вашият ISP поддържа технологията PeerCache, разрешете сваляне от кеша!" +// IDS_PEERCACHE_ENABLED "Вашият ISP поддържа технологията PeerCache, разрешете сваляне от кеша!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Разрешавам потребителите да ме добавят като приятел" IDS_SOURCESWAPBLOCKED "Прехвърли блокираните" IDS_TRICKLING "В готовност" @@ -1608,9 +1608,9 @@ BEGIN "Стартирай eMule заедно с Windows. (По подразбиране: Изкл.)" IDS_KAD_WAITCBK "Изчаквай отговор от Kad" IDS_KAD_TOOMANDYKADLKPS "Твърде много търсения в Kad" - IDS_PCDS_CLIENTWAIT "Изчакване на клиента" - IDS_PCDS_CACHEWAIT "Изчакване на кеша" - IDS_CACHE "Кеш" +// IDS_PCDS_CLIENTWAIT "Изчакване на клиента" +// IDS_PCDS_CACHEWAIT "Изчакване на кеша" +// IDS_CACHE "Кеш" IDS_INDEXED "Индексирани" IDS_KADINFO_SRC "\tИзточник: %u\r\n" IDS_KADINFO_KEYW "\tКлюч. фраза: %u\r\n" diff --git a/srchybrid/lang/bg_BG.vcxproj b/srchybrid/lang/bg_BG.vcxproj index 5f671524..1226f893 100644 --- a/srchybrid/lang/bg_BG.vcxproj +++ b/srchybrid/lang/bg_BG.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/ca_ES.rc b/srchybrid/lang/ca_ES.rc index 05950284..5febbd54 100644 --- a/srchybrid/lang/ca_ES.rc +++ b/srchybrid/lang/ca_ES.rc @@ -1544,7 +1544,7 @@ BEGIN IDS_NEWMSG "Nou missatge procedent de '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "només a la mateixa categoria" IDS_LOG_ULDL_EVENTS "Registra els esdeveniments de càrrega/descàrrega" - IDS_PEERCACHE_ENABLED "El teu ISP suporta la tecnologia de Cau-entre-Iguals (PeerCache), s'activarà la cau de descàrregues!" +// IDS_PEERCACHE_ENABLED "El teu ISP suporta la tecnologia de Cau-entre-Iguals (PeerCache), s'activarà la cau de descàrregues!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permet a l'usuari que us afegeixi com a amic." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Baixa primer les parts que calen per a previsualitzar" END @@ -1586,9 +1586,9 @@ BEGIN "Activa això per fer que l'eMule s'executi quan inicieu windows." IDS_KAD_WAITCBK "Espera el retorn de la crida Kad" IDS_KAD_TOOMANDYKADLKPS "Hi ha massa resolucions Kad" - IDS_PCDS_CLIENTWAIT "Espera del client" - IDS_PCDS_CACHEWAIT "Espera de la cau" - IDS_CACHE "Cau" +// IDS_PCDS_CLIENTWAIT "Espera del client" +// IDS_PCDS_CACHEWAIT "Espera de la cau" +// IDS_CACHE "Cau" IDS_INDEXED "Indexat" IDS_KADINFO_SRC "\tFont: %u\r\n" IDS_KADINFO_KEYW "\tParaula clau: %u\r\n" diff --git a/srchybrid/lang/ca_ES.vcxproj b/srchybrid/lang/ca_ES.vcxproj index 35df62c4..49bfd41d 100644 --- a/srchybrid/lang/ca_ES.vcxproj +++ b/srchybrid/lang/ca_ES.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/cz_CZ.rc b/srchybrid/lang/cz_CZ.rc index 5b0c5539..5bb43585 100644 --- a/srchybrid/lang/cz_CZ.rc +++ b/srchybrid/lang/cz_CZ.rc @@ -1542,7 +1542,7 @@ BEGIN IDS_NEWMSG "Zpráva od '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "pouze ve stejné kategorii" IDS_LOG_ULDL_EVENTS "Logovat události uploadu/downloadu" - IDS_PEERCACHE_ENABLED "Váš ISP podporuje technologii PeerCache, která umožňuje cashovat downloady!" +// IDS_PEERCACHE_ENABLED "Váš ISP podporuje technologii PeerCache, která umožňuje cashovat downloady!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Povolit uživateli, aby si Vás přidal mezi přítele." IDS_SOURCESWAPBLOCKED "Výměna zdrojů zablokována" IDS_A4AF_CHECK_THIS_NOW "Zkontrolujte tento zdroj (debug)" @@ -1583,9 +1583,9 @@ BEGIN "Zaškrtněte, pokud požadujete, aby se eMule spouštěl se startem Windows. (implicitně vypnuto)" IDS_KAD_WAITCBK "Čekat na zpětné volání z Kad" IDS_KAD_TOOMANDYKADLKPS "Příliš mnoho Kad vyhledávání" - IDS_PCDS_CLIENTWAIT "Klient Čeká" - IDS_PCDS_CACHEWAIT "Cache Čeká" - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "Klient Čeká" +// IDS_PCDS_CACHEWAIT "Cache Čeká" +// IDS_CACHE "Cache" //! IDS_INDEXED "Indexován" IDS_KADINFO_SRC "\tZdroj: %u\r\n" IDS_KADINFO_KEYW "\tKlíčové slovo: %u\r\n" diff --git a/srchybrid/lang/cz_CZ.vcxproj b/srchybrid/lang/cz_CZ.vcxproj index bfd28799..a7e8aba0 100644 --- a/srchybrid/lang/cz_CZ.vcxproj +++ b/srchybrid/lang/cz_CZ.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/da_DK.rc b/srchybrid/lang/da_DK.rc index 664ec5b0..235403b2 100644 --- a/srchybrid/lang/da_DK.rc +++ b/srchybrid/lang/da_DK.rc @@ -751,7 +751,7 @@ BEGIN IDS_NEWMSG "Ny besked fra '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "kun i samme kategori" IDS_LOG_ULDL_EVENTS "Log upload/download begivenheder" - IDS_PEERCACHE_ENABLED "Din ISP understøtter PeerCache teknologien, aktiverer cache downloads!" +// IDS_PEERCACHE_ENABLED "Din ISP understøtter PeerCache teknologien, aktiverer cache downloads!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Tillad bruger at tilføje dig som ven." END @@ -1592,9 +1592,9 @@ BEGIN "Aktiver dette så eMule vil starte sammen med Windows. (Deaktiveret som standard)" IDS_KAD_WAITCBK "Afventer KAD Tilbagekald" IDS_KAD_TOOMANDYKADLKPS "For mange Kad Opslag" - IDS_PCDS_CLIENTWAIT "KlientVent" - IDS_PCDS_CACHEWAIT "CacheVent" - IDS_CACHE "Cache" +// IDS_PCDS_CLIENTWAIT "KlientVent" +// IDS_PCDS_CACHEWAIT "CacheVent" +// IDS_CACHE "Cache" IDS_INDEXED "Indekseret" IDS_KADINFO_SRC "\tKilde: %u\r\n" IDS_KADINFO_KEYW "\tNøgleord: %u\r\n" diff --git a/srchybrid/lang/da_DK.vcxproj b/srchybrid/lang/da_DK.vcxproj index b5ba441f..fd89d58b 100644 --- a/srchybrid/lang/da_DK.vcxproj +++ b/srchybrid/lang/da_DK.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/de_DE.rc b/srchybrid/lang/de_DE.rc index b3fec8bb..a0a39d21 100644 --- a/srchybrid/lang/de_DE.rc +++ b/srchybrid/lang/de_DE.rc @@ -1540,7 +1540,7 @@ BEGIN IDS_NEWMSG "Neue Nachricht von '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Nur aus gleicher Kategorie" IDS_LOG_ULDL_EVENTS "Logge Upload/Download Ereignisse" - IDS_PEERCACHE_ENABLED "Dein ISP unterstützt die PeerCache Technologie. Cache Downloads aktiviert." +// IDS_PEERCACHE_ENABLED "Dein ISP unterstützt die PeerCache Technologie. Cache Downloads aktiviert." IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Erlaube dem Benutzer, dich als Freund aufzunehmen." IDS_SOURCESWAPBLOCKED "Swap blockiert" @@ -1583,9 +1583,9 @@ BEGIN "Aktiviere dies, wenn eMule beim Windowsstart automatisch starten soll." IDS_KAD_WAITCBK "Warte auf Kad Rückruf" IDS_KAD_TOOMANDYKADLKPS "Zu viele Kad Suchen" - IDS_PCDS_CLIENTWAIT "ClientWarte" - IDS_PCDS_CACHEWAIT "CacheWarte" - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "ClientWarte" +// IDS_PCDS_CACHEWAIT "CacheWarte" +// IDS_CACHE "Cache" //! IDS_INDEXED "Indexiert" IDS_KADINFO_SRC "\tQuelle: %u\r\n" IDS_KADINFO_KEYW "\tSchlüsselwort: %u\r\n" diff --git a/srchybrid/lang/de_DE.vcxproj b/srchybrid/lang/de_DE.vcxproj index 7f35c56f..77ec2b00 100644 --- a/srchybrid/lang/de_DE.vcxproj +++ b/srchybrid/lang/de_DE.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/el_GR.rc b/srchybrid/lang/el_GR.rc index 092919ae..7b8f0a29 100644 --- a/srchybrid/lang/el_GR.rc +++ b/srchybrid/lang/el_GR.rc @@ -1512,7 +1512,7 @@ BEGIN IDS_NEWMSG "Νέο μήνυμα από '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "μόνο από την ίδια κατηγορία" IDS_LOG_ULDL_EVENTS "Καταγραφή ενεργειών ανεβάσματος/κατεβάσματος" - IDS_PEERCACHE_ENABLED "Ο ISP σας υποστηρίζει την τεχνολογία PeerCache, ενεργοποιείται η λήψη μέσω αυτής!" +// IDS_PEERCACHE_ENABLED "Ο ISP σας υποστηρίζει την τεχνολογία PeerCache, ενεργοποιείται η λήψη μέσω αυτής!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Επιτρέπεται να σας προσθέσουν σαν φίλο" END @@ -1551,9 +1551,9 @@ BEGIN IDS_WIZ_STARTWITHWINDOWS "Ενεργοποιήστε αυτό για να εκκινεί το eMule όταν ξεκινάτε τα windows. (Προεπιλογή Όχι)" IDS_KAD_WAITCBK "Αναμονή απάντησης (Kademlia)" IDS_KAD_TOOMANDYKADLKPS "Πάρα πολλές αναζητήσεις (Kademlia)" - IDS_PCDS_CLIENTWAIT "ClientWait" //! - IDS_PCDS_CACHEWAIT "CacheWait" //! - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "ClientWait" //! +// IDS_PCDS_CACHEWAIT "CacheWait" //! +// IDS_CACHE "Cache" //! IDS_INDEXED "Καταχωρήσεις" IDS_KADINFO_SRC "\tΠηγή: %u\r\n" IDS_KADINFO_KEYW "\tΛέξη-κλειδί: %u\r\n" diff --git a/srchybrid/lang/el_GR.vcxproj b/srchybrid/lang/el_GR.vcxproj index 48fddb10..27560c34 100644 --- a/srchybrid/lang/el_GR.vcxproj +++ b/srchybrid/lang/el_GR.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/es_AS.rc b/srchybrid/lang/es_AS.rc index 80cf82ff..b05feb98 100644 --- a/srchybrid/lang/es_AS.rc +++ b/srchybrid/lang/es_AS.rc @@ -818,7 +818,7 @@ BEGIN IDS_NEWMSG "Nuevu mensaxe de '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Namás na mesma categoría" IDS_LOG_ULDL_EVENTS "Rexistrar eventos de subida/baxada" - IDS_PEERCACHE_ENABLED "El to proveedor d’accesu a Internet (ISP) soporta PeerCache, caché habilitáu!" +// IDS_PEERCACHE_ENABLED "El to proveedor d’accesu a Internet (ISP) soporta PeerCache, caché habilitáu!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permitir al usuariu añedite como collaciu." IDS_SOURCESWAPBLOCKED "Intercambiu bloqueáu" IDS_TRICKLING "Aguardando" @@ -1625,9 +1625,9 @@ BEGIN "Activa esta opción si quies qu’eMule s’inicie con Windows (Desactiváu por defeutu)." IDS_KAD_WAITCBK "Esperando respuesta Kad" IDS_KAD_TOOMANDYKADLKPS "Demasiaes busques Kad" - IDS_PCDS_CLIENTWAIT "Espera de veceru" - IDS_PCDS_CACHEWAIT "Espera de Cache" - IDS_CACHE "Cache" +// IDS_PCDS_CLIENTWAIT "Espera de veceru" +// IDS_PCDS_CACHEWAIT "Espera de Cache" +// IDS_CACHE "Cache" IDS_INDEXED "Indexáu" IDS_KADINFO_SRC "\tFonte: %u\r\n" IDS_KADINFO_KEYW "\tPallabra clave: %u\r\n" diff --git a/srchybrid/lang/es_AS.vcxproj b/srchybrid/lang/es_AS.vcxproj index d3fd667c..47ade0d2 100644 --- a/srchybrid/lang/es_AS.vcxproj +++ b/srchybrid/lang/es_AS.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/es_ES_T.rc b/srchybrid/lang/es_ES_T.rc index c5db28a9..b8582641 100644 --- a/srchybrid/lang/es_ES_T.rc +++ b/srchybrid/lang/es_ES_T.rc @@ -1552,7 +1552,7 @@ BEGIN IDS_NEWMSG "Nuevo Mensaje de '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Sólo en la misma categoría" IDS_LOG_ULDL_EVENTS "Registrar eventos de subida/descarga" - IDS_PEERCACHE_ENABLED "Tu proveedor de acceso a Internet (ISP) es compatible con PeerCache. ¡Activando descargas con Cache!" +// IDS_PEERCACHE_ENABLED "Tu proveedor de acceso a Internet (ISP) es compatible con PeerCache. ¡Activando descargas con Cache!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permitir a un usuario añadirte como amigo." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Descargar primero las partes necesarias para previsualizar" END @@ -1594,9 +1594,9 @@ BEGIN "Activa esta opción si quieres que eMule se inicie con Windows. (Desactivado por defecto)" IDS_KAD_WAITCBK "Esperando respuesta Kad" IDS_KAD_TOOMANDYKADLKPS "Demasiadas búsquedas Kad" - IDS_PCDS_CLIENTWAIT "Espera de Cliente" - IDS_PCDS_CACHEWAIT "Espera de Caché" - IDS_CACHE "Caché" +// IDS_PCDS_CLIENTWAIT "Espera de Cliente" +// IDS_PCDS_CACHEWAIT "Espera de Caché" +// IDS_CACHE "Caché" IDS_INDEXED "Indexado" IDS_KADINFO_SRC "\tFuente: %u\r\n" IDS_KADINFO_KEYW "\tPalabra clave: %u\r\n" diff --git a/srchybrid/lang/es_ES_T.vcxproj b/srchybrid/lang/es_ES_T.vcxproj index 649c9d28..7a3853e6 100644 --- a/srchybrid/lang/es_ES_T.vcxproj +++ b/srchybrid/lang/es_ES_T.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/et_EE.rc b/srchybrid/lang/et_EE.rc index cc8aac51..ab28c486 100644 --- a/srchybrid/lang/et_EE.rc +++ b/srchybrid/lang/et_EE.rc @@ -1538,7 +1538,7 @@ BEGIN IDS_SOURCESWAPBLOCKED "Vahetus blokitud" IDS_A4AF_CHECK_THIS_NOW "Kontrolli seda allikad kohe (silu)" IDS_LOG_ULDL_EVENTS "Üles/allalaadimiste sündmuste logi" - IDS_PEERCACHE_ENABLED "Sinu ISP toed PeerCache tehnoloogia, võimalda vahemälu allalaadimised!" +// IDS_PEERCACHE_ENABLED "Sinu ISP toed PeerCache tehnoloogia, võimalda vahemälu allalaadimised!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Luba kasutajal sind lisada sõprade nimekirja." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Allalaetud osad vajalikud emase eelvaatluseks" END @@ -1580,9 +1580,9 @@ BEGIN "Lubades selle(?) eMule käivitub kui sa käivitad windowsi." IDS_KAD_WAITCBK "Oota tagasihelistamist Kad" IDS_KAD_TOOMANDYKADLKPS "Liig palju Kad otsinguid" - IDS_PCDS_CLIENTWAIT "Klient ootab" - IDS_PCDS_CACHEWAIT "Vahemälu ootab" - IDS_CACHE "Vahemälu" +// IDS_PCDS_CLIENTWAIT "Klient ootab" +// IDS_PCDS_CACHEWAIT "Vahemälu ootab" +// IDS_CACHE "Vahemälu" IDS_INDEXED "Indekseeritud" IDS_KADINFO_SRC "\tAllikas: %u\r\n" IDS_KADINFO_KEYW "\tMärksõna: %u\r\n" diff --git a/srchybrid/lang/et_EE.vcxproj b/srchybrid/lang/et_EE.vcxproj index 83b31afa..7256afe0 100644 --- a/srchybrid/lang/et_EE.vcxproj +++ b/srchybrid/lang/et_EE.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/fa_IR.rc b/srchybrid/lang/fa_IR.rc index cb00c7f4..9d6d83d8 100644 --- a/srchybrid/lang/fa_IR.rc +++ b/srchybrid/lang/fa_IR.rc @@ -908,7 +908,7 @@ BEGIN IDS_NEWMSG "پيغام جديد از '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "فقط در قفسه دسته بندي شده يكسان" IDS_LOG_ULDL_EVENTS "گزارش آپلود/دانلود تغييرات" - IDS_PEERCACHE_ENABLED "آي اس پي شما فضاي نگهداري موقت در سرويس دهنده ها را پشتيباني ميكند, در حال فعال كردن فضاي موقتي سرويس دهنده ها!َ" +// IDS_PEERCACHE_ENABLED "آي اس پي شما فضاي نگهداري موقت در سرويس دهنده ها را پشتيباني ميكند, در حال فعال كردن فضاي موقتي سرويس دهنده ها!َ" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "به كاربران ديگر اجازه بده كه تو را به عنوان دوست به ليست خود اضافه كنند." IDS_SOURCESWAPBLOCKED "از مبادله جلوگيري شد" IDS_TRICKLING "آماده باش" @@ -1619,9 +1619,9 @@ BEGIN "فعال کردن اين گزينه موجب مي شود که با آغاز ويندوز ايمول اجرا شود" IDS_KAD_WAITCBK "باشيد Kad منتظر تماس مجدد" IDS_KAD_TOOMANDYKADLKPS "ها Kad مراجعات بيش از اندازه " - IDS_PCDS_CLIENTWAIT "مشتري(کلاينت) در حال انتظار" - IDS_PCDS_CACHEWAIT "انتظار براي ايجاد کش" - IDS_CACHE "فضاي موقت" +// IDS_PCDS_CLIENTWAIT "مشتري(کلاينت) در حال انتظار" +// IDS_PCDS_CACHEWAIT "انتظار براي ايجاد کش" +// IDS_CACHE "فضاي موقت" IDS_INDEXED "فهرست شده" IDS_KADINFO_SRC "\tمنبع: %u\r\n" IDS_KADINFO_KEYW "\tکلمات کليدي: %u\r\n" diff --git a/srchybrid/lang/fa_IR.vcxproj b/srchybrid/lang/fa_IR.vcxproj index 9b3ead8d..d7171c7b 100644 --- a/srchybrid/lang/fa_IR.vcxproj +++ b/srchybrid/lang/fa_IR.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/fi_FI.rc b/srchybrid/lang/fi_FI.rc index 73d386cc..f846e39b 100644 --- a/srchybrid/lang/fi_FI.rc +++ b/srchybrid/lang/fi_FI.rc @@ -908,7 +908,7 @@ BEGIN IDS_NEWMSG "Uusi viesti käyttäjältä '%s' (IP: %s)" IDS_PREF_STARTNEXTFILECATONLY "vain samassa kategoriassa" IDS_LOG_ULDL_EVENTS "Kirjoita lähetys- ja lataustapahtumat lokiin" - IDS_PEERCACHE_ENABLED "Internetyhteydentarjoajasi tukee PeerCache-teknologiaa. Otan teknologian käyttöön!" +// IDS_PEERCACHE_ENABLED "Internetyhteydentarjoajasi tukee PeerCache-teknologiaa. Otan teknologian käyttöön!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Salli käyttäjien lisätä minut kaverikseen." IDS_SOURCESWAPBLOCKED "Vaihto estetty" IDS_TRICKLING "Valmiustila" @@ -1620,9 +1620,9 @@ BEGIN "Käytä tätä asetusta, jos haluat että eMule käynnistyy Windowsin mukana. (Oletuksena pois päältä)" IDS_KAD_WAITCBK "Odota Kad-takaisinkutsua" IDS_KAD_TOOMANDYKADLKPS "Liian monta Kad-hakua" - IDS_PCDS_CLIENTWAIT "AsiakasOdotus" - IDS_PCDS_CACHEWAIT "VälimuistiOdotus" - IDS_CACHE "Välimuisti" +// IDS_PCDS_CLIENTWAIT "AsiakasOdotus" +// IDS_PCDS_CACHEWAIT "VälimuistiOdotus" +// IDS_CACHE "Välimuisti" IDS_INDEXED "Indeksoitu" IDS_KADINFO_SRC "\tLähde: %u\r\n" IDS_KADINFO_KEYW "\tAvainsana: %u\r\n" diff --git a/srchybrid/lang/fi_FI.vcxproj b/srchybrid/lang/fi_FI.vcxproj index ebb0d6fb..c75665f2 100644 --- a/srchybrid/lang/fi_FI.vcxproj +++ b/srchybrid/lang/fi_FI.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/fr_BR.rc b/srchybrid/lang/fr_BR.rc index 79b9159a..f8e531af 100644 --- a/srchybrid/lang/fr_BR.rc +++ b/srchybrid/lang/fr_BR.rc @@ -1523,7 +1523,7 @@ BEGIN IDS_NEWMSG "Kemennadenn nevez a-berzh '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Nemet er memes rummad" IDS_LOG_ULDL_EVENTS "Enskrivañ an darvoudoù kas/degemer" - IDS_PEERCACHE_ENABLED "Skorañ a ra ho pourchaser Internet an deknologiezh PeerCache, krubuilh gweredekaet !" +// IDS_PEERCACHE_ENABLED "Skorañ a ra ho pourchaser Internet an deknologiezh PeerCache, krubuilh gweredekaet !" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Aotreañ an implijour d'ho lakaat en e roll mignoned." IDS_SOURCESWAPBLOCKED "Eskemm harpet" IDS_TRICKLING "A-gostez" @@ -1563,9 +1563,9 @@ BEGIN IDS_WIZ_STARTWITHWINDOWS "Loc'hañ eMule gant Windows en ur ser (diweredekaet dre ziouer)" IDS_KAD_WAITCBK "O c'hortoz PCV Kad" IDS_KAD_TOOMANDYKADLKPS "Re a weladennoù Kad" - IDS_PCDS_CLIENTWAIT "O c'hortoz ostiz" - IDS_PCDS_CACHEWAIT "O c'hortoz krubuilh" - IDS_CACHE "Kuzhet" +// IDS_PCDS_CLIENTWAIT "O c'hortoz ostiz" +// IDS_PCDS_CACHEWAIT "O c'hortoz krubuilh" +// IDS_CACHE "Kuzhet" IDS_INDEXED "Merket" IDS_KADINFO_SRC "\tOrin : %u\r\n" IDS_KADINFO_KEYW "\tGer-alc'hwez : %u\r\n" diff --git a/srchybrid/lang/fr_BR.vcxproj b/srchybrid/lang/fr_BR.vcxproj index fa422501..5a1a1e74 100644 --- a/srchybrid/lang/fr_BR.vcxproj +++ b/srchybrid/lang/fr_BR.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/fr_FR.rc b/srchybrid/lang/fr_FR.rc index 3559a0d0..0906d585 100644 --- a/srchybrid/lang/fr_FR.rc +++ b/srchybrid/lang/fr_FR.rc @@ -1543,7 +1543,7 @@ BEGIN IDS_NEWMSG "Nouveau message de '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Uniquement dans la même catégorie" IDS_LOG_ULDL_EVENTS "Consigner les évènements d'émission/réception" - IDS_PEERCACHE_ENABLED "Votre FAI supporte la technologie PeerCache, cache activé !" +// IDS_PEERCACHE_ENABLED "Votre FAI supporte la technologie PeerCache, cache activé !" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Autoriser l'utilisateur à vous ajouter à sa liste d'amis." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Priorité aux parties nécessaires à l'aperçu" END @@ -1585,9 +1585,9 @@ BEGIN "Lancer eMule au démarrage de Windows (désactivé par défaut)" IDS_KAD_WAITCBK "Attente de PCV Kad" IDS_KAD_TOOMANDYKADLKPS "Trop de consultations Kad" - IDS_PCDS_CLIENTWAIT "Attente client" - IDS_PCDS_CACHEWAIT "Attente cache" - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "Attente client" +// IDS_PCDS_CACHEWAIT "Attente cache" +// IDS_CACHE "Cache" //! IDS_INDEXED "Indexé" IDS_KADINFO_SRC "\tSource: %u\r\n" //! IDS_KADINFO_KEYW "\tMot-clé: %u\r\n" diff --git a/srchybrid/lang/fr_FR.vcxproj b/srchybrid/lang/fr_FR.vcxproj index 81134f88..f48e9150 100644 --- a/srchybrid/lang/fr_FR.vcxproj +++ b/srchybrid/lang/fr_FR.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/gl_ES.rc b/srchybrid/lang/gl_ES.rc index e84bcbc4..dfb42585 100644 --- a/srchybrid/lang/gl_ES.rc +++ b/srchybrid/lang/gl_ES.rc @@ -1552,7 +1552,7 @@ BEGIN IDS_NEWMSG "Nova mensaxe de '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "só na mesma categoría" IDS_LOG_ULDL_EVENTS "Rexistrar eventos de subida/baixada" - IDS_PEERCACHE_ENABLED "O teu ISP soporta PeerCache, activando baixadas mediante cache!" +// IDS_PEERCACHE_ENABLED "O teu ISP soporta PeerCache, activando baixadas mediante cache!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permitir ao usuario engadirte como amigo." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Descargar primeiro as partes necesarias para a previsualización" END @@ -1594,9 +1594,9 @@ BEGIN "Activa isto para que eMule se inicie ao arrancar Windows. (Deshabilitado por defecto)" IDS_KAD_WAITCBK "Esperar resposta Kad" IDS_KAD_TOOMANDYKADLKPS "Demasiadas buscas Kad" - IDS_PCDS_CLIENTWAIT "Espera de cliente" - IDS_PCDS_CACHEWAIT "Espera de cache" - IDS_CACHE "Cache"//! +// IDS_PCDS_CLIENTWAIT "Espera de cliente" +// IDS_PCDS_CACHEWAIT "Espera de cache" +// IDS_CACHE "Cache"//! IDS_INDEXED "Indexado" IDS_KADINFO_SRC "\tFonte: %u\r\n" IDS_KADINFO_KEYW "\tPalabra clave: %u\r\n" diff --git a/srchybrid/lang/gl_ES.vcxproj b/srchybrid/lang/gl_ES.vcxproj index 23aed974..8162e8aa 100644 --- a/srchybrid/lang/gl_ES.vcxproj +++ b/srchybrid/lang/gl_ES.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/he_IL.rc b/srchybrid/lang/he_IL.rc index 1e21c179..34f9b13f 100644 --- a/srchybrid/lang/he_IL.rc +++ b/srchybrid/lang/he_IL.rc @@ -1541,7 +1541,7 @@ BEGIN IDS_NEWMSG "הודעה חדשה מ-'%s' (איי פי:%s)" IDS_PREF_STARTNEXTFILECATONLY "רק מאותה קטגוריה" IDS_LOG_ULDL_EVENTS "שמור ביומן אירועי העלאה/הורדה" - IDS_PEERCACHE_ENABLED "ספק האינטרנט שלך תומך בטכנולוגיית PeerCache, מפעיל הורדות מטמון!" +// IDS_PEERCACHE_ENABLED "ספק האינטרנט שלך תומך בטכנולוגיית PeerCache, מפעיל הורדות מטמון!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "אפשר למשתמש להוסיף אותך כחבר" IDS_DL_TRY_TO_GET_PREVIEW_PARTS "הורד ראשונים חלקים המשמשים לתצוגה מקדימה" END @@ -1583,9 +1583,9 @@ BEGIN "הפעל אפשרות זו אם ברצונך שאימיול יפעל בעת הפעלת ""חלונות"". (ברירת מחדל: מופסק)" IDS_KAD_WAITCBK "המתנת אימות קדמליה" IDS_KAD_TOOMANDYKADLKPS "יותר מידיי חיפושים בקדמליה" - IDS_PCDS_CLIENTWAIT "המתנת קליינט" - IDS_PCDS_CACHEWAIT "המתנת מטמון" - IDS_CACHE "מטמון" +// IDS_PCDS_CLIENTWAIT "המתנת קליינט" +// IDS_PCDS_CACHEWAIT "המתנת מטמון" +// IDS_CACHE "מטמון" IDS_INDEXED "אינדקס" IDS_KADINFO_SRC "\tמקור: %u\r\n" IDS_KADINFO_KEYW "\tמילת מפתח: %u\r\n" diff --git a/srchybrid/lang/he_IL.vcxproj b/srchybrid/lang/he_IL.vcxproj index 232f264f..272485d1 100644 --- a/srchybrid/lang/he_IL.vcxproj +++ b/srchybrid/lang/he_IL.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/hu_HU.rc b/srchybrid/lang/hu_HU.rc index 4e82e3f6..01c992d5 100644 --- a/srchybrid/lang/hu_HU.rc +++ b/srchybrid/lang/hu_HU.rc @@ -1549,7 +1549,7 @@ BEGIN IDS_NEWMSG "'%s' új üzenetet küldött (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "csak azonos kategóriában" IDS_LOG_ULDL_EVENTS "Fel/letöltések naplózása" - IDS_PEERCACHE_ENABLED "Az internetszolgáltatód támogatja a PeerCache-t, engedélyezem a gyorsítótáras letöltést!" +// IDS_PEERCACHE_ENABLED "Az internetszolgáltatód támogatja a PeerCache-t, engedélyezem a gyorsítótáras letöltést!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Megengedem a felhasználónak hogy barátnak felvegyen." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Az előnézethez szükséges részeket töltse le hamarébb" END @@ -1591,9 +1591,9 @@ BEGIN "Ezt kapcsold be, ha a Windows indításkor induljon az eMule." IDS_KAD_WAITCBK "Kad visszahívásra várás" IDS_KAD_TOOMANDYKADLKPS "Túl sok KAD keresés" - IDS_PCDS_CLIENTWAIT "Kliensre várok" - IDS_PCDS_CACHEWAIT "Gyorsítótárra várok" - IDS_CACHE "Gyorsítótár" +// IDS_PCDS_CLIENTWAIT "Kliensre várok" +// IDS_PCDS_CACHEWAIT "Gyorsítótárra várok" +// IDS_CACHE "Gyorsítótár" IDS_INDEXED "Indexelve" IDS_KADINFO_SRC "\tForrás: %u\r\n" IDS_KADINFO_KEYW "\tKulcsszó: %u\r\n" diff --git a/srchybrid/lang/hu_HU.vcxproj b/srchybrid/lang/hu_HU.vcxproj index 9c803273..5f1679b9 100644 --- a/srchybrid/lang/hu_HU.vcxproj +++ b/srchybrid/lang/hu_HU.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/it_IT.rc b/srchybrid/lang/it_IT.rc index 87375586..f61c2a5a 100644 --- a/srchybrid/lang/it_IT.rc +++ b/srchybrid/lang/it_IT.rc @@ -908,7 +908,7 @@ BEGIN IDS_NEWMSG "Nuovo messaggio da ""%s"" (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Solo nella stessa categoria" IDS_LOG_ULDL_EVENTS "Registra gli eventi di invio e recezione di dati" - IDS_PEERCACHE_ENABLED "Il tuo gestore supporta la tecnologia PeerCache, abilitata per gli scaricamenti!" +// IDS_PEERCACHE_ENABLED "Il tuo gestore supporta la tecnologia PeerCache, abilitata per gli scaricamenti!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Consenti agli altri di aggiungerti alla lista degli amici" IDS_SOURCESWAPBLOCKED "Scambio bloccato" IDS_TRICKLING "In attesa" @@ -1619,9 +1619,9 @@ BEGIN "Esegui eMule all'avvio di Windows." IDS_KAD_WAITCBK "Attendi il richiamo in Kad" IDS_KAD_TOOMANDYKADLKPS "Troppe analisi in Kad" - IDS_PCDS_CLIENTWAIT "Attesa utente" - IDS_PCDS_CACHEWAIT "Attesa cache" - IDS_CACHE "Cache" +// IDS_PCDS_CLIENTWAIT "Attesa utente" +// IDS_PCDS_CACHEWAIT "Attesa cache" +// IDS_CACHE "Cache" IDS_INDEXED "Indicizzato" IDS_KADINFO_SRC "\tFonte: %u\r\n" IDS_KADINFO_KEYW "\tParola chiave: %u\r\n" diff --git a/srchybrid/lang/it_IT.vcxproj b/srchybrid/lang/it_IT.vcxproj index db99213a..dc47f7fa 100644 --- a/srchybrid/lang/it_IT.vcxproj +++ b/srchybrid/lang/it_IT.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/jp_JP.rc b/srchybrid/lang/jp_JP.rc index 60860057..872668e2 100644 --- a/srchybrid/lang/jp_JP.rc +++ b/srchybrid/lang/jp_JP.rc @@ -824,7 +824,7 @@ BEGIN IDS_NEWMSG "'%s' (IP:%s)からの新しいメッセージ" IDS_PREF_STARTNEXTFILECATONLY "同じカテゴリ内のみ" IDS_LOG_ULDL_EVENTS "アップロード/ダウンロードイベントのログを採る" - IDS_PEERCACHE_ENABLED "あなたのISPはキャッシュダウンロードを有効にすることで、PeerCache技術をサポートしています!" +// IDS_PEERCACHE_ENABLED "あなたのISPはキャッシュダウンロードを有効にすることで、PeerCache技術をサポートしています!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "ユーザーが友達としてあなたを加えることを許可" IDS_SOURCESWAPBLOCKED "スワップがブロックされました" @@ -1606,9 +1606,9 @@ BEGIN "Windowsのスタートアップ時にeMuleを起動します。" IDS_KAD_WAITCBK "Kadのコールバックを待機" IDS_KAD_TOOMANDYKADLKPS "Kad検索が過多" - IDS_PCDS_CLIENTWAIT "ClientWait" - IDS_PCDS_CACHEWAIT "CacheWait" - IDS_CACHE "キャッシュ" +// IDS_PCDS_CLIENTWAIT "ClientWait" +// IDS_PCDS_CACHEWAIT "CacheWait" +// IDS_CACHE "キャッシュ" IDS_INDEXED "インデックス済" IDS_KADINFO_SRC "\tソース: %u\r\n" IDS_KADINFO_KEYW "\tキーワードd: %u\r\n" diff --git a/srchybrid/lang/jp_JP.vcxproj b/srchybrid/lang/jp_JP.vcxproj index 93e9d8b8..e29fe1ce 100644 --- a/srchybrid/lang/jp_JP.vcxproj +++ b/srchybrid/lang/jp_JP.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/ko_KR.rc b/srchybrid/lang/ko_KR.rc index 9719f81e..dcea581e 100644 --- a/srchybrid/lang/ko_KR.rc +++ b/srchybrid/lang/ko_KR.rc @@ -906,7 +906,7 @@ BEGIN IDS_NEWMSG "'%s'님으로부터의 새로운 메시지 (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "같은 카테고리에서만" IDS_LOG_ULDL_EVENTS "업/다운 이벤트 기록" - IDS_PEERCACHE_ENABLED "ISP가 PeerCache 기술을 지원하므로 캐시 다운로드를 활성화 함!" +// IDS_PEERCACHE_ENABLED "ISP가 PeerCache 기술을 지원하므로 캐시 다운로드를 활성화 함!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "다른 사용자가 친구로 추가할 수 있게 허용" IDS_SOURCESWAPBLOCKED "스왑 차단됨" IDS_TRICKLING "대기" @@ -1617,9 +1617,9 @@ BEGIN "Windows 시작 시 실행하려면 이 부분을 선택하십시오. (기본값: 사용하지 않음)" IDS_KAD_WAITCBK "콜백 Kad 대기" IDS_KAD_TOOMANDYKADLKPS "Kad 찾기가 너무 많음" - IDS_PCDS_CLIENTWAIT "ClientWait" - IDS_PCDS_CACHEWAIT "CacheWait" - IDS_CACHE "캐시" +// IDS_PCDS_CLIENTWAIT "ClientWait" +// IDS_PCDS_CACHEWAIT "CacheWait" +// IDS_CACHE "캐시" IDS_INDEXED "인덱스 됨" IDS_KADINFO_SRC "\t소스: %u\r\n" IDS_KADINFO_KEYW "\t검색어: %u\r\n" diff --git a/srchybrid/lang/ko_KR.vcxproj b/srchybrid/lang/ko_KR.vcxproj index 439a5278..ef04cac7 100644 --- a/srchybrid/lang/ko_KR.vcxproj +++ b/srchybrid/lang/ko_KR.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/lang.rc2 b/srchybrid/lang/lang.rc2 index cc240360..516b80b8 100644 --- a/srchybrid/lang/lang.rc2 +++ b/srchybrid/lang/lang.rc2 @@ -38,7 +38,7 @@ BEGIN VALUE "CompanyName", "http://www.emule-project.net" VALUE "FileDescription", "eMule Language DLL" VALUE "FileVersion", SZ_VERSION_NAME - VALUE "LegalCopyright", "Copyright © 2002-2023 Merkur - read license.txt for more infos" + VALUE "LegalCopyright", "Copyright © 2002-2024 Merkur - read license.txt for more infos" VALUE "ProductName", "eMule" VALUE "ProductVersion", SZ_VERSION_NAME END diff --git a/srchybrid/lang/lt_LT.rc b/srchybrid/lang/lt_LT.rc index 48e867c7..3c8adc06 100644 --- a/srchybrid/lang/lt_LT.rc +++ b/srchybrid/lang/lt_LT.rc @@ -1546,7 +1546,7 @@ BEGIN IDS_NEWMSG "Naujas pranešimas iš '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "tik toje pačioje kategorijoje" IDS_LOG_ULDL_EVENTS "Loginti išsiuntimo/gavimo įvykius" - IDS_PEERCACHE_ENABLED "Jūsų ISP palaiko PeerCache technologiją, įjungiu gavimą iš kešo!" +// IDS_PEERCACHE_ENABLED "Jūsų ISP palaiko PeerCache technologiją, įjungiu gavimą iš kešo!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Leisti vartotojam pridėti jus kaip draugą." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Pirma gauti dalis reikalingas peržiūrai" END @@ -1588,9 +1588,9 @@ BEGIN "Įjunkite ir eMule pasileis kartu su Windows. (pagal nutilėjimą išjungta)" IDS_KAD_WAITCBK "Laukti Kad Callback" IDS_KAD_TOOMANDYKADLKPS "Perdaug Kad paieškų" - IDS_PCDS_CLIENTWAIT "KlientoLaukimas" - IDS_PCDS_CACHEWAIT "KešoLaukimas" - IDS_CACHE "Kešas" +// IDS_PCDS_CLIENTWAIT "KlientoLaukimas" +// IDS_PCDS_CACHEWAIT "KešoLaukimas" +// IDS_CACHE "Kešas" IDS_INDEXED "Indeksuota" IDS_KADINFO_SRC "\tŠaltinių: %u\r\n" IDS_KADINFO_KEYW "\tRaktažodžių: %u\r\n" diff --git a/srchybrid/lang/lt_LT.vcxproj b/srchybrid/lang/lt_LT.vcxproj index f95f3b31..fae7c6e7 100644 --- a/srchybrid/lang/lt_LT.vcxproj +++ b/srchybrid/lang/lt_LT.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/lv_LV.rc b/srchybrid/lang/lv_LV.rc index 1c402c4b..ac15e5fd 100644 --- a/srchybrid/lang/lv_LV.rc +++ b/srchybrid/lang/lv_LV.rc @@ -820,7 +820,7 @@ BEGIN IDS_NEWMSG "New Message from '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Only in same category" IDS_LOG_ULDL_EVENTS "Log upload/download events" - IDS_PEERCACHE_ENABLED "Your ISP supports the PeerCache technology, enabling cache downloads!" +// IDS_PEERCACHE_ENABLED "Your ISP supports the PeerCache technology, enabling cache downloads!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Allow user to add you as a friend." IDS_SOURCESWAPBLOCKED "Swap blocked" IDS_TRICKLING "Standby" @@ -1621,9 +1621,9 @@ BEGIN "Enable this so that eMule will run when you start windows." IDS_KAD_WAITCBK "Wait Callback Kad" IDS_KAD_TOOMANDYKADLKPS "Too Many Kad Lookups" - IDS_PCDS_CLIENTWAIT "ClientWait" - IDS_PCDS_CACHEWAIT "CacheWait" - IDS_CACHE "Cache" +// IDS_PCDS_CLIENTWAIT "ClientWait" +// IDS_PCDS_CACHEWAIT "CacheWait" +// IDS_CACHE "Cache" IDS_INDEXED "Indexed" IDS_KADINFO_SRC "\tSource: %u\r\n" IDS_KADINFO_KEYW "\tKeyword: %u\r\n" diff --git a/srchybrid/lang/lv_LV.vcxproj b/srchybrid/lang/lv_LV.vcxproj index a87613ae..5340c238 100644 --- a/srchybrid/lang/lv_LV.vcxproj +++ b/srchybrid/lang/lv_LV.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/mt_MT.rc b/srchybrid/lang/mt_MT.rc index 059e24d0..be4564e8 100644 --- a/srchybrid/lang/mt_MT.rc +++ b/srchybrid/lang/mt_MT.rc @@ -819,7 +819,7 @@ BEGIN IDS_NEWMSG "Messaġġ ġdid mingħand '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Fl-istess kategorija biss" IDS_LOG_ULDL_EVENTS "Żomm Log tal-attivita tal-uploads/downloads" - IDS_PEERCACHE_ENABLED "L-ISP tiegħek jippermetti it-teknoloġija 'PeerCache', il-'cache downloads' ġew attivati!" +// IDS_PEERCACHE_ENABLED "L-ISP tiegħek jippermetti it-teknoloġija 'PeerCache', il-'cache downloads' ġew attivati!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Ippermetti li user iżidek bħala ħabib." IDS_SOURCESWAPBLOCKED "Tpartit mhux permess" IDS_TRICKLING "Stenna" @@ -1626,9 +1626,9 @@ BEGIN "Ixgħal din biex l-eMule jitla meta tixgħal il-Windows." IDS_KAD_WAITCBK "Stenna il-Callback tal-Kad" IDS_KAD_TOOMANDYKADLKPS "Hawn ħafna Lookups tal-Kad" - IDS_PCDS_CLIENTWAIT "ClientWait" - IDS_PCDS_CACHEWAIT "CacheWait" - IDS_CACHE "Cache" +// IDS_PCDS_CLIENTWAIT "ClientWait" +// IDS_PCDS_CACHEWAIT "CacheWait" +// IDS_CACHE "Cache" IDS_INDEXED "Indexjat" IDS_KADINFO_SRC "\tSors: %u\r\n" IDS_KADINFO_KEYW "\tFrażi: %u\r\n" diff --git a/srchybrid/lang/mt_MT.vcxproj b/srchybrid/lang/mt_MT.vcxproj index 73e16e31..ad6b3592 100644 --- a/srchybrid/lang/mt_MT.vcxproj +++ b/srchybrid/lang/mt_MT.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/nb_NO.rc b/srchybrid/lang/nb_NO.rc index 25ddbcce..59ebe5b0 100644 --- a/srchybrid/lang/nb_NO.rc +++ b/srchybrid/lang/nb_NO.rc @@ -745,7 +745,7 @@ BEGIN IDS_NEWMSG "Ny melding fra '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "kun i samme kategori" IDS_LOG_ULDL_EVENTS "Logg opplastning/nedlastning hendelser" - IDS_PEERCACHE_ENABLED "Din ISP understøtter PeerCache teknologien, aktiverer cache nedlastninger!" +// IDS_PEERCACHE_ENABLED "Din ISP understøtter PeerCache teknologien, aktiverer cache nedlastninger!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Tillat brukere å legge til deg som venn." END @@ -1586,9 +1586,9 @@ BEGIN "Aktiver dette så eMule vil starte sammen med Windows. (Deaktivert som standard)" IDS_KAD_WAITCBK "Avventer Callback Kad" IDS_KAD_TOOMANDYKADLKPS "For mange Kad Lookups" - IDS_PCDS_CLIENTWAIT "Klient Vent" - IDS_PCDS_CACHEWAIT "Hurtigbuffer Vent" - IDS_CACHE "Hurtigbuffet" +// IDS_PCDS_CLIENTWAIT "Klient Vent" +// IDS_PCDS_CACHEWAIT "Hurtigbuffer Vent" +// IDS_CACHE "Hurtigbuffet" IDS_INDEXED "Indeksert" IDS_KADINFO_SRC "\tKilde: %u\r\n" IDS_KADINFO_KEYW "\tSøkeord: %u\r\n" diff --git a/srchybrid/lang/nb_NO.vcxproj b/srchybrid/lang/nb_NO.vcxproj index 5f11fef8..a0d1fd7b 100644 --- a/srchybrid/lang/nb_NO.vcxproj +++ b/srchybrid/lang/nb_NO.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/nl_NL.rc b/srchybrid/lang/nl_NL.rc index d8deaebb..4789ba47 100644 --- a/srchybrid/lang/nl_NL.rc +++ b/srchybrid/lang/nl_NL.rc @@ -1546,7 +1546,7 @@ BEGIN IDS_NEWMSG "Nieuw bericht van '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Alleen in dezelfde categorie" IDS_LOG_ULDL_EVENTS "Upload-/downloadgebeurtenissen loggen" - IDS_PEERCACHE_ENABLED "ISP ondersteunt de PeerCache-technologie, activeer downloads van PeerCache-buffer!" +// IDS_PEERCACHE_ENABLED "ISP ondersteunt de PeerCache-technologie, activeer downloads van PeerCache-buffer!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Gebruiker toestaan u als vriend toe te voegen." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Downloaddelen nodig voor voorvertoning" END @@ -1588,9 +1588,9 @@ BEGIN "Activeer dit om eMule te laten starten als Windows start." IDS_KAD_WAITCBK "Wachten op terugroep van Kad" IDS_KAD_TOOMANDYKADLKPS "Te veel Kad-lookups" - IDS_PCDS_CLIENTWAIT "ClientWacht" - IDS_PCDS_CACHEWAIT "CacheWacht" - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "ClientWacht" +// IDS_PCDS_CACHEWAIT "CacheWacht" +// IDS_CACHE "Cache" //! IDS_INDEXED "Geïndexeerd" IDS_KADINFO_SRC "\tBron: %u\r\n" IDS_KADINFO_KEYW "\tSleutelwoord: %u\r\n" diff --git a/srchybrid/lang/nl_NL.vcxproj b/srchybrid/lang/nl_NL.vcxproj index 79c758e5..7655064e 100644 --- a/srchybrid/lang/nl_NL.vcxproj +++ b/srchybrid/lang/nl_NL.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/nn_NO.rc b/srchybrid/lang/nn_NO.rc index 704b7030..ebfddbb0 100644 --- a/srchybrid/lang/nn_NO.rc +++ b/srchybrid/lang/nn_NO.rc @@ -729,7 +729,7 @@ BEGIN IDS_NEWMSG "Ny melding frå '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "berre i same kategori" IDS_LOG_ULDL_EVENTS "Logg opplasting/nedlastingshendingar" - IDS_PEERCACHE_ENABLED "Internettleverandøren din støttar PeerCache teknologien; aktiverer cachenedlastingar!" +// IDS_PEERCACHE_ENABLED "Internettleverandøren din støttar PeerCache teknologien; aktiverer cachenedlastingar!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Tillat brukarar å leggje deg til som ven" END @@ -1550,9 +1550,9 @@ BEGIN IDS_WIZ_STARTWITHWINDOWS "Aktiver dette så eMule vil starte saman med Windows. [Deaktivert som standard]" IDS_KAD_WAITCBK "Avventar tilbakering Kad" IDS_KAD_TOOMANDYKADLKPS "For mange Kad-oppslag" - IDS_PCDS_CLIENTWAIT "Klient Vent" - IDS_PCDS_CACHEWAIT "Cache Vent" - IDS_CACHE "Cache" +// IDS_PCDS_CLIENTWAIT "Klient Vent" +// IDS_PCDS_CACHEWAIT "Cache Vent" +// IDS_CACHE "Cache" IDS_INDEXED "Indeksert" IDS_KADINFO_SRC "\tKjelde: %u\r\n" IDS_KADINFO_KEYW "\tSøkjeord: %u\r\n" diff --git a/srchybrid/lang/nn_NO.vcxproj b/srchybrid/lang/nn_NO.vcxproj index cb97692c..4fb8a6c2 100644 --- a/srchybrid/lang/nn_NO.vcxproj +++ b/srchybrid/lang/nn_NO.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/pl_PL.rc b/srchybrid/lang/pl_PL.rc index ad2cc035..7c00c326 100644 --- a/srchybrid/lang/pl_PL.rc +++ b/srchybrid/lang/pl_PL.rc @@ -912,7 +912,7 @@ BEGIN IDS_NEWMSG "Nowa wiadomość od '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Tylko w tej samej kategorii" IDS_LOG_ULDL_EVENTS "Loguj zdarzenia pobierania/wysyłania" - IDS_PEERCACHE_ENABLED "Twój dostawca ISP wspiera technologie PeerCache, umożliwiając szybsze pobieranie!" +// IDS_PEERCACHE_ENABLED "Twój dostawca ISP wspiera technologie PeerCache, umożliwiając szybsze pobieranie!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Pozwól użytkownikowi dodać cię do listy znajomych" IDS_SOURCESWAPBLOCKED "Wymiana zablokowana" IDS_TRICKLING "Gotowy" @@ -1623,9 +1623,9 @@ BEGIN "Włącz eMula przy starcie Windowsa" IDS_KAD_WAITCBK "Oczekiw. odp. KAD" IDS_KAD_TOOMANDYKADLKPS "Za dużo poszuka. KAD" - IDS_PCDS_CLIENTWAIT "Oczek.klient" - IDS_PCDS_CACHEWAIT "Oczek.Cache" - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "Oczek.klient" +// IDS_PCDS_CACHEWAIT "Oczek.Cache" +// IDS_CACHE "Cache" //! IDS_INDEXED "Indeksowanie" IDS_KADINFO_SRC "\tŹródło: %u\r\n" IDS_KADINFO_KEYW "\tFraza: %u\r\n" diff --git a/srchybrid/lang/pl_PL.vcxproj b/srchybrid/lang/pl_PL.vcxproj index 3aec7a7e..c58eb5c0 100644 --- a/srchybrid/lang/pl_PL.vcxproj +++ b/srchybrid/lang/pl_PL.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/pt_BR.rc b/srchybrid/lang/pt_BR.rc index 0fd50bf8..6a6139a2 100644 --- a/srchybrid/lang/pt_BR.rc +++ b/srchybrid/lang/pt_BR.rc @@ -1545,7 +1545,7 @@ BEGIN IDS_NEWMSG "Nova mensagem de '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Somente na mesma categoria" IDS_LOG_ULDL_EVENTS "Registrar eventos de upload/download" - IDS_PEERCACHE_ENABLED "O seu provedor suporta a tecnologia PeerCache, habilitando downloads em cache!" +// IDS_PEERCACHE_ENABLED "O seu provedor suporta a tecnologia PeerCache, habilitando downloads em cache!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permitir que o usuário adicione você como amigo" IDS_SOURCESWAPBLOCKED "Troca Bloqueada" @@ -1588,9 +1588,9 @@ BEGIN "Ativando esta opção o eMule iniciará quando você iniciar o Windows." IDS_KAD_WAITCBK "Aguardar retorno - Kad" IDS_KAD_TOOMANDYKADLKPS "Muitas pesquisas - Kad" - IDS_PCDS_CLIENTWAIT "Espera do Cliente" - IDS_PCDS_CACHEWAIT "Espera de Cache" - IDS_CACHE "Cache"//! +// IDS_PCDS_CLIENTWAIT "Espera do Cliente" +// IDS_PCDS_CACHEWAIT "Espera de Cache" +// IDS_CACHE "Cache"//! IDS_INDEXED "Indexado" IDS_KADINFO_SRC "\tFonte: %u\r\n" IDS_KADINFO_KEYW "\tPalavra-Chave: %u\r\n" diff --git a/srchybrid/lang/pt_BR.vcxproj b/srchybrid/lang/pt_BR.vcxproj index b243edbe..8aa1a73f 100644 --- a/srchybrid/lang/pt_BR.vcxproj +++ b/srchybrid/lang/pt_BR.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/pt_PT.rc b/srchybrid/lang/pt_PT.rc index b71d3f5b..c0cb3045 100644 --- a/srchybrid/lang/pt_PT.rc +++ b/srchybrid/lang/pt_PT.rc @@ -1549,7 +1549,7 @@ BEGIN IDS_NEWMSG "Nova mensagem de '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "apenas na mesma categoria" IDS_LOG_ULDL_EVENTS "Registar eventos de upload/download" - IDS_PEERCACHE_ENABLED "O seu suporta a tecnologia PeerCache, permitindo downloads a partir da cache!" +// IDS_PEERCACHE_ENABLED "O seu suporta a tecnologia PeerCache, permitindo downloads a partir da cache!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permitir que o utilizador o adicione como amigo." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Falta ainda descarregar partes para conseguir pré-visualizar" END @@ -1591,9 +1591,9 @@ BEGIN "Active esta opção se quiser que o eMule seja iniciado sempre que arrancar o Windows. (Desactivado por defeito)" IDS_KAD_WAITCBK "Esperar resposta Kad" IDS_KAD_TOOMANDYKADLKPS "Demasiados pedidos de informação Kad" - IDS_PCDS_CLIENTWAIT "Atraso do Cliente" - IDS_PCDS_CACHEWAIT "Atraso da Cache" - IDS_CACHE "Cache"//! +// IDS_PCDS_CLIENTWAIT "Atraso do Cliente" +// IDS_PCDS_CACHEWAIT "Atraso da Cache" +// IDS_CACHE "Cache"//! IDS_INDEXED "Indexado" IDS_KADINFO_SRC "\tFonte: %u\r\n" IDS_KADINFO_KEYW "\tPalavra-chave: %u\r\n" diff --git a/srchybrid/lang/pt_PT.vcxproj b/srchybrid/lang/pt_PT.vcxproj index af446c57..014297a3 100644 --- a/srchybrid/lang/pt_PT.vcxproj +++ b/srchybrid/lang/pt_PT.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/ro_RO.rc b/srchybrid/lang/ro_RO.rc index 46d365bb..40d9ab52 100644 --- a/srchybrid/lang/ro_RO.rc +++ b/srchybrid/lang/ro_RO.rc @@ -1548,7 +1548,7 @@ BEGIN IDS_NEWMSG "Mesaj nou de la '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "doar din aceeaşi categorie" IDS_LOG_ULDL_EVENTS "Loghez evenimentele upload/download" - IDS_PEERCACHE_ENABLED "ISP-ul tău permite tehnologia PeerCache, activez descărcarea cache!" +// IDS_PEERCACHE_ENABLED "ISP-ul tău permite tehnologia PeerCache, activez descărcarea cache!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permit utilizatorului să te adauge la Prieteni." IDS_SOURCESWAPBLOCKED "Swap blocat" @@ -1590,9 +1590,9 @@ BEGIN "Activează pentru ca eMule să pornească odată cu Windows. (Implicit: dezactivat)" IDS_KAD_WAITCBK "Aştept răspuns Kad" IDS_KAD_TOOMANDYKADLKPS "Prea multe căutări Kad" - IDS_PCDS_CLIENTWAIT "Aştept Client" - IDS_PCDS_CACHEWAIT "Aştept Cache" - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "Aştept Client" +// IDS_PCDS_CACHEWAIT "Aştept Cache" +// IDS_CACHE "Cache" //! IDS_INDEXED "Indexat" IDS_KADINFO_SRC "\tSursă: %u\r\n" IDS_KADINFO_KEYW "\tKeyword: %u\r\n" //! diff --git a/srchybrid/lang/ro_RO.vcxproj b/srchybrid/lang/ro_RO.vcxproj index d1c5f545..51ac2d81 100644 --- a/srchybrid/lang/ro_RO.vcxproj +++ b/srchybrid/lang/ro_RO.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/ru_RU.rc b/srchybrid/lang/ru_RU.rc index cc72c897..fc892762 100644 --- a/srchybrid/lang/ru_RU.rc +++ b/srchybrid/lang/ru_RU.rc @@ -820,7 +820,7 @@ BEGIN IDS_NEWMSG "Новое сообщение от '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Только в той же категории" IDS_LOG_ULDL_EVENTS "Лог событий отдачи/приёма" - IDS_PEERCACHE_ENABLED "Ваш провайдер поддерживает технологию PeerCache, включение кэша для передач!" +// IDS_PEERCACHE_ENABLED "Ваш провайдер поддерживает технологию PeerCache, включение кэша для передач!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Разрешать добавление Вас в список друзей" IDS_SOURCESWAPBLOCKED "Обмен заблокирован" IDS_TRICKLING "Резерв" @@ -1618,9 +1618,9 @@ BEGIN "Запускать eMule вместе с Windows." IDS_KAD_WAITCBK "Ожидание Kad ответа" IDS_KAD_TOOMANDYKADLKPS "Слишком много поисков Kad" - IDS_PCDS_CLIENTWAIT "Ожидание клиента" - IDS_PCDS_CACHEWAIT "Ожидание кэша" - IDS_CACHE "Кэш" +// IDS_PCDS_CLIENTWAIT "Ожидание клиента" +// IDS_PCDS_CACHEWAIT "Ожидание кэша" +// IDS_CACHE "Кэш" IDS_INDEXED "Индексировано" IDS_KADINFO_SRC "\tИсточник: %u\r\n" IDS_KADINFO_KEYW "\tКлюч. слово: %u\r\n" diff --git a/srchybrid/lang/ru_RU.vcxproj b/srchybrid/lang/ru_RU.vcxproj index 2b69dcd9..6cfae427 100644 --- a/srchybrid/lang/ru_RU.vcxproj +++ b/srchybrid/lang/ru_RU.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/sl_SI.rc b/srchybrid/lang/sl_SI.rc index 8941b311..5a73d936 100644 --- a/srchybrid/lang/sl_SI.rc +++ b/srchybrid/lang/sl_SI.rc @@ -1538,7 +1538,7 @@ BEGIN IDS_NEWMSG "Novo sporočilo od '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "samo v isti kategoriji" IDS_LOG_ULDL_EVENTS "Beleži dogodke prenosov gor/dol" - IDS_PEERCACHE_ENABLED "Vaš ponudnik interneta podpira PeerCache tehnologijo, omogočanje prenosov iz predpomnilnika!" +// IDS_PEERCACHE_ENABLED "Vaš ponudnik interneta podpira PeerCache tehnologijo, omogočanje prenosov iz predpomnilnika!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Dovolite uporabnikom, da vas dodajo na seznam prijateljev." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Najprej prenesi dele, ki so potrebni za predogled" END @@ -1580,9 +1580,9 @@ BEGIN "Odkljukajte tukaj, če želite, da se bo eMule zagnal ob zagonu Windowsov." IDS_KAD_WAITCBK "Čakanje na povratni klic Kad" IDS_KAD_TOOMANDYKADLKPS "Preveč iskanj Kad" - IDS_PCDS_CLIENTWAIT "Čakanje odjemalca" - IDS_PCDS_CACHEWAIT "Čakanje predpomnilnika" - IDS_CACHE "Predpomnilnik" +// IDS_PCDS_CLIENTWAIT "Čakanje odjemalca" +// IDS_PCDS_CACHEWAIT "Čakanje predpomnilnika" +// IDS_CACHE "Predpomnilnik" IDS_INDEXED "Indeksirano" IDS_KADINFO_SRC "\tVir: %u\r\n" IDS_KADINFO_KEYW "\tKljučna beseda: %u\r\n" diff --git a/srchybrid/lang/sl_SI.vcxproj b/srchybrid/lang/sl_SI.vcxproj index e00a05c7..44cb9f60 100644 --- a/srchybrid/lang/sl_SI.vcxproj +++ b/srchybrid/lang/sl_SI.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/sq_AL.rc b/srchybrid/lang/sq_AL.rc index 947adfb3..279b6729 100644 --- a/srchybrid/lang/sq_AL.rc +++ b/srchybrid/lang/sq_AL.rc @@ -818,7 +818,7 @@ BEGIN IDS_NEWMSG "Mesazh i Ri nga '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Vetëm në të njëjtën kategori" IDS_LOG_ULDL_EVENTS "Trego ngjarje mbi ngarkesën/shkarkesën" - IDS_PEERCACHE_ENABLED "ISPja juaj e përkrah teknologjinë 'PeerCache', merret leje shkarkimi nga depo e fshehtë!" +// IDS_PEERCACHE_ENABLED "ISPja juaj e përkrah teknologjinë 'PeerCache', merret leje shkarkimi nga depo e fshehtë!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Lejo përdoruesin që t'ju shtojë si shok" IDS_SOURCESWAPBLOCKED "Tramba u bllokua" IDS_TRICKLING "Në mbështetje" @@ -1622,9 +1622,9 @@ BEGIN "Lejo këtë zgjedhje që eMule të punojë kur Windows nis. (Tipike: Palejuar)" IDS_KAD_WAITCBK "Prit Marrjen e Kad-it" IDS_KAD_TOOMANDYKADLKPS "Shumë Shikime në Kad" - IDS_PCDS_CLIENTWAIT "KlientPritje" - IDS_PCDS_CACHEWAIT "DepoPritje" - IDS_CACHE "Depoja" +// IDS_PCDS_CLIENTWAIT "KlientPritje" +// IDS_PCDS_CACHEWAIT "DepoPritje" +// IDS_CACHE "Depoja" IDS_INDEXED "E treguar" IDS_KADINFO_SRC "\tBurimi: %u\r\n" IDS_KADINFO_KEYW "\tFjala: %u\r\n" diff --git a/srchybrid/lang/sq_AL.vcxproj b/srchybrid/lang/sq_AL.vcxproj index 3ff814a1..542785d3 100644 --- a/srchybrid/lang/sq_AL.vcxproj +++ b/srchybrid/lang/sq_AL.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/sv_SE.rc b/srchybrid/lang/sv_SE.rc index 7551f10d..8d0c2596 100644 --- a/srchybrid/lang/sv_SE.rc +++ b/srchybrid/lang/sv_SE.rc @@ -1543,7 +1543,7 @@ BEGIN IDS_NEWMSG "Nytt meddelande från '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "bara i samma kategori" IDS_LOG_ULDL_EVENTS "Logga uppladdnings-/nedladdningshändelser" - IDS_PEERCACHE_ENABLED "Din ISP stöder PeerCache teknologin, aktiverar cachade nedladdningar!" +// IDS_PEERCACHE_ENABLED "Din ISP stöder PeerCache teknologin, aktiverar cachade nedladdningar!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Tillåt användare att lägga till dig som kompis." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Ladda hem de delar som behövs för förhandsvisning först" END @@ -1585,9 +1585,9 @@ BEGIN "Aktivera så att eMule startar när windows startar. (avaktiverad som standard)" IDS_KAD_WAITCBK "Vänta på svar från Kad" IDS_KAD_TOOMANDYKADLKPS "För många Kad Lookups" - IDS_PCDS_CLIENTWAIT "ClientWait" //! - IDS_PCDS_CACHEWAIT "CacheWait" //! - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "ClientWait" //! +// IDS_PCDS_CACHEWAIT "CacheWait" //! +// IDS_CACHE "Cache" //! IDS_INDEXED "Indexerad" IDS_KADINFO_SRC "\tKälla: %u\r\n" IDS_KADINFO_KEYW "\tOrd: %u\r\n" diff --git a/srchybrid/lang/sv_SE.vcxproj b/srchybrid/lang/sv_SE.vcxproj index 7e6a44ac..9ef6cdab 100644 --- a/srchybrid/lang/sv_SE.vcxproj +++ b/srchybrid/lang/sv_SE.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/tr_TR.rc b/srchybrid/lang/tr_TR.rc index 55b62530..b3a356f1 100644 --- a/srchybrid/lang/tr_TR.rc +++ b/srchybrid/lang/tr_TR.rc @@ -1566,7 +1566,7 @@ BEGIN IDS_NEWMSG "'%s' kullanıcısından Yeni Mesaj (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Sadece aynı kategori içindeki" IDS_LOG_ULDL_EVENTS "Gönderme/İndirme olaylarını günlükle" - IDS_PEERCACHE_ENABLED "ISS'niz PeerCache teknolojisini destekliyor, önbellek indirmeler etkinleştiriliyor!" +// IDS_PEERCACHE_ENABLED "ISS'niz PeerCache teknolojisini destekliyor, önbellek indirmeler etkinleştiriliyor!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Sizi arkadaş olarak eklemesi için kullanıcıya izin ver." IDS_SOURCESWAPBLOCKED "Geçiş Engellendi!" @@ -1609,9 +1609,9 @@ BEGIN "Bunu etkinleştirdiğiniz takdirde Windows'u başlattığınızda eMule çalışacak." IDS_KAD_WAITCBK "Kad geri aramayı beklemede" IDS_KAD_TOOMANDYKADLKPS "Çok fazla Kad Araması" - IDS_PCDS_CLIENTWAIT "İstemci Beklemede" - IDS_PCDS_CACHEWAIT "Önbellek Beklemede" - IDS_CACHE "Önbellek" +// IDS_PCDS_CLIENTWAIT "İstemci Beklemede" +// IDS_PCDS_CACHEWAIT "Önbellek Beklemede" +// IDS_CACHE "Önbellek" IDS_INDEXED "İndekslendi" IDS_KADINFO_SRC "\tKaynak: %u\r\n" IDS_KADINFO_KEYW "\tAnahtar Kelime: %u\r\n" diff --git a/srchybrid/lang/tr_TR.vcxproj b/srchybrid/lang/tr_TR.vcxproj index e2ce53da..356edb2a 100644 --- a/srchybrid/lang/tr_TR.vcxproj +++ b/srchybrid/lang/tr_TR.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/ua_UA.rc b/srchybrid/lang/ua_UA.rc index 9fb43d41..8ff04a19 100644 --- a/srchybrid/lang/ua_UA.rc +++ b/srchybrid/lang/ua_UA.rc @@ -819,7 +819,7 @@ BEGIN IDS_NEWMSG "Нове Повідомлення від '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Тільки в тій же категорії" IDS_LOG_ULDL_EVENTS "Лог відвантаження/завантаження" - IDS_PEERCACHE_ENABLED "Ваш провайдер підтримує технологію PeerCache." +// IDS_PEERCACHE_ENABLED "Ваш провайдер підтримує технологію PeerCache." IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Дозволити користувачам додавати Вас як Друга." IDS_SOURCESWAPBLOCKED "Блокований обмін" IDS_TRICKLING "Резерв" @@ -1626,9 +1626,9 @@ BEGIN "Запускати eMule разом з Windows. (За замовчуванням: Вимкн)" IDS_KAD_WAITCBK "Чекайте на відповідь Kad" IDS_KAD_TOOMANDYKADLKPS "Надто багато пошуків Kad" - IDS_PCDS_CLIENTWAIT "Клієнт в очікуванні" - IDS_PCDS_CACHEWAIT "Резервний в очікуванні" - IDS_CACHE "Резервний" +// IDS_PCDS_CLIENTWAIT "Клієнт в очікуванні" +// IDS_PCDS_CACHEWAIT "Резервний в очікуванні" +// IDS_CACHE "Резервний" IDS_INDEXED "Внесений у вказівник" IDS_KADINFO_SRC "\tДжерело: %u\r\n" IDS_KADINFO_KEYW "\tКлюч. слово: %u\r\n" diff --git a/srchybrid/lang/ua_UA.vcxproj b/srchybrid/lang/ua_UA.vcxproj index a3ac75a4..30654598 100644 --- a/srchybrid/lang/ua_UA.vcxproj +++ b/srchybrid/lang/ua_UA.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/ug_CN.rc b/srchybrid/lang/ug_CN.rc index 04169007..0001e1e9 100644 --- a/srchybrid/lang/ug_CN.rc +++ b/srchybrid/lang/ug_CN.rc @@ -907,7 +907,7 @@ BEGIN IDS_NEWMSG "‫يېڭى ئۇچۇر '%s' (IP:%s) كەلگەن‬" IDS_PREF_STARTNEXTFILECATONLY "پەقەت ئوخشاش تۈردىلا" IDS_LOG_ULDL_EVENTS "يوللاش چۈشۈرۈش ھادىسىنى خاتىرىلە" - IDS_PEERCACHE_ENABLED "‫ISP ئىنتېرنېت ئۇلىنىش مۇلازىمىتى تەمىنلىگۈچىڭىز PeerCache تېخنىكىسىنى قوللايدۇ، PeerCache نى قوزغىتىپ چۈشۈر!‬" +// IDS_PEERCACHE_ENABLED "‫ISP ئىنتېرنېت ئۇلىنىش مۇلازىمىتى تەمىنلىگۈچىڭىز PeerCache تېخنىكىسىنى قوللايدۇ، PeerCache نى قوزغىتىپ چۈشۈر!‬" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "باشقىلارنىڭ سىزنى دوست قاتارىغا قوشۇشىغا يول قوي" IDS_SOURCESWAPBLOCKED "ئالماشتۇرۇش چەكلەندى" IDS_TRICKLING "كۈتۈش" @@ -1618,9 +1618,9 @@ BEGIN "‫بۇ تاللانما تاللانسا Windows قوزغالغاندا eMule ئۆزلۈكىدىن قوزغىلىدۇ. [ئەسلىدىكى چەكلەنگەن]‬" IDS_KAD_WAITCBK "‫Kad قايتۇرۇش ئۇچۇرى كۈتۈۋاتىدۇ‬" IDS_KAD_TOOMANDYKADLKPS "‫Kad ئىزدەش بەك كۆپ‬" - IDS_PCDS_CLIENTWAIT "خېرىدار كۈتۈۋاتىدۇ" - IDS_PCDS_CACHEWAIT "غەملەك كۈتۈۋاتىدۇ" - IDS_CACHE "غەملەك" +// IDS_PCDS_CLIENTWAIT "خېرىدار كۈتۈۋاتىدۇ" +// IDS_PCDS_CACHEWAIT "غەملەك كۈتۈۋاتىدۇ" +// IDS_CACHE "غەملەك" IDS_INDEXED "ئىندېكس" IDS_KADINFO_SRC "\tمەنبە: %u\r\n" IDS_KADINFO_KEYW "\tھالقىلىق سۆز: %u\r\n" diff --git a/srchybrid/lang/ug_CN.vcxproj b/srchybrid/lang/ug_CN.vcxproj index 3a6fe84f..f5a8c8c6 100644 --- a/srchybrid/lang/ug_CN.vcxproj +++ b/srchybrid/lang/ug_CN.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/va_ES.rc b/srchybrid/lang/va_ES.rc index 39f6ba8e..f86e4fac 100644 --- a/srchybrid/lang/va_ES.rc +++ b/srchybrid/lang/va_ES.rc @@ -1544,7 +1544,7 @@ BEGIN IDS_NEWMSG "Missatge nou procedent de «%s» (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "només a la mateixa categoria" IDS_LOG_ULDL_EVENTS "Registra els esdeveniments de pujada/baixada" - IDS_PEERCACHE_ENABLED "El vostre proveïdor d'Internet admet la tecnologia de cau-entre-iguals (PeerCache). S'activarà la cau de baixades" +// IDS_PEERCACHE_ENABLED "El vostre proveïdor d'Internet admet la tecnologia de cau-entre-iguals (PeerCache). S'activarà la cau de baixades" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permet a l'usuari que vos afegisca com a amic." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Baixa primer les parts que calen per a la previsualització" END @@ -1586,9 +1586,9 @@ BEGIN "Activeu-ho per i fer que l'eMule s'execute quan inicieu el Windows." IDS_KAD_WAITCBK "Espera el retorn de la crida Kad" IDS_KAD_TOOMANDYKADLKPS "Hi ha massa resolucions Kad" - IDS_PCDS_CLIENTWAIT "Espera del client" - IDS_PCDS_CACHEWAIT "Espera de la cau" - IDS_CACHE "Cau" +// IDS_PCDS_CLIENTWAIT "Espera del client" +// IDS_PCDS_CACHEWAIT "Espera de la cau" +// IDS_CACHE "Cau" IDS_INDEXED "Indexat" IDS_KADINFO_SRC "\tFont: %u\r\n" IDS_KADINFO_KEYW "\tParaula clau: %u\r\n" diff --git a/srchybrid/lang/va_ES.vcxproj b/srchybrid/lang/va_ES.vcxproj index 148c54b9..8c028561 100644 --- a/srchybrid/lang/va_ES.vcxproj +++ b/srchybrid/lang/va_ES.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/va_ES_RACV.rc b/srchybrid/lang/va_ES_RACV.rc index 80c2506b..954ad2bc 100644 --- a/srchybrid/lang/va_ES_RACV.rc +++ b/srchybrid/lang/va_ES_RACV.rc @@ -1554,7 +1554,7 @@ BEGIN IDS_NEWMSG "Nou Mensage de '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Només en la mateixa categoria" IDS_LOG_ULDL_EVENTS "Registrar events de pujada/descarrega" - IDS_PEERCACHE_ENABLED "El teu proveïdor d'accés a Internet (ISP) es compatible en PeerCache. ¡Activant descarregues en Cache!" +// IDS_PEERCACHE_ENABLED "El teu proveïdor d'accés a Internet (ISP) es compatible en PeerCache. ¡Activant descarregues en Cache!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Permetre a un usuari afegir-te com amic." IDS_DL_TRY_TO_GET_PREVIEW_PARTS "Descarregar primer les parts necessàries per a previsualisar" END @@ -1596,9 +1596,9 @@ BEGIN "Activa esta opció si vols que l'eMule s'inicie a la volta que Windows. (Desactivat per defecte)" IDS_KAD_WAITCBK "Esperant resposta Kad" IDS_KAD_TOOMANDYKADLKPS "Moltes busques Kad" - IDS_PCDS_CLIENTWAIT "Espera de Client" - IDS_PCDS_CACHEWAIT "Espera de Caché" - IDS_CACHE "Caché" +// IDS_PCDS_CLIENTWAIT "Espera de Client" +// IDS_PCDS_CACHEWAIT "Espera de Caché" +// IDS_CACHE "Caché" IDS_INDEXED "Indexat" IDS_KADINFO_SRC "\tFont: %u\r\n" IDS_KADINFO_KEYW "\tParaula clau: %u\r\n" diff --git a/srchybrid/lang/va_ES_RACV.vcxproj b/srchybrid/lang/va_ES_RACV.vcxproj index c53996ac..68c8c680 100644 --- a/srchybrid/lang/va_ES_RACV.vcxproj +++ b/srchybrid/lang/va_ES_RACV.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/vi_VN.rc b/srchybrid/lang/vi_VN.rc index f6737e09..282c9963 100644 --- a/srchybrid/lang/vi_VN.rc +++ b/srchybrid/lang/vi_VN.rc @@ -820,7 +820,7 @@ BEGIN IDS_NEWMSG "Tin nhắn mới từ '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "Chỉ các Tập tin cùng Danh mục" IDS_LOG_ULDL_EVENTS "Ghi lại sự kiện tải lên/xuống" - IDS_PEERCACHE_ENABLED "Nhà cung cấp Mạng của bạn hỗ trợ công nghệ PeerCache, kích hoạt tải về từ bộ nhớ truy xuất nhanh - cache!" +// IDS_PEERCACHE_ENABLED "Nhà cung cấp Mạng của bạn hỗ trợ công nghệ PeerCache, kích hoạt tải về từ bộ nhớ truy xuất nhanh - cache!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "Cho phép người dùng thêm bạn là Bạn bè." IDS_SOURCESWAPBLOCKED "Trao đổi bị khóa" IDS_TRICKLING "Đang đợi" @@ -1627,9 +1627,9 @@ BEGIN "eMule sẽ tự chạy khi khởi động windows." IDS_KAD_WAITCBK "Đợi yêu cầu thông qua Kad" //Wait Callback Kad IDS_KAD_TOOMANDYKADLKPS "Quá nhiều Tìm kiếm Kad" - IDS_PCDS_CLIENTWAIT "Máykhách-Đợi" - IDS_PCDS_CACHEWAIT "Cache-Đợi" - IDS_CACHE "Cache" //! +// IDS_PCDS_CLIENTWAIT "Máykhách-Đợi" +// IDS_PCDS_CACHEWAIT "Cache-Đợi" +// IDS_CACHE "Cache" //! IDS_INDEXED "Số chỉ mục" IDS_KADINFO_SRC "\tNguồn: %u\r\n" IDS_KADINFO_KEYW "\từKhóa: %u\r\n" diff --git a/srchybrid/lang/vi_VN.vcxproj b/srchybrid/lang/vi_VN.vcxproj index c15de2bb..82fcb523 100644 --- a/srchybrid/lang/vi_VN.vcxproj +++ b/srchybrid/lang/vi_VN.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/zh_CN.rc b/srchybrid/lang/zh_CN.rc index 3d4d0b39..0f050c3a 100644 --- a/srchybrid/lang/zh_CN.rc +++ b/srchybrid/lang/zh_CN.rc @@ -910,7 +910,7 @@ BEGIN IDS_NEWMSG "新的消息来自 '%s' (IP:%s) " IDS_PREF_STARTNEXTFILECATONLY "仅在相同的分类中" IDS_LOG_ULDL_EVENTS "记录上传/下载事件" - IDS_PEERCACHE_ENABLED "你的 ISP 支持 PeerCache 技术,启用 PeerCache 下载!" +// IDS_PEERCACHE_ENABLED "你的 ISP 支持 PeerCache 技术,启用 PeerCache 下载!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "允许其他用户添加你为好友" IDS_SOURCESWAPBLOCKED "已禁止置换" IDS_TRICKLING "阻塞" @@ -1621,9 +1621,9 @@ BEGIN "允许这个选项将使得eMule在Windows启动时自动运行.(默认 禁止)" IDS_KAD_WAITCBK "等待 Kad 返回消息" IDS_KAD_TOOMANDYKADLKPS "过多的 Kad 查找" - IDS_PCDS_CLIENTWAIT "客户端等待" - IDS_PCDS_CACHEWAIT "缓存等待" - IDS_CACHE "缓存" +// IDS_PCDS_CLIENTWAIT "客户端等待" +// IDS_PCDS_CACHEWAIT "缓存等待" +// IDS_CACHE "缓存" IDS_INDEXED "索引" IDS_KADINFO_SRC "\t来源: %u\r\n" IDS_KADINFO_KEYW "\t关键字: %u\r\n" diff --git a/srchybrid/lang/zh_CN.vcxproj b/srchybrid/lang/zh_CN.vcxproj index 8673d158..4ac56909 100644 --- a/srchybrid/lang/zh_CN.vcxproj +++ b/srchybrid/lang/zh_CN.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/lang/zh_TW.rc b/srchybrid/lang/zh_TW.rc index 478ae6bd..15d06c3a 100644 --- a/srchybrid/lang/zh_TW.rc +++ b/srchybrid/lang/zh_TW.rc @@ -1536,7 +1536,7 @@ BEGIN IDS_NEWMSG "新的訊息來自 '%s' (IP:%s)" IDS_PREF_STARTNEXTFILECATONLY "只在相同的類別" IDS_LOG_ULDL_EVENTS "記錄 上載/下載 事件" - IDS_PEERCACHE_ENABLED "您的 ISP 支援 PeerCache 技術, 啟用快取下載!" +// IDS_PEERCACHE_ENABLED "您的 ISP 支援 PeerCache 技術, 啟用快取下載!" IDS_IRC_EMULEPROTO_ALLOWADDFRIEND "允許使用者將您加入成為好友" IDS_SOURCESWAPBLOCKED "置換被封鎖" IDS_TRICKLING "待命" @@ -1578,9 +1578,9 @@ BEGIN "啟用這個 eMule 將會在您的 Windows 啟動時執行." IDS_KAD_WAITCBK "等待 Kad 回覆" IDS_KAD_TOOMANDYKADLKPS "太多的 Kad 回授" - IDS_PCDS_CLIENTWAIT "客戶端等待" - IDS_PCDS_CACHEWAIT "快取等待" - IDS_CACHE "快取" +// IDS_PCDS_CLIENTWAIT "客戶端等待" +// IDS_PCDS_CACHEWAIT "快取等待" +// IDS_CACHE "快取" IDS_INDEXED "索引" IDS_KADINFO_SRC "\t來源: %u\r\n" IDS_KADINFO_KEYW "\t關鍵字: %u\r\n" diff --git a/srchybrid/lang/zh_TW.vcxproj b/srchybrid/lang/zh_TW.vcxproj index ee196d77..5e6009d3 100644 --- a/srchybrid/lang/zh_TW.vcxproj +++ b/srchybrid/lang/zh_TW.vcxproj @@ -19,7 +19,7 @@ DynamicLibrary Unicode - v143 + v141_xp diff --git a/srchybrid/res/emule.rc2 b/srchybrid/res/emule.rc2 index fd29ef34..852bc1d8 100644 --- a/srchybrid/res/emule.rc2 +++ b/srchybrid/res/emule.rc2 @@ -38,7 +38,7 @@ BEGIN VALUE "FileDescription", "eMule" VALUE "FileVersion", SZ_VERSION_NAME " Unicode" VALUE "InternalName", "emule.exe" - VALUE "LegalCopyright", "Copyright © 2002-2023 Merkur - Read license.txt for more infos." + VALUE "LegalCopyright", "Copyright © 2002-2024 Merkur - Read license.txt for more infos." VALUE "OriginalFilename", "emule.exe" VALUE "ProductName", "eMule" VALUE "ProductVersion", SZ_VERSION_NAME " Unicode" diff --git a/srchybrid/res/emuleWin32.manifest b/srchybrid/res/emuleWin32.manifest index c9e4087a..6b124684 100644 --- a/srchybrid/res/emuleWin32.manifest +++ b/srchybrid/res/emuleWin32.manifest @@ -4,7 +4,7 @@ name="eMule" processorArchitecture="x86" publicKeyToken="0000000000000000" - version="0.70.0.9" + version="0.70.1.5" /> eMule by https://www.emule-project.net diff --git a/srchybrid/res/emulex64.manifest b/srchybrid/res/emulex64.manifest index d7d35dad..3f1667ee 100644 --- a/srchybrid/res/emulex64.manifest +++ b/srchybrid/res/emulex64.manifest @@ -4,7 +4,7 @@ name="eMule" processorArchitecture="amd64" publicKeyToken="0000000000000000" - version="0.70.0.9" + version="0.70.1.5" /> eMule by https://www.emule-project.net