X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=nlite%2Fnlite_property.cpp;h=ae7a190e8ecfc36733cb0fcd26b34c02b2c2e57e;hb=409aafc01755afbdfae7528ae8f65ad962aac502;hp=aefe70477c8c18a91db6be8b1c997572bf85e3d3;hpb=860f8b87b4ca77a0c517a35247e7b35a5da1199e;p=nlite%2Fnlite.git 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