OSDN Git Service

リスナー設定ウィンドウ作成
[nlite/nlite.git] / nlite / nlite_chatData.h
1 #pragma once
2
3 namespace nlite{
4
5         //\91O\95û\90é\8c¾
6         class CCommentListWindow;
7
8         //\8d\91\83R\81[\83h
9         namespace cuntry{
10
11                 enum LOCALE{
12                         unknown,
13                         jp
14
15                 };
16
17         }
18
19         ///
20         ///\83\8a\83X\83i\81[\83f\81[\83^
21         ///
22         struct ListenerData{
23         private:
24
25         public:
26                 CNLiteString user_id;                                   //\83\86\81[\83U\81[ID
27                 CNLiteString name;                                              //\83\86\81[\83U\81[\96¼
28                 CNLiteString community;                                 //\93o\98^\82µ\82½\83R\83~\83\85\83j\83e\83B
29                 COLORREF bgcolor;                                               //\94w\8ci\90F
30                 time_t time;                                                    //\93o\98^\8e\9e\8aÔ
31                 BOOL writePropertyFlag;                                 //\83v\83\8d\83p\83e\83B\8f\91\82«\8d\9e\82Ý\83t\83\89\83O
32                 BOOL onlyCommunityFlag;
33         public:
34
35                 enum {
36                         INIT_COLOR = -1
37
38                 };
39                 
40                 ///
41                 ///\83R\83\93\83X\83g\83\89\83N\83^
42                 ///
43                 ListenerData();
44
45                 ///
46                 ///\94w\8ci\90F\90Ý\92è
47                 ///
48                 VOID SetBkColor(COLORREF bkColor_in);
49                 
50                 ///
51                 ///\83\86\81[\83U\96¼\90Ý\92è
52                 ///
53                 VOID SetUserName(LPCTSTR name);
54         };
55
56         //
57         //\83\8a\83X\83i\81[\83f\81[\83^\82©\82ç\94w\8ci\83J\83\89\81[\8eû\8fW\83t\83@\83\93\83N\83V\83\87\83i\83\8b
58         //
59         class CListenerColorCollector{
60
61         private:
62                 std::deque<COLORREF> colorlist;                                                                         //\90F\83\8a\83X\83g
63
64         public:
65
66                 typedef std::deque<COLORREF>::iterator iterator;
67
68                 //\8ew\92è\82µ\82½\90F\82ª\93o\98^\82³\82ê\82Ä\82¢\82é\82©\92²\82×\82é
69                 BOOL Find(COLORREF target){
70
71                         iterator end = colorlist.end();
72
73                         return std::find(colorlist.begin(),end,target) != end ? TRUE : FALSE;
74                 }
75
76                 //\83t\83@\83\93\83N\83V\83\87\83i\83\8b
77                 void operator()(ListenerData &target){
78
79                         if(target.bgcolor != ListenerData::INIT_COLOR){
80
81                                 colorlist.push_back(target.bgcolor);
82                         }
83
84                 }
85
86         };
87         
88         
89         ///
90         ///\83\8a\83X\83i\81[\83\8a\83X\83g
91         ///
92         class CListenerList{
93
94         private:
95                 typedef ListenerData InternalType;
96                 typedef std::list<InternalType> ListenerList_Internal; 
97                 ListenerList_Internal m_listenerList;
98
99         public:
100
101                 typedef InternalType& reference;
102                 typedef ListenerList_Internal::value_type value_type;
103                 typedef ListenerList_Internal::iterator iterator;
104
105                 
106
107                 ///
108                 ///\83\86\81[\83U\81[\93o\98^
109                 ///
110                 reference Register(ListenerData &listener,BOOL bUpdate);
111
112
113                 ///
114                 ///\83\8a\83X\83i\81[\83f\81[\83^\93Ç\82Ý\8d\9e\82Ý
115                 ///
116                 BOOL ReadProperty(LPCTSTR fileName);
117
118                 ///
119                 ///\83\8a\83X\83i\81[\83f\81[\83^\8f\91\82«\8d\9e\82Ý
120                 ///
121                 BOOL WriteProperty(LPCTSTR fileName);
122
123                 
124                 ///
125                 ///\94w\8ci\90F\82ð\8eû\8fW\82·\82é
126                 ///
127                 VOID BkColorCollect(CListenerColorCollector &target);
128
129         };
130
131         
132
133         class CChatData{
134
135                 
136         public:
137                 struct ViewData{
138
139                         //\90F\83R\81[\83h\8f\89\8aú\92l
140                         enum{
141                                 INIT_COLOR = -1
142                         };
143
144                         BOOL selectFlag;                                        //\91I\91ð\8fó\91Ô
145                         COLORREF stringColor;                           //\93Æ\8e©\95\8e\9a\90F
146                         COLORREF backColor;                                     //\93Æ\8e©\94w\8ci\90F
147                         COLORREF sellLineColor;                         //\98g\90ü\90F
148                         UINT_PTR height;
149
150                         ViewData();
151                 };
152
153                 ViewData viewData;                                      //\95\\8e¦\97p\83f\81[\83^
154                 UINT_PTR premium;                                       //\83v\83\8c\83~\83A\83\80\8eí\95Ê
155                 BOOL anonymity;                                         //\93½\96¼\83t\83\89\83O
156                 UINT_PTR no;                                            //\83R\83\81\94Ô
157                 UINT_PTR vpos;                                          //\83R\83\81\83\93\83g\95\\8e¦\88Ê\92u
158                 time_t date;                                            //\8e\9e\8aÔ
159                 cuntry::LOCALE locale;                          //\8d\91\83R\81[\83h
160                 ListenerData *listenerData;                     //\83\86\81[\83U\8fî\95ñ
161                 CNLiteString name;                                      //\96¼\91O\81B\82Â\82¢\82Ä\82±\82È\82¢\8e\9e\82à\82 \82é
162                 CNLiteString chatBuf;                           //\83`\83\83\83b\83g\96{\95
163                 std::vector<CNLiteString> mail;         //\83\81\81[\83\8b\83R\83}\83\93\83h
164                 ULONG_PTR thread;                                       //\83X\83\8c\83b\83h\94Ô\8d\86
165                 
166         public:
167
168
169                 ///
170                 ///nlib\82Ì\83`\83\83\83b\83g\83f\81[\83^\82ð\83Z\83b\83g
171                 ///
172                 VOID SetChat(NicoLiveChat &chat_in,ListenerData &listener);
173
174         };
175
176
177
178
179         ///
180         ///\83R\83\81\83\93\83g\83\8a\83X\83g\83N\83\89\83X
181         ///
182         class CCommentList{
183
184         private:
185                 typedef std::list<CChatData> ChatList;
186         public:
187                 typedef ChatList::iterator iterator;
188                 typedef ChatList::reference reference;
189                 typedef ChatList::reverse_iterator reverse_iterator;
190         private:
191                 ChatList chatList;
192                 iterator shortcut;
193         
194
195         
196                 //\83G\83\89\81[\83R\81[\83h
197         public:
198                 enum ERRORCORD{
199                         ERR = -1,
200                         OK = 0
201
202
203                 };
204
205
206                 //\8c^\92è\8b`
207         
208
209         public:
210
211                 ///
212                 ///\83R\83\93\83X\83g\83\89\83N\83^
213                 ///
214                 CCommentList();
215                 
216                 ///
217                 ///\83f\83X\83g\83\89\83N\83^
218                 ///
219                 ~CCommentList();
220                 
221                 ///
222                 ///\90\95ú\91\97\90Ú\91±\8e\9e\82Ì\8f\88\97\9d
223                 ///
224                 VOID OnConnect();
225                 
226
227                 ///
228                 ///\94j\8aü\8e\9e\82Ì\8f\88\97\9d
229                 ///
230                 VOID OnDestroy();
231                 
232                 ///
233                 ///\8ai\94[\82³\82ê\82½\83R\83\81\83\93\83g\90\94\8eæ\93¾
234                 ///
235                 UINT_PTR Size();
236                 
237
238                 ///
239                 ///\91I\91ð\8d\80\96Ú\82ð\8eæ\93¾
240                 ///
241                 iterator GetCurSel();
242
243
244                 INT_PTR GetCurSelNo();
245
246                 ///
247                 ///\91I\91ð\8d\80\96Ú\82ð\90Ý\92è
248                 ///
249                 VOID SetCurSel(iterator cursel);
250
251                 ///
252                 ///\91I\91ð\8fó\91Ô\82Ì\83A\83C\83e\83\80\82ð\8eæ\93¾
253                 ///
254                 iterator GetCurSelItem();
255
256                 ///
257                 ///\8bó\82©\94»\92è
258                 ///
259                 BOOL empty();
260
261                 ///
262                 ///\8dÅ\8f\89\82Ì\83C\83e\83\8c\81[\83^\82ð\8eæ\93¾
263                 ///
264                 iterator begin();
265
266                 ///
267                 ///\8dÅ\8cã\82Ì\83C\83e\83\8c\81[\83^\82ð\8eæ\93¾
268                 ///
269                 iterator end();
270
271                 ///
272                 ///\8bt\8cü\82«\83C\83e\83\8c\81[\83^\82Ì\8dÅ\8f\89\82ð\8eæ\93¾
273                 ///
274                 reverse_iterator rbegein();
275
276                 ///
277                 ///\8bt\8cü\82«\83C\83e\83\8c\81[\83^\82Ì\8dÅ\8cã\82ð\8eæ\93¾
278                 ///
279                 reverse_iterator rend();
280
281                 ///
282                 ///\83`\83\83\83b\83g\8eó\90M\8e\9e\82Ì\8f\88\97\9d
283                 ///\83`\83\83\83b\83g\83f\81[\83^\82Ì\91}\93ü\82ð\8ds\82¤
284                 ///\83\8a\83X\83g\82ª\8bó\82©\81A\8eó\90M\82µ\82½\83`\83\83\83b\83g\83f\81[\83^\82Ìdate\82Ì\92l\82ª\83\8a\83X\83g\8dÅ\8cã\94ö\88È\8fã\82Ì\82à\82Ì\82¾\82Á\82½\8fê\8d\87\8dÅ\8cã\94ö\82É\91}\93ü\82³\82ê\82é
285                 ///\82»\82¤\82Å\82È\82©\82Á\82½\8fê\8d\87\82Í\83\8a\83X\83g\82Ì\8dÅ\8f\89\82©\82ç\88ø\90\94\82É\93n\82³\82ê\82½\83`\83\83\83b\83g\83f\81[\83^\82Ìdate\82æ\82è\91å\82«\82¢date\82ð\8e\9d\82Â\83f\81[\83^\82ð\92T\82µ\81A\82»\82Ì\83f\81[\83^\82Ì\92¼\91O\82É\91}\93ü\82·\82é
286                 ///
287                 iterator OnChatReceve(NicoLiveChat_P chatData,LPCTSTR communityID, UINT_PTR count,CCommentListWindow &listWindow);
288
289                 ///
290                 ///\8ew\92è\82µ\82½\94Ô\8d\86\82Ì\83R\83\81\83\93\83g\8eQ\8fÆ\82ð\8eæ\93¾
291                 ///
292                 reference GetChatAt(UINT_PTR no);
293                 
294
295                 ///
296                 ///\83\8a\83X\83g\8dÅ\8cã\82Ì\8eQ\8fÆ\82ð\8eæ\93¾
297                 ///
298                 reference back();
299
300                 ///
301                 ///\83V\83\87\81[\83g\83J\83b\83g\83C\83e\83\8c\81[\83^\82ð\8eæ\93¾
302                 ///
303                 iterator GetShortCut();
304                 
305                 ///
306                 ///\83V\83\87\81[\83g\83J\83b\83g\82ð\90Ý\92è
307                 ///
308                 BOOL SetShortCut(UINT_PTR no);
309
310                 
311                 
312         };
313
314
315         ///
316         ///\83\86\81[\83U\90Ý\92è\83t\83@\83C\83\8b\93Ç\8eæ\83N\83\89\83X
317         ///
318         class ReadUserSettingXML:public CXmlParser{
319
320         private:
321                 ListenerData listenerBuff;
322                 CListenerList &m_listenerList;
323                 BOOL userNodeFlag;
324                 
325                 
326                 
327
328
329         public:
330
331                 ReadUserSettingXML(CListenerList &in_listenerList);
332
333                 void OnStartElement (const XML_Char *pszName, const XML_Char **papszAttrs);
334
335                 void OnEndElement (const XML_Char *pszName);
336
337                 void OnCharacterData (const XML_Char *pszData, int nLength);
338         };
339         
340 }