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);
239 //
\83C
\83\93\83f
\83\93\83g
\97L
\8cø
\89»
240 pWriter->SetProperty(XmlWriterProperty_Indent, TRUE);
242 // <?xml version="1.0" encoding="UTF-8"?>
243 pWriter->WriteStartDocument(XmlStandalone_Omit);
245 pWriter->WriteStartElement(NULL,TEXT("nliteconfig"),NULL);
246 //
\83R
\83\81\83\93\83g
\93Ç
\82Ý
\8fã
\82°
\90Ý
\92è
\8f\91\82«
\8d\9e\82Ý
247 NLITE_XMLELLMENT_WRITE(pWriter,crp);
248 NLITE_ELLEMENT_WRITE_STR(pWriter,crp.outString);
249 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.administratorCommentReadFlag);
250 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.besideLengthFlag);
251 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.bspReadFlag);
252 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.commentReadFlag);
253 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.maxCommentLength);
254 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.newLineReadFlag);
255 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.ngUserReadFlag);
256 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.ngWordReadFlag);
257 NLITE_ELLEMENT_WRITE_STR(pWriter,crp.shortComment);
258 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.teropReadFlag);
259 NLITE_ELLEMENT_WRITE_INT(pWriter,crp.userCommentReadFlag);
260 pWriter->WriteEndElement();
261 //commentview
\90Ý
\92è
\92l
\8f\91\82«
\8d\9e\82Ý
262 NLITE_XMLELLMENT_WRITE(pWriter,cvp);
263 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerholSize);
264 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.anonymousIDLinkColor);
265 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.backColor);
266 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.baseStringColor);
267 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.commentFoldingFlag);
268 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.commentTimeType);
269 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerOrderArray);
270 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.linkStringColor);
271 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.selectBackColor);
272 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.selectSellLineColor);
273 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.colLineColor);
274 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.normalSellLineColor);
275 NLITE_ELLEMENT_WRITE_INT(pWriter,cvp.ownerStringColor);
277 pWriter->WriteEndElement();
280 NLITE_XMLELLMENT_WRITE(pWriter,mfp);
281 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowSize.cx);
282 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowSize.cy);
283 NLITE_ELLEMENT_WRITE_INT(pWriter,mfp.windowFrontFlag);
284 pWriter->WriteEndElement();
287 //
\8b¤
\92Ê
\90Ý
\92è
\8f\91\82«
\8d\9e\82Ý
288 NLITE_XMLELLMENT_WRITE(pWriter,gp);
289 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.activeCountTimeFlag);
290 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoColorRegisterFlag);
291 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoNameUpdateFlag);
292 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.autoNameRegisterFlag);
293 NLITE_ELLEMENT_WRITE_STR(pWriter,gp.browserPath);
294 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.browserType);
295 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.commentLogAutoSaveFlag);
296 NLITE_ELLEMENT_WRITE_STR(pWriter,gp.commentPath);
297 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.defaultBrowserFlag);
298 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.numberNameFlag);
299 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.userCountUpdateFlag);
300 NLITE_ELLEMENT_WRITE_INT(pWriter,gp.ncvUserSettingReadedFlag);
302 pWriter->WriteEndElement();
303 pWriter->WriteEndDocument();
312 ///
\83R
\83\93\83X
\83g
\83\89\83N
\83^
314 ReadPropertyXML::ReadPropertyXML(Property &in_property):nliteProperty(in_property),propertyType(Node::None){
322 //
\90Ý
\92è
\83t
\83@
\83C
\83\8b\89ð
\90Í
\8f\88\97\9d
325 #define NLITE_PSZNAME_CMP(t,p) (_tcscmp(NLITE_GET_TYPENAME(t),(LPCTSTR)(p)) == 0)
326 void ReadPropertyXML::OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs){
328 switch(propertyType){
332 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName)){
334 propertyType = Node::CommentReadProperty;
336 } else if(NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)){
338 propertyType = Node::CommentViewProperty;
340 } else if(NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
342 propertyType = Node::MainFrameProperty;
344 } else if(NLITE_PSZNAME_CMP(nliteProperty.gp,pszName)){
346 propertyType = Node::GeneralProperty;
353 case Node::CommentReadProperty:
354 case Node::CommentViewProperty:
355 case Node::GeneralProperty:
356 case Node::MainFrameProperty:
358 nodeName = (LPCTSTR)pszName;
372 void ReadPropertyXML::OnEndElement (const XML_Char *pszName){
374 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName) ||
375 NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)||
376 NLITE_PSZNAME_CMP(nliteProperty.gp,pszName) ||
377 NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
379 propertyType = Node::None;
387 #define NLITE_R_X_P_S(p,p2,v) \
388 if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
389 _tcsncpy(p.p2.v,(LPCTSTR)pszData,nLength);\
393 #define NLITE_R_X_P_I(p,p2,v) \
394 if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
396 strToIntN(p.p2.v,pszData,nLength);\
400 #define NLITE_RXP_AI(p,p2,v) {\
401 TCHAR name[LENGTH_256];\
402 for(INT_PTR index = 0;index < ARRAY_LENGTH(p.p2.v);index++){\
403 _stprintf(name,TEXT("%s%d"),TEXT(#v),index);\
404 if(_tcscmp(name,nodeName.c_str()) == 0){\
406 strToIntN(p.p2.v[index],pszData,nLength);\
412 #define NLITE_NAME(n) (#n)
414 void ReadPropertyXML::OnCharacterData (const XML_Char *pszData, int nLength){
416 if (nodeName.empty() == true)return;
418 switch(propertyType){
422 case Node::CommentReadProperty:
424 NLITE_R_X_P_S(nliteProperty,crp,shortComment);
425 NLITE_R_X_P_I(nliteProperty,crp,administratorCommentReadFlag);
426 NLITE_R_X_P_I(nliteProperty,crp,besideLengthFlag);
427 NLITE_R_X_P_I(nliteProperty,crp,bspReadFlag);
428 NLITE_R_X_P_I(nliteProperty,crp,commentReadFlag);
429 NLITE_R_X_P_I(nliteProperty,crp,maxCommentLength);
430 NLITE_R_X_P_I(nliteProperty,crp,newLineReadFlag);
431 NLITE_R_X_P_I(nliteProperty,crp,ngUserReadFlag);
432 NLITE_R_X_P_I(nliteProperty,crp,ngWordReadFlag);
433 NLITE_R_X_P_S(nliteProperty,crp,outString);
434 NLITE_R_X_P_S(nliteProperty,crp,shortComment);
435 NLITE_R_X_P_I(nliteProperty,crp,teropReadFlag);
436 NLITE_R_X_P_I(nliteProperty,crp,userCommentReadFlag);
439 case Node::CommentViewProperty:
440 NLITE_R_X_P_I(nliteProperty,cvp,anonymousIDLinkColor);
441 NLITE_R_X_P_I(nliteProperty,cvp,backColor);
442 NLITE_R_X_P_I(nliteProperty,cvp,baseStringColor);
443 NLITE_R_X_P_I(nliteProperty,cvp,commentFoldingFlag);
444 NLITE_R_X_P_I(nliteProperty,cvp,commentTimeType);
445 NLITE_R_X_P_I(nliteProperty,cvp,linkStringColor);
446 NLITE_RXP_AI(nliteProperty,cvp,headerholSize);
447 NLITE_RXP_AI(nliteProperty,cvp,headerOrderArray);
448 NLITE_R_X_P_I(nliteProperty,cvp,selectBackColor);
449 NLITE_R_X_P_I(nliteProperty,cvp,selectSellLineColor);
450 NLITE_R_X_P_I(nliteProperty,cvp,normalSellLineColor);
451 NLITE_R_X_P_I(nliteProperty,cvp,colLineColor);
452 NLITE_R_X_P_I(nliteProperty,cvp,ownerStringColor);
455 case Node::GeneralProperty:
456 NLITE_R_X_P_I(nliteProperty,gp,activeCountTimeFlag);
457 NLITE_R_X_P_I(nliteProperty,gp,autoColorRegisterFlag);
458 NLITE_R_X_P_I(nliteProperty,gp,autoNameRegisterFlag);
459 NLITE_R_X_P_I(nliteProperty,gp,autoNameUpdateFlag);
460 NLITE_R_X_P_S(nliteProperty,gp,browserPath);
461 NLITE_R_X_P_I(nliteProperty,gp,browserType);
462 NLITE_R_X_P_I(nliteProperty,gp,commentLogAutoSaveFlag);
463 NLITE_R_X_P_S(nliteProperty,gp,commentPath);
464 NLITE_R_X_P_I(nliteProperty,gp,defaultBrowserFlag);
465 NLITE_R_X_P_I(nliteProperty,gp,numberNameFlag);
466 NLITE_R_X_P_I(nliteProperty,gp,userCountUpdateFlag);
467 NLITE_R_X_P_I(nliteProperty,gp,ncvUserSettingReadedFlag);
469 case Node::MainFrameProperty:
470 NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cx);
471 NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cy);
472 NLITE_R_X_P_I(nliteProperty,mfp,windowFrontFlag);