OSDN Git Service

2012/01/16 15:12:41
authorunknown <qwerty2501@users.sourceforge.jp>
Mon, 16 Jan 2012 06:12:41 +0000 (15:12 +0900)
committerunknown <qwerty2501@users.sourceforge.jp>
Mon, 16 Jan 2012 06:12:41 +0000 (15:12 +0900)
nlib/nlib_nicoLive.c
nlib/nlib_nicoLive.h
nlite/nlite_commentWrite.h
nlite/nlite_commentview.cpp
nlite/nlite_commentview.h
nlite/nlite_string.h
nlite_stub/nlib_stub.h
nlite_stub/nlite_stub.cpp

index 5c2738f..9793ddf 100644 (file)
@@ -126,7 +126,7 @@ static unsigned int loopCommon(NicoLiveStream_P self,WSAEVENT sendEvent,WSAEVENT
 ///
 ///\83R\83\81\83\93\83g\89ð\90Í\8aÖ\90\94
 ///
-static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentCountSum,SIZE_T* commentBufSize);
+static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentBufSize);
 
 static void NicoLiveError(void *buf);
 
@@ -1544,18 +1544,15 @@ static BOOL NicoLiveRecvChatLoop(NicoLiveStream_P self){
        WSANETWORKEVENTS netEvents;                                                             //\83l\83b\83g\83\8f\81[\83N\83C\83x\83\93\83g
        DWORD dwResult;                                                                                 //\83C\83x\83\93\83g\82ª\83E\83F\83C\83g\8aÖ\90\94\82Ì\8c\8b\89Ê\82ð\8ai\94[\82·\82é\95Ï\90\94
 
-
+       
        SIZE_T commentBufSize = sizeof(WCHAR) * LENGTH_2048;    //\83R\83\81\83\93\83g\83o\83b\83t\83@\92·
        SIZE_T mailCountBufSize = sizeof(LPWSTR) * LENGTH_256;  //\83\81\81[\83\8b\82Ì\83|\83C\83\93\83^\97p\83o\83b\83t\83@\92·
 
 
-
-
-
-       SIZE_T commentCountSum = 0;                                                             //\83R\83\81\83\93\83g\83J\83E\83\93\83g                              
        WSAEVENT hRecvEvent = NULL;
 
        //\8eó\90M\8f\80\94õ\8f\88\97\9d
+       self->chatManager.commentCountSum = 0;
        hRecvEvent = WSACreateEvent();
        self->chatManager.recvBuf[0] = '\0';
        WSAEventSelect(self->chatManager.sock, hRecvEvent, FD_READ | FD_CLOSE);
@@ -1608,7 +1605,7 @@ static BOOL NicoLiveRecvChatLoop(NicoLiveStream_P self){
 
 
 
-                               NicoLiveParseComment(self,commentBuf,messageBufLen + recevedLen,mailCountBuf,&mailCountBufSize,&commentCountSum,&commentBufSize);
+                               NicoLiveParseComment(self,commentBuf,messageBufLen + recevedLen,mailCountBuf,&mailCountBufSize,&commentBufSize);
 
 
 
@@ -1644,7 +1641,7 @@ end:
 
 
 
-static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentCountSum,SIZE_T* commentBufSize){
+static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_PTR endSize,LPWSTR* mailCountBuf,SIZE_T* mailCountBufSize,SIZE_T* commentBufSize){
 
        LPWSTR indexPtr;                                                                                //\89ð\90Í\8e\9e\82Ì\8ew\95W\83|\83C\83\93\83^
        NicoLiveChat nicoLiveChat;                                                              //\83`\83\83\83b\83g\83R\83\81\83\93\83g\8ai\94[\97p\8d\\91¢\91Ì
@@ -1860,7 +1857,7 @@ static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_P
 
 
                        
-                       (*commentCountSum)++;
+                       self->chatManager.commentCountSum++;
                        isReceveChat = TRUE;
 
                        check((_heapchk() == _HEAPOK),TEXT("\83q\81[\83v\83G\83\89\81[\82Å\82·"));
@@ -1870,7 +1867,7 @@ static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_P
                                
                                _beginthread(NicoLiveSelfDisconnect,0,self);
                        }
-                       self->callBack(NICOLIVE_EVENT_RECEVE_CHAT,self,self->option,(NICOLIVE_PARAM)&nicoLiveChat,*commentCountSum);
+                       self->callBack(NICOLIVE_EVENT_RECEVE_CHAT,self,self->option,(NICOLIVE_PARAM)&nicoLiveChat,self->chatManager.commentCountSum);
                        
 
                        //chat_result\83m\81[\83h\82Ì\8fê\8d\87
@@ -1913,7 +1910,7 @@ static VOID  NicoLiveParseComment(NicoLiveStream_P self,LPWSTR commentBuf,UINT_P
        }
 
        if(recvBufTmp == recvEndPoint && isReceveChat){
-               self->callBack(NICOLIVE_EVENT_RECEVE_CHATSETTLE,self,self->option,self->chatManager.chatNo,*commentCountSum);
+               self->callBack(NICOLIVE_EVENT_RECEVE_CHATSETTLE,self,self->option,self->chatManager.chatNo,self->chatManager.commentCountSum);
        }
 
 
index a6e8a7b..03ef895 100644 (file)
@@ -55,6 +55,7 @@ typedef struct {
        WSAEVENT  endEvent;
        WSAEVENT resetEvents[3];
        UINT_PTR chatNo;
+       UINT_PTR commentCountSum;
        DWORD commentStartTime;
        time_t baseVpos;
 }ChatManager,*ChatManager_P;
index 067072e..83ad1f3 100644 (file)
@@ -45,7 +45,9 @@ namespace nlite{
                        commentWriteButton.Create(m_hWnd,0,WC_BUTTON,WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,0);
 
                        anonymousButton.SetWindowTextW(TEXT("184"));
+                       anonymousButton.SetFont(AtlGetDefaultGuiFont());
                        commentWriteButton.SetWindowTextW(TEXT("\8f\91\82«\8d\9e\82Ý"));
+                       commentWriteButton.SetFont(AtlGetDefaultGuiFont());
                        return 0;
                }
 
index 3fb9e1a..404c670 100644 (file)
@@ -46,9 +46,12 @@ VOID CCommentView::Unlock(){
 VOID CCommentView::OnConnect(){
        m_commentListWindow.SetRedraw(FALSE);
        commentlist.OnConnect();
+       
        SCROLLINFO vScrollInfo = {0};
-       vScrollInfo.fMask = SIF_ALL;
-       this->SetScrollInfo(SB_VERT,&vScrollInfo);
+       vScrollInfo.cbSize = sizeof(vScrollInfo);
+       vScrollInfo.fMask = SIF_RANGE;
+       this->SetScrollInfo(SB_VERT,&vScrollInfo,TRUE);
+       
        m_commentListWindow.SetRedraw(TRUE);
        
        
@@ -132,7 +135,7 @@ LRESULT CCommentView::OnHeaderEndTrack(LPNMHDR lParam){
                SCROLLINFO vScrollInfo = {0};
                vScrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
                this->GetScrollInfo(SB_VERT,&vScrollInfo);
-               vScrollInfo.nPage = m_commentListWindow.CalcScrolPage();
+               vScrollInfo.nPage = m_commentListWindow.CalcScrollPage();
                vScrollInfo.fMask = SIF_PAGE;
                this->SetScrollInfo(SB_VERT,&vScrollInfo);
                BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage + 1>= vScrollInfo.nMax;
@@ -190,16 +193,16 @@ VOID CCommentView::OnChatReceveSettle(UINT_PTR chatNo,UINT_PTR commentCountSum){
        BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage >= vScrollInfo.nMax;
        
 
-       vScrollInfo.fMask = SIF_RANGE;
+
+       vScrollInfo.fMask = SIF_RANGE | SIF_PAGE;
+       vScrollInfo.cbSize = sizeof(vScrollInfo);
        vScrollInfo.nMax = commentCountSum;
-       this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
-       
+       vScrollInfo.nPage = m_commentListWindow.CalcScrollPage();
        
-       
-       vScrollInfo.nPage = m_commentListWindow.CalcScrolPage();
-       
-       vScrollInfo.fMask = SIF_PAGE;
-       this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+       this->SetScrollInfo(SB_VERT,&vScrollInfo);
+
+       this->GetScrollInfo(SB_VERT,&vScrollInfo);
+
 
        if(scrollFlag == TRUE){
                this->SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
@@ -578,8 +581,9 @@ VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
        vScrollInfo.fMask = SIF_ALL;
        self.GetScrollInfo(SB_VERT,&vScrollInfo);
        BOOL scrollFlag = (UINT)(vScrollInfo.nPage + vScrollInfo.nPos + 1) >= (UINT)vScrollInfo.nMax;
-       vScrollInfo.nPage = CalcScrolPage();
+       vScrollInfo.nPage = CalcScrollPage();
        
+       vScrollInfo.fMask = SIF_PAGE;
        self.SetScrollInfo(SB_VERT,&vScrollInfo);
        
        if(scrollFlag == TRUE){
@@ -589,7 +593,7 @@ VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
 }
 
 
-UINT_PTR CCommentListWindow::CalcScrolPage(){
+UINT_PTR CCommentListWindow::CalcScrollPage(){
        
        RECT clientRect;
        INT_PTR rslt = 0;
index 2f4d249..a4a4b11 100644 (file)
@@ -73,7 +73,7 @@ namespace nlite{
                ///
                ///\83X\83N\83\8d\81[\83\8b\83y\81[\83W\8cv\8eZ
                ///
-               UINT_PTR CalcScrolPage();
+               UINT_PTR CalcScrollPage();
 
                //\83v\83\89\83C\83x\81[\83g\8aÖ\90\94
        private:
index 9a6b8b3..1fc2b62 100644 (file)
@@ -1,33 +1,32 @@
 #pragma once
 
 namespace nlite{
+       
+//\96¼\91O\82â\83N\83\89\83X\82ð\95Ï\82¦\82½\82¢\8fê\8d\87\82Í\82±\82±\82ð\95Ï\82¦\82é
+#define CNLITESTRING_THISTYPE CNLiteString                             //\95\8e\9a\97ñ\83N\83\89\83X\96¼
+#define CNLITESTRING_INTERNALSTRINGTYPE CString                        //\93à\95\94\82Å\8f\88\97\9d\82ð\82·\82é\95\8e\9a\97ñ\83N\83\89\83X\96¼
+
+
+
+
+#define CNLITESTRING_THISTYPE_REFERENCE CNLITESTRING_THISTYPE&
+#define CNLITESTRING_INTERNALSTRINGTYPE_REFERENCE CNLITESTRING_INTERNALSTRINGTYPE& 
+
+
+
        ///
        ///nlite\95\8e\9a\97ñ\83N\83\89\83X
        ///\8aù\91\82Ì\95\8e\9a\97ñ\83N\83\89\83X\82Ì\83\89\83b\83p
        ///
+       class CNLITESTRING_THISTYPE{
 
-       class CNLiteString{
-               //
-               //\8c^\92è\8b`
-               //
-       private:
-               typedef CString InternalString;
-               typedef LPSTR StrPtr;
-               typedef LPCSTR StrCPtr;
-               typedef LPWSTR WStrPtr;
-               typedef LPCWSTR WStrCPtr;
-               typedef CHAR Char_Type;
-               typedef WCHAR WChar_Type;
 
        public:
-               typedef WStrPtr NLiteStrPtr;
-               typedef WStrCPtr NLiteStrCPtr;
-               typedef TCHAR NLiteChar;
-               typedef CNLiteString ThisType;
+               
 
                //\83\81\83\93\83o
        private:
-               InternalString is_string;
+               CNLITESTRING_INTERNALSTRINGTYPE is_string;
 
 
 
@@ -35,49 +34,185 @@ namespace nlite{
                ///
                ///\83R\83\93\83X\83g\83\89\83N\83^
                ///
-               CNLiteString():is_string(){}
+               CNLITESTRING_THISTYPE():is_string(){}
 
-               CNLiteString(const NLiteStrCPtr in_str):is_string(in_str){}
+               CNLITESTRING_THISTYPE(LPCTSTR in_str):is_string(in_str){}
 
-               CNLiteString(const InternalString &in_str):is_string(in_str){}
+               CNLITESTRING_THISTYPE(const CNLITESTRING_INTERNALSTRINGTYPE_REFERENCE in_str):is_string(in_str){}
 
-               CNLiteString(const CNLiteString &in_str):is_string(in_str.is_string){}
+               CNLITESTRING_THISTYPE(const CNLITESTRING_THISTYPE_REFERENCE in_str):is_string(in_str.is_string){}
 
 
 
 
 
+               ///
+               ///\95\8e\9a\97ñ\82Ì\92·\82³\82ð\8eæ\93¾
+               ///
                UINT_PTR length(){
 
                        return _tcslen(is_string);
                }
 
-               operator NLiteStrCPtr(){
-                       return (NLiteStrCPtr)(LPCWSTR)is_string;
+               ///
+               ///\95\8e\9a\97ñ\82ð\8c\9f\8dõ
+               ///
+               template<typename T>
+               int Find(const T pszSub,int iStart = 0)const throw(){
+
+                       return is_string.Find(pszSub,iStart);
+               }
+
+               ///
+               ///\8f\91\8e®\82Å\83t\83H\81[\83}\83b\83g\89»\82·\82é
+               ///
+               template<typename T>
+               void Format(T format,...){
+                       va_list ap;
+                       va_start(ap,format);
+
+                       is_string.Format(format,ap);
+                       va_end(ap);
+
+               }
+
+
+               //
+               //\89\89\8eZ\8eq
+               //
+       public:
+               operator LPCTSTR(){
+                       return (LPCWSTR)is_string;
                }
                
                template<typename T>
-               ThisType &operator=(const T &instr){
+               CNLITESTRING_THISTYPE_REFERENCE operator=(const T &instr){
                        is_string = instr;
                        return *this;
                }
                
-               template<typename T>
-               ThisType &operator=(const T instr[]){
-                       is_string = instr;
+               
+               CNLITESTRING_THISTYPE_REFERENCE operator=(const CNLITESTRING_THISTYPE_REFERENCE instr){
+                       is_string = instr.is_string;
                        return *this;
                }
                
                template<typename T>
-               ThisType &operator+=(const T &instr){
+               CNLITESTRING_THISTYPE_REFERENCE operator+=(const T &instr){
                        is_string += instr;
                        return *this;
                }
 
                
+               CNLITESTRING_THISTYPE_REFERENCE operator+=(const CNLITESTRING_THISTYPE_REFERENCE instr){
+                       is_string += instr.is_string;
+                       return *this;
+               }
+
+
+               template<typename T>
+               friend CNLITESTRING_THISTYPE operator+(const CNLITESTRING_THISTYPE_REFERENCE instr1, const T &instr2){
+                       return CNLITESTRING_THISTYPE(instr1.is_string + instr2);
+               }
+
+
+               template<typename T>
+               friend CNLITESTRING_THISTYPE operator+(const T &instr1, const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return CNLITESTRING_THISTYPE(instr1 + instr2.is);
+               }
+
+               
+               friend CNLITESTRING_THISTYPE operator+(const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+
+                       return CNLITESTRING_THISTYPE(instr1.is_string + instr2.is_string);
+               }
+               
+               template<typename T>
+               friend bool operator< (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+                       return instr1.is_string < instr2;
+               }
+
+               template<typename T>
+               friend bool operator< (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string < instr2;
+               }
+               
+               friend bool operator< (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string < instr2.is_string;
+               }
+
+
+               template<typename T>
+               friend bool operator> (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+                       return instr1.is_string > instr2;
+               }
+
+               template<typename T>
+               friend bool operator> (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string > instr2;
+               }
+               
+               friend bool operator> (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string > instr2.is_string;
+               }
+
+               template<typename T>
+               friend bool operator<= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+                       return instr1.is_string <= instr2;
+               }
+
+               template<typename T>
+               friend bool operator<= (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string <= instr2;
+               }
+               
+               friend bool operator<= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string <= instr2.is_string;
+               }
+
+
+               template<typename T>
+               friend bool operator>= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+                       return instr1.is_string >= instr2;
+               }
+
+               template<typename T>
+               friend bool operator>= (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string >= instr2;
+               }
+               
+               friend bool operator>= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string >= instr2.is_string;
+               }
+
+
+               template<typename T>
+               friend bool operator== (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+                       return instr1.is_string == instr2;
+               }
+
+               template<typename T>
+               friend bool operator== (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string == instr2;
+               }
+               
+               friend bool operator== (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string == instr2.is_string;
+               }
+
+
+               template<typename T>
+               friend bool operator!= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const T &instr2){
+                       return instr1.is_string != instr2;
+               }
+
+               template<typename T>
+               friend bool operator!= (const T &instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string != instr2;
+               }
                
-               bool operator< (const ThisType &instr) const{
-                       return is_string < instr.is_string;
+               friend bool operator!= (const CNLITESTRING_THISTYPE_REFERENCE instr1,const CNLITESTRING_THISTYPE_REFERENCE instr2){
+                       return instr1.is_string != instr2.is_string;
                }
 
        };
index ca50155..ec27d4c 100644 (file)
@@ -4,6 +4,7 @@ typedef struct nicolivestream_t{
        NicoRecvCallBack callback;
        HANDLE threadHandle;
        HANDLE endEvent;
+       HANDLE receveEvent;
        LPVOID option;
        StreamStatus stream;
-}NicoLiveStream;
\ No newline at end of file
+}NicoLiveStream,*NicoLiveStream_P;
\ No newline at end of file
index 0f43c73..dec2141 100644 (file)
@@ -20,6 +20,7 @@ NicoLiveStream_P NicoLiveStream_new(){
        NicoLiveStream_P rslt = (NicoLiveStream_P)malloc(sizeof(NicoLiveStream));
        ZeroMemory(rslt,sizeof(*rslt));
        rslt->endEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
+       rslt->receveEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
        return rslt;
 }
 
@@ -27,6 +28,7 @@ VOID NicoLiveStream_delete(NicoLiveStream_P* self){
 
        NicoLiveStream_disConnect(*self);
        CloseHandle((*self)->endEvent);
+       CloseHandle((*self)->receveEvent);
        free(*self);
        *self = NULL;
        return;
@@ -112,6 +114,22 @@ StreamStatus_P NicoLiveStream_getStreamStatus(NicoLiveStream_P self){
        return &self->stream;
 }
 
+void commentthread_inteanal(void* userdata){
+
+       NicoLiveStream_P self = (NicoLiveStream_P)userdata;
+       DWORD rslt;
+       do{
+               rslt = WaitForSingleObject(self->endEvent,1000);
+
+               if(rslt != WAIT_TIMEOUT){
+                       break;
+               }
+
+               SetEvent(self->receveEvent);
+
+       }while(TRUE);
+       _endthread();
+}
 
 unsigned int WINAPI commentthread(VOID *usadata){
 
@@ -154,8 +172,9 @@ unsigned int WINAPI commentthread(VOID *usadata){
                self->callback(NICOLIVE_EVENT_RECEVE_CHAT,self,self->option,(NICOLIVE_PARAM)&liveChat,commentcount);
                
        }
-
        
+       _beginthread(commentthread_inteanal,0,self);
+       HANDLE eventarray[] = {self->endEvent,self->receveEvent};
        for(int index = 0,index2; index < 65536;index++){
 
                
@@ -171,11 +190,15 @@ unsigned int WINAPI commentthread(VOID *usadata){
                }
 
                self->callback(NICOLIVE_EVENT_RECEVE_CHATSETTLE,self,self->option,100,commentcount);
-               if(( rslt = WaitForSingleObject(self->endEvent,1000)) != WAIT_TIMEOUT){
+               ResetEvent(self->receveEvent);
+               rslt = WaitForMultipleObjects(ARRAY_LENGTH(eventarray),eventarray,FALSE,INFINITE);
+               
+               //\83G\83\89\81[\82Ì\8fê\8d\87
+               if(rslt == WAIT_OBJECT_0 ){
 
                        goto end;
                }
-
+               
                
                
        }
@@ -183,4 +206,6 @@ end:
 
        _endthreadex(0);
        return 0;
-}
\ No newline at end of file
+}
+
+