Пример #1
0
void ApiWrap::requestFullPeer(PeerData *peer) {
	if (!peer || _fullPeerRequests.contains(peer)) return;

	mtpRequestId req;
	if (peer->chat) {
		req = MTP::send(MTPmessages_GetFullChat(MTP_int(App::chatFromPeer(peer->id))), rpcDone(&ApiWrap::gotChatFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	} else {
		req = MTP::send(MTPusers_GetFullUser(peer->asUser()->inputUser), rpcDone(&ApiWrap::gotUserFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	}
	_fullPeerRequests.insert(peer, req);
}
Пример #2
0
void ProfileInner::reorderParticipants() {
	int32 was = _participants.size(), t = unixtime(), onlineCount = 0;
	if (_peerChat && !_peerChat->forbidden) {
		if (_peerChat->count <= 0 || !_peerChat->participants.isEmpty()) {
			_participants.clear();
			for (ParticipantsData::iterator i = _participantsData.begin(), e = _participantsData.end(); i != e; ++i) {
				if (*i) {
					delete *i;
					*i = 0;
				}
			}
			_participants.reserve(_peerChat->participants.size());
			_participantsData.resize(_peerChat->participants.size());
		}
		UserData *self = App::self();
		for (ChatData::Participants::const_iterator i = _peerChat->participants.cbegin(), e = _peerChat->participants.cend(); i != e; ++i) {
			UserData *user = i.key();
			int32 until = user->onlineTill;
			Participants::iterator before = _participants.begin();
			if (user != self) {
				if (before != _participants.end() && (*before) == self) {
					++before;
				}
				while (before != _participants.end() && (*before)->onlineTill >= until) {
					++before;
				}
			}
			_participants.insert(before, user);
			if (until > t) {
				++onlineCount;
			}
		}
		if (_peerChat->count > 0 && _participants.isEmpty() && !_loadingId) {
			_loadingId = MTP::send(MTPmessages_GetFullChat(App::peerToMTP(_peerChat->id).c_peerChat().vchat_id), rpcDone(&ProfileInner::gotFullChat));
			if (_onlineText.isEmpty()) _onlineText = lang(lng_chat_members).arg(_peerChat->count);
		} else if (onlineCount) {
			_onlineText = lang(lng_chat_members_online).arg(_participants.size()).arg(onlineCount);
		} else {
			_onlineText = lang(lng_chat_members).arg(_participants.size());
		}
		loadProfilePhotos(_lastPreload);
	} else {
		_participants.clear();
		if (_peerUser) {
			_onlineText = App::onlineText(_peerUser->onlineTill, t, true);
		} else {
			_onlineText = lang(lng_chat_no_members);
		}
	}
	if (was != _participants.size()) {
		resizeEvent(0);
	}
}
Пример #3
0
void ApiWrap::requestFullPeer(PeerData *peer) {
	if (!peer || _fullPeerRequests.contains(peer)) return;

	mtpRequestId req = 0;
	if (peer->isUser()) {
		req = MTP::send(MTPusers_GetFullUser(peer->asUser()->inputUser), rpcDone(&ApiWrap::gotUserFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	} else if (peer->isChat()) {
		req = MTP::send(MTPmessages_GetFullChat(peer->asChat()->inputChat), rpcDone(&ApiWrap::gotChatFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	} else if (peer->isChannel()) {
		req = MTP::send(MTPchannels_GetFullChannel(peer->asChannel()->inputChannel), rpcDone(&ApiWrap::gotChatFull, peer), rpcFail(&ApiWrap::gotPeerFullFailed, peer));
	}
	if (req) _fullPeerRequests.insert(peer, req);
}
Пример #4
0
ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const PeerData *peer) : TWidget(0),
	_profile(profile), _scroll(scroll), _peer(App::peer(peer->id)),
	_peerUser(_peer->chat ? 0 : _peer->asUser()), _peerChat(_peer->chat ? _peer->asChat() : 0), _hist(App::history(peer->id)),
	_chatAdmin(_peerChat ? (_peerChat->admin == MTP::authedId()) : false),

	// profile
	_nameCache(peer->name),
	_uploadPhoto(this, lang(lng_profile_set_group_photo), st::btnShareContact),
	_addParticipant(this, lang(lng_profile_add_participant), st::btnShareContact),
	_sendMessage(this, lang(lng_profile_send_message), st::btnShareContact),
	_shareContact(this, lang(lng_profile_share_contact), st::btnShareContact),
	_cancelPhoto(this, lang(lng_cancel)),

	a_photo(0),
	_photoOver(false),

	// settings
	_enableNotifications(this, lang(lng_profile_enable_notifications)),
	_clearHistory(this, lang(lng_profile_clear_history)),

	// shared media
	_allMediaTypes(false),
	_mediaShowAll(this, lang(lng_profile_show_all_types)),
	_mediaPhotos(this, QString()),
	_mediaVideos(this, QString()),
	_mediaDocuments(this, QString()),
	_mediaAudios(this, QString()),

	// participants
	_pHeight(st::profileListPhotoSize + st::profileListPadding.height() * 2),
	_kickWidth(st::linkFont->m.width(lang(lng_profile_kick))),
	_selectedRow(-1), _lastPreload(0), _contactId(0),
	_kickOver(0), _kickDown(0), _kickConfirm(0),
	
	_loadingId(0), _menu(0) {

	if (_peerUser) {
		_phoneText = _peerUser->phone.isEmpty() ? QString() : App::formatPhone(_peerUser->phone);
		_loadingId = MTP::send(MTPusers_GetFullUser(_peerUser->inputUser), rpcDone(&ProfileInner::gotFullUser));
	} else if (_peerChat->photoId) {
		PhotoData *ph = App::photo(_peerChat->photoId);
		if (ph->date) {
			_photoLink = TextLinkPtr(new PhotoLink(ph, _peer));
		}
	} else {
		_loadingId = MTP::send(MTPmessages_GetFullChat(App::peerToMTP(_peerChat->id).c_peerChat().vchat_id), rpcDone(&ProfileInner::gotFullChat));
	}

	// profile
	_nameText.setText(st::profileNameFont, _nameCache, _textNameOptions);

	connect(&_uploadPhoto, SIGNAL(clicked()), this, SLOT(onUpdatePhoto()));
	connect(&_addParticipant, SIGNAL(clicked()), this, SLOT(onAddParticipant()));
	connect(&_sendMessage, SIGNAL(clicked()), this, SLOT(onSendMessage()));
	connect(&_shareContact, SIGNAL(clicked()), this, SLOT(onShareContact()));
	connect(&_cancelPhoto, SIGNAL(clicked()), this, SLOT(onUpdatePhotoCancel()));

	connect(App::app(), SIGNAL(peerPhotoDone(PeerId)), this, SLOT(onPhotoUpdateDone(PeerId)));
	connect(App::app(), SIGNAL(peerPhotoFail(PeerId)), this, SLOT(onPhotoUpdateFail(PeerId)));

	connect(App::main(), SIGNAL(peerPhotoChanged(PeerData *)), this, SLOT(peerUpdated(PeerData *)));
	connect(App::main(), SIGNAL(peerUpdated(PeerData *)), this, SLOT(peerUpdated(PeerData *)));
	connect(App::main(), SIGNAL(peerNameChanged(PeerData *, const PeerData::Names &, const PeerData::NameFirstChars &)), this, SLOT(peerUpdated(PeerData *)));

	// settings
	connect(&_enableNotifications, SIGNAL(clicked()), this, SLOT(onEnableNotifications()));
	connect(&_clearHistory, SIGNAL(clicked()), this, SLOT(onClearHistory()));

	// shared media
	connect(&_mediaShowAll, SIGNAL(clicked()), this, SLOT(onMediaShowAll()));
	connect(&_mediaPhotos, SIGNAL(clicked()), this, SLOT(onMediaPhotos()));
	connect(&_mediaVideos, SIGNAL(clicked()), this, SLOT(onMediaVideos()));
	connect(&_mediaDocuments, SIGNAL(clicked()), this, SLOT(onMediaDocuments()));
	connect(&_mediaAudios, SIGNAL(clicked()), this, SLOT(onMediaAudios()));
	_mediaLinks[OverviewPhotos] = &_mediaPhotos;
	_mediaLinks[OverviewVideos] = &_mediaVideos;
	_mediaLinks[OverviewDocuments] = &_mediaDocuments;
	_mediaLinks[OverviewAudios] = &_mediaAudios;
	App::main()->preloadOverviews(_peer);

	App::contextItem(0);

	resizeEvent(0);
	showAll();
}