3 #include "nlite_include.h"
8 //
\83}
\83N
\83\8d\92è
\8b`
10 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11 #define NLITE_GET_TYPENAME(n) (_tcsstr(CComBSTR(typeid(n).name()),TEXT("::")) + 2)
12 #define NLITE_XMLELLMENT_WRITE(s,p) s->WriteStartElement(NULL, NLITE_GET_TYPENAME(p), NULL)
14 #define NLITE_ELLEMENT_WRITE_STR(s,n) s->WriteElementString(NULL, _tcsstr(TEXT(#n),TEXT(".")) != NULL ? _tcsstr(TEXT(#n),TEXT(".")) + 1 : TEXT(#n), NULL, n)
17 #define NLITE_ELLEMENT_WRITE_INT(s,n) \
19 TCHAR buffer[sizeof(n) * 8];\
20 _stprintf(buffer,TEXT("%d"),static_cast<INT>(n));\
21 s->WriteElementString(NULL, _tcsstr(TEXT(#n),TEXT(".")) + 1, NULL,buffer );\
24 #define NLITE_XML_WRITE_FOR_INT(s,n)\
26 TCHAR nbuffer[LENGTH_256];\
27 TCHAR buffer[sizeof(n[0]) * 8];\
28 for(UINT_PTR index = 0;index < ARRAY_LENGTH(n);index++){\
29 _stprintf(nbuffer,TEXT("%s%d"),_tcsstr(TEXT(#n),TEXT(".")) + 1,index);\
30 _stprintf(buffer,TEXT("%d"),n[index]);\
31 s->WriteElementString(NULL, nbuffer, NULL,buffer );\
39 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40 static const LPCTSTR headerFormat = TEXT("headerholSize%u");
41 static const LPCTSTR headerOrderFormat = TEXT("headerOrderArray%u");
42 static const LPCTSTR bt_none = TEXT("none");
43 static const LPCTSTR bt_ie = TEXT("ie");
44 static const LPCTSTR bt_chrome = TEXT("chrome");
45 static const LPCTSTR bt_firefox = TEXT("firefox");
46 static const LPCTSTR bt_iecm = TEXT("iecm");
51 CommentViewProperty::CommentViewProperty():
52 commentFoldingFlag(TRUE),
53 commentTimeType(StreamingTimeType),
54 baseStringColor(PALETTERGB(0,0,0)),
55 backColor(PALETTERGB(255,255,255)),
56 selectBackColor(PALETTERGB(255,240,240)),
57 selectSellLineColor(PALETTERGB(255,0,0)),
58 normalSellLineColor( PALETTERGB(0,0,0)),
59 colLineColor(PALETTERGB(224,224,224)),
60 linkStringColor(PALETTERGB(30,140,255)),
61 ownerStringColor(PALETTERGB(255,0,0))
64 for(INT_PTR orderIndex = 0;orderIndex < ARRAY_LENGTH(headerOrderArray);orderIndex++){
66 new(&headerOrderArray[orderIndex]) INT_PTR(orderIndex);
70 memset(headerholSize,-1,sizeof(headerholSize));
76 CommentReadProperty::CommentReadProperty():
77 commentReadFlag(FALSE),
80 administratorCommentReadFlag(TRUE),
82 userCommentReadFlag(TRUE),
89 GeneralProperty::GeneralProperty():
90 userCountUpdateFlag(TRUE),
91 commentLogAutoSaveFlag(FALSE),
92 defaultBrowserFlag(TRUE),
93 autoNameRegisterFlag(FALSE),
94 autoNameUpdateFlag(FALSE),
95 numberNameFlag(FALSE),
96 autoColorRegisterFlag(FALSE),
97 activeCountTimeFlag(TRUE),
98 browserType(BT_NOSETTING),
99 ncvUserSettingReadedFlag(FALSE)
104 MainFrameProperty::MainFrameProperty():
105 windowFrontFlag(TRUE)
108 ZeroMemory(&windowSize,sizeof(windowSize));
117 TCHAR localAppPath[_MAX_PATH];
118 SHGetFolderPathW(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT,localAppPath);
120 this->appLocalPath = localAppPath;
123 Property::~Property()
129 VOID Property::Initialize(){
135 BROWSERTYPE Property::CookieSetting(){
137 CCookieSettingWindow cookieSettingwindow;
139 cookieSettingwindow.SetBrowserType(gp.browserType);
141 cookieSettingwindow.DoModal();
143 this->gp.browserType = cookieSettingwindow.GetBrowserType();
148 return this->gp.browserType;
152 VOID Property::ReadProperty(){
154 CreatePropertyFile();
155 CAtlFile propertyFile;
157 ULONGLONG propertyFileSize;
159 if(SUCCEEDED(propertyFile.Create(propertyPath,GENERIC_READ,FILE_SHARE_READ,OPEN_ALWAYS)) == FALSE || SUCCEEDED(propertyFile.GetSize(propertyFileSize)) == FALSE){
161 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__));
165 std::vector<char> propertyBuf(static_cast<UINT_PTR>(propertyFileSize / sizeof(char) + (1 * sizeof(char))));
168 propertyFile.Read(&propertyBuf[0],propertyBuf.size());
170 LPSTR propertyTagStart = strstr(&propertyBuf[0],"<");
171 if(propertyTagStart != NULL){
172 ReadPropertyXML reader(*this);
173 reader.Parse(propertyTagStart);
183 VOID Property::CreatePropertyFile(){
186 iniFile = appLocalPath;
187 iniFile += TEXT("\\qwerty_nico\\nlite.ini");
188 SurelyCreate(iniFile,TRUE);
191 TCHAR propertyBuf[_MAX_PATH];
192 LPCTSTR sectionName = TEXT("property");
193 LPCTSTR keyName = TEXT("dir");
194 ::GetPrivateProfileString(sectionName,keyName,TEXT(""),propertyBuf,ARRAY_LENGTH(propertyBuf),iniFile);
196 if((_tcslen(propertyBuf) == 0) || !((PathFileExists(propertyBuf) && !::PathIsDirectory( propertyBuf )))){
198 propertyFolderPath = appLocalPath;
199 propertyFolderPath += TEXT("\\qwerty_nico\\");
201 ::WritePrivateProfileString(sectionName,keyName,propertyFolderPath,iniFile);
204 propertyFolderPath = propertyBuf;
207 propertySaveFolderPath = propertyFolderPath;
208 propertySaveFolderPath += TEXT("nlite\\");
209 propertyPath = propertySaveFolderPath;
210 propertyPath += TEXT("property.xml");
211 listenerDataPath = propertySaveFolderPath;
212 listenerDataPath += TEXT("listenerData.xml");
213 SurelyCreate(propertySaveFolderPath,FALSE);
214 SurelyCreate(propertyPath,TRUE);
215 SurelyCreate(listenerDataPath,TRUE);
221 VOID Property::WriteProperty(){
223 CreatePropertyFile();
224 CComPtr<IXmlWriter> pWriter;
225 CreateXmlWriter(__uuidof(IXmlWriter), reinterpret_cast<void**>(&pWriter), 0);
227 // XML
\83t
\83@
\83C
\83\8b\83p
\83X
\8dì
\90¬
229 _tcscpy(xml,this->propertyPath);
233 //
\83t
\83@
\83C
\83\8b\83X
\83g
\83\8a\81[
\83\80\8dì
\90¬
234 CComPtr<IStream> pStream;
235 SHCreateStreamOnFile(xml, STGM_CREATE | STGM_WRITE, &pStream);
237 pWriter->SetOutput(pStream);
238 //
\83C
\83\93\83f
\83\93\83g
\97L
\8cø
\89»
239 pWriter->SetProperty(XmlWriterProperty_Indent, TRUE);
241 // <?xml version="1.0" encoding="UTF-8"?>
242 pWriter->WriteStartDocument(XmlStandalone_Omit);
244 pWriter->WriteStartElement(NULL,TEXT("nliteconfig"),NULL);
245 //
\83R
\83\81\83\93\83g
\93Ç
\82Ý
\8fã
\82°
\90Ý
\92è
\8f\91\82«
\8d\9e\82Ý
246 NLITE_XMLELLMENT_WRITE(pWriter,crp);
247 NLITE_ELLEMENT_WRITE_STR(pWriter,crp.outString);
248 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.administratorCommentReadFlag);
249 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.besideLengthFlag);
250 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.bspReadFlag);
251 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.commentReadFlag);
252 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.maxCommentLength);
253 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.newLineReadFlag);
254 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.ngUserReadFlag);
255 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.ngWordReadFlag);
256 NLITE_ELLEMENT_WRITE_STR(pWriter,crp.shortComment);
257 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.teropReadFlag);
258 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.userCommentReadFlag);
259 pWriter->WriteEndElement();
260 //commentview
\90Ý
\92è
\92l
\8f\91\82«
\8d\9e\82Ý
261 NLITE_XMLELLMENT_WRITE(pWriter,cvp);
262 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerholSize);
263 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.anonymousIDLinkColor);
264 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.backColor);
265 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.baseStringColor);
266 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.commentFoldingFlag);
267 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.commentTimeType);
268 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerOrderArray);
269 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.linkStringColor);
270 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.selectBackColor);
271 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.selectSellLineColor);
272 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.colLineColor);
273 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.normalSellLineColor);
274 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.ownerStringColor);
276 pWriter->WriteEndElement();
279 NLITE_XMLELLMENT_WRITE(pWriter,mfp);
280 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowSize.cx);
281 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowSize.cy);
282 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowFrontFlag);
283 pWriter->WriteEndElement();
286 //
\8b¤
\92Ê
\90Ý
\92è
\8f\91\82«
\8d\9e\82Ý
287 NLITE_XMLELLMENT_WRITE(pWriter,gp);
288 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.activeCountTimeFlag);
289 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoColorRegisterFlag);
290 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoNameUpdateFlag);
291 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoNameRegisterFlag);
292 NLITE_ELLEMENT_WRITE_STR(pWriter,gp.browserPath);
293 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.browserType);
294 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.commentLogAutoSaveFlag);
295 NLITE_ELLEMENT_WRITE_STR(pWriter,gp.commentPath);
296 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.defaultBrowserFlag);
297 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.numberNameFlag);
298 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.userCountUpdateFlag);
299 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.ncvUserSettingReadedFlag);
301 pWriter->WriteEndElement();
302 pWriter->WriteEndDocument();
311 ///
\83R
\83\93\83X
\83g
\83\89\83N
\83^
313 ReadPropertyXML::ReadPropertyXML(Property &in_property):nliteProperty(in_property),propertyType(Node::None){
321 //
\90Ý
\92è
\83t
\83@
\83C
\83\8b\89ð
\90Í
\8f\88\97\9d
324 #define NLITE_PSZNAME_CMP(t,p) (_tcscmp(NLITE_GET_TYPENAME(t),(LPCTSTR)(p)) == 0)
325 void ReadPropertyXML::OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs){
327 switch(propertyType){
331 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName)){
333 propertyType = Node::CommentReadProperty;
335 } else if(NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)){
337 propertyType = Node::CommentViewProperty;
339 } else if(NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
341 propertyType = Node::MainFrameProperty;
343 } else if(NLITE_PSZNAME_CMP(nliteProperty.gp,pszName)){
345 propertyType = Node::GeneralProperty;
352 case Node::CommentReadProperty:
353 case Node::CommentViewProperty:
354 case Node::GeneralProperty:
355 case Node::MainFrameProperty:
357 nodeName = (LPCTSTR)pszName;
371 void ReadPropertyXML::OnEndElement (const XML_Char *pszName){
373 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName) ||
374 NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)||
375 NLITE_PSZNAME_CMP(nliteProperty.gp,pszName) ||
376 NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
378 propertyType = Node::None;
386 #define NLITE_R_X_P_S(p,p2,v) \
387 if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
388 _tcsncpy(p.p2.v,(LPCTSTR)pszData,nLength);\
392 #define NLITE_R_X_P_I(p,p2,v) \
393 if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
395 strToIntN(p.p2.v,pszData,nLength);\
399 #define NLITE_RXP_AI(p,p2,v) {\
400 TCHAR name[LENGTH_256];\
401 for(INT_PTR index = 0;index < ARRAY_LENGTH(p.p2.v);index++){\
402 _stprintf(name,TEXT("%s%d"),TEXT(#v),index);\
403 if(_tcscmp(name,nodeName.c_str()) == 0){\
405 strToIntN(p.p2.v[index],pszData,nLength);\
411 #define NLITE_NAME(n) (#n)
413 void ReadPropertyXML::OnCharacterData (const XML_Char *pszData, int nLength){
415 if (nodeName.empty() == true)return;
417 switch(propertyType){
421 case Node::CommentReadProperty:
423 NLITE_R_X_P_S(nliteProperty,crp,shortComment);
424 NLITE_R_X_P_I(nliteProperty,crp,administratorCommentReadFlag);
425 NLITE_R_X_P_I(nliteProperty,crp,besideLengthFlag);
426 NLITE_R_X_P_I(nliteProperty,crp,bspReadFlag);
427 NLITE_R_X_P_I(nliteProperty,crp,commentReadFlag);
428 NLITE_R_X_P_I(nliteProperty,crp,maxCommentLength);
429 NLITE_R_X_P_I(nliteProperty,crp,newLineReadFlag);
430 NLITE_R_X_P_I(nliteProperty,crp,ngUserReadFlag);
431 NLITE_R_X_P_I(nliteProperty,crp,ngWordReadFlag);
432 NLITE_R_X_P_S(nliteProperty,crp,outString);
433 NLITE_R_X_P_S(nliteProperty,crp,shortComment);
434 NLITE_R_X_P_I(nliteProperty,crp,teropReadFlag);
435 NLITE_R_X_P_I(nliteProperty,crp,userCommentReadFlag);
438 case Node::CommentViewProperty:
439 NLITE_R_X_P_I(nliteProperty,cvp,anonymousIDLinkColor);
440 NLITE_R_X_P_I(nliteProperty,cvp,backColor);
441 NLITE_R_X_P_I(nliteProperty,cvp,baseStringColor);
442 NLITE_R_X_P_I(nliteProperty,cvp,commentFoldingFlag);
443 NLITE_R_X_P_I(nliteProperty,cvp,commentTimeType);
444 NLITE_R_X_P_I(nliteProperty,cvp,linkStringColor);
445 NLITE_RXP_AI(nliteProperty,cvp,headerholSize);
446 NLITE_RXP_AI(nliteProperty,cvp,headerOrderArray);
447 NLITE_R_X_P_I(nliteProperty,cvp,selectBackColor);
448 NLITE_R_X_P_I(nliteProperty,cvp,selectSellLineColor);
449 NLITE_R_X_P_I(nliteProperty,cvp,normalSellLineColor);
450 NLITE_R_X_P_I(nliteProperty,cvp,colLineColor);
451 NLITE_R_X_P_I(nliteProperty,cvp,ownerStringColor);
454 case Node::GeneralProperty:
455 NLITE_R_X_P_I(nliteProperty,gp,activeCountTimeFlag);
456 NLITE_R_X_P_I(nliteProperty,gp,autoColorRegisterFlag);
457 NLITE_R_X_P_I(nliteProperty,gp,autoNameRegisterFlag);
458 NLITE_R_X_P_I(nliteProperty,gp,autoNameUpdateFlag);
459 NLITE_R_X_P_S(nliteProperty,gp,browserPath);
460 NLITE_R_X_P_I(nliteProperty,gp,browserType);
461 NLITE_R_X_P_I(nliteProperty,gp,commentLogAutoSaveFlag);
462 NLITE_R_X_P_S(nliteProperty,gp,commentPath);
463 NLITE_R_X_P_I(nliteProperty,gp,defaultBrowserFlag);
464 NLITE_R_X_P_I(nliteProperty,gp,numberNameFlag);
465 NLITE_R_X_P_I(nliteProperty,gp,userCountUpdateFlag);
466 NLITE_R_X_P_I(nliteProperty,gp,ncvUserSettingReadedFlag);
468 case Node::MainFrameProperty:
469 NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cx);
470 NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cy);
471 NLITE_R_X_P_I(nliteProperty,mfp,windowFrontFlag);