From: qwerty2501 Date: Thu, 1 Mar 2012 15:41:46 +0000 (+0900) Subject: バグレポート機能実装途中 X-Git-Tag: v0.101~6 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=430792cc47fec70ee6c00c71c20ca6797f7bc4aa;hp=0f627e518b7e91cc98d29704d409b7feb7e01c92;p=nlite%2Fnlite.git バグレポート機能実装途中 --- diff --git a/nlite.suo b/nlite.suo index 7c80bde..eb5c166 100644 Binary files a/nlite.suo and b/nlite.suo differ diff --git a/nlite/nlite.cpp b/nlite/nlite.cpp index 8f33502..432b86f 100644 --- a/nlite/nlite.cpp +++ b/nlite/nlite.cpp @@ -11,12 +11,9 @@ CAppModule _Module; -static WSAData wsaData; //winsockdata -static HINTERNET hInternet = NULL; -static BOOL InitializeNlite(); //ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‰Šú‰» -static VOID FinalizeNlite(); //ƒAƒvƒŠƒP[ƒVƒ‡ƒ“I—¹ˆ— -static CNliteMainFrame wnd; //ƒƒCƒ“ƒtƒŒ[ƒ€ƒEƒBƒ“ƒhƒE + +#ifndef NLITE_TEST //ƒƒCƒ“ŠÖ” int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, @@ -76,125 +73,88 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, UnexpectedErrorMessageShow(TEXT("ƒnƒ“ƒhƒ‹‚³‚ê‚Ä‚¢‚È‚¢ƒGƒ‰["),e.what(),e.getLineNo(),e.getFileName(),e.getFunctionName()); - goto nlitefinally; + goto nliteexception; } catch(nlib::Exception &e){ UnexpectedErrorMessageShow(TEXT("nlib‚Ńnƒ“ƒhƒ‹‚³‚ê‚Ä‚¢‚È‚¢ƒGƒ‰["),e.what(),e.getLineNo(),e.getFileName(),e.getFunctionName()); - goto nlitefinally; + goto nliteexception; }catch(std::exception &e){ UnexpectedErrorMessageShow(TEXT("ƒnƒ“ƒhƒ‹‚³‚ê‚Ä‚¢‚È‚¢ƒGƒ‰["),CComBSTR(e.what()),-1,TEXT("”­¶ƒtƒ@ƒCƒ‹‚ª“Á’èo—ˆ‚Ü‚¹‚ñ"),TEXT("”­¶ŠÖ”‚ª“Á’è‚Å‚«‚Ü‚¹‚ñ")); - goto nlitefinally; + goto nliteexception; } -nlitefinally: - wnd.OnException(); - wnd.DestroyWindow(); - FreeLibrary(hRich); -nliteend: + +nliteend: + FreeLibrary(hRich); _Module.RemoveMessageLoop(); FinalizeNlite(); _Module.Term(); ::CoUninitialize(); return nRet; -} - -static BOOL InitializeNlite(){ - - BOOL rslt = FALSE; - - try{ - - nlite::appInfo = &CApplicationInfo::getInstance(); - INT_PTR err; - INT_PTR count = 0; - - //WSAData‚ð‰Šú‰» - while((err = WSAStartup(MAKEWORD(2,0),&wsaData)) == WSASYSNOTREADY){ - - count++; - if(count >= 5)break; - Sleep(500); +nliteexception: + wnd.OnException(); + wnd.DestroyWindow(); + goto nliteend; +} - } +#else +#ifdef NLITE_TEST - if(err != ERROR_SUCCESS){ - throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); - } +//ƒƒCƒ“ŠÖ” +int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, + LPTSTR lpCmdLine, int nCmdShow) +{ + HINSTANCE hRich = LoadLibrary(CRichEditCtrl::GetLibraryName()); + int nRet = -1; - //ƒAƒvƒŠƒP[ƒVƒ‡ƒ“î•ñƒCƒ“ƒXƒ^ƒ“ƒX¶¬ - const CApplicationInfo &appInfo = CApplicationInfo::getInstance(); - CNLiteString userAgent; - userAgent = appInfo.getProcuctName(); - userAgent += TEXT("/"); - userAgent += appInfo.getProductVersion(); + // + //ƒAƒvƒŠƒPƒP[ƒVƒ‡ƒ“‰Šú‰»ˆ— + // + HRESULT hRes = ::CoInitialize(NULL); + ATLASSERT(SUCCEEDED(hRes)); + AtlInitCommonControls(ICC_COOL_CLASSES | ICC_WIN95_CLASSES); + GUID guid; + _Module.Init(NULL, hInstance,&guid); + AtlAxWinInit(); + InitializeNlite(); - //HTTPƒIƒuƒWƒFƒNƒg¶¬ - hInternet = WinHttpOpen(userAgent,WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,(LPCWSTR)WINHTTP_NO_PROXY_NAME,(LPCWSTR)WINHTTP_NO_PROXY_BYPASS,0); + - if(hInternet == NULL){ - throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); - } - //nlib‚̏‰Šú‰» - InitializeNLIB(hInternet); - //ƒ[ƒJƒ‹ƒAƒvƒŠƒP[ƒVƒ‡ƒ“ƒtƒHƒ‹ƒ_ŒŸõ - if(SHGetFolderPathW(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT,localAppDataPath) != S_OK){ - throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); - } + //I—¹Œãƒƒ‚ƒŠƒ`ƒFƒbƒN + vcassert(_heapchk() == _HEAPOK,TEXT("ƒq[ƒvƒGƒ‰[‚Å‚·")); - SystemParametersInfo (SPI_SETLISTBOXSMOOTHSCROLLING,FALSE,FALSE,0); + nRet = 0; + FreeLibrary(hRich); - if(SHGetFolderPathW(0,CSIDL_APPDATA,0,SHGFP_TYPE_CURRENT,appFolderPath) != S_OK){ - throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); - } - ncvAppSettingPath = appFolderPath; - ncvAppSettingPath += TEXT("\\posite-c\\NiconamaCommentViewer\\AppSetting.xml"); - rslt = TRUE; - }catch (AppInitException e){ - rslt = FALSE; - } - + FinalizeNlite(); + ::CoUninitialize(); - return rslt; + return nRet; } +#endif -VOID FinalizeNlite(){ - - //ƒƒCƒ“ƒtƒŒ[ƒ€ƒEƒBƒ“ƒhƒEŒãˆ— - wnd.Finalaize(); - - //nlibŒãˆ— - FinalizeNLIB(); - - //HTTPƒIƒuƒWƒFƒNƒgŠJ•ú - WinHttpCloseHandle(hInternet); - - //winsockŠJ•ú - WSACleanup(); - - return; -} - +#endif diff --git a/nlite/nlite.h b/nlite/nlite.h index e8555e6..8a0adaf 100644 --- a/nlite/nlite.h +++ b/nlite/nlite.h @@ -10,7 +10,7 @@ namespace nlite{ class CProperty; class CGeneralProperty; class CListenerData; - + class CNliteMainFrame; diff --git a/nlite/nlite.vcxproj b/nlite/nlite.vcxproj index 0bd9f02..4d84a60 100644 --- a/nlite/nlite.vcxproj +++ b/nlite/nlite.vcxproj @@ -165,7 +165,7 @@ xcopy "$(ProjectDir)libs" "$(targetdir)libs" /e /y - mkdir "$(targetdir)nlite\libs" /y + mkdir "$(targetdir)nlite\libs" xcopy "$(ProjectDir)libs" "$(targetdir)nlite\libs" /e /y copy "$(targetdir)nlite.exe" "$(targetdir)nlite\" /y @@ -195,7 +195,7 @@ copy "$(targetdir)nlite.exe" "$(targetdir)nlite\" /y - mkdir "$(targetdir)nlite_preview\libs" /y + mkdir "$(targetdir)nlite_preview\libs" xcopy "$(ProjectDir)libs" "$(targetdir)nlite_preview\libs" /e /y copy "$(targetdir)nlite.exe" "$(targetdir)nlite_preview\" /y @@ -211,6 +211,7 @@ copy "$(targetdir)nlite.exe" "$(targetdir)nlite_preview\" /y + @@ -231,6 +232,7 @@ copy "$(targetdir)nlite.exe" "$(targetdir)nlite_preview\" /y + diff --git a/nlite/nlite.vcxproj.filters b/nlite/nlite.vcxproj.filters index 885ff9e..cca32ed 100644 --- a/nlite/nlite.vcxproj.filters +++ b/nlite/nlite.vcxproj.filters @@ -80,6 +80,9 @@ ヘッダー ファイル + + ヘッダー ファイル + @@ -121,6 +124,9 @@ ソース ファイル + + ソース ファイル + diff --git a/nlite/nlite_bugreport.cpp b/nlite/nlite_bugreport.cpp new file mode 100644 index 0000000..c4b9486 --- /dev/null +++ b/nlite/nlite_bugreport.cpp @@ -0,0 +1,98 @@ +#include "stdafx.h" +#include "nlite_include.h" + +namespace nlite{ + + + BugTrail::BugTrail(): + headMessage(), + summary(), + line(), + fileName(), + function() + {} + + + HINTERNET CBugReport::hInternet = NULL; + CString CBugReport::outputDir; + const CString CBugReport::szHostName(TEXT("http://localhost")); + const CString CBugReport::szUrlPath(TEXT("bugreport.rb")); + const UINT_PTR CBugReport::portNo(8080); + VOID CBugReport::OutBugFile(){ + + + + return; + } + + BOOL CBugReport::SendBugReport(const BugTrail& bugtrail){ + + BOOL result = FALSE; + + HINTERNET hConnect = NULL; + HINTERNET hRequest = NULL; + TCHAR szHeader[] = TEXT("Content-Type: application/x-www-form-urlencoded\r\n"); + DWORD dwHeaderLength = _tcslen(szHeader); + DWORD dwTotalLength; + DWORD dwStatusCode; + DWORD dwDataLength; + hConnect = WinHttpConnect(CBugReport::hInternet, CBugReport::szHostName, CBugReport::portNo, 0); + if (hConnect == NULL) { + goto networderr; + } + + hRequest = WinHttpOpenRequest(hConnect, TEXT("POST"), CBugReport::szUrlPath, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, 0); + if (hRequest == NULL) { + goto networderr; + } + + CString postData; + postData = TEXT("sourcefile="); + postData += bugtrail.fileName; + postData += TEXT("\r\n"); + + + + + std::vector body; + body.reserve(GetLenToMB(CP_UTF8,postData)); + WideToMB(CP_UTF8,postData,&body[0],body.capacity()); + dwDataLength = body.size(); + dwTotalLength = dwDataLength; + WinHttpSendRequest(hRequest, szHeader, dwHeaderLength, WINHTTP_NO_REQUEST_DATA, 0, dwTotalLength, 0); + WinHttpWriteData(hRequest,&body[0],dwTotalLength ,&dwDataLength); + WinHttpReceiveResponse(hRequest, NULL); + + DWORD dwSize = sizeof(DWORD); + WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &dwStatusCode, &dwSize, WINHTTP_NO_HEADER_INDEX); + + +end: + + + WinHttpCloseHandle(hRequest); + WinHttpCloseHandle(hConnect); + + + + return result; + +networderr: + result = FALSE; + + goto end; + } + + VOID CBugReport::TakeBugFiles(){ + + return; + } + + VOID CBugReport::Initalize(HINTERNET hInternet,const CString &outputDir){ + + CBugReport::hInternet = hInternet; + CBugReport::outputDir = outputDir; + return; + } + +} \ No newline at end of file diff --git a/nlite/nlite_bugreport.h b/nlite/nlite_bugreport.h new file mode 100644 index 0000000..40b6437 --- /dev/null +++ b/nlite/nlite_bugreport.h @@ -0,0 +1,44 @@ +#pragma once + + +namespace nlite{ + + + struct BugTrail{ + + CString headMessage; + CString summary; + CString line; + CString fileName; + CString function; + + + BugTrail(); + }; + + class CBugReport{ + + private: + //ƒCƒ“ƒ^[ƒlƒbƒgƒnƒ“ƒhƒ‹ + static HINTERNET hInternet; + static CString outputDir; + const static CString szHostName; + const static CString szUrlPath; + const static UINT_PTR portNo; + private: + /// + ///ƒoƒOî•ñ‚ðƒtƒ@ƒCƒ‹‚ɏo—Í + /// + VOID OutBugFile(); + + public: + BOOL SendBugReport(const BugTrail& bugtrail); + + VOID TakeBugFiles(); + + + static VOID Initalize(HINTERNET hInternet,const CString &outputDir); + + }; + +} \ No newline at end of file diff --git a/nlite/nlite_common.cpp b/nlite/nlite_common.cpp index 201133a..c1434d7 100644 --- a/nlite/nlite_common.cpp +++ b/nlite/nlite_common.cpp @@ -4,7 +4,7 @@ namespace nlite{ - + namespace nliteregex{ namespace text{ const CString URL_TEXT = TEXT("(https?|ftp)(://[-_.!~*\'()a-zA-Z0-9;/?:@&=+$,%#]+)"); @@ -28,6 +28,10 @@ namespace nlite{ CString ncvAppSettingPath; TCHAR localAppDataPath[_MAX_PATH]; speaker::ISpeaker &g_speaker = speaker::ISpeaker::GetMeiNormal(TEXT("libs\\Voice\\mei_normal\\"),TEXT("libs\\open_jtalk_dic\\")); + WSAData wsaData; //winsockdata + HINTERNET hInternet = NULL; + CNliteMainFrame wnd; //ƒƒCƒ“ƒtƒŒ[ƒ€ƒEƒBƒ“ƒhƒE + VOID nlite::UnexpectedErrorMessageShow(LPCTSTR headMessage,LPCTSTR summary,UINT line,LPCTSTR fileName,LPCTSTR function){ CString errLogFilePath(nliteProperty.GetPropertySaveFolderPath()); @@ -243,5 +247,129 @@ err: const CApplicationInfo * appInfo = NULL; + + + + + BOOL InitializeNlite(){ + + BOOL rslt = FALSE; + + try{ + + nlite::appInfo = &CApplicationInfo::getInstance(); + INT_PTR err; + INT_PTR count = 0; + + //WSAData‚ð‰Šú‰» + while((err = WSAStartup(MAKEWORD(2,0),&wsaData)) == WSASYSNOTREADY){ + + count++; + if(count >= 5)break; + Sleep(500); + + + + } + + if(err != ERROR_SUCCESS){ + + throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); + } + + //ƒAƒvƒŠƒP[ƒVƒ‡ƒ“î•ñƒCƒ“ƒXƒ^ƒ“ƒX¶¬ + const CApplicationInfo &appInfo = CApplicationInfo::getInstance(); + CNLiteString userAgent; + userAgent = appInfo.getProcuctName(); + userAgent += TEXT("/"); + userAgent += appInfo.getProductVersion(); + + + + //HTTPƒIƒuƒWƒFƒNƒg¶¬ + hInternet = WinHttpOpen(userAgent,WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,(LPCWSTR)WINHTTP_NO_PROXY_NAME,(LPCWSTR)WINHTTP_NO_PROXY_BYPASS,0); + + if(hInternet == NULL){ + + throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); + + } + + //nlib‚̏‰Šú‰» + InitializeNLIB(hInternet); + + //ƒ[ƒJƒ‹ƒAƒvƒŠƒP[ƒVƒ‡ƒ“ƒtƒHƒ‹ƒ_ŒŸõ + if(SHGetFolderPathW(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT,localAppDataPath) != S_OK){ + + throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); + } + + + + + + + if(SHGetFolderPathW(0,CSIDL_APPDATA,0,SHGFP_TYPE_CURRENT,appFolderPath) != S_OK){ + + throw AppInitException(__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); + } + ncvAppSettingPath = appFolderPath; + ncvAppSettingPath += TEXT("\\posite-c\\NiconamaCommentViewer\\AppSetting.xml"); + + nliteProperty.ReadProperty(); + + if((nliteProperty.GetGeneralProperty().IsNCVUserSettingReaded() == FALSE)){ + + ReadNCVListenerData(); + } + + listenerList.ReadProperty(nliteProperty.GetListenerDataPath()); + + CBugReport::Initalize(hInternet,CString(nliteProperty.GetPropertySaveFolderPath()) + TEXT("bugReport\\")); + rslt = TRUE; + }catch (AppInitException e){ + + rslt = FALSE; + + } + + + return rslt; + } + + + VOID FinalizeNlite(){ + + //ƒƒCƒ“ƒtƒŒ[ƒ€ƒEƒBƒ“ƒhƒEŒãˆ— + wnd.Finalaize(); + + //nlibŒãˆ— + FinalizeNLIB(); + + //HTTPƒIƒuƒWƒFƒNƒgŠJ•ú + WinHttpCloseHandle(hInternet); + + //winsockŠJ•ú + WSACleanup(); + + return; + } + + + BOOL ReadNCVListenerData(){ + + BOOL rslt = FALSE; + + if((PathFileExists(ncvAppSettingPath) && (!::PathIsDirectory( ncvAppSettingPath )))){ + + if((::MessageBox(NULL,TEXT("NCV‚̃ŠƒXƒi[î•ñ‚Æ“¯Šú‚µ‚Ü‚·‚©H"),TEXT("ƒŠƒXƒi[î•ñ“ǂݍž‚Ý"),MB_OK | MB_OKCANCEL) == IDOK)){ + listenerList.ReadProperty(GetNCVListenerInfoFilePath()); + } + nliteProperty.GetGeneralProperty().SetNCVUSerSettingReaded(TRUE); + rslt = TRUE; + } + + return rslt; + } } diff --git a/nlite/nlite_common.h b/nlite/nlite_common.h index 255a456..cd3e959 100644 --- a/nlite/nlite_common.h +++ b/nlite/nlite_common.h @@ -9,7 +9,11 @@ namespace nlite{ extern TCHAR localAppDataPath[]; extern TCHAR appFolderPath[]; extern CString ncvAppSettingPath; - + extern WSAData wsaData; //winsockdata + extern HINTERNET hInternet; + extern BOOL InitializeNlite(); //ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‰Šú‰» + extern VOID FinalizeNlite(); //ƒAƒvƒŠƒP[ƒVƒ‡ƒ“I—¹ˆ— + extern CNliteMainFrame wnd; //ƒƒCƒ“ƒtƒŒ[ƒ€ƒEƒBƒ“ƒhƒE //ƒOƒ[ƒoƒ‹ŠÖ” extern VOID UnexpectedErrorMessageShow(LPCTSTR headMessage,LPCTSTR summary,UINT line,LPCTSTR fileName,LPCTSTR function); @@ -23,6 +27,11 @@ namespace nlite{ /// + ///NCV‚̃ŠƒXƒi[ƒf[ƒ^‚ð“Ç‚ÝŽæ‚è + /// + extern BOOL ReadNCVListenerData(); + + /// ///ncv‚̃ŠƒXƒi[î•ñƒtƒ@ƒCƒ‹ƒpƒX‚ðŽæ“¾ /// extern CString GetNCVListenerInfoFilePath(); diff --git a/nlite/nlite_include.h b/nlite/nlite_include.h index 7eed2e3..aa51920 100644 --- a/nlite/nlite_include.h +++ b/nlite/nlite_include.h @@ -23,6 +23,7 @@ #include "nlite_appinfo.h" #include "nlite_propertyWindow.h" #include "nlite_mainframe.h" +#include "nlite_bugreport.h" diff --git a/nlite/nlite_mainframe.cpp b/nlite/nlite_mainframe.cpp index e3aab74..1594829 100644 --- a/nlite/nlite_mainframe.cpp +++ b/nlite/nlite_mainframe.cpp @@ -187,24 +187,11 @@ LRESULT CNliteMainFrame::OnCreate(LPCREATESTRUCT lpcs){ VOID CNliteMainFrame::Initialize(LPCTSTR localAppDataPath){ try{ - nliteProperty.ReadProperty(); + - if((nliteProperty.GetGeneralProperty().IsNCVUserSettingReaded() == FALSE) && - ((PathFileExists(ncvAppSettingPath) && (!::PathIsDirectory( ncvAppSettingPath ))))){ - - if((::MessageBox(NULL,TEXT("NCV‚̃ŠƒXƒi[î•ñ‚Æ“¯Šú‚µ‚Ü‚·‚©H"),TEXT("ƒŠƒXƒi[î•ñ“ǂݍž‚Ý"),MB_OK | MB_OKCANCEL) == IDOK)){ - listenerList.ReadProperty(GetNCVListenerInfoFilePath()); - } - nliteProperty.GetGeneralProperty().SetNCVUSerSettingReaded(TRUE); - - - } - - listenerList.ReadProperty(nliteProperty.GetListenerDataPath()); - commentView.SetProperty(nliteProperty.GetCommentViewProperty(),nliteProperty.GetGeneralProperty()); if(nliteProperty.GetGeneralProperty().GetBrowserType() == BT_NOSETTING){ nliteProperty.CookieSetting(); diff --git a/nlite/stdafx.h b/nlite/stdafx.h index a09444e..8ec1680 100644 --- a/nlite/stdafx.h +++ b/nlite/stdafx.h @@ -15,6 +15,9 @@ #define WINDEBUGER_NOPRINTING //ƒfƒoƒbƒOo—Í‚ðƒRƒ“ƒ\[ƒ‹‚É•\Ž¦‚µ‚½‚­‚È‚¢ê‡’è‹`‚·‚é #define _WTL_NO_CSTRING + +//#define NLITE_TEST + // Windows ƒwƒbƒ_[ ƒtƒ@ƒCƒ‹: #include #include