OSDN Git Service

2011/11/23 20:57:55
authorqwerty2501 <riot313@gmail.com>
Wed, 23 Nov 2011 11:57:55 +0000 (20:57 +0900)
committerqwerty2501 <riot313@gmail.com>
Wed, 23 Nov 2011 11:57:55 +0000 (20:57 +0900)
nlite.sln
nlite/nlite.cpp
nlite/nlite.vcxproj
nlite/nlite_appInfo.cpp
nlite/nlite_appinfo.h
nlite/nlite_common.h
nlite/nlite_include.h
nlite/nlite_mailframe.h
nlite/nlite_nlib.h [new file with mode: 0644]
nlite/stdafx.h
nlite_stub/nlite_stub.cpp

index 56b3ef4..570362c 100644 (file)
--- 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
index 22b65bf..b06d577 100644 (file)
@@ -9,8 +9,8 @@ CAppModule _Module;
 
 const nlite::CApplicationInfo* appInfo = NULL;
 
-
-
+static WSAData wsaData;                                                        //winsockdata
+static HINTERNET hInternet = NULL;
 
 static BOOL InitializeNlite();                                 //\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8f\89\8aú\89»
 static VOID FinalizeNlite();                                   //\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8fI\97¹\8f\88\97\9d
@@ -43,7 +43,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE,
 
                nRet = theLoop.Run();
 
-               vcassert(_heapchk() == -2,TEXT("\83q\81[\83v\83G\83\89\81[\82Å\82·"));
+               vcassert(_heapchk() == _HEAPOK,TEXT("\83q\81[\83v\83G\83\89\81[\82Å\82·"));
 
                _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\82ð\8f\89\8aú\89»
+               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
index 96f223e..55b848d 100644 (file)
     <ClInclude Include="nlite_listviewex.h" />
     <ClInclude Include="nlite_mailframe.h" />
     <ClInclude Include="nlite_appinfo.h" />
+    <ClInclude Include="nlite_nlib.h" />
     <ClInclude Include="Resource.h" />
     <ClInclude Include="stdafx.h" />
     <ClInclude Include="targetver.h" />
index f98b2b6..44e1f3e 100644 (file)
@@ -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){
index 5d63b8b..ffa2ebf 100644 (file)
@@ -18,6 +18,7 @@ namespace nlite{
                LPTSTR  pProductVersion;                                //\83o\81[\83W\83\87\83\93\8fî\95ñ
                LPTSTR  pOriginalFileName;                              //\83I\83\8a\83W\83i\83\8b\83t\83@\83C\83\8b\96¼
                LPTSTR  pLegalCopyright;                                //\92\98\8dì\8c 
+               LPTSTR  pProductName;                                   //\90»\95i\96¼
        private:
                ///
                ///\83R\83\93\83c\83g\83\89\83N\83^
@@ -62,6 +63,11 @@ namespace nlite{
 
                }
 
+               LPCTSTR getProcuctName() const{
+
+                       return pProductName;
+               }
+
                VOID show() const {
 
                        tstring szApp;
index d09e367..24196ec 100644 (file)
@@ -68,8 +68,6 @@ namespace nlite{
                        bspReadFlag(TRUE),
                        userCommentReadFlag(TRUE),
                        teropReadFlag(TRUE)
-
-
                {}
 
        };
@@ -99,9 +97,7 @@ namespace nlite{
                        numberNameFlag(FALSE),
                        autoColorRegisterFlag(FALSE),
                        activeCountTimeFlag(TRUE)
-               {
-
-               }
+               {}
        };
        
 
index 8ac0fb1..0d6006c 100644 (file)
@@ -7,14 +7,14 @@
 #include <nlib_define.h>
 #include <vcmpool.h>
 #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"
 
 
 #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
index 8914004..9386304 100644 (file)
@@ -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 (file)
index 0000000..efa28a3
--- /dev/null
@@ -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
index 3eef542..600efdf 100644 (file)
@@ -13,6 +13,8 @@
 // Windows \83w\83b\83_\81\83t\83@\83C\83\8b:
 #include <windows.h>
 #include <WindowsX.h>
+#include <WinSock2.h>
+#include <winhttp.h>
 
 // C \83\89\83\93\83^\83C\83\80 \83w\83b\83_\81\83t\83@\83C\83\8b
 #include <stdlib.h>
@@ -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
index a96fc92..c9578ca 100644 (file)
@@ -1,8 +1,11 @@
 #include <nlib\nlib.h>
+#include <nlib\nlib_define.h>
 #include <stdio.h>
 #include <memory.h>
 #include <stdlib.h>
 
+
+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