forked from irwir/eMule
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatSelector.cpp
678 lines (593 loc) · 17.9 KB
/
ChatSelector.cpp
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
//this file is part of eMule
//Copyright (C)2002-2008 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / http://www.emule-project.net )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "stdafx.h"
#include "emule.h"
#include "ChatSelector.h"
#include "packets.h"
#include "HTRichEditCtrl.h"
#include "emuledlg.h"
#include "Statistics.h"
#include "OtherFunctions.h"
#include "UpDownClient.h"
#include "Preferences.h"
#include "TaskbarNotifier.h"
#include "ListenSocket.h"
#include "ChatWnd.h"
#include "SafeFile.h"
#include "Log.h"
#include "MenuCmds.h"
#include "ClientDetailDialog.h"
#include "FriendList.h"
#include "ClientList.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define STATUS_MSG_COLOR RGB(0,128,0) // dark green
#define SENT_TARGET_MSG_COLOR RGB(0,192,0) // bright green
#define RECV_SOURCE_MSG_COLOR RGB(0,128,255) // bright cyan/blue
#define TIME_STAMP_FORMAT _T("[%H:%M] ")
///////////////////////////////////////////////////////////////////////////////
// CChatItem
CChatItem::CChatItem()
{
client = NULL;
log = NULL;
notify = false;
history_pos = 0;
}
CChatItem::~CChatItem()
{
delete log;
}
///////////////////////////////////////////////////////////////////////////////
// CChatSelector
IMPLEMENT_DYNAMIC(CChatSelector, CClosableTabCtrl)
BEGIN_MESSAGE_MAP(CChatSelector, CClosableTabCtrl)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_TIMER()
ON_WM_SYSCOLORCHANGE()
ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnTcnSelChangeChatSel)
ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()
CChatSelector::CChatSelector()
{
m_lastemptyicon = false;
m_blinkstate = false;
m_Timer = 0;
m_bCloseable = true;
}
CChatSelector::~CChatSelector()
{
}
void CChatSelector::Init(CChatWnd *pParent)
{
m_pParent = pParent;
ModifyStyle(0, WS_CLIPCHILDREN);
SetAllIcons();
VERIFY( (m_Timer = SetTimer(20, 1500, 0)) != NULL );
}
void CChatSelector::OnSysColorChange()
{
CClosableTabCtrl::OnSysColorChange();
SetAllIcons();
}
void CChatSelector::SetAllIcons()
{
CImageList iml;
iml.Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1);
iml.Add(CTempIconLoader(_T("Chat")));
iml.Add(CTempIconLoader(_T("Message")));
iml.Add(CTempIconLoader(_T("MessagePending")));
SetImageList(&iml);
m_imlChat.DeleteImageList();
m_imlChat.Attach(iml.Detach());
SetPadding(CSize(12, 3));
}
void CChatSelector::UpdateFonts(CFont* pFont)
{
TCITEM item;
item.mask = TCIF_PARAM;
int i = 0;
while (GetItem(i++, &item)){
CChatItem* ci = (CChatItem*)item.lParam;
ci->log->SetFont(pFont);
}
}
CChatItem* CChatSelector::StartSession(CUpDownClient* client, bool show)
{
if (show)
m_pParent->m_wndMessage.SetFocus();
if (GetTabByClient(client) != -1){
if (show){
SetCurSel(GetTabByClient(client));
ShowChat();
}
return NULL;
}
CChatItem* chatitem = new CChatItem();
chatitem->client = client;
chatitem->log = new CHTRichEditCtrl;
CRect rcChat;
GetChatSize(rcChat);
if (GetItemCount() == 0)
rcChat.top += 19; // add the height of the tab which is not yet there
// using ES_NOHIDESEL is actually not needed, but it helps to get around a tricky window update problem!
// If that style is not specified there are troubles with right clicking into the control for the very first time!?
chatitem->log->Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_NOHIDESEL, rcChat, this, (UINT)-1);
chatitem->log->ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED);
chatitem->log->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
chatitem->log->SetEventMask(chatitem->log->GetEventMask() | ENM_LINK);
chatitem->log->SetFont(&theApp.m_fontHyperText);
chatitem->log->SetProfileSkinKey(_T("Chat"));
chatitem->log->ApplySkin();
chatitem->log->EnableSmileys(thePrefs.GetMessageEnableSmileys());
PARAFORMAT pf = {0};
pf.cbSize = sizeof pf;
pf.dwMask = PFM_OFFSET;
pf.dxOffset = 150;
chatitem->log->SetParaFormat(pf);
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(chatitem);
chatitem->log->AppendKeyWord(GetResString(IDS_CHAT_START) + client->GetUserName() + _T("\n"), STATUS_MSG_COLOR);
client->SetChatState(MS_CHATTING);
CString name;
if (client->GetUserName() != NULL)
name = client->GetUserName();
else
name.Format(_T("(%s)"), GetResString(IDS_UNKNOWN));
chatitem->log->SetTitle(name);
TCITEM newitem;
newitem.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE;
newitem.lParam = (LPARAM)chatitem;
name.Replace(_T("&"), _T("&&"));
newitem.pszText = const_cast<LPTSTR>((LPCTSTR)name);
newitem.iImage = 0;
int iItemNr = InsertItem(GetItemCount(), &newitem);
if (show || IsWindowVisible()){
SetCurSel(iItemNr);
ShowChat();
}
return chatitem;
}
int CChatSelector::GetTabByClient(CUpDownClient* client)
{
for (int i = 0; i < GetItemCount(); i++){
TCITEM cur_item;
cur_item.mask = TCIF_PARAM;
if (GetItem(i, &cur_item) && ((CChatItem*)cur_item.lParam)->client == client)
return i;
}
return -1;
}
CChatItem* CChatSelector::GetItemByIndex(int index)
{
TCITEM item;
item.mask = TCIF_PARAM;
if (GetItem(index, &item)==FALSE)
return NULL;
return (CChatItem*)item.lParam;
}
CChatItem* CChatSelector::GetItemByClient(CUpDownClient* client)
{
for (int i = 0; i < GetItemCount(); i++){
TCITEM cur_item;
cur_item.mask = TCIF_PARAM;
if (GetItem(i, &cur_item) && ((CChatItem*)cur_item.lParam)->client == client)
return (CChatItem*)cur_item.lParam;
}
return NULL;
}
void CChatSelector::ProcessMessage(CUpDownClient* sender, const CString& message)
{
sender->IncMessagesReceived();
CChatItem* ci = GetItemByClient(sender);
AddLogLine(true, GetResString(IDS_NEWMSG), sender->GetUserName(), ipstr(sender->GetConnectIP()));
bool isNewChatWindow = false;
if (!ci)
{
if ((UINT)GetItemCount() >= thePrefs.GetMsgSessionsMax())
return;
ci = StartSession(sender, false);
isNewChatWindow = true;
}
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(ci);
ci->log->AppendKeyWord(sender->GetUserName(), RECV_SOURCE_MSG_COLOR);
ci->log->AppendText(_T(": "));
ci->log->AppendText(message + _T("\n"));
int iTabItem = GetTabByClient(sender);
if (GetCurSel() == iTabItem && GetParent()->IsWindowVisible())
{
// chat window is already visible
;
}
else if (GetCurSel() != iTabItem)
{
// chat window is already visible, but tab is not selected
ci->notify = true;
}
else
{
ci->notify = true;
if (isNewChatWindow || thePrefs.GetNotifierOnEveryChatMsg())
theApp.emuledlg->ShowNotifier(GetResString(IDS_TBN_NEWCHATMSG) + _T(" ") + CString(sender->GetUserName()) + _T(":'") + message + _T("'\n"), TBN_CHAT);
isNewChatWindow = false;
}
}
void CChatSelector::ShowCaptchaRequest(CUpDownClient* sender, HBITMAP bmpCaptcha)
{
CChatItem* ci = GetItemByClient(sender);
if (ci != NULL)
{
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(ci);
ci->log->AppendKeyWord(_T("*** ") + GetResString(IDS_CAPTCHAREQUEST), STATUS_MSG_COLOR);
ci->log->AddCaptcha(bmpCaptcha);
ci->log->AddLine(_T("\n"));
}
}
void CChatSelector::ShowCaptchaResult(CUpDownClient* sender, CString strResult)
{
CChatItem* ci = GetItemByClient(sender);
if (ci != NULL)
{
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(ci);
ci->log->AppendKeyWord(_T("*** ") + strResult + _T("\n"), STATUS_MSG_COLOR);
}
}
bool CChatSelector::SendMessage(const CString& rstrMessage)
{
CChatItem* ci = GetCurrentChatItem();
if (!ci)
return false;
if ((UINT)ci->history.GetCount() == thePrefs.GetMaxChatHistoryLines())
ci->history.RemoveAt(0);
ci->history.Add(rstrMessage);
ci->history_pos = ci->history.GetCount();
// advance spamfilter stuff
ci->client->IncMessagesSent();
ci->client->SetSpammer(false);
if (ci->client->GetChatState() == MS_CONNECTING)
return false;
if (ci->client->GetChatCaptchaState() == CA_CAPTCHARECV)
ci->client->SetChatCaptchaState(CA_SOLUTIONSENT);
else if (ci->client->GetChatCaptchaState() == CA_SOLUTIONSENT)
ASSERT( false ); // we responsed to a captcha but didn't heard from the client afterwards - hopefully its just lag and this message will get through
else
ci->client->SetChatCaptchaState(CA_ACCEPTING);
// there are three cases on connectiing/sending the message:
if (ci->client->socket && ci->client->socket->IsConnected())
{
// 1.) the client is connected already - this is simple, jsut send it
ci->client->SendChatMessage(rstrMessage);
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(ci);
ci->log->AppendKeyWord(thePrefs.GetUserNick(), SENT_TARGET_MSG_COLOR);
ci->log->AppendText(_T(": "));
ci->log->AppendText(rstrMessage + _T("\n"));
}
else if (ci->client->GetFriend() != NULL)
{
// We are not connected and this client is a friend - friends have additional ways to connect and additional checks
// to make sure they are really friends, let the friend class is handling it
ci->strMessagePending = rstrMessage;
ci->client->SetChatState(MS_CONNECTING);
ci->client->GetFriend()->TryToConnect(this);
}
else
{
// this is a normal client, who is not connected right now. just try to connect to the given IP, without any
// additional checks or searchings.
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(ci);
ci->log->AppendKeyWord(_T("*** ") + GetResString(IDS_CONNECTING), STATUS_MSG_COLOR);
ci->strMessagePending = rstrMessage;
ci->client->SetChatState(MS_CONNECTING);
ci->client->TryToConnect(true);
}
return true;
}
void CChatSelector::ConnectingResult(CUpDownClient* sender, bool success)
{
CChatItem* ci = GetItemByClient(sender);
if (!ci)
return;
ci->client->SetChatState(MS_CHATTING);
if (!success){
if (!ci->strMessagePending.IsEmpty()){
ci->log->AppendKeyWord(_T(" ...") + GetResString(IDS_FAILED) + _T("\n"), STATUS_MSG_COLOR);
ci->strMessagePending.Empty();
}
else{
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(ci);
ci->log->AppendKeyWord(GetResString(IDS_CHATDISCONNECTED) + _T("\n"), STATUS_MSG_COLOR);
}
}
else if (!ci->strMessagePending.IsEmpty()){
ci->log->AppendKeyWord(_T(" ...") + GetResString(IDS_TREEOPTIONS_OK) + _T("\n"), STATUS_MSG_COLOR);
ci->client->SendChatMessage(ci->strMessagePending);
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(ci);
ci->log->AppendKeyWord(thePrefs.GetUserNick(), SENT_TARGET_MSG_COLOR);
ci->log->AppendText(_T(": "));
ci->log->AppendText(ci->strMessagePending + _T("\n"));
ci->strMessagePending.Empty();
}
else{
if (thePrefs.GetIRCAddTimeStamp())
AddTimeStamp(ci);
ci->log->AppendKeyWord(_T("*** Connected\n"), STATUS_MSG_COLOR);
}
}
void CChatSelector::DeleteAllItems()
{
for (int i = 0; i < GetItemCount(); i++){
TCITEM cur_item;
cur_item.mask = TCIF_PARAM;
if (GetItem(i, &cur_item))
delete (CChatItem*)cur_item.lParam;
}
}
void CChatSelector::OnTimer(UINT_PTR /*nIDEvent*/)
{
m_blinkstate = !m_blinkstate;
bool globalnotify = false;
for (int i = 0; i < GetItemCount();i++)
{
TCITEM cur_item;
cur_item.mask = TCIF_PARAM | TCIF_IMAGE;
if (!GetItem(i, &cur_item))
break;
cur_item.mask = TCIF_IMAGE;
if (((CChatItem*)cur_item.lParam)->notify){
cur_item.iImage = (m_blinkstate) ? 1 : 2;
SetItem(i, &cur_item);
HighlightItem(i, TRUE);
globalnotify = true;
}
else if (cur_item.iImage != 0){
cur_item.iImage = 0;
SetItem(i, &cur_item);
HighlightItem(i, FALSE);
}
}
if (globalnotify) {
theApp.emuledlg->ShowMessageState(m_blinkstate ? 1 : 2);
m_lastemptyicon = false;
}
else if (!m_lastemptyicon) {
theApp.emuledlg->ShowMessageState(0);
m_lastemptyicon = true;
}
}
CChatItem* CChatSelector::GetCurrentChatItem()
{
int iCurSel = GetCurSel();
if (iCurSel == -1)
return NULL;
TCITEM cur_item;
cur_item.mask = TCIF_PARAM;
if (!GetItem(iCurSel, &cur_item))
return NULL;
return (CChatItem*)cur_item.lParam;
}
void CChatSelector::ShowChat()
{
CChatItem* ci = GetCurrentChatItem();
if (!ci)
return;
// show current chat window
ci->log->ShowWindow(SW_SHOW);
m_pParent->m_wndMessage.SetFocus();
TCITEM item;
item.mask = TCIF_IMAGE;
item.iImage = 0;
SetItem(GetCurSel(), &item);
HighlightItem(GetCurSel(), FALSE);
// hide all other chat windows
item.mask = TCIF_PARAM;
int i = 0;
while (GetItem(i++, &item)){
CChatItem* ci2 = (CChatItem*)item.lParam;
if (ci2 != ci)
ci2->log->ShowWindow(SW_HIDE);
}
ci->notify = false;
}
void CChatSelector::OnTcnSelChangeChatSel(NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
ShowChat();
*pResult = 0;
}
int CChatSelector::InsertItem(int nItem, TCITEM* pTabCtrlItem)
{
int iResult = CClosableTabCtrl::InsertItem(nItem, pTabCtrlItem);
RedrawWindow();
return iResult;
}
BOOL CChatSelector::DeleteItem(int nItem)
{
CClosableTabCtrl::DeleteItem(nItem);
RedrawWindow();
return TRUE;
}
void CChatSelector::EndSession(CUpDownClient* client)
{
int iCurSel;
if (client)
iCurSel = GetTabByClient(client);
else
iCurSel = GetCurSel();
if (iCurSel == -1)
return;
TCITEM item;
item.mask = TCIF_PARAM;
if (!GetItem(iCurSel, &item) || item.lParam == 0)
return;
CChatItem* ci = (CChatItem*)item.lParam;
ci->client->SetChatState(MS_NONE);
ci->client->SetChatCaptchaState(CA_NONE);
DeleteItem(iCurSel);
delete ci;
int iTabItems = GetItemCount();
if (iTabItems > 0){
// select next tab
if (iCurSel == CB_ERR)
iCurSel = 0;
else if (iCurSel >= iTabItems)
iCurSel = iTabItems - 1;
(void)SetCurSel(iCurSel); // returns CB_ERR if error or no prev. selection(!)
iCurSel = GetCurSel(); // get the real current selection
if (iCurSel == CB_ERR) // if still error
iCurSel = SetCurSel(0);
ShowChat();
}
}
void CChatSelector::GetChatSize(CRect& rcChat)
{
CRect rcClient;
GetClientRect(&rcClient);
AdjustRect(FALSE, rcClient);
rcChat.left = rcClient.left + 4;
rcChat.top = rcClient.top + 4;
rcChat.right = rcClient.right - 4;
rcChat.bottom = rcClient.bottom - 4;
}
void CChatSelector::OnSize(UINT nType, int cx, int cy)
{
CClosableTabCtrl::OnSize(nType, cx, cy);
CRect rcChat;
GetChatSize(rcChat);
TCITEM item;
item.mask = TCIF_PARAM;
int i = 0;
while (GetItem(i++, &item)){
CChatItem* ci = (CChatItem*)item.lParam;
ci->log->SetWindowPos(NULL, rcChat.left, rcChat.top, rcChat.Width(), rcChat.Height(), SWP_NOZORDER);
}
}
void CChatSelector::AddTimeStamp(CChatItem* ci)
{
ci->log->AppendText(CTime::GetCurrentTime().Format(TIME_STAMP_FORMAT));
}
void CChatSelector::OnDestroy()
{
if (m_Timer){
KillTimer(m_Timer);
m_Timer = NULL;
}
CClosableTabCtrl::OnDestroy();
}
BOOL CChatSelector::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch (wParam) {
case MP_DETAIL:{
const CChatItem* ci = GetItemByIndex(m_iContextIndex);
if (ci) {
CClientDetailDialog dialog(ci->client);
dialog.DoModal();
}
return TRUE;
}
case MP_ADDFRIEND:{
const CChatItem* ci = GetItemByIndex(m_iContextIndex);
if (ci) {
CFriend* fr = theApp.friendlist->SearchFriend(ci->client->GetUserHash(), 0, 0);
if (!fr)
theApp.friendlist->AddFriend(ci->client);
}
return TRUE;
}
case MP_REMOVEFRIEND:{
const CChatItem* ci = GetItemByIndex(m_iContextIndex);
if (ci) {
CFriend* fr = theApp.friendlist->SearchFriend(ci->client->GetUserHash(), 0, 0);
if (fr)
theApp.friendlist->RemoveFriend(fr);
}
return TRUE;
}
case MP_REMOVE:{
const CChatItem* ci = GetItemByIndex(m_iContextIndex);
if (ci)
EndSession(ci->client);
return TRUE;
}
}
return CClosableTabCtrl::OnCommand(wParam, lParam);
}
void CChatSelector::OnContextMenu(CWnd*, CPoint point)
{
TCHITTESTINFO hti = {0};
::GetCursorPos(&hti.pt);
ScreenToClient(&hti.pt);
m_iContextIndex=this->HitTest(&hti);
if (m_iContextIndex==-1)
return;
TCITEM item;
item.mask = TCIF_PARAM;
GetItem(m_iContextIndex, &item);
const CChatItem* ci = (CChatItem*)item.lParam;
if (ci == NULL)
return;
CFriend* pFriend = theApp.friendlist->SearchFriend(ci->client->GetUserHash(), 0, 0);
CTitleMenu menu;
menu.CreatePopupMenu();
menu.AddMenuTitle(GetResString(IDS_CLIENT), true);
menu.AppendMenu(MF_STRING, MP_DETAIL, GetResString(IDS_SHOWDETAILS), _T("CLIENTDETAILS"));
GetCurrentChatItem();
if (pFriend == NULL)
menu.AppendMenu(MF_STRING, MP_ADDFRIEND, GetResString(IDS_IRC_ADDTOFRIENDLIST), _T("ADDFRIEND"));
else
menu.AppendMenu(MF_STRING, MP_REMOVEFRIEND, GetResString(IDS_REMOVEFRIEND), _T("DELETEFRIEND"));
menu.AppendMenu(MF_STRING, MP_REMOVE, GetResString(IDS_FD_CLOSE));
m_ptCtxMenu = point;
ScreenToClient(&m_ptCtxMenu);
menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}
void CChatSelector::EnableSmileys(bool bEnable)
{
for (int i = 0; i < GetItemCount(); i++){
TCITEM cur_item;
cur_item.mask = TCIF_PARAM;
if (GetItem(i, &cur_item) && ((CChatItem*)cur_item.lParam)->log)
((CChatItem*)cur_item.lParam)->log->EnableSmileys(bEnable);
}
}
void CChatSelector::ReportConnectionProgress(CUpDownClient* pClient, CString strProgressDesc, bool bNoTimeStamp)
{
CChatItem* ci = GetItemByClient(pClient);
if (!ci)
return;
if (thePrefs.GetIRCAddTimeStamp() && !bNoTimeStamp)
AddTimeStamp(ci);
ci->log->AppendKeyWord(strProgressDesc, STATUS_MSG_COLOR);
}
void CChatSelector::ClientObjectChanged(CUpDownClient* pOldClient, CUpDownClient* pNewClient){
// the friend has deceided to change the clients objects (because the old doesnt seems to be our friend) during a connectiontry
// in order to not close and reopen a new session and loose the prior chat, switch the objects on a existing tab
// nothing else changes since the tab is supposed to be still connected to the same friend
CChatItem* ci = GetItemByClient(pOldClient);
if (!ci)
return;
ci->client = pNewClient;
}