OSDN Git Service

ncvからリスナーデータを読み取る処理を追加
[nlite/nlite.git] / nlite / nlite_property.cpp
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