2 #include "nlite_include.h"
7 #define NLITE_GET_TYPENAME(n) (_tcsstr(CComBSTR(typeid(n).name()),TEXT("::")) + 2)
11 #define NLITE_XMLELLMENT_WRITE(s,p) s->WriteStartElement(NULL, NLITE_GET_TYPENAME(p), NULL)
13 #define NLITE_ATTRIBUTE_WRITE_STR(s,n) s->WriteElementString(NULL, _tcsstr(TEXT(#n),TEXT(".")) != NULL ? _tcsstr(TEXT(#n),TEXT(".")) + 1 : TEXT(#n), NULL, n)
16 #define NLITE_ATTRIBUTE_WRITE_INT(s,n) \
18 TCHAR buffer[sizeof(n) * 8];\
19 _stprintf(buffer,TEXT("%d"),static_cast<INT>(n));\
20 s->WriteElementString(NULL, _tcsstr(TEXT(#n),TEXT(".")) + 1, NULL,buffer );\
23 #define NLITE_XML_WRITE_FOR_INT(s,n)\
25 TCHAR nbuffer[LENGTH_256];\
26 TCHAR buffer[sizeof(n[0]) * 8];\
27 for(UINT_PTR index = 0;index < ARRAY_LENGTH(n);index++){\
28 _stprintf(nbuffer,TEXT("%s%d"),_tcsstr(TEXT(#n),TEXT(".")) + 1,index);\
29 _stprintf(buffer,TEXT("%d"),n[index]);\
30 s->WriteElementString(NULL, nbuffer, NULL,buffer );\
36 static LPCTSTR headerFormat = TEXT("headerholSize%u");
37 static LPCTSTR headerOrderFormat = TEXT("headerOrderArray%u");
38 static const LPCTSTR bt_none = TEXT("none");
39 static const LPCTSTR bt_ie = TEXT("ie");
40 static const LPCTSTR bt_chrome = TEXT("chrome");
41 static const LPCTSTR bt_firefox = TEXT("firefox");
42 static const LPCTSTR bt_iecm = TEXT("iecm");
49 WritePrivateProfileInt(
56 TCHAR value[LENGTH_256];
58 _stprintf(value, TEXT("%d"), lData);
59 return WritePrivateProfileString(
67 PropertyBase::PropertyBase(LPCTSTR in_sectionName):sectionName(in_sectionName){}
70 LPCTSTR PropertyBase::GetSectionName(){
76 BOOL CCookieSettingWindow::OnInitDialog(CWindow wndFocus, LPARAM lInitParam){
77 //
\83X
\83N
\83\8a\81[
\83\93\82Ì
\92\86\89\9b\82É
\94z
\92u
83 switch(this->browserType){
85 case BT_INTERNET_EXPLORER:
87 radio = GetDlgItem(IDC_RADIO_IE);
93 radio = GetDlgItem(IDC_RADIO_FIREFOX);
98 case BT_GOOGLE_CHROME:
100 radio = GetDlgItem(IDC_RADIO_CHROME);
104 case BT_IE_COMPONENT:
106 radio = GetDlgItem(IDC_RADIO_IECM);
113 radio.SetCheck(BST_CHECKED);
120 VOID CCookieSettingWindow::OnOK(UINT uNotifyCode, int nID, CWindow wndCtl){
121 CButton ieRadio = GetDlgItem(IDC_RADIO_IE);
122 CButton firefoxRadio = GetDlgItem(IDC_RADIO_FIREFOX);
123 CButton chromeRadio = GetDlgItem(IDC_RADIO_CHROME);
124 CButton iecmRadio = GetDlgItem(IDC_RADIO_IECM);
126 if(ieRadio.GetCheck() == BST_CHECKED){
128 this->browserType = BT_INTERNET_EXPLORER;
132 if(firefoxRadio.GetCheck() == BST_CHECKED){
134 this->browserType = BT_FIRE_FOX;
138 if(chromeRadio.GetCheck() == BST_CHECKED){
140 this->browserType = BT_GOOGLE_CHROME;
144 if(iecmRadio.GetCheck() == BST_CHECKED){
146 this->browserType = BT_IE_COMPONENT;
154 VOID CCookieSettingWindow::OnCancel(UINT uNotifyCode, int nID, CWindow wndCtl){
158 VOID CCookieSettingWindow::SetBrowserType(BROWSERTYPE browserType){
160 this->browserType = browserType;
166 BROWSERTYPE CCookieSettingWindow::GetBrowserType(){
167 return this->browserType;
172 CommentViewProperty::CommentViewProperty():
173 commentFoldingFlag(TRUE),
174 commentTimeType(StreamingTimeType),
175 PropertyBase(TEXT("COMMENTVIEW")),
176 baseStringColor(PALETTERGB(0,0,0)),
177 backColor(PALETTERGB(255,255,255)),
178 selectBackColor(PALETTERGB(255,240,240)),
179 selectSellLineColor(PALETTERGB(255,0,0)),
180 normalSellLineColor( PALETTERGB(0,0,0)),
181 colLineColor(PALETTERGB(224,224,224))
185 memset(headerholSize,-1,sizeof(headerholSize));
191 CommentReadProperty::CommentReadProperty():
192 commentReadFlag(FALSE),
193 ngWordReadFlag(TRUE),
194 ngUserReadFlag(TRUE),
195 administratorCommentReadFlag(TRUE),
197 userCommentReadFlag(TRUE),
199 PropertyBase(TEXT("COMMENTREAD"))
205 GeneralProperty::GeneralProperty():
206 userCountUpdateFlag(TRUE),
207 commentLogAutoSaveFlag(FALSE),
208 defaultBrowserFlag(TRUE),
209 autoNameRegisterFlag(FALSE),
210 autoNameUpdateFlag(FALSE),
211 numberNameFlag(FALSE),
212 autoColorRegisterFlag(FALSE),
213 activeCountTimeFlag(TRUE),
214 PropertyBase(TEXT("GENERAL")),
215 browserType(BT_NOSETTING)
220 MainFrameProperty::MainFrameProperty():
221 windowFrontFlag(TRUE),
222 PropertyBase(TEXT("MAINFRAME"))
225 ZeroMemory(&windowSize,sizeof(windowSize));
234 TCHAR localAppPath[_MAX_PATH];
235 SHGetFolderPathW(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT,localAppPath);
237 this->appLocalPath = localAppPath;
240 Property::~Property()
246 VOID Property::Initialize(){
252 BROWSERTYPE Property::CookieSetting(){
254 CCookieSettingWindow cookieSettingwindow;
256 cookieSettingwindow.SetBrowserType(gp.browserType);
258 cookieSettingwindow.DoModal();
260 this->gp.browserType = cookieSettingwindow.GetBrowserType();
262 return this->gp.browserType;
266 VOID Property::ReadProperty(){
268 CreatePropertyFile();
269 CAtlFile propertyFile;
272 check(SUCCEEDED(propertyFile.Create(propertyPath,GENERIC_READ,FILE_SHARE_READ,OPEN_ALWAYS)),TEXT("
\90Ý
\92è
\83t
\83@
\83C
\83\8b\82ª
\8aJ
\82¯
\82Ü
\82¹
\82ñ"));
273 check(SUCCEEDED(propertyFile.GetSize(nLen)),TEXT("
\90Ý
\92è
\83t
\83@
\83C
\83\8b\90Ý
\92è
\8eæ
\93¾
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½"));
274 std::vector<char> buf(static_cast<UINT_PTR>(nLen / sizeof(char) + 1));
275 buf[buf.size() -1 ] = TEXT('\0');
276 propertyFile.Read(&buf[0],buf.size());
277 ReadPropertyXML reader(*this);
278 reader.Parse(&buf[0],buf.size());
284 VOID Property::CreatePropertyFile(){
286 propertyPath = appLocalPath;
288 propertyPath += TEXT("\\qwerty_nico");
290 if(PathIsDirectory(propertyPath) == FALSE){
292 if(CreateDirectory(propertyPath,NULL) == 0){
293 throw Exception(TEXT("
\90Ý
\92è
\83t
\83@
\83C
\83\8b\8dì
\90¬
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
298 propertyPath += TEXT("\\nlite");
300 if(PathIsDirectory(propertyPath) == FALSE){
302 if(CreateDirectory(propertyPath,NULL) == 0){
303 throw Exception(TEXT("
\90Ý
\92è
\83t
\83@
\83C
\83\8b\8dì
\90¬
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
308 propertyPath += TEXT("\\property.xml");
311 if(PathFileExists(propertyPath)== FALSE || PathIsDirectory(propertyPath) == TRUE){
313 HANDLE hPropertyxml = CreateFile(propertyPath,GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
315 if(hPropertyxml == INVALID_HANDLE_VALUE ){
317 throw Exception(TEXT("
\90Ý
\92è
\83t
\83@
\83C
\83\8b\8dì
\90¬
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½"),__LINE__,TEXT(__FILE__),TEXT(__FUNCTION__));
322 CloseHandle(hPropertyxml);
330 VOID Property::WriteProperty(){
332 CreatePropertyFile();
333 CComPtr<IXmlWriter> pWriter;
334 CreateXmlWriter(__uuidof(IXmlWriter), reinterpret_cast<void**>(&pWriter), 0);
336 // XML
\83t
\83@
\83C
\83\8b\83p
\83X
\8dì
\90¬
338 _tcscpy(xml,this->propertyPath);
342 //
\83t
\83@
\83C
\83\8b\83X
\83g
\83\8a\81[
\83\80\8dì
\90¬
343 CComPtr<IStream> pStream;
344 SHCreateStreamOnFile(xml, STGM_CREATE | STGM_WRITE, &pStream);
346 pWriter->SetOutput(pStream);
348 //
\83C
\83\93\83f
\83\93\83g
\97L
\8cø
\89»
349 pWriter->SetProperty(XmlWriterProperty_Indent, TRUE);
351 // <?xml version="1.0" encoding="UTF-8"?>
352 pWriter->WriteStartDocument(XmlStandalone_Omit);
354 pWriter->WriteStartElement(NULL,TEXT("nliteconfig"),NULL);
355 //
\83R
\83\81\83\93\83g
\93Ç
\82Ý
\8fã
\82°
\90Ý
\92è
\8f\91\82«
\8d\9e\82Ý
356 NLITE_XMLELLMENT_WRITE(pWriter,crp);
357 NLITE_ATTRIBUTE_WRITE_STR(pWriter,crp.outString);
358 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.administratorCommentReadFlag);
359 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.besideLengthFlag);
360 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.bspReadFlag);
361 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.commentReadFlag);
362 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.maxCommentLength);
363 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.newLineReadFlag);
364 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.ngUserReadFlag);
365 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.ngWordReadFlag);
366 NLITE_ATTRIBUTE_WRITE_STR(pWriter,crp.shortComment);
367 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.teropReadFlag);
368 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.userCommentReadFlag);
369 pWriter->WriteEndElement();
370 //commentview
\90Ý
\92è
\92l
\8f\91\82«
\8d\9e\82Ý
371 NLITE_XMLELLMENT_WRITE(pWriter,cvp);
372 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerholSize);
373 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.anonymousIDLinkColor);
374 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.backColor);
375 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.baseStringColor);
376 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.commentFoldingFlag);
377 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.commentTimeType);
378 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerOraderArray);
379 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.IDLinkColor);
380 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.selectBackColor);
381 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.selectSellLineColor);
382 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.colLineColor);
383 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.normalSellLineColor);
386 pWriter->WriteEndElement();
389 NLITE_XMLELLMENT_WRITE(pWriter,mfp);
390 NLITE_ATTRIBUTE_WRITE_INT(pWriter,mfp.windowSize.cx);
391 NLITE_ATTRIBUTE_WRITE_INT(pWriter,mfp.windowSize.cy);
392 NLITE_ATTRIBUTE_WRITE_INT(pWriter,mfp.windowFrontFlag);
393 pWriter->WriteEndElement();
395 NLITE_XMLELLMENT_WRITE(pWriter,gp);
396 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.activeCountTimeFlag);
397 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.autoColorRegisterFlag);
398 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.autoNameUpdateFlag);
399 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.autoNameRegisterFlag);
400 NLITE_ATTRIBUTE_WRITE_STR(pWriter,gp.browserPath);
401 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.browserType);
402 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.commentLogAutoSaveFlag);
403 NLITE_ATTRIBUTE_WRITE_STR(pWriter,gp.commentPath);
404 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.defaultBrowserFlag);
405 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.numberNameFlag);
406 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.userCountUpdateFlag);
407 pWriter->WriteEndElement();
408 pWriter->WriteEndDocument();
417 ///
\83R
\83\93\83X
\83g
\83\89\83N
\83^
419 ReadPropertyXML::ReadPropertyXML(Property &in_property):nliteProperty(in_property),propertyType(Node::None){
425 #define NLITE_PSZNAME_CMP(t,p) (_tcscmp(NLITE_GET_TYPENAME(t),(LPCTSTR)(p)) == 0)
426 void ReadPropertyXML::OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs){
428 switch(propertyType){
432 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName)){
434 propertyType = Node::CommentReadProperty;
436 } else if(NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)){
438 propertyType = Node::CommentViewProperty;
440 } else if(NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
442 propertyType = Node::MainFrameProperty;
444 } else if(NLITE_PSZNAME_CMP(nliteProperty.gp,pszName)){
446 propertyType = Node::GeneralProperty;
453 case Node::CommentReadProperty:
454 case Node::CommentViewProperty:
455 case Node::GeneralProperty:
456 case Node::MainFrameProperty:
458 nodeName = (LPCTSTR)pszName;
472 void ReadPropertyXML::OnEndElement (const XML_Char *pszName){
474 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName) ||
475 NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)||
476 NLITE_PSZNAME_CMP(nliteProperty.gp,pszName) ||
477 NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
479 propertyType = Node::None;
487 #define NLITE_R_X_P_S(p,p2,v) \
488 if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
489 _tcsncpy(p.p2.v,(LPCTSTR)pszData,nLength);\
493 #define NLITE_R_X_P_I(p,p2,v) \
494 if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
496 strToIntN(p.p2.v,pszData,nLength);\
500 #define NLITE_RXP_AI(p,p2,v) {\
501 TCHAR name[LENGTH_256];\
502 for(INT_PTR index = 0;index < ARRAY_LENGTH(p.p2.v);index++){\
503 _stprintf(name,TEXT("%s%d"),TEXT(#v),index);\
504 if(_tcscmp(name,nodeName.c_str()) == 0){\
506 strToIntN(p.p2.v[index],pszData,nLength);\
512 #define NLITE_NAME(n) (#n)
514 void ReadPropertyXML::OnCharacterData (const XML_Char *pszData, int nLength){
516 if (nodeName.empty() == true)return;
518 switch(propertyType){
522 case Node::CommentReadProperty:
524 NLITE_R_X_P_S(nliteProperty,crp,shortComment);
525 NLITE_R_X_P_I(nliteProperty,crp,administratorCommentReadFlag);
526 NLITE_R_X_P_I(nliteProperty,crp,besideLengthFlag);
527 NLITE_R_X_P_I(nliteProperty,crp,bspReadFlag);
528 NLITE_R_X_P_I(nliteProperty,crp,commentReadFlag);
529 NLITE_R_X_P_I(nliteProperty,crp,maxCommentLength);
530 NLITE_R_X_P_I(nliteProperty,crp,newLineReadFlag);
531 NLITE_R_X_P_I(nliteProperty,crp,ngUserReadFlag);
532 NLITE_R_X_P_I(nliteProperty,crp,ngWordReadFlag);
533 NLITE_R_X_P_S(nliteProperty,crp,outString);
534 NLITE_R_X_P_S(nliteProperty,crp,shortComment);
535 NLITE_R_X_P_I(nliteProperty,crp,teropReadFlag);
536 NLITE_R_X_P_I(nliteProperty,crp,userCommentReadFlag);
539 case Node::CommentViewProperty:
540 NLITE_R_X_P_I(nliteProperty,cvp,anonymousIDLinkColor);
541 NLITE_R_X_P_I(nliteProperty,cvp,backColor);
542 NLITE_R_X_P_I(nliteProperty,cvp,baseStringColor);
543 NLITE_R_X_P_I(nliteProperty,cvp,commentFoldingFlag);
544 NLITE_R_X_P_I(nliteProperty,cvp,commentTimeType);
545 NLITE_R_X_P_I(nliteProperty,cvp,IDLinkColor);
546 NLITE_RXP_AI(nliteProperty,cvp,headerholSize);
547 NLITE_RXP_AI(nliteProperty,cvp,headerOraderArray);
548 NLITE_R_X_P_I(nliteProperty,cvp,selectBackColor);
549 NLITE_R_X_P_I(nliteProperty,cvp,selectSellLineColor);
550 NLITE_R_X_P_I(nliteProperty,cvp,normalSellLineColor);
551 NLITE_R_X_P_I(nliteProperty,cvp,colLineColor);
553 case Node::GeneralProperty:
554 NLITE_R_X_P_I(nliteProperty,gp,activeCountTimeFlag);
555 NLITE_R_X_P_I(nliteProperty,gp,autoColorRegisterFlag);
556 NLITE_R_X_P_I(nliteProperty,gp,autoNameRegisterFlag);
557 NLITE_R_X_P_I(nliteProperty,gp,autoNameUpdateFlag);
558 NLITE_R_X_P_S(nliteProperty,gp,browserPath);
559 NLITE_R_X_P_I(nliteProperty,gp,browserType);
560 NLITE_R_X_P_I(nliteProperty,gp,commentLogAutoSaveFlag);
561 NLITE_R_X_P_S(nliteProperty,gp,commentPath);
562 NLITE_R_X_P_I(nliteProperty,gp,defaultBrowserFlag);
563 NLITE_R_X_P_I(nliteProperty,gp,numberNameFlag);
564 NLITE_R_X_P_I(nliteProperty,gp,userCountUpdateFlag);
566 case Node::MainFrameProperty:
567 NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cx);
568 NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cy);
569 NLITE_R_X_P_I(nliteProperty,mfp,windowFrontFlag);