Exemplo n.º 1
0
void SessionLayout::FreshGroupMemberAvatar(IN const std::string& sID)
{
	module::UserInfoEntity userInfo;
	if (!module::getUserListModule()->getUserInfoBySId(sID, userInfo))
	{
		APP_LOG(LOG_ERROR, _T("SessionLayout::_updateGroupMembersList(),can't find the userInfo"));
		return;
	}

	if (!m_pGroupMemberList)
	{
		return;
	}
	for (int n = 0; n < m_pGroupMemberList->GetCount(); n++)
	{
		CListContainerElementUI* pItem = (CListContainerElementUI*)m_pGroupMemberList->GetItemAt(n);
		if (pItem)
		{
			CDuiString userData = pItem->GetUserData();
			if (!userData.IsEmpty())
			{
				std::string sid = util::cStringToString(CString(userData));
				if (sid == sID)
				{
					CButtonUI* btnAvatarInfo = (CButtonUI*)pItem->FindSubControl(_T("AvatarInfo"));
					if (btnAvatarInfo)
					{
						btnAvatarInfo->SetBkImage(util::stringToCString(userInfo.getAvatarPath()));
					}
				}
			}
		}
	}
	m_pGroupMemberList->SortItems(GroupMemberListItemCompareFunc, 0);
}
Exemplo n.º 2
0
void SessionLayout::FreshAllGroupMemberAvatar()
{
	if (!m_pGroupMemberList)
	{
		return;
	}
	for (int n = 0; n < m_pGroupMemberList->GetCount(); n++)
	{
		CListContainerElementUI* pItem = (CListContainerElementUI*)m_pGroupMemberList->GetItemAt(n);
		if (pItem)
		{
			CDuiString userData = pItem->GetUserData();
			if (!userData.IsEmpty())
			{
				std::string sid = util::cStringToString(CString(userData));
				module::UserInfoEntity userInfo;
				if (!module::getUserListModule()->getUserInfoBySId(sid, userInfo))
				{
					LOG__(ERR, _T("can't find the userInfo:%s,GroupId:%s"),util::stringToCString(sid),util::stringToCString(m_sId));
					continue;;
				}
				CButtonUI* btnAvatarInfo = (CButtonUI*)pItem->FindSubControl(_T("AvatarInfo"));
				if (btnAvatarInfo)
				{
					btnAvatarInfo->SetBkImage(util::stringToCString(userInfo.getAvatarPath()));
				}
			}
		}
	}
	m_pGroupMemberList->SortItems(GroupMemberListItemCompareFunc, 0);
}
Exemplo n.º 3
0
static bool OnLogoButtonEvent(void* event) {
	if (((TEventUI*)event)->Type == UIEVENT_BUTTONDOWN) {
		CControlUI* pButton = ((TEventUI*)event)->pSender;
		if (pButton != NULL) {
			CListContainerElementUI* pListElement = (CListContainerElementUI*)(pButton->GetTag());
			if (pListElement != NULL)
			{
				pListElement->DoEvent(*(TEventUI*)event);
				std::string sid = util::cStringToString(CString(pListElement->GetUserData()));
				if (!sid.empty())
				{
					//show the detail window.
					module::getSysConfigModule()->asynNotifyObserver(module::KEY_SYSCONFIG_SHOW_USERDETAILDIALOG, sid);
				}
			}
		}
	}
	return true;
}
Exemplo n.º 4
0
void SessionLayout::_GetGroupNameListByShortName(IN const CString& sShortName, OUT std::vector<string>& nameList)
{
	for (int n = 0; n < m_pGroupMemberList->GetCount();++n)
	{
		CListContainerElementUI* pListElement = static_cast<CListContainerElementUI*>(m_pGroupMemberList->GetItemAt(n));
		if (pListElement)
		{
			CLabelUI* pNameLable = static_cast<CLabelUI*>(pListElement->FindSubControl(_T("nickname")));
			if (!pNameLable)
			{
				continue;;
			}
			CString Name = pNameLable->GetText();
			std::string sid = util::cStringToString(CString(pListElement->GetUserData()));

			if (util::isIncludeChinese(util::cStringToString(sShortName, CP_ACP)))//检索中文
			{
				if (Name.Find(sShortName) != -1)
				{
					nameList.push_back(sid);
				}
			}
			else//检索字母
			{
				CString firstPY = util::HZ2FirstPY(util::cStringToString(Name, CP_ACP));
				if (firstPY.Find(sShortName) != -1)//先检索简拼
				{
					nameList.push_back(sid);
				}
				else
				{
					CString allPY = util::HZ2AllPY(Name);//再检索全拼
					if (allPY.Find(sShortName) != -1)
					{
						nameList.push_back(sid);
					}
				}
			}
		}
	}
}
Exemplo n.º 5
0
void SessionLayout::Notify(TNotifyUI& msg)
{
	if (_tcsicmp(msg.sType, DUI_MSGTYPE_WINDOWINIT) == 0 )
	{
		OnWindowInitialized(msg);
	}
	else if (msg.sType == DUI_MSGTYPE_CLICK)
	{
		if (msg.pSender == m_pBtnSendMsg)
		{
			SendMsg();
		}
		else if (m_pBtnClose == msg.pSender)
		{
		}
		else if (msg.pSender == m_pBtnEmotion)
		{
			//表情先不展示
			POINT pt = { 0 };
			CDuiRect rcEmotionBtn = msg.pSender->GetPos();
			CDuiRect rcWindow;
			GetWindowRect(m_pManager->GetPaintWindow(), &rcWindow);

			pt.y = rcWindow.top + rcEmotionBtn.top;
			pt.x = rcWindow.left + rcEmotionBtn.left;

			module::getEmotionModule()->showEmotionDialog(m_sId,pt);
		}
		else if (msg.pSender == m_pBtnSendImage)
		{
			std::list<CString> lstFile;
			util::GetOpenFilePath(AfxGetMainWnd(), lstFile, FALSE, _T("图片 文件|*.png;*.jpeg;*.jpg;*.gif;*.bmp||"));
			if (lstFile.empty())
				return;
			CString strFile = lstFile.front();
			if (strFile.IsEmpty())
			{
				return;
			}
			_SendImage(strFile);
		}
		else if (msg.pSender == m_pBtnbanGroupMsg)
		{
			_OnBanGroupMsg(true);
		}
		else if (msg.pSender == m_pBtndisplayGroupMsg)
		{
			_OnBanGroupMsg(false);
		}
		else if (msg.pSender == m_pBtnshock)
		{
			module::UserInfoEntity userInfo;
			if (module::getUserListModule()->getUserInfoBySId(m_sId, userInfo))
			{
				if (userInfo.onlineState != USER_STATUS_ONLINE)
				{
					_DisplaySysMsg(_T("STRID_SESSIONMODULE_SHAKEWINDOW_OFFLINE_TIP"));
					return;
				}
			}
			else
			{
				return;
			}
			DWORD CurTime = GetTickCount();
			if (CurTime - m_tShakeWindow < 5000)
			{
				_DisplaySysMsg(_T("STRID_SESSIONMODULE_SHAKEWINDOW_TOOMAMY_TIP"));
				return;
			}
			m_tShakeWindow = CurTime;
			_DisplaySysMsg(_T("STRID_SESSIONMODULE_SHAKEWINDOW_SEND_TIP"));
			logic::GetLogic()->asynNotifyObserver(module::KEY_SESSION_SHAKEWINDOW_MSG, m_sId);
			module::getP2PCmdModule()->tcpSendShakeWindowCMD(m_sId);
		}
		//文件传输
		else if (msg.pSender == m_pBtnsendfile)
		{
			module::UserInfoEntity userInfo;
			if (!module::getUserListModule()->getUserInfoBySId(m_sId, userInfo))
			{
				APP_LOG(LOG_ERROR, _T("SendFile can't find the sid"));
				return;
			}
			std::list<CString> lstFile;
			util::GetOpenFilePath(AfxGetMainWnd(), lstFile, FALSE, _T("文件|*.*||"));
			if (lstFile.empty())
				return;
			CString strFile = lstFile.front();
			if (strFile.IsEmpty())
			{
				return;
			}
			module::getFileTransferModule()->sendFile(strFile, m_sId, userInfo.isOnlne());
		}
		else if (msg.pSender == m_pBtnadduser)
		{
			module::getGroupListModule()->onCreateDiscussionGrpDialog(m_sId);
		}
	}
	else if (msg.sType == _T("return"))
	{
		if (msg.pSender == m_pInputRichEdit)
		{
			SendMsg();
		}
	}
	else if (0 == _tcsicmp(msg.sType, DUI_MSGTYPE_ITEMACTIVATE))
	{
		if (msg.pSender->GetName() == _T("ListGroupMembersItem"))
		{
			CListContainerElementUI* pListElement = static_cast<CListContainerElementUI*>(msg.pSender);
			if (!pListElement->GetUserData().IsEmpty())
			{
				std::string sid = util::cStringToString(CString(pListElement->GetUserData()));
				logic::GetLogic()->asynNotifyObserver(module::KEY_SESSION_OPENNEWSESSION, sid);//通知主窗口创建会话
			}
		}
	}
	else if (0 == _tcsicmp(msg.sType, UIIMEdit_MSGTYPE_TEXTCHANGED))
	{
		if (msg.pSender->GetName() == _T("input_richedit"))
		{
			if (!m_bGroupSession)
			{
				module::getP2PCmdModule()->tcpSendWritingCMD(m_sId, TRUE);
				m_pManager->KillTimer(this, TIMER_CHECK_WRITING);
				m_pManager->SetTimer(this, TIMER_CHECK_WRITING, 5000);
			}
		}
	}
	else if (0 == _tcsicmp(msg.sType, DUI_MSGTYPE_KILLFOCUS))
	{
		if (!m_bGroupSession)
		{
			m_pManager->KillTimer(this, TIMER_CHECK_WRITING);
			module::getP2PCmdModule()->tcpSendWritingCMD(m_sId, FALSE);
		}
	}
	else if (0 == _tcsicmp(msg.sType, DUI_MSGTYPE_TEXTCHANGED))
	{
		if (msg.pSender == m_pSearchEdit)
		{
			m_pSearchResultList->RemoveAll();
			CDuiString inputText = m_pSearchEdit->GetText();
			if (inputText.IsEmpty())
			{
				m_pSearchResultList->SetVisible(false);
				m_pGroupMemberList->SetVisible(true);
			}
			else
			{
				m_pGroupMemberList->SetVisible(false);
				m_pSearchResultList->SetVisible(true);

				module::UserInfoEntityVec userList;
				_GetGroupNameListByShortName(inputText.GetData(), userList);
				_UpdateSearchRsultList(userList);
			}
		}
	}
}