summaryrefslogtreecommitdiff
path: root/protocols/Yahoo/src/chat.cpp
blob: f229a942c1b8876bf576438dce83f937994ab328 (plain)
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
/*
 *
 * myYahoo Miranda Plugin
 *
 * Authors: Gennady Feldman (aka Gena01)
 *          Laurent Marechal (aka Peorth)
 *          Boris Krasnovskiy (aka borkra)
 *
 * This code is under GPL and is based on AIM, MSN and Miranda source code.
 * I want to thank Robert Rainwater and George Hazan for their code and support
 * and for answering some of my questions during development of this plugin.
 */

#include "stdafx.h"
#include "resource.h"
#include <m_protosvc.h>
#include <m_langpack.h>
#include <m_message.h>
#include <m_chat.h>
#include <m_userinfo.h>
#include <m_history.h>

struct InviteChatParam
{
	char* room;
	CYahooProto* ppro;


	InviteChatParam(const char* room, CYahooProto* ppro)
		: room(strdup(room)), ppro(ppro) {}

	~InviteChatParam()
	{ free(room); }
};

struct InviteChatReqParam
{
	char* room;
	char* who;
	wchar_t* msg;
	CYahooProto* ppro;

	InviteChatReqParam(const char* room, const char* who, const char* msg, CYahooProto* ppro)
		: room(mir_strdup(room)), who(mir_strdup(who)), msg(mir_utf8decodeW(msg)), ppro(ppro) {}

	~InviteChatReqParam()
	{ mir_free(room); mir_free(who); mir_free(msg); }
};

INT_PTR CALLBACK InviteToChatDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);

void ext_yahoo_conf_userdecline(int id, const char*, const char *who, const char *room, const char *msg)
{
	wchar_t info[1024];
	wchar_t *whot = mir_utf8decodeW(who);
	wchar_t *msgt = mir_utf8decodeW(msg);
	mir_snwprintf(info, TranslateT("%s denied invitation with message: %s"), whot, msgt ? msgt : L"");
	GETPROTOBYID(id)->ChatEvent(room, who, GC_EVENT_INFORMATION, info);
	mir_free(msgt);
	mir_free(whot);
}

void ext_yahoo_conf_userjoin(int id, const char*, const char *who, const char *room)
{
	CYahooProto* ppro = getProtoById(id);
	if (!ppro) return;

	CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
	if (!cm) return;
	for (YList *l = cm->members; l; l = l->next) {
		if (!mir_strcmp(who, (char*)l->data))
			return;
	}

	cm->members = y_list_append(cm->members, strdup(who));
	ppro->ChatEvent(room, who, GC_EVENT_JOIN);
}

void ext_yahoo_conf_userleave(int id, const char*, const char *who, const char *room)
{
	CYahooProto* ppro = getProtoById(id);
	if (!ppro) return;

	CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
	if (!cm) return;

	for (YList *l = cm->members; l; l = l->next) {
		if (mir_strcmp((char*)l->data, who) == 0) {
			free(l->data);
			y_list_remove_link(cm->members, l);
			y_list_free_1(l);
			break;
		}
	}

	ppro->ChatEvent(room, who, GC_EVENT_PART);
}

void ext_yahoo_conf_message(int id, const char*, const char *who, const char *room, const char *msg, int utf8)
{
	wchar_t *msgt = utf8 ? mir_utf8decodeW(msg) : mir_a2u(msg);
	GETPROTOBYID(id)->ChatEvent(room, who, GC_EVENT_MESSAGE, msgt);
	mir_free(msgt);
}

/* chat handlers */
void ext_yahoo_chat_cat_xml(int, const char*)
{}

void ext_yahoo_chat_join(int, const char*, const char*, const char*, YList *members, INT_PTR)
{
	for (YList *l = members; l; l = l->next) free(l->data);
	y_list_free(members);
}

void ext_yahoo_chat_userjoin(int, const char*, const char*, yahoo_chat_member*)
{}

void ext_yahoo_chat_userleave(int, const char*, const char*, const char*)
{}

void ext_yahoo_chat_message(int, const char*, const char*, const char*, const char*, int, int)
{}

void ext_yahoo_chat_yahoologout(int, const char*)
{
	LOG(("got chat logout"));
}

void ext_yahoo_chat_yahooerror(int, const char*)
{
	LOG(("got chat error"));
}

static const COLORREF crCols[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

void CYahooProto::ChatRegister(void)
{
	GCREGISTER gcr = { sizeof(gcr) };
	gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
	gcr.nColors = 16;
	gcr.pColors = (COLORREF*)crCols;
	gcr.ptszDispName = m_tszUserName;
	gcr.pszModule = m_szModuleName;
	Chat_Register(&gcr);

	HookProtoEvent(ME_GC_EVENT, &CYahooProto::OnGCEventHook);
	HookProtoEvent(ME_GC_BUILDMENU, &CYahooProto::OnGCMenuHook);
}

void CYahooProto::ChatStart(const char* room)
{
	wchar_t* idt = mir_a2u(room);

	GCSESSION gcw = { sizeof(gcw) };
	gcw.iType = GCW_CHATROOM;
	gcw.pszModule = m_szModuleName;
	gcw.ptszName = idt;
	gcw.ptszID = idt;
	Chat_NewSession(&gcw);

	GCDEST gcd = { m_szModuleName, idt, GC_EVENT_ADDGROUP };
	GCEVENT gce = { sizeof(gce), &gcd };
	gce.ptszStatus = TranslateT("Me");
	Chat_Event(0, &gce);

	gcd.iType = GC_EVENT_ADDGROUP;
	gce.ptszStatus = TranslateT("Others");
	Chat_Event(0, &gce);

	gcd.iType = GC_EVENT_CONTROL;
	Chat_Event(SESSION_INITDONE, &gce);
	Chat_Event(SESSION_ONLINE, &gce);
	Chat_Event(WINDOW_VISIBLE, &gce);

	mir_free(idt);
}

void CYahooProto::ChatLeave(const char* room)
{
	wchar_t* idt = mir_a2u(room);

	GCDEST gcd = { m_szModuleName, idt, GC_EVENT_CONTROL };
	GCEVENT gce = { sizeof(gce), &gcd };
	gce.dwFlags = GCEF_REMOVECONTACT;
	Chat_Event(SESSION_OFFLINE, &gce);
	Chat_Event(SESSION_TERMINATE, &gce);

	mir_free(idt);
}

void CYahooProto::ChatLeaveAll(void)
{
	for (int i = 0; i < m_chatrooms.getCount(); ++i)
		ChatLeave(m_chatrooms[i].name);
}

void CYahooProto::ChatEvent(const char* room, const char* who, int evt, const wchar_t* msg)
{
	wchar_t* idt = mir_a2u(room);
	wchar_t* snt = mir_a2u(who);

	MCONTACT hContact = getbuddyH(who);
	wchar_t* nick = hContact ? (wchar_t*)pcli->pfnGetContactDisplayName(WPARAM(hContact), 0) : snt;

	GCDEST gcd = { m_szModuleName, idt, evt };
	GCEVENT gce = { sizeof(gce), &gcd };
	gce.dwFlags = GCEF_ADDTOLOG;
	gce.ptszNick = nick;
	gce.ptszUID = snt;
	gce.bIsMe = _stricmp(who, m_yahoo_id) == 0;
	gce.ptszStatus = gce.bIsMe ? TranslateT("Me") : TranslateT("Others");
	gce.ptszText = msg;
	gce.time = time(NULL);
	Chat_Event(0, &gce);

	mir_free(snt);
	mir_free(idt);
}

int __cdecl CYahooProto::OnGCEventHook(WPARAM, LPARAM lParam)
{
	GCHOOK *gch = (GCHOOK*)lParam;
	if (!gch) return 1;

	if (mir_strcmp(gch->pDest->pszModule, m_szModuleName)) return 0;

	char *room = mir_u2a(gch->pDest->ptszID);
	char *who = mir_u2a(gch->ptszUID);

	switch (gch->pDest->iType) {
	case GC_SESSION_TERMINATE:
		{
			ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
			if (cm) {
				yahoo_conference_logoff(m_id, NULL, cm->members, room);
				m_chatrooms.remove((ChatRoom*)&room);
			}
		}
		break;

	case GC_USER_MESSAGE:
		if (gch->ptszText && gch->ptszText[0]) {
			ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
			if (cm)
				yahoo_conference_message(m_id, NULL, cm->members, room, T2Utf(gch->ptszText), 1);
		}
		break;

	case GC_USER_CHANMGR:
		DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, InviteToChatDialog,
			LPARAM(new InviteChatParam(room, this)));
		break;

	case GC_USER_PRIVMESS:
		CallService(MS_MSG_SENDMESSAGE, (WPARAM)getbuddyH(who));
		break;

	case GC_USER_LOGMENU:
		switch (gch->dwData) {
		case 10:
			DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, InviteToChatDialog,
				LPARAM(new InviteChatParam(room, this)));
			break;

		case 20:
			ChatLeave(room);
			break;
		}
		break;

	case GC_USER_NICKLISTMENU:
		switch (gch->dwData) {
		case 10:
			CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)getbuddyH(who));
			break;

		case 20:
			CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)getbuddyH(who));
			break;

		case 110:
			ChatLeave(room);
			break;
		}
		break;

	case GC_USER_TYPNOTIFY:
		break;
	}
	mir_free(who);
	mir_free(room);

	return 0;
}

int __cdecl CYahooProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{
	GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;

	if (gcmi == NULL || _stricmp(gcmi->pszModule, m_szModuleName)) return 0;

	if (gcmi->Type == MENU_ON_LOG) {
		static const gc_item Items[] =
		{
			{ TranslateT("&Invite user..."), 10, MENU_ITEM, FALSE },
			{ TranslateT("&Leave chat session"), 20, MENU_ITEM, FALSE }
		};
		gcmi->nItems = _countof(Items);
		gcmi->Item = (gc_item*)Items;
	}
	else if (gcmi->Type == MENU_ON_NICKLIST) {
		char* id = mir_u2a(gcmi->pszUID);
		if (!_stricmp(m_yahoo_id, id)) {
			static const gc_item Items[] =
			{
				{ TranslateT("User &details"), 10, MENU_ITEM, FALSE },
				{ TranslateT("User &history"), 20, MENU_ITEM, FALSE },
				{ L"", 100, MENU_SEPARATOR, FALSE },
				{ TranslateT("&Leave chat session"), 110, MENU_ITEM, FALSE }
			};
			gcmi->nItems = _countof(Items);
			gcmi->Item = (gc_item*)Items;
		}
		else {
			static const gc_item Items[] =
			{
				{ TranslateT("User &details"), 10, MENU_ITEM, FALSE },
				{ TranslateT("User &history"), 20, MENU_ITEM, FALSE }
			};
			gcmi->nItems = _countof(Items);
			gcmi->Item = (gc_item*)Items;
		}
		mir_free(id);
	}

	return 0;
}

/////////////////////////////////////////////////////////////////////////////////////////
// Invite to chat dialog

static void clist_chat_invite_send(MCONTACT hItem, HWND hwndList, YList* &who, char* room, CYahooProto* ppro, wchar_t *msg)
{
	bool root = !hItem;
	if (root)
		hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem) {
		if (IsHContactGroup(hItem)) {
			MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT)
				clist_chat_invite_send(hItemT, hwndList, who, room, ppro, msg);
		}
		else {
			int chk = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
			if (chk) {
				if (IsHContactInfo(hItem)) {
					wchar_t buf[128] = L"";
					SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf);

					who = y_list_append(who, mir_u2a(buf));
				}
				else {
					DBVARIANT dbv;
					if (!ppro->getString(hItem, YAHOO_LOGINID, &dbv))
						who = y_list_append(who, dbv.pszVal);
				}
			}
		}
		hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
	}

	if (root && who) {
		T2Utf msg8(msg);
		CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
		if (cm) {
			for (YList *l = who; l; l = l->next)
				yahoo_conference_addinvite(ppro->m_id, NULL, (char*)l->data, room, cm->members, msg8);
		}
		else yahoo_conference_invite(ppro->m_id, NULL, who, room, msg8);

		for (YList *l = who; l; l = l->next) mir_free(l->data);
		y_list_free(who);
	}
}

static void ClistValidateContact(MCONTACT hItem, HWND hwndList, CYahooProto* ppro)
{
	if (!ppro->IsMyContact(hItem) || ppro->isChatRoom(hItem) ||
		ppro->getWord(hItem, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONTHEPHONE)
		SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0);
}

static void ClistChatPrepare(MCONTACT hItem, HWND hwndList, CYahooProto* ppro)
{
	if (hItem == NULL)
		hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);

	while (hItem) {
		MCONTACT hItemN = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);

		if (IsHContactGroup(hItem)) {
			MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
			if (hItemT)
				ClistChatPrepare(hItemT, hwndList, ppro);
		}
		else if (IsHContactContact(hItem))
			ClistValidateContact(hItem, hwndList, ppro);

		hItem = hItemN;
	}
}

INT_PTR CALLBACK InviteToChatDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	InviteChatParam* param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch (uMsg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);

		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
		param = (InviteChatParam*)lParam;

		Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_YAHOO));

		SetDlgItemTextA(hwndDlg, IDC_ROOMNAME, param->room);
		SetDlgItemText(hwndDlg, IDC_MSG, TranslateT("Join My Conference..."));
		break;

	case WM_CLOSE:
		EndDialog(hwndDlg, 0);
		break;

	case WM_NCDESTROY:
		Window_FreeIcon_IcoLib(hwndDlg);
		delete param;
		break;

	case WM_NOTIFY:
		{
			NMCLISTCONTROL* nmc = (NMCLISTCONTROL*)lParam;
			if (nmc->hdr.idFrom == IDC_CCLIST) {
				switch (nmc->hdr.code) {
				case CLN_NEWCONTACT:
					if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
						ClistValidateContact((MCONTACT)nmc->hItem, nmc->hdr.hwndFrom, param->ppro);
					break;

				case CLN_LISTREBUILT:
					if (param)
						ClistChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro);
					break;
				}
			}
		}
		break;

	case WM_COMMAND:
		{
			switch (LOWORD(wParam)) {
			case IDC_ADDSCR:
				if (param->ppro->m_bLoggedIn) {
					wchar_t sn[64];
					GetDlgItemText(hwndDlg, IDC_EDITSCR, sn, _countof(sn));

					CLCINFOITEM cii = { 0 };
					cii.cbSize = sizeof(cii);
					cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS;
					cii.pszText = sn;

					HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
					SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1);
				}
				break;

			case IDOK:
				{
					wchar_t msg[1024];
					GetDlgItemText(hwndDlg, IDC_MSG, msg, _countof(msg));

					HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST);
					YList *who = NULL;
					clist_chat_invite_send(NULL, hwndList, who, param->room, param->ppro, msg);

					EndDialog(hwndDlg, IDOK);
					PostMessage(hwndDlg, WM_DESTROY, 0, 0);
				}
				break;

			case IDCANCEL:
				EndDialog(hwndDlg, IDCANCEL);
				PostMessage(hwndDlg, WM_DESTROY, 0, 0);
				break;
			}
		}
		break;
	}
	return FALSE;
}

/////////////////////////////////////////////////////////////////////////////////////////
// Chat request dialog

INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	InviteChatReqParam* param = (InviteChatReqParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch (uMsg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);

		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
		param = (InviteChatReqParam*)lParam;

		Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_YAHOO));

		SetDlgItemTextA(hwndDlg, IDC_SCREENNAME, param->who);
		SetDlgItemText(hwndDlg, IDC_MSG, param->msg);
		SetDlgItemText(hwndDlg, IDC_MSG2, TranslateT("No, thank you..."));
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_NCDESTROY:
		Window_FreeIcon_IcoLib(hwndDlg);
		delete param;
		break;

	case WM_COMMAND:
		{
			CYahooProto::ChatRoom *cm = param->ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&param->room);
			switch (LOWORD(wParam)) {
			case IDOK:
				if (cm) {
					param->ppro->ChatStart(param->room);

					for (YList *l = cm->members; l; l = l->next)
						param->ppro->ChatEvent(param->room, (char*)l->data, GC_EVENT_JOIN);

					yahoo_conference_logon(param->ppro->m_id, NULL, cm->members, param->room);
				}
				DestroyWindow(hwndDlg);
				break;

			case IDCANCEL:
				if (cm) {
					wchar_t msg[1024];
					GetDlgItemText(hwndDlg, IDC_MSG2, msg, _countof(msg));
					yahoo_conference_decline(param->ppro->m_id, NULL, cm->members, param->room, T2Utf(msg));

					param->ppro->m_chatrooms.remove((CYahooProto::ChatRoom*)&param->room);
				}
				DestroyWindow(hwndDlg);
				break;
			}
		}
		break;
	}
	return FALSE;
}

INT_PTR __cdecl CYahooProto::CreateConference(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	char room[128];
	mir_snprintf(room, "%s-%u", m_yahoo_id, time(NULL));

	InviteChatParam* param = new InviteChatParam(room, this);
	DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL,
		InviteToChatDialog, LPARAM(param));
	return 0;
}

void CALLBACK ConferenceRequestCB(PVOID pParam)
{
	CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE_REQ), NULL, ChatRequestDialog, (LPARAM)pParam);
}

/* Conference handlers */
void ext_yahoo_got_conf_invite(int id, const char *me, const char *who, const char *room, const char *msg, YList *members)
{
	char z[1024];
	mir_snprintf(z, Translate("[miranda] Got conference invite to room: %s with msg: %s"), room ? room : "", msg ? msg : "");
	LOG(("[ext_yahoo_got_conf_invite] %s", z));

	CYahooProto* ppro = getProtoById(id);
	if (!ppro) return;

	bool freeList = true;
	CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
	if (!cm) {
		if (mir_strcmp(who, me)) {
			cm = new CYahooProto::ChatRoom(room, members);
			ppro->m_chatrooms.insert(cm);

			InviteChatReqParam* req = new InviteChatReqParam(room, who, msg, ppro);
			CallFunctionAsync(ConferenceRequestCB, req);
			freeList = false;
		}
		else {
			cm = new CYahooProto::ChatRoom(room, NULL);
			ppro->m_chatrooms.insert(cm);
			ppro->ChatStart(room);

			yahoo_conference_logon(id, NULL, members, room);
		}
	}

	if (freeList) {
		for (YList *l = members; l; l = l->next) free(l->data);
		y_list_free(members);
	}
}