From 0d91973c0f44eedcd34dfe41df3c71aaec1305bb Mon Sep 17 00:00:00 2001 From: qwerty2501 Date: Wed, 23 Nov 2011 20:57:55 +0900 Subject: [PATCH] 2011/11/23 20:57:55 --- nlite.sln | 3 +++ nlite/nlite.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++----- nlite/nlite.vcxproj | 1 + nlite/nlite_appInfo.cpp | 8 +++++++- nlite/nlite_appinfo.h | 6 ++++++ nlite/nlite_common.h | 6 +----- nlite/nlite_include.h | 17 ++++++++++++----- nlite/nlite_mailframe.h | 33 +------------------------------- nlite/nlite_nlib.h | 38 +++++++++++++++++++++++++++++++++++++ nlite/stdafx.h | 6 +++++- nlite_stub/nlite_stub.cpp | 17 +++++++++++++++++ 11 files changed, 134 insertions(+), 49 deletions(-) create mode 100644 nlite/nlite_nlib.h diff --git a/nlite.sln b/nlite.sln index 56b3ef4..570362c 100644 --- a/nlite.sln +++ b/nlite.sln @@ -39,6 +39,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memorypool", "memorypool\memorypool.vcxproj", "{E36BC5DE-60A1-4A78-90EA-F3BFEF89F9A8}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nlite", "nlite\nlite.vcxproj", "{EB0B5264-9BB4-4EE3-B196-A0472DCB32A8}" + ProjectSection(ProjectDependencies) = postProject + {5150C843-E70B-4696-8F08-11B900B7F91F} = {5150C843-E70B-4696-8F08-11B900B7F91F} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nlite_stub", "nlite_stub\nlite_stub.vcxproj", "{5150C843-E70B-4696-8F08-11B900B7F91F}" EndProject diff --git a/nlite/nlite.cpp b/nlite/nlite.cpp index 22b65bf..b06d577 100644 --- a/nlite/nlite.cpp +++ b/nlite/nlite.cpp @@ -9,8 +9,8 @@ CAppModule _Module; const nlite::CApplicationInfo* appInfo = NULL; - - +static WSAData wsaData; //winsockdata +static HINTERNET hInternet = NULL; static BOOL InitializeNlite(); //ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‰Šú‰» static VOID FinalizeNlite(); //ƒAƒvƒŠƒP[ƒVƒ‡ƒ“I—¹ˆ— @@ -43,7 +43,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, nRet = theLoop.Run(); - vcassert(_heapchk() == -2,TEXT("ƒq[ƒvƒGƒ‰[‚Å‚·")); + vcassert(_heapchk() == _HEAPOK,TEXT("ƒq[ƒvƒGƒ‰[‚Å‚·")); _Module.RemoveMessageLoop(); } catch(Exception e){ @@ -57,6 +57,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, FinalizeNlite(); _Module.Term(); + return nRet; } @@ -67,7 +68,42 @@ static BOOL InitializeNlite(){ try{ 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(); + } + + const CApplicationInfo &appInfo = CApplicationInfo::getInstance(); + tstring userAgent; + userAgent.reserve(256); + userAgent = appInfo.getProcuctName(); + userAgent += TEXT("/"); + userAgent += appInfo.getProductVersion(); + + + hInternet = WinHttpOpen(userAgent.c_str(),WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,(LPCWSTR)WINHTTP_NO_PROXY_NAME,(LPCWSTR)WINHTTP_NO_PROXY_BYPASS,0); + + if(hInternet == NULL){ + + throw AppInitException(); + + } + + InitializeNLIB(hInternet); }catch (AppInitException e){ @@ -84,7 +120,9 @@ static BOOL InitializeNlite(){ VOID FinalizeNlite(){ - + FinalizeNLIB(); + WinHttpCloseHandle(hInternet); + WSACleanup(); return; } \ No newline at end of file diff --git a/nlite/nlite.vcxproj b/nlite/nlite.vcxproj index 96f223e..55b848d 100644 --- a/nlite/nlite.vcxproj +++ b/nlite/nlite.vcxproj @@ -115,6 +115,7 @@ + diff --git a/nlite/nlite_appInfo.cpp b/nlite/nlite_appInfo.cpp index f98b2b6..44e1f3e 100644 --- a/nlite/nlite_appInfo.cpp +++ b/nlite/nlite_appInfo.cpp @@ -74,7 +74,13 @@ CApplicationInfo::CApplicationInfo(){ } - + _stprintf(subBlock,TEXT("\\StringFileInfo\\%04x%04x\\ProductName"),lpTranslate->wLanguage,lpTranslate->wCodePage); + + if(VerQueryValue(pBlock,subBlock,(LPVOID *)&pProductName,&ulen) == FALSE){ + + throw err; + + } } catch (const AppInitException& e){ diff --git a/nlite/nlite_appinfo.h b/nlite/nlite_appinfo.h index 5d63b8b..ffa2ebf 100644 --- a/nlite/nlite_appinfo.h +++ b/nlite/nlite_appinfo.h @@ -18,6 +18,7 @@ namespace nlite{ LPTSTR pProductVersion; //ƒo[ƒWƒ‡ƒ“î•ñ LPTSTR pOriginalFileName; //ƒIƒŠƒWƒiƒ‹ƒtƒ@ƒCƒ‹–¼ LPTSTR pLegalCopyright; //’˜ìŒ  + LPTSTR pProductName; //»•i–¼ private: /// ///ƒRƒ“ƒcƒgƒ‰ƒNƒ^ @@ -62,6 +63,11 @@ namespace nlite{ } + LPCTSTR getProcuctName() const{ + + return pProductName; + } + VOID show() const { tstring szApp; diff --git a/nlite/nlite_common.h b/nlite/nlite_common.h index d09e367..24196ec 100644 --- a/nlite/nlite_common.h +++ b/nlite/nlite_common.h @@ -68,8 +68,6 @@ namespace nlite{ bspReadFlag(TRUE), userCommentReadFlag(TRUE), teropReadFlag(TRUE) - - {} }; @@ -99,9 +97,7 @@ namespace nlite{ numberNameFlag(FALSE), autoColorRegisterFlag(FALSE), activeCountTimeFlag(TRUE) - { - - } + {} }; diff --git a/nlite/nlite_include.h b/nlite/nlite_include.h index 8ac0fb1..0d6006c 100644 --- a/nlite/nlite_include.h +++ b/nlite/nlite_include.h @@ -7,14 +7,14 @@ #include #include #include "resource.h" + + +#include "nlite_exception.h" +#include "nlite_nlib.h" #include "nlite_define.h" #include "nlite_common.h" - #include "nlite_listviewex.h" #include "nlite_commentview.h" -//#include "nlite_controlPaine.h" - -#include "nlite_exception.h" #include "nlite_appinfo.h" #include "nlite.h" #include "nlite_mailframe.h" @@ -22,4 +22,11 @@ #pragma comment(lib, "memorypool.lib") -#pragma comment(lib,"nlite_stub.lib") \ No newline at end of file + +#ifndef NDEBUG + +#pragma comment(lib,"nlite_stub.lib") + +#else + +#endif \ No newline at end of file diff --git a/nlite/nlite_mailframe.h b/nlite/nlite_mailframe.h index 8914004..9386304 100644 --- a/nlite/nlite_mailframe.h +++ b/nlite/nlite_mailframe.h @@ -6,6 +6,7 @@ namespace nlite{ const static LPCTSTR NLITE_MAINWINDOW = TEXT("nlite"); + class CLiveUserData { public: @@ -18,38 +19,6 @@ namespace nlite{ }; - class CNicoVideoAuth{ - - private: - NicoVideoAuth_P nicoVideoAuth; - - - public: - CNicoVideoAuth() - :nicoVideoAuth(NicoVideoAuth_new()){} - - ~CNicoVideoAuth(){ - - NicoVideoAuth_delete(&nicoVideoAuth); - } - - VOID SetBrowserType(BROWSERTYPE bt){ - NLIB_RESULT rslt; - - rslt = NicoVideoAuth_getNicoVideoAuth(nicoVideoAuth,bt); - if(rslt != NLIB_ERR_OK){ - - throw NLIBException(rslt); - } - - } - - NicoVideoAuth_P GetAuth(){ - - return this->nicoVideoAuth; - } - - }; class CNicoLiveStream{ diff --git a/nlite/nlite_nlib.h b/nlite/nlite_nlib.h new file mode 100644 index 0000000..efa28a3 --- /dev/null +++ b/nlite/nlite_nlib.h @@ -0,0 +1,38 @@ +#pragma once + +namespace nlite{ + + + class CNicoVideoAuth{ + + private: + NicoVideoAuth_P nicoVideoAuth; + + + public: + CNicoVideoAuth() + :nicoVideoAuth(NicoVideoAuth_new()){} + + ~CNicoVideoAuth(){ + + NicoVideoAuth_delete(&nicoVideoAuth); + } + + VOID SetBrowserType(BROWSERTYPE bt){ + NLIB_RESULT rslt; + + rslt = NicoVideoAuth_getNicoVideoAuth(nicoVideoAuth,bt); + if(rslt != NLIB_ERR_OK){ + + throw NLIBException(rslt); + } + + } + + NicoVideoAuth_P GetAuth(){ + + return this->nicoVideoAuth; + } + + }; +} \ No newline at end of file diff --git a/nlite/stdafx.h b/nlite/stdafx.h index 3eef542..600efdf 100644 --- a/nlite/stdafx.h +++ b/nlite/stdafx.h @@ -13,6 +13,8 @@ // Windows ƒwƒbƒ_[ ƒtƒ@ƒCƒ‹: #include #include +#include +#include // C ƒ‰ƒ“ƒ^ƒCƒ€ ƒwƒbƒ_[ ƒtƒ@ƒCƒ‹ #include @@ -42,4 +44,6 @@ extern CAppModule _Module; #pragma comment(lib,"shell32.lib") #pragma comment(lib,"atlthunk.lib") -#pragma comment(lib,"version.lib") \ No newline at end of file +#pragma comment(lib,"version.lib") +#pragma comment(lib,"WinHttp.lib") +#pragma comment(lib,"ws2_32.lib") \ No newline at end of file diff --git a/nlite_stub/nlite_stub.cpp b/nlite_stub/nlite_stub.cpp index a96fc92..c9578ca 100644 --- a/nlite_stub/nlite_stub.cpp +++ b/nlite_stub/nlite_stub.cpp @@ -1,8 +1,11 @@ #include +#include #include #include #include + +void *nlibmemory; NicoLiveStream_P NicoLiveStream_new(){ @@ -25,4 +28,18 @@ VOID NicoVideoAuth_delete(NicoVideoAuth_P *self){ free(*self); *self= NULL; +} + + +NLIB_RESULT InitializeNLIB(HINTERNET hInternet){ + + nlibmemory = malloc(65536); + + return NLIB_ERR_OK; +} + + +VOID FinalizeNLIB(){ + + free(nlibmemory); } \ No newline at end of file -- 2.11.0