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 CCommentViewProperty::CCommentViewProperty():
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));
75 COLORREF CCommentViewProperty::GetOwnerStringColor()const{
77 return this->ownerStringColor;
80 COLORREF CCommentViewProperty::GetBaseStringColor()const{
82 return this->baseStringColor;
86 COLORREF CCommentViewProperty::GetSelectBackColor()const{
88 return this->selectBackColor;
91 COLORREF CCommentViewProperty::GetSelectSellLineColor()const{
93 return this->selectBackColor;
96 COLORREF CCommentViewProperty::GetBackColor()const{
98 return this->backColor;
101 COLORREF CCommentViewProperty::GetNormalLineColor()const{
103 return this->normalSellLineColor;
106 COLORREF CCommentViewProperty::GetLinkStringColor()const{
108 return this->linkStringColor;
111 COLORREF CCommentViewProperty::GetColLineColor()const{
113 return this->colLineColor;
116 BOOL CCommentViewProperty::IsCommentFoldingFlag()const{
118 return this->commentFoldingFlag;
121 INT_PTR *CCommentViewProperty::GetHeaderHolSize(){
123 return this->headerholSize;
127 INT_PTR *CCommentViewProperty::GetHeaderOrderArray(){
129 return this->headerOrderArray;
132 UINT_PTR CCommentViewProperty::GetHeaderOrderArrayLength()const{
134 return ARRAY_LENGTH(this->headerOrderArray);
136 CCommentReadProperty::CCommentReadProperty():
137 commentReadFlag(FALSE),
138 ngWordReadFlag(TRUE),
139 ngUserReadFlag(TRUE),
140 administratorCommentReadFlag(TRUE),
142 userCommentReadFlag(TRUE),
146 VOID CCommentReadProperty::SetCommentRead(BOOL flag){
148 this->commentReadFlag = flag;
151 BOOL CCommentReadProperty::IsCommentRead()const{
153 return this->commentReadFlag;
158 CGeneralProperty::CGeneralProperty():
159 userCountUpdateFlag(TRUE),
160 commentLogAutoSaveFlag(FALSE),
161 defaultBrowserFlag(TRUE),
162 autoNameRegisterFlag(FALSE),
163 autoNameUpdateFlag(FALSE),
164 numberNameFlag(FALSE),
165 autoColorRegisterFlag(FALSE),
166 activeCountTimeFlag(TRUE),
167 browserType(BT_DEFAULT),
168 ncvUserSettingReadedFlag(FALSE)
171 VOID CGeneralProperty::SetNCVUSerSettingReaded(BOOL flag){
172 this->ncvUserSettingReadedFlag = flag;
176 BOOL CGeneralProperty::IsNCVUserSettingReaded()const{
178 return this->ncvUserSettingReadedFlag;
182 BOOL CGeneralProperty::IsNumberName()const{
184 return this->numberNameFlag;
187 BROWSERTYPE CGeneralProperty::GetBrowserType()const{
189 return this->browserType;
192 const CNLiteString &CGeneralProperty::GetBrowserPath()const{
194 return this->browserPath;
197 CMainFrameProperty::CMainFrameProperty():
198 windowFrontFlag(TRUE)
201 ZeroMemory(&windowSize,sizeof(windowSize));
204 VOID CMainFrameProperty::SetWindowFront(BOOL flag){
205 this->windowFrontFlag = flag;
209 const SIZE &CMainFrameProperty::GetWindowSize()const{
211 return this->windowSize;
214 BOOL CMainFrameProperty::IsWindowFront()const{
216 return this->windowFrontFlag;
221 CProperty::CProperty()
223 TCHAR localAppPath[_MAX_PATH];
224 SHGetFolderPathW(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT,localAppPath);
226 this->appLocalPath = localAppPath;
229 CProperty::~CProperty()
235 VOID CProperty::Initialize(){
241 BROWSERTYPE CProperty::CookieSetting(){
243 CCookieSettingWindow cookieSettingwindow;
245 cookieSettingwindow.SetBrowserType(gp.browserType);
247 cookieSettingwindow.DoModal();
249 this->gp.browserType = cookieSettingwindow.GetBrowserType();
254 return this->gp.browserType;
258 VOID CProperty::SetCommentViewProperty(const CCommentViewProperty& commentViewProperty){
260 this->cvp = commentViewProperty;
264 CCommentViewProperty &CProperty::GetCommentViewProperty(){
269 CMainFrameProperty &CProperty::GetMainFrameProperty(){
274 CGeneralProperty &CProperty::GetGeneralProperty(){
279 CCommentReadProperty &CProperty::GetCommentReadProperty(){
285 VOID CProperty::ReadProperty(){
287 CreatePropertyFile();
288 CAtlFile propertyFile;
290 ULONGLONG propertyFileSize;
292 if(SUCCEEDED(propertyFile.Create(propertyPath,GENERIC_READ,FILE_SHARE_READ,OPEN_ALWAYS)) == FALSE || SUCCEEDED(propertyFile.GetSize(propertyFileSize)) == FALSE){
294 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__));
298 std::vector<char> propertyBuf(static_cast<UINT_PTR>(propertyFileSize / sizeof(char) + (1 * sizeof(char))));
301 propertyFile.Read(&propertyBuf[0],propertyBuf.size());
303 LPSTR propertyTagStart = strstr(&propertyBuf[0],"<");
304 if(propertyTagStart != NULL){
305 CReadPropertyXML reader(*this);
306 reader.Parse(propertyTagStart);
315 const CNLiteString &CProperty::GetListenerDataPath()const{
317 return this->listenerDataPath;
320 const CNLiteString &CProperty::GetPropertySaveFolderPath()const{
322 return this->propertyFolderPath;
326 VOID CProperty::CreatePropertyFile(){
329 iniFile = appLocalPath;
330 iniFile += TEXT("\\qwerty_nico\\nlite.ini");
331 SurelyCreate(iniFile,TRUE);
334 TCHAR propertyBuf[_MAX_PATH];
335 LPCTSTR sectionName = TEXT("property");
336 LPCTSTR keyName = TEXT("dir");
337 ::GetPrivateProfileString(sectionName,keyName,TEXT(""),propertyBuf,ARRAY_LENGTH(propertyBuf),iniFile);
339 if((_tcslen(propertyBuf) == 0) || !((PathFileExists(propertyBuf) && !::PathIsDirectory( propertyBuf )))){
341 propertyFolderPath = appLocalPath;
342 propertyFolderPath += TEXT("\\qwerty_nico\\");
344 ::WritePrivateProfileString(sectionName,keyName,propertyFolderPath,iniFile);
347 propertyFolderPath = propertyBuf;
350 propertySaveFolderPath = propertyFolderPath;
351 propertySaveFolderPath += TEXT("nlite\\");
352 propertyPath = propertySaveFolderPath;
353 propertyPath += TEXT("property.xml");
354 listenerDataPath = propertySaveFolderPath;
355 listenerDataPath += TEXT("listenerData.xml");
356 SurelyCreate(propertySaveFolderPath,FALSE);
357 SurelyCreate(propertyPath,TRUE);
358 SurelyCreate(listenerDataPath,TRUE);
364 VOID CProperty::WriteProperty(){
366 CreatePropertyFile();
367 CComPtr<IXmlWriter> pWriter;
368 CreateXmlWriter(__uuidof(IXmlWriter), reinterpret_cast<void**>(&pWriter), 0);
370 // XML
\83t
\83@
\83C
\83\8b\83p
\83X
\8dì
\90¬
372 _tcscpy(xml,this->propertyPath);
376 //
\83t
\83@
\83C
\83\8b\83X
\83g
\83\8a\81[
\83\80\8dì
\90¬
377 CComPtr<IStream> pStream;
378 SHCreateStreamOnFile(xml, STGM_CREATE | STGM_WRITE, &pStream);
380 pWriter->SetOutput(pStream);
381 //
\83C
\83\93\83f
\83\93\83g
\97L
\8cø
\89»
382 pWriter->SetProperty(XmlWriterProperty_Indent, TRUE);
384 // <?xml version="1.0" encoding="UTF-8"?>
385 pWriter->WriteStartDocument(XmlStandalone_Omit);
387 pWriter->WriteStartElement(NULL,TEXT("nliteconfig"),NULL);
388 //
\83R
\83\81\83\93\83g
\93Ç
\82Ý
\8fã
\82°
\90Ý
\92è
\8f\91\82«
\8d\9e\82Ý
389 NLITE_XMLELLMENT_WRITE(pWriter,crp);
390 NLITE_ELLEMENT_WRITE_STR(pWriter,crp.outString);
391 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.administratorCommentReadFlag);
392 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.besideLengthFlag);
393 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.bspReadFlag);
394 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.commentReadFlag);
395 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.maxCommentLength);
396 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.newLineReadFlag);
397 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.ngUserReadFlag);
398 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.ngWordReadFlag);
399 NLITE_ELLEMENT_WRITE_STR(pWriter,crp.shortComment);
400 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.teropReadFlag);
401 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.userCommentReadFlag);
402 pWriter->WriteEndElement();
403 //commentview
\90Ý
\92è
\92l
\8f\91\82«
\8d\9e\82Ý
404 NLITE_XMLELLMENT_WRITE(pWriter,cvp);
405 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerholSize);
406 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.anonymousIDLinkColor);
407 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.backColor);
408 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.baseStringColor);
409 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.commentFoldingFlag);
410 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.commentTimeType);
411 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerOrderArray);
412 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.linkStringColor);
413 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.selectBackColor);
414 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.selectSellLineColor);
415 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.colLineColor);
416 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.normalSellLineColor);
417 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.ownerStringColor);
419 pWriter->WriteEndElement();
422 NLITE_XMLELLMENT_WRITE(pWriter,mfp);
423 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowSize.cx);
424 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowSize.cy);
425 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowFrontFlag);
426 pWriter->WriteEndElement();
429 //
\8b¤
\92Ê
\90Ý
\92è
\8f\91\82«
\8d\9e\82Ý
430 NLITE_XMLELLMENT_WRITE(pWriter,gp);
431 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.activeCountTimeFlag);
432 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoColorRegisterFlag);
433 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoNameUpdateFlag);
434 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoNameRegisterFlag);
435 NLITE_ELLEMENT_WRITE_STR(pWriter,gp.browserPath);
436 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.browserType);
437 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.commentLogAutoSaveFlag);
438 NLITE_ELLEMENT_WRITE_STR(pWriter,gp.commentPath);
439 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.defaultBrowserFlag);
440 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.numberNameFlag);
441 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.userCountUpdateFlag);
442 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.ncvUserSettingReadedFlag);
444 pWriter->WriteEndElement();
445 pWriter->WriteEndDocument();
454 ///
\83R
\83\93\83X
\83g
\83\89\83N
\83^
456 CReadPropertyXML::CReadPropertyXML(CProperty &in_property):nliteProperty(in_property),propertyType(Node::None){
464 //
\90Ý
\92è
\83t
\83@
\83C
\83\8b\89ð
\90Í
\8f\88\97\9d
467 #define NLITE_PSZNAME_CMP(t,p) (_tcscmp(NLITE_GET_TYPENAME(t),(LPCTSTR)(p)) == 0)
468 void CReadPropertyXML::OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs){
470 switch(propertyType){
474 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName)){
476 propertyType = Node::CCommentReadProperty;
478 } else if(NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)){
480 propertyType = Node::CCommentViewProperty;
482 } else if(NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
484 propertyType = Node::CMainFrameProperty;
486 } else if(NLITE_PSZNAME_CMP(nliteProperty.gp,pszName)){
488 propertyType = Node::CGeneralProperty;
495 case Node::CCommentReadProperty:
496 case Node::CCommentViewProperty:
497 case Node::CGeneralProperty:
498 case Node::CMainFrameProperty:
500 nodeName = (LPCTSTR)pszName;
514 void CReadPropertyXML::OnEndElement (const XML_Char *pszName){
516 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName) ||
517 NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)||
518 NLITE_PSZNAME_CMP(nliteProperty.gp,pszName) ||
519 NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
521 propertyType = Node::None;
529 #define NLITE_R_X_P_S(p,p2,v) \
530 if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
531 _tcsncpy(p.p2.v,(LPCTSTR)pszData,nLength);\
535 #define NLITE_R_X_P_I(p,p2,v) \
536 if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
538 strToIntN(p.p2.v,pszData,nLength);\
542 #define NLITE_RXP_AI(p,p2,v) {\
543 TCHAR name[LENGTH_256];\
544 for(INT_PTR index = 0;index < ARRAY_LENGTH(p.p2.v);index++){\
545 _stprintf(name,TEXT("%s%d"),TEXT(#v),index);\
546 if(_tcscmp(name,nodeName.c_str()) == 0){\
548 strToIntN(p.p2.v[index],pszData,nLength);\
554 #define NLITE_NAME(n) (#n)
556 void CReadPropertyXML::OnCharacterData (const XML_Char *pszData, int nLength){
558 if (nodeName.empty() == true)return;
560 switch(propertyType){
564 case Node::CCommentReadProperty:
566 NLITE_R_X_P_S(nliteProperty,crp,shortComment);
567 NLITE_R_X_P_I(nliteProperty,crp,administratorCommentReadFlag);
568 NLITE_R_X_P_I(nliteProperty,crp,besideLengthFlag);
569 NLITE_R_X_P_I(nliteProperty,crp,bspReadFlag);
570 NLITE_R_X_P_I(nliteProperty,crp,commentReadFlag);
571 NLITE_R_X_P_I(nliteProperty,crp,maxCommentLength);
572 NLITE_R_X_P_I(nliteProperty,crp,newLineReadFlag);
573 NLITE_R_X_P_I(nliteProperty,crp,ngUserReadFlag);
574 NLITE_R_X_P_I(nliteProperty,crp,ngWordReadFlag);
575 NLITE_R_X_P_S(nliteProperty,crp,outString);
576 NLITE_R_X_P_S(nliteProperty,crp,shortComment);
577 NLITE_R_X_P_I(nliteProperty,crp,teropReadFlag);
578 NLITE_R_X_P_I(nliteProperty,crp,userCommentReadFlag);
581 case Node::CCommentViewProperty:
582 NLITE_R_X_P_I(nliteProperty,cvp,anonymousIDLinkColor);
583 NLITE_R_X_P_I(nliteProperty,cvp,backColor);
584 NLITE_R_X_P_I(nliteProperty,cvp,baseStringColor);
585 NLITE_R_X_P_I(nliteProperty,cvp,commentFoldingFlag);
586 NLITE_R_X_P_I(nliteProperty,cvp,commentTimeType);
587 NLITE_R_X_P_I(nliteProperty,cvp,linkStringColor);
588 NLITE_RXP_AI(nliteProperty,cvp,headerholSize);
589 NLITE_RXP_AI(nliteProperty,cvp,headerOrderArray);
590 NLITE_R_X_P_I(nliteProperty,cvp,selectBackColor);
591 NLITE_R_X_P_I(nliteProperty,cvp,selectSellLineColor);
592 NLITE_R_X_P_I(nliteProperty,cvp,normalSellLineColor);
593 NLITE_R_X_P_I(nliteProperty,cvp,colLineColor);
594 NLITE_R_X_P_I(nliteProperty,cvp,ownerStringColor);
597 case Node::CGeneralProperty:
598 NLITE_R_X_P_I(nliteProperty,gp,activeCountTimeFlag);
599 NLITE_R_X_P_I(nliteProperty,gp,autoColorRegisterFlag);
600 NLITE_R_X_P_I(nliteProperty,gp,autoNameRegisterFlag);
601 NLITE_R_X_P_I(nliteProperty,gp,autoNameUpdateFlag);
602 NLITE_R_X_P_S(nliteProperty,gp,browserPath);
603 NLITE_R_X_P_I(nliteProperty,gp,browserType);
604 NLITE_R_X_P_I(nliteProperty,gp,commentLogAutoSaveFlag);
605 NLITE_R_X_P_S(nliteProperty,gp,commentPath);
606 NLITE_R_X_P_I(nliteProperty,gp,defaultBrowserFlag);
607 NLITE_R_X_P_I(nliteProperty,gp,numberNameFlag);
608 NLITE_R_X_P_I(nliteProperty,gp,userCountUpdateFlag);
609 NLITE_R_X_P_I(nliteProperty,gp,ncvUserSettingReadedFlag);
611 case Node::CMainFrameProperty:
612 NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cx);
613 NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cy);
614 NLITE_R_X_P_I(nliteProperty,mfp,windowFrontFlag);