Beispiel #1
0
INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	InviteChatParam *param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

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

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

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

	case WM_NCDESTROY:
		delete param;
		break;

	case WM_NOTIFY:
		NMCLISTCONTROL* nmc;
		{
			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)
						ChatValidateContact((UINT_PTR)nmc->hItem, nmc->hdr.hwndFrom, param->ppro);
					break;

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

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_ADDSCR:
			if (param->ppro->msnLoggedIn) {
				TCHAR email[MSN_MAX_EMAIL_LEN];
				GetDlgItemText(hwndDlg, IDC_EDITSCR, email, _countof(email));

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

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

		case IDCANCEL:
			EndDialog(hwndDlg, IDCANCEL);
			break;

		case IDOK:
			char tEmail[MSN_MAX_EMAIL_LEN]; tEmail[0] = 0;
			GCThreadData *info = NULL;
			if (param->id)
				info = param->ppro->MSN_GetThreadByChatId(param->id);
			/*else if (param->hContact) {
				if (!param->ppro->MSN_IsMeByContact(param->hContact, tEmail))
					info = param->ppro->MSN_GetThreadByContact(tEmail);
			}*/

			HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST);
			STRLIST *cont = new STRLIST;
			ChatInviteSend(NULL, hwndList, *cont, param->ppro);

			if (info) {
				for (int i = 0; i < cont->getCount(); ++i)
					ChatInviteUser(param->ppro->msnNsThread, info, (*cont)[i]);
				delete cont;
			}
			else {
				/* Group chats only work for Skype users */
				CMStringA buf;
				buf.AppendFormat("<thread><id></id><members><member><mri>%d:%s</mri><role>admin</role></member>",
					NETID_SKYPE, param->ppro->GetMyUsername(NETID_SKYPE));
				for (int i = 0; i < cont->getCount(); ++i) {
					// TODO: Add support for assigning role in invite dialog maybe?
					buf.AppendFormat("<member><mri>%s</mri><role>user</role></member>", (*cont)[i]);
				}
				buf.Append("</members></thread>");
				param->ppro->msnNsThread->sendPacketPayload("PUT", "MSGR\\THREAD", buf);
			}

			EndDialog(hwndDlg, IDOK);
		}
		break;
	}
	return FALSE;
}
Beispiel #2
0
INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	InviteChatParam* param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

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

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

//		WindowSetIcon(hwndDlg, "msn");
		break;

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

	case WM_NCDESTROY:
//		WindowFreeIcon(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) 
					ChatValidateContact(nmc->hItem, nmc->hdr.hwndFrom, param->ppro);
				break;

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

	case WM_COMMAND:
		{
			switch (LOWORD(wParam)) 
			{
			case IDC_ADDSCR:
				if (param->ppro->msnLoggedIn)
				{
					TCHAR email[MSN_MAX_EMAIL_LEN];
					GetDlgItemText(hwndDlg, IDC_EDITSCR, email, SIZEOF(email));

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

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

			case IDOK:
				{
					char tEmail[MSN_MAX_EMAIL_LEN] = "";
					ThreadData *info = NULL;
					if (param->id)
						info = param->ppro->MSN_GetThreadByChatId(param->id);
					else if (param->hContact)
					{
						if (!param->ppro->MSN_IsMeByContact(param->hContact, tEmail))
							info =  param->ppro->MSN_GetThreadByContact(tEmail);
					}

					HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST);
					STRLIST *cont = new STRLIST;
					ChatInviteSend(NULL, hwndList, *cont, param->ppro);

					if (info)
					{
						for (int i = 0; i < cont->getCount(); ++i)
							ChatInviteUser(info, (*cont)[i]);
						delete cont;
					}
					else 
					{
						if (tEmail[0]) cont->insertn(tEmail);
						param->ppro->MsgQueue_Add("chat", 'X', NULL, 0, NULL, 0, cont);
						if (param->ppro->msnLoggedIn)
							param->ppro->msnNsThread->sendPacket("XFR", "SB");
					}
				}

				EndDialog(hwndDlg, IDOK);
				break;

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