From: qwerty2501 Date: Thu, 9 Feb 2012 16:40:23 +0000 (+0900) Subject: ncvからリスナーデータを読み取る処理を追加 X-Git-Tag: v0.002~2^2~10 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=409aafc01755afbdfae7528ae8f65ad962aac502;p=nlite%2Fnlite.git ncvからリスナーデータを読み取る処理を追加 --- diff --git a/nlite.suo b/nlite.suo index 9250c4e..167ec28 100644 Binary files a/nlite.suo and b/nlite.suo differ diff --git a/nlite/nlite.h b/nlite/nlite.h index c32351a..5bb27b5 100644 --- a/nlite/nlite.h +++ b/nlite/nlite.h @@ -9,6 +9,7 @@ namespace nlite{ class CListenerList; struct Property; struct GeneralProperty; + struct ListenerData; diff --git a/nlite/nlite_chatData.cpp b/nlite/nlite_chatData.cpp index 36112f7..0177243 100644 --- a/nlite/nlite_chatData.cpp +++ b/nlite/nlite_chatData.cpp @@ -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; diff --git a/nlite/nlite_chatData.h b/nlite/nlite_chatData.h index a05a2ca..0690b24 100644 --- a/nlite/nlite_chatData.h +++ b/nlite/nlite_chatData.h @@ -101,8 +101,10 @@ namespace nlite{ /// ///ƒ†[ƒU[“o˜^ /// - reference Register(ListenerData &listener); + reference Register(ListenerData &listener,BOOL bUpdate); + + /// ///”wŒiF‚ðŽûW‚·‚é /// diff --git a/nlite/nlite_include.h b/nlite/nlite_include.h index e3012d6..7357f78 100644 --- a/nlite/nlite_include.h +++ b/nlite/nlite_include.h @@ -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" diff --git a/nlite/nlite_property.cpp b/nlite/nlite_property.cpp index aefe704..ae7a190 100644 --- a/nlite/nlite_property.cpp +++ b/nlite/nlite_property.cpp @@ -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("Ý’èƒtƒ@ƒCƒ‹‚ªŠJ‚¯‚Ü‚¹‚ñ‚Å‚µ‚½B‚±‚̃Gƒ‰[‚ª‘±‚­‚悤‚Å‚ ‚ê‚΁Aˆê“xÝ’èƒtƒ@ƒCƒ‹‚ðíœ‚µ‚čēxŽŽ‚µ‚Ä‚Ý‚Ä‚­‚¾‚³‚¢"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); + } + + std::vector propertyBuf(static_cast(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 buf(static_cast(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("ƒŠƒXƒi[Ý’èƒtƒ@ƒCƒ‹‚ªŠJ‚¯‚Ü‚¹‚ñ‚Å‚µ‚½B‚±‚̃Gƒ‰[‚ª‘±‚­‚悤‚Å‚ ‚ê‚΁Aˆê“xÝ’èƒtƒ@ƒCƒ‹‚ðíœ‚µ‚čēxŽŽ‚µ‚Ä‚Ý‚Ä‚­‚¾‚³‚¢"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__)); + } + std::vector ncvUserSettingBuf(static_cast(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(); + + //‹¤’ʐݒ菑‚«ž‚Ý 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 diff --git a/nlite/nlite_property.h b/nlite/nlite_property.h index f2ee46c..e83832e 100644 --- a/nlite/nlite_property.h +++ b/nlite/nlite_property.h @@ -84,6 +84,7 @@ namespace nlite{ BOOL autoColorRegisterFlag; //–¼‘O“o˜^Ž‚ɐF‚ðŽ©“®“I‚ÉŽw’è‚·‚é‚©‚̃tƒ‰ƒO BOOL activeCountTimeFlag; //ƒAƒNƒeƒBƒul”‚ðŽ©“®XV‚·‚é‚©‚̃tƒ‰ƒO BROWSERTYPE browserType; //ƒuƒ‰ƒEƒUƒ^ƒCƒv + BOOL ncvUserSettingReadedFlag; //ncvƒŠƒXƒi[ƒf[ƒ^“ǂݍž‚ݍς݃tƒ‰ƒO /// @@ -196,4 +197,26 @@ namespace nlite{ }; + /// + ///ƒ†[ƒUÝ’èƒtƒ@ƒCƒ‹“ÇŽæƒNƒ‰ƒX + /// + 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