OSDN Git Service

ncvからリスナーデータを読み取る処理を追加
authorqwerty2501 <riot313@gmail.com>
Thu, 9 Feb 2012 16:40:23 +0000 (01:40 +0900)
committerqwerty2501 <riot313@gmail.com>
Thu, 9 Feb 2012 16:40:23 +0000 (01:40 +0900)
nlite.suo
nlite/nlite.h
nlite/nlite_chatData.cpp
nlite/nlite_chatData.h
nlite/nlite_include.h
nlite/nlite_property.cpp
nlite/nlite_property.h

index 9250c4e..167ec28 100644 (file)
Binary files a/nlite.suo and b/nlite.suo differ
index c32351a..5bb27b5 100644 (file)
@@ -9,6 +9,7 @@ namespace nlite{
        class CListenerList;
        struct Property;
        struct GeneralProperty;
+       struct ListenerData;
 
        
 
index 36112f7..0177243 100644 (file)
@@ -76,7 +76,7 @@ VOID CChatData::SetChat(NicoLiveChat &chat_in,ListenerData &listener){
 
 
        
-       this->listenerData = &listenerList.Register(listener);
+       this->listenerData = &listenerList.Register(listener,FALSE);
 
        
        this->vpos = _ttol(chat_in.vpos);
@@ -289,7 +289,7 @@ VOID CListenerList::BkColorCollect(CListenerColorCollector &target){
        std::for_each(m_listenerList.begin(), end,target);
 }
 
-CListenerList::reference CListenerList::Register(ListenerData &listener){
+CListenerList::reference CListenerList::Register(ListenerData &listener,BOOL bUpdate){
 
        ListenerPre listenerPre(listener);
 
@@ -307,6 +307,10 @@ CListenerList::reference CListenerList::Register(ListenerData &listener){
 
                return m_listenerList.back();
 
+       } else if(bUpdate == TRUE){
+
+               *rslt = listener;
+
        }
        
        return *rslt;
index a05a2ca..0690b24 100644 (file)
@@ -101,8 +101,10 @@ namespace nlite{
                ///
                ///\83\86\81[\83U\81[\93o\98^
                ///
-               reference Register(ListenerData &listener);
+               reference Register(ListenerData &listener,BOOL bUpdate);
 
+
+               
                ///
                ///\94w\8ci\90F\82ð\8eû\8fW\82·\82é
                ///
index e3012d6..7357f78 100644 (file)
@@ -15,8 +15,8 @@
 #include "nlite_exception.h"
 #include "nlite_commentWrite.h"
 #include "nlite_nlib.h"
-#include "nlite_property.h"
 #include "nlite_chatData.h"
+#include "nlite_property.h"
 #include "nlite_commentview.h"
 #include "nlite_appinfo.h"
 #include "nlite_propertyWindow.h"
index aefe704..ae7a190 100644 (file)
@@ -95,7 +95,8 @@ namespace nlite{
                numberNameFlag(FALSE),
                autoColorRegisterFlag(FALSE),
                activeCountTimeFlag(TRUE),
-               browserType(BT_NOSETTING)
+               browserType(BT_NOSETTING),
+               ncvUserSettingReadedFlag(FALSE)
        {}
 
 
@@ -152,19 +153,45 @@ namespace nlite{
 
                CreatePropertyFile();
                CAtlFile        propertyFile;
-               ULONGLONG nLen;
-
-               if(SUCCEEDED(propertyFile.Create(propertyPath,GENERIC_READ,FILE_SHARE_READ,OPEN_ALWAYS)) == FALSE || SUCCEEDED(propertyFile.GetSize(nLen)) == FALSE){
+               CAtlFile        ncvUserSettingFile;
+               ULONGLONG propertyFileSize;
+               ULONGLONG ncvUserSettingFileSize;
+               if(SUCCEEDED(propertyFile.Create(propertyPath,GENERIC_READ,FILE_SHARE_READ,OPEN_ALWAYS)) == FALSE || SUCCEEDED(propertyFile.GetSize(propertyFileSize)) == FALSE){
 
                        throw Exception(TEXT("\90Ý\92è\83t\83@\83C\83\8b\82ª\8aJ\82¯\82Ü\82¹\82ñ\82Å\82µ\82½\81B\82±\82Ì\83G\83\89\81[\82ª\91±\82­\82æ\82¤\82Å\82 \82ê\82Î\81A\88ê\93x\90Ý\92è\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82µ\82Ä\8dÄ\93x\8e\8e\82µ\82Ä\82Ý\82Ä\82­\82¾\82³\82¢"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
 
+               } 
+
+               std::vector<char> propertyBuf(static_cast<UINT_PTR>(propertyFileSize / sizeof(char) + (1 * sizeof(char))));
+               
+               
+               propertyFile.Read(&propertyBuf[0],propertyBuf.size());
+               
+               LPSTR propertyTagStart = strstr(&propertyBuf[0],"<");
+               if(propertyTagStart != NULL){
+                       ReadPropertyXML reader(*this);
+                       reader.Parse(propertyTagStart);
                }
 
-               std::vector<char> buf(static_cast<UINT_PTR>(nLen / sizeof(char) + 1));
-               buf[buf.size() -1 ] = '\0'; 
-               propertyFile.Read(&buf[0],buf.size());
-               ReadPropertyXML reader(*this);
-               reader.Parse(&buf[0],buf.size());
+
+               if(this->gp.ncvUserSettingReadedFlag == FALSE){
+
+                       TCHAR appFolderPath[_MAX_PATH];
+                       SHGetFolderPathW(0,CSIDL_APPDATA,0,SHGFP_TYPE_CURRENT,appFolderPath);
+                       CString ncvUserSettingPath = appFolderPath;
+                       ncvUserSettingPath += TEXT("\\posite-c\\NiconamaCommentViewer\\UserSetting.xml");
+                       if(SUCCEEDED(ncvUserSettingFile.Create(ncvUserSettingPath,GENERIC_READ,FILE_SHARE_READ,OPEN_ALWAYS)) == FALSE || SUCCEEDED(ncvUserSettingFile.GetSize(ncvUserSettingFileSize)) == FALSE){
+
+                               throw Exception(TEXT("\83\8a\83X\83i\81[\90Ý\92è\83t\83@\83C\83\8b\82ª\8aJ\82¯\82Ü\82¹\82ñ\82Å\82µ\82½\81B\82±\82Ì\83G\83\89\81[\82ª\91±\82­\82æ\82¤\82Å\82 \82ê\82Î\81A\88ê\93x\90Ý\92è\83t\83@\83C\83\8b\82ð\8dí\8f\9c\82µ\82Ä\8dÄ\93x\8e\8e\82µ\82Ä\82Ý\82Ä\82­\82¾\82³\82¢"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
+                       }
+                       std::vector<char> ncvUserSettingBuf(static_cast<UINT_PTR>(ncvUserSettingFileSize / sizeof(char) + (1 * sizeof(char))));
+                       ncvUserSettingFile.Read(&ncvUserSettingBuf[0],ncvUserSettingBuf.size());
+                       LPSTR ncvUserSettingStart = strstr(&ncvUserSettingBuf[0],"<");
+                       if(ncvUserSettingStart != NULL){
+                               ReadUserSettingXML rusx;
+                               rusx.Parse(ncvUserSettingStart);
+                       }
+               }
 
                return;
        }
@@ -271,6 +298,8 @@ namespace nlite{
                NLITE_ATTRIBUTE_WRITE_INT(pWriter,mfp.windowFrontFlag);
                pWriter->WriteEndElement();
 
+
+               //\8b¤\92Ê\90Ý\92è\8f\91\82«\8d\9e\82Ý
                NLITE_XMLELLMENT_WRITE(pWriter,gp);
                NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.activeCountTimeFlag);
                NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.autoColorRegisterFlag);
@@ -283,6 +312,8 @@ namespace nlite{
                NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.defaultBrowserFlag);
                NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.numberNameFlag);
                NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.userCountUpdateFlag);
+               NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.ncvUserSettingReadedFlag);
+               
                pWriter->WriteEndElement();
                pWriter->WriteEndDocument();
 
@@ -448,6 +479,7 @@ namespace nlite{
                        NLITE_R_X_P_I(nliteProperty,gp,defaultBrowserFlag);
                        NLITE_R_X_P_I(nliteProperty,gp,numberNameFlag);
                        NLITE_R_X_P_I(nliteProperty,gp,userCountUpdateFlag);
+                       NLITE_R_X_P_I(nliteProperty,gp,ncvUserSettingReadedFlag);
                        break;
                case Node::MainFrameProperty:
                        NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cx);
@@ -468,4 +500,61 @@ end:
                return;
        }
 
+
+
+#define NLITE_READ_USER_STRING(at,l,t) if(_tcscmp(at[0],TEXT(#t)) == 0)l.t = at[1]
+#define NLITE_READ_USER_INT(at,l,t)            if(_tcscmp(at[0],TEXT(#t))==0)l.t = _tcstol((const wchar_t*)at[1],NULL,10)
+
+       void ReadUserSettingXML::OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs){
+
+               if(_tcscmp(pszName,TEXT("user")) == 0){
+
+                       this->userNodeFlag = TRUE;
+
+
+                       for(;papszAttrs[0] != NULL;papszAttrs += 2){
+
+                               NLITE_READ_USER_STRING(papszAttrs,listenerBuff,name);
+                               NLITE_READ_USER_STRING(papszAttrs,listenerBuff,community);
+                               NLITE_READ_USER_INT(papszAttrs,listenerBuff,bgcolor);
+                               NLITE_READ_USER_INT(papszAttrs,listenerBuff,time);
+                               
+                       }
+
+               }
+
+               return;
+       }
+
+       void ReadUserSettingXML::OnEndElement (const XML_Char *pszName){
+
+               if(_tcscmp(pszName,TEXT("user")) == 0){
+
+                       listenerList.Register(listenerBuff,TRUE);
+                       this->userNodeFlag = FALSE;
+                       this->listenerBuff.~ListenerData();
+                       new(&listenerBuff) ListenerData();
+
+               }
+
+               return;
+       }
+
+       void ReadUserSettingXML::OnCharacterData (const XML_Char *pszData, int nLength){
+
+               if(this->userNodeFlag == TRUE){
+
+
+                       listenerBuff.user_id.Append(pszData,nLength);
+
+
+
+
+               }
+
+               
+
+               return;
+       }
+
 }
\ No newline at end of file
index f2ee46c..e83832e 100644 (file)
@@ -84,6 +84,7 @@ namespace nlite{
                BOOL  autoColorRegisterFlag;                            //\96¼\91O\93o\98^\8e\9d\82É\90F\82ð\8e©\93®\93I\82É\8ew\92è\82·\82é\82©\82Ì\83t\83\89\83O
                BOOL activeCountTimeFlag;                                       //\83A\83N\83e\83B\83u\90l\90\94\82ð\8e©\93®\8dX\90V\82·\82é\82©\82Ì\83t\83\89\83O
                BROWSERTYPE browserType;                                        //\83u\83\89\83E\83U\83^\83C\83v
+               BOOL ncvUserSettingReadedFlag;                          //ncv\83\8a\83X\83i\81[\83f\81[\83^\93Ç\82Ý\8d\9e\82Ý\8dÏ\82Ý\83t\83\89\83O
                
 
                ///
@@ -196,4 +197,26 @@ namespace nlite{
        };
 
 
+       ///
+       ///\83\86\81[\83U\90Ý\92è\83t\83@\83C\83\8b\93Ç\8eæ\83N\83\89\83X
+       ///
+       class ReadUserSettingXML:public CXmlParser{
+
+       private:
+               ListenerData listenerBuff;
+               BOOL userNodeFlag;
+               
+               
+
+
+
+       public:
+               void OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs);
+
+               void OnEndElement (const XML_Char *pszName);
+
+               void OnCharacterData (const XML_Char *pszData, int nLength);
+       };
+
+
 }
\ No newline at end of file