OSDN Git Service

9edb2200c6f49397c834e1164f0f8897939544ec
[nlite/nlite.git] / nlite / nlite_property.cpp
1 #include "stdafx.h"
2
3 #include "nlite_include.h"
4
5 namespace nlite{
6
7         //
8         //\83}\83N\83\8d\92è\8b`
9         //
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)
13
14 #define NLITE_ATTRIBUTE_WRITE_STR(s,n)  s->WriteElementString(NULL, _tcsstr(TEXT(#n),TEXT("."))  != NULL ? _tcsstr(TEXT(#n),TEXT(".")) + 1 : TEXT(#n), NULL, n)
15
16
17 #define NLITE_ATTRIBUTE_WRITE_INT(s,n)  \
18         {\
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 );\
22 }
23
24 #define NLITE_XML_WRITE_FOR_INT(s,n)\
25         {\
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 );\
32         }\
33 }
34
35
36
37         //
38         //\92è\90\94\90é\8c¾
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");
47
48
49
50
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))
62
63         {
64                 for(INT_PTR orderIndex = 0;orderIndex < ARRAY_LENGTH(headerOrderArray);orderIndex++){
65
66                         new(&headerOrderArray[orderIndex]) INT_PTR(orderIndex);
67
68                 }
69
70                 memset(headerholSize,-1,sizeof(headerholSize));
71         }
72
73
74
75
76         CommentReadProperty::CommentReadProperty():
77         commentReadFlag(FALSE),
78                 ngWordReadFlag(TRUE),
79                 ngUserReadFlag(TRUE),
80                 administratorCommentReadFlag(TRUE),
81                 bspReadFlag(TRUE),
82                 userCommentReadFlag(TRUE),
83                 teropReadFlag(TRUE)
84         {}
85
86
87
88
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)
100         {}
101
102
103
104         MainFrameProperty::MainFrameProperty():
105         windowFrontFlag(TRUE)
106         {
107
108                 ZeroMemory(&windowSize,sizeof(windowSize));
109
110         }
111
112
113
114
115         Property::Property()
116         {
117                 TCHAR localAppPath[_MAX_PATH];
118                 SHGetFolderPathW(0,CSIDL_LOCAL_APPDATA,0,SHGFP_TYPE_CURRENT,localAppPath);
119
120                 this->appLocalPath = localAppPath;
121         }
122
123         Property::~Property()
124         {
125
126
127         }
128
129         VOID Property::Initialize(){
130                 this->~Property();
131                 new(this) Property;
132
133         }
134
135         BROWSERTYPE Property::CookieSetting(){
136
137                 CCookieSettingWindow cookieSettingwindow;
138
139                 cookieSettingwindow.SetBrowserType(gp.browserType);
140
141                 cookieSettingwindow.DoModal();
142
143                 this->gp.browserType = cookieSettingwindow.GetBrowserType();
144
145
146                 
147
148                 return this->gp.browserType;
149
150         }
151
152         VOID Property::ReadProperty(){
153
154                 CreatePropertyFile();
155                 CAtlFile        propertyFile;
156                 CAtlFile        ncvUserSettingFile;
157                 ULONGLONG propertyFileSize;
158                 ULONGLONG ncvUserSettingFileSize;
159                 if(SUCCEEDED(propertyFile.Create(propertyPath,GENERIC_READ,FILE_SHARE_READ,OPEN_ALWAYS)) == FALSE || SUCCEEDED(propertyFile.GetSize(propertyFileSize)) == FALSE){
160
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__));
162
163                 } 
164
165                 std::vector<char> propertyBuf(static_cast<UINT_PTR>(propertyFileSize / sizeof(char) + (1 * sizeof(char))));
166                 
167                 
168                 propertyFile.Read(&propertyBuf[0],propertyBuf.size());
169                 
170                 LPSTR propertyTagStart = strstr(&propertyBuf[0],"<");
171                 if(propertyTagStart != NULL){
172                         ReadPropertyXML reader(*this);
173                         reader.Parse(propertyTagStart);
174                 }
175
176
177                 if(this->gp.ncvUserSettingReadedFlag == FALSE){
178
179                         TCHAR appFolderPath[_MAX_PATH];
180                         SHGetFolderPathW(0,CSIDL_APPDATA,0,SHGFP_TYPE_CURRENT,appFolderPath);
181                         CString ncvUserSettingPath = appFolderPath;
182                         ncvUserSettingPath += TEXT("\\posite-c\\NiconamaCommentViewer\\UserSetting.xml");
183                         if(SUCCEEDED(ncvUserSettingFile.Create(ncvUserSettingPath,GENERIC_READ,FILE_SHARE_READ,OPEN_ALWAYS)) == FALSE || SUCCEEDED(ncvUserSettingFile.GetSize(ncvUserSettingFileSize)) == FALSE){
184
185                                 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__));
186                         }
187                         std::vector<char> ncvUserSettingBuf(static_cast<UINT_PTR>(ncvUserSettingFileSize / sizeof(char) + (1 * sizeof(char))));
188                         ncvUserSettingFile.Read(&ncvUserSettingBuf[0],ncvUserSettingBuf.size());
189                         LPSTR ncvUserSettingStart = strstr(&ncvUserSettingBuf[0],"<");
190                         if(ncvUserSettingStart != NULL){
191                                 ReadUserSettingXML rusx;
192                                 rusx.Parse(ncvUserSettingStart);
193                         }
194                 }
195
196                 return;
197         }
198
199
200         VOID Property::CreatePropertyFile(){
201
202                 CString iniFile;
203                 iniFile = appLocalPath;
204                 iniFile += TEXT("\\qwerty_nico\\nlite.ini");
205                 SurelyCreate(iniFile,TRUE);
206                 
207
208                 TCHAR propertyBuf[_MAX_PATH];
209                 LPCTSTR sectionName = TEXT("property");
210                 LPCTSTR keyName = TEXT("dir");
211                 ::GetPrivateProfileString(sectionName,keyName,TEXT(""),propertyBuf,ARRAY_LENGTH(propertyBuf),iniFile);
212
213                 if((_tcslen(propertyBuf) == 0) || !((PathFileExists(propertyBuf) &&  !::PathIsDirectory( propertyBuf )))){
214                         
215                         propertyFolderPath = appLocalPath;
216                         propertyFolderPath += TEXT("\\qwerty_nico");
217                         
218                         ::WritePrivateProfileString(sectionName,keyName,propertyFolderPath,iniFile);
219                         
220                 } else {
221                         propertyFolderPath = propertyBuf;
222
223                 }
224                 propertySaveFolderPath = propertyFolderPath;
225                 propertySaveFolderPath += TEXT("\\nlite");
226                 propertyPath = propertySaveFolderPath;
227                 propertyPath += TEXT("\\property.xml");
228                 userSettingPath = propertySaveFolderPath;
229                 userSettingPath += TEXT("\\user_setting.xml");
230                 SurelyCreate(propertySaveFolderPath,FALSE);
231                 SurelyCreate(propertyPath,TRUE);
232                 SurelyCreate(userSettingPath,TRUE);
233                 
234                 return;
235         }
236
237
238         VOID Property::WriteProperty(){
239
240                 CreatePropertyFile();
241                 CComPtr<IXmlWriter> pWriter;
242                 CreateXmlWriter(__uuidof(IXmlWriter), reinterpret_cast<void**>(&pWriter), 0);
243
244                 // XML\83t\83@\83C\83\8b\83p\83X\8dì\90¬
245                 TCHAR xml[MAX_PATH];
246                 _tcscpy(xml,this->propertyPath);
247
248
249
250                 // \83t\83@\83C\83\8b\83X\83g\83\8a\81[\83\80\8dì\90¬
251                 CComPtr<IStream> pStream;
252                 SHCreateStreamOnFile(xml, STGM_CREATE | STGM_WRITE, &pStream);
253
254                 pWriter->SetOutput(pStream);
255
256                 // \83C\83\93\83f\83\93\83g\97L\8cø\89»
257                 pWriter->SetProperty(XmlWriterProperty_Indent, TRUE);
258
259                 // <?xml version="1.0" encoding="UTF-8"?>
260                 pWriter->WriteStartDocument(XmlStandalone_Omit);
261
262                 pWriter->WriteStartElement(NULL,TEXT("nliteconfig"),NULL);
263                 //\83R\83\81\83\93\83g\93Ç\82Ý\8fã\82°\90Ý\92è\8f\91\82«\8d\9e\82Ý
264                 NLITE_XMLELLMENT_WRITE(pWriter,crp);
265                 NLITE_ATTRIBUTE_WRITE_STR(pWriter,crp.outString);
266                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.administratorCommentReadFlag);
267                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.besideLengthFlag);
268                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.bspReadFlag);
269                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.commentReadFlag);
270                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.maxCommentLength);
271                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.newLineReadFlag);
272                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.ngUserReadFlag);
273                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.ngWordReadFlag);
274                 NLITE_ATTRIBUTE_WRITE_STR(pWriter,crp.shortComment);
275                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.teropReadFlag);
276                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,crp.userCommentReadFlag);
277                 pWriter->WriteEndElement();
278                 //commentview\90Ý\92è\92l\8f\91\82«\8d\9e\82Ý
279                 NLITE_XMLELLMENT_WRITE(pWriter,cvp);
280                 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerholSize);
281                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.anonymousIDLinkColor);
282                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.backColor);
283                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.baseStringColor);
284                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.commentFoldingFlag);
285                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.commentTimeType);
286                 NLITE_XML_WRITE_FOR_INT(pWriter,cvp.headerOrderArray);
287                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.linkStringColor);
288                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.selectBackColor);
289                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.selectSellLineColor);
290                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.colLineColor);
291                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.normalSellLineColor);
292                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,cvp.ownerStringColor);
293                 
294                 pWriter->WriteEndElement();
295
296
297                 NLITE_XMLELLMENT_WRITE(pWriter,mfp);
298                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,mfp.windowSize.cx);
299                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,mfp.windowSize.cy);
300                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,mfp.windowFrontFlag);
301                 pWriter->WriteEndElement();
302
303
304                 //\8b¤\92Ê\90Ý\92è\8f\91\82«\8d\9e\82Ý
305                 NLITE_XMLELLMENT_WRITE(pWriter,gp);
306                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.activeCountTimeFlag);
307                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.autoColorRegisterFlag);
308                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.autoNameUpdateFlag);
309                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.autoNameRegisterFlag);
310                 NLITE_ATTRIBUTE_WRITE_STR(pWriter,gp.browserPath);
311                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.browserType);
312                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.commentLogAutoSaveFlag);
313                 NLITE_ATTRIBUTE_WRITE_STR(pWriter,gp.commentPath);
314                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.defaultBrowserFlag);
315                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.numberNameFlag);
316                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.userCountUpdateFlag);
317                 NLITE_ATTRIBUTE_WRITE_INT(pWriter,gp.ncvUserSettingReadedFlag);
318                 
319                 pWriter->WriteEndElement();
320                 pWriter->WriteEndDocument();
321
322                 pWriter->Flush();
323
324                 return;
325         }
326
327
328         ///
329         ///\83R\83\93\83X\83g\83\89\83N\83^
330         ///
331         ReadPropertyXML::ReadPropertyXML(Property &in_property):nliteProperty(in_property),propertyType(Node::None){
332
333                 return;
334         }
335
336
337
338         //
339         //\90Ý\92è\83t\83@\83C\83\8b\89ð\90Í\8f\88\97\9d
340         //
341
342 #define NLITE_PSZNAME_CMP(t,p) (_tcscmp(NLITE_GET_TYPENAME(t),(LPCTSTR)(p)) == 0)
343         void ReadPropertyXML::OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs){
344
345                 switch(propertyType){
346
347                 case Node::None:
348
349                         if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName)){
350
351                                 propertyType = Node::CommentReadProperty;
352
353                         } else if(NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)){
354
355                                 propertyType = Node::CommentViewProperty;
356
357                         } else if(NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
358
359                                 propertyType = Node::MainFrameProperty;
360
361                         } else if(NLITE_PSZNAME_CMP(nliteProperty.gp,pszName)){
362
363                                 propertyType = Node::GeneralProperty;
364
365                         }
366
367                         break;
368
369
370                 case Node::CommentReadProperty:
371                 case Node::CommentViewProperty:
372                 case Node::GeneralProperty:
373                 case Node::MainFrameProperty:
374
375                         nodeName = (LPCTSTR)pszName;
376                         break;
377
378                 default:
379
380                         break;
381                 }
382
383                 return;
384         }
385
386
387
388
389         void ReadPropertyXML::OnEndElement (const XML_Char *pszName){
390
391                 if(NLITE_PSZNAME_CMP(nliteProperty.crp,pszName) || 
392                         NLITE_PSZNAME_CMP(nliteProperty.cvp,pszName)||
393                         NLITE_PSZNAME_CMP(nliteProperty.gp,pszName) || 
394                         NLITE_PSZNAME_CMP(nliteProperty.mfp,pszName)){
395
396                                 propertyType = Node::None;
397
398                 }
399                 nodeName = TEXT("");
400
401                 return;
402         }
403
404 #define NLITE_R_X_P_S(p,p2,v) \
405         if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
406         _tcsncpy(p.p2.v,(LPCTSTR)pszData,nLength);\
407         break;\
408         }
409
410 #define NLITE_R_X_P_I(p,p2,v) \
411         if(_tcscmp(TEXT(#v),nodeName.c_str()) == 0){\
412         p.p2.v = 0;\
413         strToIntN(p.p2.v,pszData,nLength);\
414         break;\
415         }
416
417 #define NLITE_RXP_AI(p,p2,v) {\
418         TCHAR name[LENGTH_256];\
419         for(INT_PTR index = 0;index < ARRAY_LENGTH(p.p2.v);index++){\
420         _stprintf(name,TEXT("%s%d"),TEXT(#v),index);\
421         if(_tcscmp(name,nodeName.c_str()) == 0){\
422         p.p2.v[index] = 0;\
423         strToIntN(p.p2.v[index],pszData,nLength);\
424         goto end;\
425         }\
426         }\
427         }
428
429 #define NLITE_NAME(n) (#n)
430
431         void ReadPropertyXML::OnCharacterData (const XML_Char *pszData, int nLength){
432
433                 if (nodeName.empty() == true)return;
434
435                 switch(propertyType){
436
437
438
439                 case Node::CommentReadProperty:
440
441                         NLITE_R_X_P_S(nliteProperty,crp,shortComment);
442                         NLITE_R_X_P_I(nliteProperty,crp,administratorCommentReadFlag);
443                         NLITE_R_X_P_I(nliteProperty,crp,besideLengthFlag);
444                         NLITE_R_X_P_I(nliteProperty,crp,bspReadFlag);
445                         NLITE_R_X_P_I(nliteProperty,crp,commentReadFlag);
446                         NLITE_R_X_P_I(nliteProperty,crp,maxCommentLength);
447                         NLITE_R_X_P_I(nliteProperty,crp,newLineReadFlag);
448                         NLITE_R_X_P_I(nliteProperty,crp,ngUserReadFlag);
449                         NLITE_R_X_P_I(nliteProperty,crp,ngWordReadFlag);
450                         NLITE_R_X_P_S(nliteProperty,crp,outString);
451                         NLITE_R_X_P_S(nliteProperty,crp,shortComment);
452                         NLITE_R_X_P_I(nliteProperty,crp,teropReadFlag);
453                         NLITE_R_X_P_I(nliteProperty,crp,userCommentReadFlag);
454
455                         break;
456                 case Node::CommentViewProperty:
457                         NLITE_R_X_P_I(nliteProperty,cvp,anonymousIDLinkColor);
458                         NLITE_R_X_P_I(nliteProperty,cvp,backColor);
459                         NLITE_R_X_P_I(nliteProperty,cvp,baseStringColor);
460                         NLITE_R_X_P_I(nliteProperty,cvp,commentFoldingFlag);
461                         NLITE_R_X_P_I(nliteProperty,cvp,commentTimeType);
462                         NLITE_R_X_P_I(nliteProperty,cvp,linkStringColor);
463                         NLITE_RXP_AI(nliteProperty,cvp,headerholSize);
464                         NLITE_RXP_AI(nliteProperty,cvp,headerOrderArray);
465                         NLITE_R_X_P_I(nliteProperty,cvp,selectBackColor);
466                         NLITE_R_X_P_I(nliteProperty,cvp,selectSellLineColor);
467                         NLITE_R_X_P_I(nliteProperty,cvp,normalSellLineColor);
468                         NLITE_R_X_P_I(nliteProperty,cvp,colLineColor);
469                         NLITE_R_X_P_I(nliteProperty,cvp,ownerStringColor);
470                         
471                         break;
472                 case Node::GeneralProperty:
473                         NLITE_R_X_P_I(nliteProperty,gp,activeCountTimeFlag);
474                         NLITE_R_X_P_I(nliteProperty,gp,autoColorRegisterFlag);
475                         NLITE_R_X_P_I(nliteProperty,gp,autoNameRegisterFlag);
476                         NLITE_R_X_P_I(nliteProperty,gp,autoNameUpdateFlag);
477                         NLITE_R_X_P_S(nliteProperty,gp,browserPath);
478                         NLITE_R_X_P_I(nliteProperty,gp,browserType);
479                         NLITE_R_X_P_I(nliteProperty,gp,commentLogAutoSaveFlag);
480                         NLITE_R_X_P_S(nliteProperty,gp,commentPath);
481                         NLITE_R_X_P_I(nliteProperty,gp,defaultBrowserFlag);
482                         NLITE_R_X_P_I(nliteProperty,gp,numberNameFlag);
483                         NLITE_R_X_P_I(nliteProperty,gp,userCountUpdateFlag);
484                         NLITE_R_X_P_I(nliteProperty,gp,ncvUserSettingReadedFlag);
485                         break;
486                 case Node::MainFrameProperty:
487                         NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cx);
488                         NLITE_R_X_P_I(nliteProperty,mfp,windowSize.cy);
489                         NLITE_R_X_P_I(nliteProperty,mfp,windowFrontFlag);
490                         break;
491
492
493                 default:
494
495                         break;
496
497
498                 }
499
500 end:
501
502                 return;
503         }
504
505
506
507 #define NLITE_READ_USER_STRING(at,l,t) if(_tcscmp(at[0],TEXT(#t)) == 0)l.t = at[1]
508 #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)
509
510         void ReadUserSettingXML::OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs){
511
512                 if(_tcscmp(pszName,TEXT("user")) == 0){
513
514                         this->userNodeFlag = TRUE;
515
516
517                         for(;papszAttrs[0] != NULL;papszAttrs += 2){
518
519                                 NLITE_READ_USER_STRING(papszAttrs,listenerBuff,name);
520                                 NLITE_READ_USER_STRING(papszAttrs,listenerBuff,community);
521                                 NLITE_READ_USER_INT(papszAttrs,listenerBuff,bgcolor);
522                                 NLITE_READ_USER_INT(papszAttrs,listenerBuff,time);
523                                 
524                         }
525
526                 }
527
528                 return;
529         }
530
531         void ReadUserSettingXML::OnEndElement (const XML_Char *pszName){
532
533                 if(_tcscmp(pszName,TEXT("user")) == 0){
534
535                         listenerList.Register(listenerBuff,TRUE);
536                         this->userNodeFlag = FALSE;
537                         this->listenerBuff.~ListenerData();
538                         new(&listenerBuff) ListenerData();
539
540                 }
541
542                 return;
543         }
544
545         void ReadUserSettingXML::OnCharacterData (const XML_Char *pszData, int nLength){
546
547                 if(this->userNodeFlag == TRUE){
548
549
550                         listenerBuff.user_id.Append(pszData,nLength);
551
552
553
554
555                 }
556
557                 
558
559                 return;
560         }
561
562 }