Skip to content

Commit

Permalink
Small improvements and regression fixes made after the release of 0.60b.
Browse files Browse the repository at this point in the history
irwir committed May 11, 2021
1 parent 0c8a84c commit 230972e
Showing 65 changed files with 235 additions and 213 deletions.
5 changes: 4 additions & 1 deletion srchybrid/BaseClient.cpp
Original file line number Diff line number Diff line change
@@ -161,6 +161,7 @@ void CUpDownClient::Init()
m_dwLastSourceRequest = 0;
m_dwLastSourceAnswer = 0;
m_dwLastAskedForSources = 0;
m_uSearchID = 0;
m_iFileListRequested = 0;

m_uFileRating = 0;
@@ -2283,6 +2284,7 @@ void CUpDownClient::AssertValid() const
(void)m_dwLastSourceRequest;
(void)m_dwLastSourceAnswer;
(void)m_dwLastAskedForSources;
(void)m_uSearchID;
(void)m_iFileListRequested;
(void)m_byCompatibleClient;
m_WaitingPackets_list.AssertValid();
@@ -2994,7 +2996,8 @@ void CUpDownClient::SetConnectOptions(uint8 byOptions, bool bEncryption, bool bC

void CUpDownClient::SendSharedDirectories()
{
//TODO: Don't send shared directories which do not contain any files
//TODO: Don't send shared directories without any files
theApp.sharedfiles->ResetPseudoDirNames(); //purge stale data
// add shared directories
CStringArray arFolders;
for (POSITION pos = thePrefs.shareddir_list.GetHeadPosition(); pos != NULL;) {
2 changes: 1 addition & 1 deletion srchybrid/DownloadQueue.cpp
Original file line number Diff line number Diff line change
@@ -881,7 +881,7 @@ bool CDownloadQueue::SendNextUDPPacket()
Debug(_T("Rotating file list\n"));

// move the last 35 files to the head
if (filelist.GetCount() >= MAX_REQUESTS_PER_SERVER)
if (filelist.GetCount() > MAX_REQUESTS_PER_SERVER)
for (int i = MAX_REQUESTS_PER_SERVER; --i >= 0;)
filelist.AddHead(filelist.RemoveTail());

46 changes: 25 additions & 21 deletions srchybrid/EMSocket.cpp
Original file line number Diff line number Diff line change
@@ -863,18 +863,20 @@ SocketSentBytes CEMSocket::SendOv(uint32 maxNumberOfBytesToSend, uint32 minFragS
else
m_numberOfSentBytesCompleteFile += pCurBuf.len;
}
// all right, prepare to send our collected buffers
memset(&m_PendingSendOperation, 0, sizeof WSAOVERLAPPED);
m_PendingSendOperation.hEvent = theApp.uploadBandwidthThrottler->GetSocketAvailableEvent();
m_bPendingSendOv = true;
if (CEncryptedStreamSocket::SendOv(m_aBufferSend, &m_PendingSendOperation) == 0)
CleanUpOverlappedSendOperation(false);
else {
int nError = WSAGetLastError();
if (nError != WSA_IO_PENDING) {
anErrorHasOccured = true;
theApp.QueueDebugLogLineEx(ERROR, _T("WSASend() Error: %u, %s"), nError, (LPCTSTR)GetErrorMessage(nError));
CleanUpOverlappedSendOperation(true);
if (m_aBufferSend.GetCount() > 0) {
// all right, prepare to send our collected buffers
memset(&m_PendingSendOperation, 0, sizeof WSAOVERLAPPED);
m_PendingSendOperation.hEvent = theApp.uploadBandwidthThrottler->GetSocketAvailableEvent();
m_bPendingSendOv = true;
if (CEncryptedStreamSocket::SendOv(m_aBufferSend, &m_PendingSendOperation) == 0)
CleanUpOverlappedSendOperation(false);
else {
int nError = WSAGetLastError();
if (nError != WSA_IO_PENDING) {
anErrorHasOccured = true;
theApp.QueueDebugLogLineEx(ERROR, _T("WSASend() Error: %u, %s"), nError, (LPCTSTR)GetErrorMessage(nError));
CleanUpOverlappedSendOperation(true);
}
}
}
}
@@ -1155,17 +1157,19 @@ bool CEMSocket::UseBigSendBuffer()
int val = BIGSIZE;
int oldval;
int vallen = sizeof oldval;
if (GetSockOpt(SO_SNDBUF, &oldval, &vallen) && BIGSIZE > oldval) {
SetSockOpt(SO_SNDBUF, &val, sizeof val);
vallen = sizeof val;
m_bUseBigSendBuffers = (GetSockOpt(SO_SNDBUF, &val, &vallen) && val >= BIGSIZE);
}
if (GetSockOpt(SO_SNDBUF, &oldval, &vallen))
if (BIGSIZE > oldval) {
SetSockOpt(SO_SNDBUF, &val, sizeof val);
vallen = sizeof val;
m_bUseBigSendBuffers = (GetSockOpt(SO_SNDBUF, &val, &vallen) && val >= BIGSIZE);
#if defined(_DEBUG) || defined(_BETA) || defined(_DEVBUILD)
if (m_bUseBigSendBuffers)
theApp.QueueDebugLogLine(false, _T("Increased Sendbuffer for uploading socket from %u KiB to %u KiB"), oldval / 1024, val / 1024);
else
theApp.QueueDebugLogLine(false, _T("Failed to increase Sendbuffer for uploading socket, stays at %u KiB"), oldval / 1024);
if (m_bUseBigSendBuffers)
theApp.QueueDebugLogLine(false, _T("Increased Sendbuffer for uploading socket from %u KiB to %u KiB"), oldval / 1024, val / 1024);
else
theApp.QueueDebugLogLine(false, _T("Failed to increase Sendbuffer for uploading socket, stays at %u KiB"), oldval / 1024);
#endif
} else
m_bUseBigSendBuffers = true;
}
return m_bUseBigSendBuffers;
}
6 changes: 2 additions & 4 deletions srchybrid/EmuleDlg.cpp
Original file line number Diff line number Diff line change
@@ -359,6 +359,7 @@ void DialogCreateIndirect(CDialog *pWnd, UINT uID)

BOOL CemuleDlg::OnInitDialog()
{
theStats.starttime = ::GetTickCount();
#ifdef HAVE_WIN7_SDK_H
// allow the TaskbarButtonCreated- & (tbb-)WM_COMMAND message to be sent to our window if our app is running elevated
if (thePrefs.GetWindowsVersion() >= _WINVER_7_) {
@@ -610,8 +611,6 @@ BOOL CemuleDlg::OnInitDialog()
if (thePrefs.GetVerbose() && !m_hTimer)
AddDebugLogLine(true, _T("Failed to create 'startup' timer - %s"), (LPCTSTR)GetErrorMessage(::GetLastError()));

theStats.starttime = ::GetTickCount();

// Start UPnP port forwarding
if (thePrefs.IsUPnPEnabled())
StartUPnP();
@@ -2008,9 +2007,8 @@ void CemuleDlg::RestoreWindow()
preferenceswnd->BringWindowToTop();
return;
}
if (TrayIsVisible())
TrayHide();

TrayHide();
DestroyMiniMule();

if (m_wpFirstRestore.length) {
4 changes: 2 additions & 2 deletions srchybrid/FileInfoDialog.cpp
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ class CMediaInfoDLL
(FARPROC &)m_pfnMediaInfo_Count_Get = GetProcAddress(m_hLib, "MediaInfo_Count_Get");
if (m_pfnMediaInfo5_Open && m_pfnMediaInfo_Close && m_pfnMediaInfo_Get)
m_ullVersion = ullVersion;
} else if (ullVersion < MAKEDLLVERULL(20, 10, 0, 0)) { //here ullVersion >= 7.0
} else if (ullVersion < MAKEDLLVERULL(21, 4, 0, 0)) { //here ullVersion >= 7.0
(FARPROC &)m_pfnMediaInfo_New = GetProcAddress(m_hLib, "MediaInfo_New");
(FARPROC &)m_pfnMediaInfo_Delete = GetProcAddress(m_hLib, "MediaInfo_Delete");
(FARPROC &)m_pfnMediaInfo_Open = GetProcAddress(m_hLib, "MediaInfo_Open");
@@ -1230,9 +1230,9 @@ bool CGetMediaInfoThread::GetMediaInfo(HWND hWndOwner, const CShareableFile *pFi
case ID3FID_WWWUSER:
{
wchar_t *sURL = ID3_GetStringW(frame, ID3FN_URL);
wchar_t *sDesc = ID3_GetStringW(frame, ID3FN_DESCRIPTION);
CString strURL(sURL);
if (!strURL.Trim().IsEmpty()) {
wchar_t* sDesc = ID3_GetStringW(frame, ID3FN_DESCRIPTION);
CString strDesc(sDesc);
if (!strDesc.Trim().IsEmpty())
strFidInfo << _T("(") << strDesc << _T("): ");
2 changes: 1 addition & 1 deletion srchybrid/PartFile.cpp
Original file line number Diff line number Diff line change
@@ -2085,7 +2085,7 @@ void CPartFile::DrawStatusBar(CDC *dc, const CRect &rect, bool bFlat) /*const*/
s_LoadBar.Fill(crProgress);
s_LoadBar.Draw(dc, rect.left, rect.top, false);
} else {
RECT gaprect = { rect.left, rect.top, rect.left + (LONG)width, gaprect.top + PROGRESS_HEIGHT };
RECT gaprect = { rect.left, rect.top, rect.left + (LONG)width, rect.top + PROGRESS_HEIGHT };
dc->FillSolidRect(&gaprect, crProgress);
//draw gray progress only if flat
gaprect.left = gaprect.right;
9 changes: 7 additions & 2 deletions srchybrid/SearchList.cpp
Original file line number Diff line number Diff line change
@@ -167,9 +167,14 @@ void CSearchList::NewSearch(CSearchListCtrl *pWnd, const CString &strResultFileT
}

UINT CSearchList::ProcessSearchAnswer(const uchar *in_packet, uint32 size
, const CUpDownClient &sender, bool *pbMoreResultsAvailable, LPCTSTR pszDirectory)
, CUpDownClient &sender, bool *pbMoreResultsAvailable, LPCTSTR pszDirectory)
{
uint32 uSearchID = theApp.emuledlg->searchwnd->m_pwndResults->GetNextSearchID();
uint32 uSearchID = sender.GetSearchID();
if (!uSearchID) {
uSearchID = theApp.emuledlg->searchwnd->m_pwndResults->GetNextSearchID();
sender.SetSearchID(uSearchID);
}
ASSERT(uSearchID);
SSearchParams *pParams = new SSearchParams;
pParams->strExpression = sender.GetUserName();
pParams->dwSearchID = uSearchID;
2 changes: 1 addition & 1 deletion srchybrid/SearchList.h
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ class CSearchList

void Clear();
void NewSearch(CSearchListCtrl *pWnd, const CString &strResultFileType, SSearchParams *pParams);
UINT ProcessSearchAnswer(const uchar *in_packet, uint32 size, const CUpDownClient &sender, bool *pbMoreResultsAvailable, LPCTSTR pszDirectory = NULL);
UINT ProcessSearchAnswer(const uchar *in_packet, uint32 size, CUpDownClient &sender, bool *pbMoreResultsAvailable, LPCTSTR pszDirectory = NULL);
UINT ProcessSearchAnswer(const uchar *in_packet, uint32 size, bool bOptUTF8, uint32 nServerIP, uint16 nServerPort, bool *pbMoreResultsAvailable);
UINT ProcessUDPSearchAnswer(CFileDataIO &packet, bool bOptUTF8, uint32 nServerIP, uint16 nServerPort);
UINT GetED2KResultCount() const;
5 changes: 4 additions & 1 deletion srchybrid/SharedFileList.h
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ class CSharedFileList
friend class CSharedFilesCtrl;
friend class CClientReqSocket;

void AddDirectory(const CString &strDir, CStringList &dirlist);
public:
explicit CSharedFileList(CServerConnect *in_server);
~CSharedFileList();
@@ -101,6 +100,8 @@ class CSharedFileList

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; };
void ResetPseudoDirNames() { m_mapPseudoDirNames.RemoveAll(); }

protected:
bool AddFile(CKnownFile *pFile);
void AddFilesFromDirectory(const CString &rstrDirectory);
@@ -115,6 +116,8 @@ class CSharedFileList
bool CheckAndAddSingleFile(const CString &rstrFilePath); // add specific files without editing sharing preferences

private:
void AddDirectory(const CString& strDir, CStringList& dirlist);

CMap<CCKey, const CCKey&, CKnownFile*, CKnownFile*> m_Files_map;
CMap<CSKey, const CSKey&, bool, bool> m_UnsharedFiles_map;
CMapStringToString m_mapPseudoDirNames;
3 changes: 2 additions & 1 deletion srchybrid/TimeTick.cpp
Original file line number Diff line number Diff line change
@@ -40,8 +40,9 @@ float CTimeTick::Tick()

if (m_nPerformanceFrequency) {
QueryPerformanceCounter(&nTime);
float nTickTime = GetTimeInMilliSeconds(nTime.QuadPart - m_nTimeElapsed.QuadPart);
m_nTimeElapsed.QuadPart = nTime.QuadPart;
return GetTimeInMilliSeconds(nTime.QuadPart - m_nTimeElapsed.QuadPart);
return nTickTime;
}
return 0.0f;
}
10 changes: 6 additions & 4 deletions srchybrid/ToolTipCtrlX.cpp
Original file line number Diff line number Diff line change
@@ -414,7 +414,7 @@ void CToolTipCtrlX::CustomPaint(LPNMTTCUSTOMDRAW pNMCD)
const CRect rect(ptText.x + iIconDrawingWidth, ptText.y, ptText.x + iMaxSingleLineWidth, ptText.y + iTextHeight);
// first line on special file icon tab - draw icon and bold filename
if (hTheme && bUseEmbeddedThemeFonts)
g_xpStyle.DrawThemeText(hTheme, pdc->m_hDC, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), m_dwCol1DrawTextFlags, 0, &rect);
g_xpStyle.DrawThemeText(hTheme, pdc->m_hDC, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), m_dwCol1DrawTextFlags, 0, rect);
else {
CFont *pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL;
pdc->DrawText(strLine, const_cast<CRect&>(rect), m_dwCol1DrawTextFlags);
@@ -451,8 +451,10 @@ void CToolTipCtrlX::CustomPaint(LPNMTTCUSTOMDRAW pNMCD)
} else {
// Text is written in the currently selected font. If 'nTabPositions' is 0 and 'lpnTabStopPositions' is NULL,
// tabs are expanded to eight times the average character width.
// Win98: To draw an empty line we need to output at least a space.
siz = pdc->TabbedTextOut(ptText.x, ptText.y, (strLine.IsEmpty() ? _T(" ") : strLine), -1, NULL, 0);
if (strLine.IsEmpty()) // Win98: To draw an empty line we need to output at least a space.
siz = pdc->TabbedTextOut(ptText.x, ptText.y, _T(" "), 1, NULL, 0);
else
siz = pdc->TabbedTextOut(ptText.x, ptText.y, strLine, strLine.GetLength(), NULL, 0);
ptText.y += siz.cy + iLineHeightOff;
}
}
@@ -528,7 +530,7 @@ BOOL CToolTipCtrlX::OnTTShow(LPNMHDR pNMHDR, LRESULT *pResult)
// exact positioning of in-place tooltips which is performed by the tooltip control by default.
// Thus it is important that we tell MFC (not the Windows API in that case) to further route this message.
*pResult = FALSE; // Windows API: Perform default positioning
return FALSE; // MFC API. Perform further routing of this message (to the sub-classed tooltip control)
return FALSE; // MFC API. Perform further routing of this message (to the subclassed tooltip control)
}

void CToolTipCtrlX::OnNmCustomDraw(LPNMHDR pNMHDR, LRESULT *pResult)
33 changes: 15 additions & 18 deletions srchybrid/TrayDialog.cpp
Original file line number Diff line number Diff line change
@@ -52,9 +52,9 @@ CTrayDialog::CTrayDialog(UINT uIDD, CWnd *pParent /*=NULL*/)
, m_pbMinimizeToTray()
, m_hPrevIconDelete()
, m_uSingleClickTimer()
, u_DblClickSpeed(::GetDoubleClickTime())
, m_uLButtonDown()
, m_bCurIconDelete()
, m_bLButtonDblClk()
, m_bLButtonDown()
, m_bTrayIconVisible()
//, m_nDefaultMenuItem()
{
@@ -137,8 +137,8 @@ bool CTrayDialog::TrayShow()
bool CTrayDialog::TrayHide()
{
bool bSuccess = Shell_NotifyIcon(NIM_DELETE, &m_nidIconData);
if (bSuccess)
m_bTrayIconVisible = false;
m_bTrayIconVisible = false;
m_uLButtonDown = 0;
return bSuccess;
}

@@ -204,16 +204,12 @@ LRESULT CTrayDialog::OnTrayNotify(WPARAM wParam, LPARAM lParam)
// WM_LBUTTONUP without checking this, we may get a single WM_LBUTTONUP message
// whereby the according WM_LBUTTONDOWN message was meant for some other tray bar
// icon.
if (m_bLButtonDblClk || (m_bLButtonDown && !thePrefs.m_bEnableMiniMule)) { //use single click to restore from tray
KillSingleClickTimer();
RestoreWindow();
if (!thePrefs.m_bEnableMiniMule) //if restoring on single click
m_bLButtonDown = false; //reset single click too
m_bLButtonDblClk = false;
} else if (m_bLButtonDown) {
if (!m_uSingleClickTimer && !IsWindowVisible())
m_uSingleClickTimer = SetTimer(IDT_SINGLE_CLICK, 300, NULL);
m_bLButtonDown = false;
if (m_uLButtonDown) {
if (m_uLButtonDown > 1 || !thePrefs.m_bEnableMiniMule) { //use single click to restore from tray
KillSingleClickTimer();
RestoreWindow();
} else if (!m_uSingleClickTimer && !IsWindowVisible())
m_uSingleClickTimer = SetTimer(IDT_SINGLE_CLICK, u_DblClickSpeed, NULL);
}
break;
case WM_LBUTTONDBLCLK:
@@ -244,6 +240,7 @@ void CTrayDialog::KillSingleClickTimer()
VERIFY(KillTimer(m_uSingleClickTimer));
m_uSingleClickTimer = 0;
}
m_uLButtonDown = 0;
}

void CTrayDialog::OnTimer(UINT_PTR nIDEvent)
@@ -253,8 +250,8 @@ void CTrayDialog::OnTimer(UINT_PTR nIDEvent)
// Kill that timer before calling 'OnTrayLButtonUp' which may create the MiniMule window asynchronously!
KillSingleClickTimer();
OnTrayLButtonUp(CPoint());
}
CDialogMinTrayBtn<CResizableDialog>::OnTimer(nIDEvent);
} else
CDialogMinTrayBtn<CResizableDialog>::OnTimer(nIDEvent);
}

void CTrayDialog::OnSysCommand(UINT nID, LPARAM lParam)
@@ -292,7 +289,7 @@ void CTrayDialog::OnTrayRButtonUp(CPoint)

void CTrayDialog::OnTrayLButtonDown(CPoint)
{
m_bLButtonDown = true;
m_uLButtonDown = 1;
}

void CTrayDialog::OnTrayLButtonUp(CPoint)
@@ -301,7 +298,7 @@ void CTrayDialog::OnTrayLButtonUp(CPoint)

void CTrayDialog::OnTrayLButtonDblClk(CPoint)
{
m_bLButtonDblClk = true;
m_uLButtonDown = 2;
}

void CTrayDialog::OnTrayRButtonDblClk(CPoint)
6 changes: 3 additions & 3 deletions srchybrid/TrayDialog.h
Original file line number Diff line number Diff line change
@@ -38,10 +38,10 @@ class CTrayDialog : public CDialogMinTrayBtn<CResizableDialog>
HICON m_hPrevIconDelete;
CMenu m_mnuTrayMenu;
NOTIFYICONDATA m_nidIconData;
UINT_PTR m_uSingleClickTimer;
UINT_PTR m_uSingleClickTimer;
UINT u_DblClickSpeed;
byte m_uLButtonDown;
bool m_bCurIconDelete;
bool m_bLButtonDblClk;
bool m_bLButtonDown;
bool m_bTrayIconVisible;
// UINT m_nDefaultMenuItem;

2 changes: 1 addition & 1 deletion srchybrid/UPnPImplMiniLib.cpp
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ int CUPnPImplMiniLib::CStartDiscoveryThread::Run()
{
if (!m_pOwner->m_bCheckAndRefresh) {
int error = 0;
UPNPDev *structDeviceList = upnpDiscover(2000, NULL, NULL, 0, 0, 2, &error);
UPNPDev *structDeviceList = upnpDiscover(2000, thePrefs.m_pszBindAddrA, NULL, 0, 0, 2, &error);
if (structDeviceList == NULL) {
DebugLog(_T("UPNP: No Internet Gateway Devices found, aborting: %d"), error);
m_pOwner->m_bUPnPPortsForwarded = TRIS_FALSE;
Loading

0 comments on commit 230972e

Please sign in to comment.