Пример #1
0
void PhotoService::DownloadUserPhoto(const nim::UserNameCard &info)
{
	std::string url = info.GetIconUrl();
	std::wstring photo_path = GetPhotoDir(kUser) + nbase::UTF8ToUTF16(QString::GetMd5(url));
	int valid = CheckForDownload(kUser, url);
	if (valid != 0)
	{
		if (valid == 1)
		{
			for (auto &it : photo_ready_cb_list_) // 执行监听头像下载的回调
				(*it.second)(kUser, info.GetAccId(), photo_path);
		}
		return;
	}

	nim::NOS::DownloadMediaCallback cb = ToWeakCallback([this, info, photo_path](nim::NIMResCode res_code, const std::string& file_path, const std::string& call_id, const std::string& res_id) {
		if (res_code == nim::kNIMResSuccess)
		{
			std::wstring ws_file_path = nbase::UTF8ToUTF16(file_path);
			if (nbase::FilePathIsExist(ws_file_path, false))
			{
				nbase::CopyFileW(ws_file_path, photo_path);
				nbase::DeleteFile(ws_file_path);

				for (auto &it : photo_ready_cb_list_) // 执行监听头像下载的回调
					(*it.second)(kUser, info.GetAccId(), photo_path);
			}
		}
	});
	nim::NOS::DownloadResource(url, cb);
}
Пример #2
0
void BlackListWindow::ResetUserInfo(const nim::UserNameCard &info)
{
	ui::ListContainerElement* black_item = (ui::ListContainerElement*)m_black_list->FindSubControl(nbase::UTF8ToUTF16(info.GetAccId()));
	if (black_item == NULL)
		return;
	ui::Control* head_image = black_item->FindSubControl(L"head_image");
	ui::Label* contact = static_cast<ui::Label*>(black_item->FindSubControl(L"contact"));
	head_image->SetBkImage(PhotoService::GetInstance()->GetUserPhoto(info.GetAccId()));
	contact->SetText(UserService::GetInstance()->GetUserName(info.GetAccId()));
}
Пример #3
0
void BlackListWindow::AddBlackListMember(const nim::UserNameCard & info)
{
	ui::ListContainerElement* black_item = (ui::ListContainerElement*)m_black_list->FindSubControl(nbase::UTF8ToUTF16(info.GetAccId()));
	if (black_item != NULL)
		return;
	black_item = dynamic_cast<ui::ListContainerElement*>(ui::GlobalManager::CreateBoxWithCache(L"black_list/black_list_item.xml"));
	black_item->SetUTF8Name(info.GetAccId());
	m_black_list->Add(black_item);
	ResetUserInfo(info);
	ui::Button* remove = static_cast<ui::Button*>(black_item->FindSubControl(L"confirm"));
	remove->SetUTF8DataID(info.GetAccId()); // 把用户帐号保存到按钮的m_sUserData中
	remove->AttachClick(nbase::Bind(&BlackListWindow::OnRemoveBtnClicked, this, std::placeholders::_1));
}
Пример #4
0
void CustomMsgBubble::OnUserInfoChange(const nim::UserNameCard & info)
{
	if (info.GetAccId() == sender_id_)
	{
		std::wstring sender = UserService::GetInstance()->GetUserName(info.GetAccId());
		if (session_type_ == nim::kNIMSessionTypeP2P)
		{
			name_->SetText(sender);
			head_->SetBkImage(PhotoService::GetInstance()->GetUserPhoto(info.GetAccId()));
		}
		else
		{
			std::wstring team_sender = name_->GetText();
			size_t pos = team_sender.find(L"->");
			if (pos != std::wstring::npos)
				name_->SetText(team_sender.substr(0, pos + 2) + sender);
		}
	}
}
Пример #5
0
void SessionList::UpdateSessionInfo(const nim::UserNameCard& user_info)
{
	SessionItem* session_item = dynamic_cast<SessionItem*>(session_list_->FindSubControl(nbase::UTF8ToUTF16(user_info.GetAccId())));
	if (session_item != NULL)
		session_item->InitUserProfile();

	for (int i = 0; i < session_list_->GetCount(); i++)
	{
		SessionItem* session_item = dynamic_cast<SessionItem*>(session_list_->GetItemAt(i));
		if (session_item && session_item->GetIsTeam())
			session_item->UpdateMsgContent(user_info.GetAccId()); //群通知消息内容中可能含有用户名
	}
}