Skip to content

Commit

Permalink
・接続が多数ある状態で接続リストを開こうとするとデッドロックするバグを修正
Browse files Browse the repository at this point in the history
・バイパス状態時にタスクトレイアイコンを変更するようにした
・ログウィンドウは別スレッドでメッセージループするようにした
・ページ内やヘッダ指定の文字コードに"UNICODE"と書かれているとページを正常にデコードできないのを修正
  • Loading branch information
amate committed Feb 6, 2016
1 parent 32551ba commit 4a5d092
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Proxydomo/AppConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#endif

/// アプリケーションのバージョン
#define APP_VERSION _T("1.79")
#define APP_VERSION _T("1.80")



Expand Down
12 changes: 9 additions & 3 deletions Proxydomo/ConnectionMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ void ConnectionData::SetVerb(const std::wstring& verb)
{
CCritSecLock lock(cs);
this->verb = verb;
CConnectionManager::UpdateNotify(this);
ConnectionData conData(*this);
lock.Unlock();
CConnectionManager::UpdateNotify(&conData);
}

void ConnectionData::SetUrl(const std::wstring& url)
{
CCritSecLock lock(cs);
this->url = url;
CConnectionManager::UpdateNotify(this);
ConnectionData conData(*this);
lock.Unlock();
CConnectionManager::UpdateNotify(&conData);
}

void ConnectionData::SetInStep(STEP in)
Expand Down Expand Up @@ -96,7 +100,9 @@ void CConnectionManager::RegisterCallback(std::function<void(ConnectionData*, Up
s_funcCallback = callback;
for (auto rit = s_connectionDataList.rbegin(); rit != s_connectionDataList.rend(); ++rit) {
CCritSecLock lock(rit->cs);
s_funcCallback(&*rit, kAddConnection);
auto conData = *rit;
lock.Unlock();
s_funcCallback(&conData, kAddConnection);
}

}
Expand Down
7 changes: 7 additions & 0 deletions Proxydomo/LogViewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,11 @@ BOOL CLogViewWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
return 0;
}

void CLogViewWindow::OnClose()
{
DestroyWindow();
}

void CLogViewWindow::OnDestroy()
{
CLog::RemoveLogTrace(this);
Expand Down Expand Up @@ -518,6 +523,8 @@ void CLogViewWindow::OnDestroy()
pt.put("LogWindow.ViewPostData" , m_bViewPostData);

write_ini(settingsPath, pt);

PostQuitMessage(0);
}

// ShowWindowと対になる関数
Expand Down
2 changes: 2 additions & 0 deletions Proxydomo/LogViewWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class CLogViewWindow :

BEGIN_MSG_MAP_EX( CLogViewWindow )
MSG_WM_INITDIALOG( OnInitDialog )
MSG_WM_CLOSE( OnClose )
MSG_WM_DESTROY( OnDestroy )

COMMAND_ID_HANDLER_EX( IDCANCEL, OnCancel )
Expand Down Expand Up @@ -129,6 +130,7 @@ class CLogViewWindow :
// void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)

BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam);
void OnClose();
void OnDestroy();

void OnCancel(UINT uNotifyCode, int nID, CWindow wndCtl);
Expand Down
29 changes: 28 additions & 1 deletion Proxydomo/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ void CMainDlg::_CreateTasktrayIcon()
} while (::Shell_NotifyIcon(NIM_ADD, &nid) == FALSE);
}
DestroyIcon(hIconSmall);

_ChangeTasttrayIcon();
}

void CMainDlg::_ChangeTasttrayIcon()
{
UINT iconid = CSettings::s_bypass ? IDI_PROXYDOMO_BYPASS : IDR_MAINFRAME;
HICON hIconSmall = AtlLoadIconImage(iconid, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
NOTIFYICONDATA nid = { sizeof(NOTIFYICONDATA) };
nid.uFlags = NIF_ICON;
nid.hWnd = m_hWnd;
nid.hIcon = hIconSmall;
nid.uID = kTrayIconId;
::Shell_NotifyIcon(NIM_MODIFY, &nid);

DestroyIcon(hIconSmall);
}

LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
Expand Down Expand Up @@ -141,7 +157,11 @@ LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam
CenterWindow();
}

m_logView.Create(m_hWnd);
m_threadLogView = std::thread([this]() {
m_logView.Create(m_hWnd);
CMessageLoop loop;
loop.Run();
});

m_wndLogButton.SubclassWindow(GetDlgItem(IDC_BUTTON_SHOWLOGWINDOW));

Expand Down Expand Up @@ -176,6 +196,9 @@ LRESULT CMainDlg::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,

_SaveMainDlgWindowPos();

m_logView.PostMessage(WM_CLOSE);
m_threadLogView.join();

return 0;
}

Expand Down Expand Up @@ -337,6 +360,7 @@ LRESULT CMainDlg::OnTrayIconNotify(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam,
case kBypass:
CSettings::s_bypass = !CSettings::s_bypass;
DoDataExchange(DDX_LOAD, IDC_CHECK_BYPASS);
_ChangeTasttrayIcon();
break;

case kUseRemoteProxy:
Expand Down Expand Up @@ -391,6 +415,9 @@ LRESULT CMainDlg::OnShowOption(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
LRESULT CMainDlg::OnFilterButtonCheck(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
DoDataExchange(DDX_SAVE, wID);
if (wID == IDC_CHECK_BYPASS) {
_ChangeTasttrayIcon();
}
return 0;
}

Expand Down
3 changes: 3 additions & 0 deletions Proxydomo/MainDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
#pragma once

#include <thread>
#include <atlchecked.h>
#include <atlddx.h>
#include "LogViewWindow.h"
Expand Down Expand Up @@ -128,10 +129,12 @@ class CMainDlg :
private:
void _SaveMainDlgWindowPos();
void _CreateTasktrayIcon();
void _ChangeTasttrayIcon();

// Data members
CProxy* m_proxy;
CLogViewWindow m_logView;
std::thread m_threadLogView;
CContainedWindow m_wndLogButton;
CFilterManageWindow m_filterManagerWindow;
bool m_bVisibleOnDestroy;
Expand Down
12 changes: 10 additions & 2 deletions Proxydomo/Proxydomo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\Proxydomo.ico"

IDI_FOLDER ICON "res\\folder.ico"

IDI_FILTER ICON "res\\filter.ico"

IDI_HEADERFILTER ICON "res\\HeaderFilter.ico"

IDI_WEBFILTER ICON "res\\WebFilter.ico"

IDI_PROXYDOMO_BYPASS ICON "res\\Proxydomo_bypass.ico"


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
Expand Down Expand Up @@ -99,8 +106,8 @@ CAPTION "
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
COMBOBOX IDC_COMBO_REQUEST,4,169,306,204,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL
CONTROL "",IDC_RICHEDIT_LOG,"RichEdit20W",ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_TABSTOP,0,0,314,145
CONTROL "",IDC_RICHEDIT_PARTLOG,"RichEdit20W",ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | WS_BORDER | WS_VSCROLL | WS_TABSTOP,0,0,314,146
CONTROL "",IDC_RICHEDIT_LOG,"RichEdit20W",WS_BORDER | WS_VSCROLL | WS_TABSTOP | 0x1884,0,0,314,145
CONTROL "",IDC_RICHEDIT_PARTLOG,"RichEdit20W",WS_BORDER | WS_VSCROLL | WS_TABSTOP | 0x18c4,0,0,314,146
CONTROL "",IDC_LIST_RECENTURLS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | NOT WS_VISIBLE | WS_BORDER | WS_TABSTOP,0,0,314,146
PUSHBUTTON "�N���A",IDC_BUTTON_CLEAR,113,150,33,15
CONTROL "���O���~",IDC_CHECKBOX_STOPLOG,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,4,150,51,15
Expand Down Expand Up @@ -366,6 +373,7 @@ END

IDB_FILTERMANAGERTOOLBAR BITMAP "res\\FilterManagerToolBar.bmp"


/////////////////////////////////////////////////////////////////////////////
//
// AFX_DIALOG_LAYOUT
Expand Down
2 changes: 2 additions & 0 deletions Proxydomo/Proxydomo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,9 @@
<Image Include="res\FilterManagerToolBar.bmp" />
<Image Include="res\folder.ico" />
<Image Include="res\HeaderFilter.ico" />
<Image Include="res\icon1.ico" />
<Image Include="res\Proxydomo.ico" />
<Image Include="res\Proxydomo_bypass.ico" />
<Image Include="res\WebFilter.ico" />
</ItemGroup>
<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions Proxydomo/Proxydomo.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@
<Image Include="res\WebFilter.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="res\Proxydomo_bypass.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="res\icon1.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
4 changes: 2 additions & 2 deletions Proxydomo/TextBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void CTextBuffer::_decideCharset()
{
charaCode = attrResult.str(1);
CUtil::upper(charaCode);
if (charaCode == "NONE")
if (charaCode == "NONE" || charaCode == "UNICODE")
charaCode.clear();
break;
}
Expand All @@ -266,7 +266,7 @@ void CTextBuffer::_decideCharset()
if (nPos != std::wstring::npos) {
charaCode = UTF8fromUTF16(contentType.substr(nPos + 8));
CUtil::upper(charaCode);
if (charaCode == "NONE")
if (charaCode == "NONE" || charaCode == "UNICODE")
charaCode.clear();
}
}
Expand Down
Binary file added Proxydomo/res/Proxydomo_bypass.ico
Binary file not shown.
10 changes: 6 additions & 4 deletions Proxydomo/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#define IDB_FILTERMANAGERTOOLBAR 250
#define IDD_CONNECTIONMANAGER 251
#define IDD_CONNECTIONMONITOR 251
#define IDI_ICON1 254
#define IDI_PROXYDOMO_BYPASS 254
#define IDC_RICHEDIT_LOG 1000
#define IDC_BUTTON_CLEAR 1001
#define IDC_BUTTON_SHOWLOGWINDOW 1002
Expand Down Expand Up @@ -127,7 +129,7 @@
#define ID_TRANS_INHEADER 40005
#define ID_TRANS_ERROR 40006
#define ID_TRANS_SUCCESS 40007
#define ID_TRANS_FAILURE 40008
#define ID_TRANS_FAILURE 40008
#define ID_TASKTRAYMENUBEGIN 50000
#define ID_TASKTRAYMENUEND 50999
#define ID_FILTERMANAGERWINDOWMENUBEGIN 51000
Expand Down Expand Up @@ -190,14 +192,14 @@
#define ID_OPENFILTERXMLFAILED 51155
#define ID_LOADFILTERXMLFAILED 51156
#define ID_SAVEFILTERXMLFAILED 51157
#define ID_SUCCEEDGETROOTCA 51158
#define ID_FAILEDGETROOTCA 51159
#define ID_SUCCEEDGETROOTCA 51158
#define ID_FAILEDGETROOTCA 51159

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 253
#define _APS_NEXT_RESOURCE_VALUE 255
#define _APS_NEXT_COMMAND_VALUE 32775
#define _APS_NEXT_CONTROL_VALUE 1100
#define _APS_NEXT_SYMED_VALUE 140
Expand Down

0 comments on commit 4a5d092

Please sign in to comment.