Example #1
0
void MsgRecordForm::RefreshRecord(std::string id, nim::NIMSessionType type)
{
	if(id == session_id_)
		return;
	session_id_ = id;
	session_type_ = type;

	//初始化
	first_show_msg_ = true;
	last_msg_time_ = 0;
	farst_msg_time_ = 0;
	last_server_id_ = 0;

	has_more_ = true;
	is_loading_ = false;

	std::wstring name;
	if (type == nim::kNIMSessionTypeP2P)
		name = UserService::GetInstance()->GetUserName(id);
	else
		name = TeamService::GetInstance()->GetTeamName(id);
	label_title_->SetText(name);
	SetTaskbarTitle(name);

	msg_list_->RemoveAll();
	id_bubble_pair_.clear();

	std::string play_sid = AudioCallback::GetPlaySid();
	std::wstring wsid = nbase::UTF8ToUTF16(play_sid);
	if(GetWindowId() == wsid)
	{
		AudioCallback::SetPlaySid("");
		AudioCallback::SetPlayCid("");

		nim_audio::Audio::StopPlayAudio();
	}

	if (type == nim::kNIMSessionTypeTeam)
	{
		nim::Team::QueryTeamMembersCallback cb = ToWeakCallback([this](const std::string& tid, int member_count, const std::list<nim::TeamMemberProperty>& props) 
		{
			team_member_info_list_.clear();
			for (const auto &info : props)
				team_member_info_list_[info.GetAccountID()] = info;
			ShowMore(false);
		});
		nim::Team::QueryTeamMembersAsync(session_id_, cb);
	}
	else
		ShowMore(false);
}
Example #2
0
bool MsgRecordForm::Notify(ui::EventArgs* param)
{
	std::wstring name = param->pSender->GetName();
	if(param->Type == ui::kEventNotify)
	{
		MsgBubbleItem* item = dynamic_cast<MsgBubbleItem*>( param->pSender );
		assert(item);
		nim::IMMessage md = item->GetMsg();

		if(param->wParam == BET_RELOAD)
		{
			item->SetLoadStatus(RS_LOADING);
			nim::NOS::FetchMedia(md, nbase::Bind(&MsgRecordForm::OnDownloadCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4), nim::NOS::ProgressCallback());
		}
	}
	else if(param->Type == ui::kEventScrollChange)
	{
		if(name == L"msg_list")
		{
			bool list_top= (msg_list_->GetScrollPos().cy <= 10);
			if(list_top && has_more_ && !is_loading_)
			{
				is_loading_ = true;

				LoadingTip(true);
				msg_list_->SetScrollPosY(0);

				ShowMore(true);
			}
		}
	}
	return true;
}