-
Notifications
You must be signed in to change notification settings - Fork 0
/
No5IrcObj.h
352 lines (290 loc) · 8.49 KB
/
No5IrcObj.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
// No5IrcObj.h: declaração do CNo5IrcObj
#pragma once
#include "stdafx.h"
#include "resource.h" // símbolos principais
#include "..\NO5TL\no5tlbase.h"
#include "irc12.h"
#include "IIRCEvents.h"
#include "_INo5IrcObjEvents_CP.h"
#include "usermsgs.h"
#include "MarqueeOptions.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Objetos COM de única thread não são apropriadamente suportados na plataforma Windows CE, como a plataforma Windows Mobile que não possui suporte DCOM completo. Defina _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA para forçar o ATL a suportar a criação de objetos de única thread e para permitir o uso de suas implementações de objetos COM de única thread. Seu modelo de threading nos arquivos rgs foram definidos com 'Free' uma vez que esse é o único modelo de thread suportado em plataformas Windows CE não DCOM."
#endif
#include "IIrc.h"
//#include "IIRCEvents.h"
using namespace ATL;
// CNo5IrcObj
class ATL_NO_VTABLE CNo5IrcObj :
public CComObjectRootEx<CComSingleThreadModel>,
public CProxy_INo5IrcObjEvents<CNo5IrcObj>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CNo5IrcObj>,
public IProvideClassInfo2Impl<&CLSID_No5IrcObj, &DIID__INo5IrcObjEvents>,
public IDispatchImpl<INo5IrcObj, &IID_INo5IrcObj>,
public IDispatchImpl<_INo5IrcObjEvents, &__uuidof(_INo5IrcObjEvents)>
{
IIrc* m_pirc;
IIRCEvents* m_pircevts;
CString m_nick;
int m_iMarquee;
public:
CNo5IrcObj()
{
m_iMarquee = 0;
m_pirc = NULL;
m_pircevts = NULL;
}
void Init(IIrc* pIrc, IIRCEvents* pEvents, LPCTSTR nick) {
ITypeLib* ptl = NULL;
m_pirc = pIrc;
m_pircevts = pEvents;
m_nick = nick;
HRESULT hr = LoadTypeLib(OLESTR("irc12.tlb"), &ptl);
if (SUCCEEDED(hr)) {
ptl->Release();
//hr = UpdateRegistry(FALSE);
}
ATLASSERT(SUCCEEDED(hr));
if (FAILED(hr)) {
MessageBox(GetDesktopWindow(), GetErrorDesc(hr), _T("NO5 IRC"), MB_ICONERROR);
}
}
//DECLARE_REGISTRY_RESOURCEID(IDR_NO5IRCOBJ)
DECLARE_REGISTRY_RESOURCEID(IDR_REGISTRY1)
DECLARE_NOT_AGGREGATABLE(CNo5IrcObj)
BEGIN_COM_MAP(CNo5IrcObj)
COM_INTERFACE_ENTRY(INo5IrcObj)
COM_INTERFACE_ENTRY2(IDispatch, INo5IrcObj)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
//COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(_INo5IrcObjEvents)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CNo5IrcObj)
CONNECTION_POINT_ENTRY(__uuidof(_INo5IrcObjEvents))
END_CONNECTION_POINT_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD(SendActiveChannelMsg)(BSTR msg);
STDMETHOD(SendChannelMsg)(BSTR channel, BSTR msg);
STDMETHOD(SendPrivateMsg)(BSTR to, BSTR msg);
STDMETHOD(SendNoticeMsg)(BSTR to, BSTR msg);
STDMETHOD(JoinChannel)(BSTR channel);
STDMETHOD(LeaveChannel)(BSTR channel, BSTR msg);
STDMETHOD(Quit)(BSTR msg);
STDMETHOD(SendPass)(BSTR pw);
STDMETHOD(SendNick)(BSTR nick);
STDMETHOD(SendUser)(BSTR user, BSTR name);
STDMETHOD(ListChannels)();
STDMETHOD(ListChannelNames)(BSTR channel);
STDMETHOD(GetTopic)(BSTR channel);
STDMETHOD(GetMode)(BSTR NameOrChannel);
STDMETHOD(WhoIs)(BSTR nick);
STDMETHOD(Who)(BSTR nick);
STDMETHOD(WhoWas)(BSTR nick);
STDMETHOD(Output)(BSTR msg);
STDMETHOD(SetTimer)(LONG id, LONG ms, LONG* pRes);
STDMETHOD(get_Marquee)(IDispatch** pRes);
STDMETHOD(DestroyMarquee)(IDispatch* pRes);
STDMETHOD(get_ActiveViewName)(BSTR* pRes);
STDMETHOD(get_Views)(IDispatch** ppDisp);
};
//OBJECT_ENTRY_NON_CREATEABLE_EX_AUTO(CLSID_No5IrcObj, CNo5IrcObj);
//OBJECT_ENTRY_AUTO(CLSID_No5IrcObj, CNo5IrcObj);
//(CLSID_No5IrcObj, CNo5IrcObj);
class ATL_NO_VTABLE CUser :
public CComObjectRootEx<CComSingleThreadModel>,
public ISupportErrorInfo,
public IDispatchImpl<IUser, &IID_IUser>
{
CComBSTR m_name;
public:
CUser()
{
}
virtual ~CUser()
{
}
void Init(LPCTSTR name) {
m_name = name;
}
DECLARE_NOT_AGGREGATABLE(CUser)
BEGIN_COM_MAP(CUser)
//COM_INTERFACE_ENTRY(IUnknown)
COM_INTERFACE_ENTRY(IUser)
COM_INTERFACE_ENTRY2(IDispatch, IUser)
//COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD(get_Name)(BSTR* pRes);
};
class CUsers : \
public CComObjectRootEx<CComSingleThreadModel>,
public ISupportErrorInfo,
public IDispatchImpl<IUsers, &IID_IUsers>
{
CSimpleArray<CComBSTR> m_users;
public:
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
DECLARE_NOT_AGGREGATABLE(CUsers)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CUsers)
//COM_INTERFACE_ENTRY(IUnknown)
COM_INTERFACE_ENTRY(IUsers)
COM_INTERFACE_ENTRY2(IDispatch, IUsers)
//COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
void CUsers::Init(const CSimpleArray<CComBSTR>& users)
{
CopySimpleArray(m_users, users);
}
STDMETHOD(get_Count)(long* pVal);
STDMETHOD(get_Item)(long n, IDispatch** pVal);
STDMETHOD(get__NewEnum)(IUnknown** pVal);
};
class ATL_NO_VTABLE CChannel :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IView, &IID_IView /*wMajor = 1, /*wMinor = 0*/>,
public IProvideClassInfo2Impl<&CLSID_Channel, &IID_IView>
{
public:
CChannel()
{
}
//DECLARE_REGISTRY_RESOURCEID(IDR_NO5IRCOBJ)
DECLARE_NOT_AGGREGATABLE(CChannel)
BEGIN_COM_MAP(CChannel)
COM_INTERFACE_ENTRY(IView)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
CComBSTR m_name;
void Init(LPCOLESTR name)
{
m_name = name;
}
STDMETHOD(get_Name)(BSTR* pName)
{
HRESULT hr = m_name.CopyTo(pName);
return hr;
}
STDMETHOD(get_Users)(IDispatch** ppDisp);
};
typedef CComEnum<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _Copy<VARIANT>,
CComSingleThreadModel> EnumVar;
class ATL_NO_VTABLE CViews :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IViews, &IID_IViews>,
//public IDispatchImpl< EnumVar,&IID_IEnumVARIANT>,
public IProvideClassInfo2Impl<&CLSID_Views, &IID_IViews>
{
public:
CViews()
{
}
//DECLARE_REGISTRY_RESOURCEID(IDR_REGISTRY1)
DECLARE_NOT_AGGREGATABLE(CViews)
BEGIN_COM_MAP(CViews)
COM_INTERFACE_ENTRY(IViews)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IProvideClassInfo)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
CSimpleArray<CComPtr<IView>> m_aViews;
void Init(CSimpleArray<CComPtr<IView>> aViews)
{
for (int i = 0; i < aViews.GetSize(); i++) {
m_aViews.Add(aViews[i]);
}
}
STDMETHOD(get_Count)(long* pCount);
STDMETHOD(get_Item)(long index, IDispatch** ppDisp);
STDMETHOD(get__NewEnum)(IUnknown** ppUnk);
};
class ATL_NO_VTABLE CMarquee :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IMyMarquee,&IID_IMyMarquee>,
//public IDispatchImpl< EnumVar,&IID_IEnumVARIANT>,
public IProvideClassInfo2Impl<&CLSID_Marquee, &IID_IMyMarquee>
{
public:
CMarquee()
{
}
//DECLARE_REGISTRY_RESOURCEID(IDR_NO5IRCOBJ)
DECLARE_NOT_AGGREGATABLE(CMarquee)
BEGIN_COM_MAP(CMarquee)
COM_INTERFACE_ENTRY(IMyMarquee)
COM_INTERFACE_ENTRY2(IDispatch, IMyMarquee)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IProvideClassInfo)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
MarqueeOptions m_mo;
public:
void Init(MarqueeOptions& mo);
STDMETHOD(AddItem)(BSTR bstr,OLE_COLOR clr);
STDMETHOD(SetFontColor)(OLE_COLOR color);
STDMETHOD(SetBkColor)(OLE_COLOR color);
STDMETHOD(Destroy)();
STDMETHOD(Start)();
STDMETHOD(Stop)();
};