コード例 #1
0
void PhotoService::DownloadTeamIcon(const nim::TeamInfo &info)
{
	std::string url = info.GetIcon();
	std::wstring photo_path = GetPhotoDir(kTeam) + nbase::UTF8ToUTF16(QString::GetMd5(url));
	int valid = CheckForDownload(kTeam, url);
	if (valid != 0)
	{
		if (valid == 1)
		{
			for (auto &it : photo_ready_cb_list_) // 执行监听头像下载的回调
			(*it.second)(kTeam, info.GetTeamID(), 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)(kTeam, info.GetTeamID(), photo_path);
			}
		}
	});
	nim::NOS::DownloadResource(url, cb);
}
コード例 #2
0
void SessionForm::OnTeamNameChange(const nim::TeamInfo& team_info)
{
	if (session_id_ == team_info.GetTeamID())
	{
		std::wstring name = nbase::UTF8ToUTF16(team_info.GetName());

		SetTaskbarTitle(name);
		label_title_->SetText(name);
	}
}
コード例 #3
0
ファイル: custom_msg.cpp プロジェクト: netease-im/NIM_PC_Demo
void CustomMsgBubble::OnTeamNameChange(const nim::TeamInfo & team_info)
{
	if (team_info.GetTeamID() == receiver_id_ && session_type_ == nim::kNIMSessionTypeTeam)
	{
		std::wstring team_sender = name_->GetText();
		size_t pos = team_sender.find(L"->");
		if (pos != std::wstring::npos)
			name_->SetText(nbase::UTF8ToUTF16(team_info.GetName()) + team_sender.substr(pos));
	}
}
コード例 #4
0
void TeamService::UIGetLocalTeamInfoCb(const std::string& tid, const nim::TeamInfo& result)
{
	assert(nbase::MessageLoop::current()->ToUIMessageLoop());

	if (!result.GetName().empty())
	{
		tid_tname_pair_[tid] = result.GetName();

		InvokeChangeTeamName(result);
	}

	tid_type_pair_[tid] = result.GetType();

	on_query_tids_.erase(tid); //已经查到,从post_tids_中删除
}
コード例 #5
0
void SessionList::OnTeamNameChange(const nim::TeamInfo& team_info)
{
	SessionItem* item = (SessionItem*)session_list_->FindSubControl(nbase::UTF8ToUTF16(team_info.GetTeamID()));
	if (item)
		((Label*)item->FindSubControl(L"label_name"))->SetUTF8Text(team_info.GetName());
}