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); }
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); } }
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)); } }
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()); }