MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / requestProfileMusic

Method requestProfileMusic

Telegram/SourceFiles/export/export_api_wrap.cpp:1129–1162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1127}
1128
1129void ApiWrap::requestProfileMusic(
1130 FnMut<bool(Data::ProfileMusicInfo&&)> start,
1131 Fn<bool(DownloadProgress)> progress,
1132 Fn<bool(Data::ProfileMusicSlice&&)> slice,
1133 FnMut<void()> finish) {
1134 Expects(_profileMusicProcess == nullptr);
1135
1136 _profileMusicProcess = std::make_unique<ProfileMusicProcess>();
1137 _profileMusicProcess->start = std::move(start);
1138 _profileMusicProcess->fileProgress = std::move(progress);
1139 _profileMusicProcess->handleSlice = std::move(slice);
1140 _profileMusicProcess->finish = std::move(finish);
1141
1142 mainRequest(MTPusers_GetSavedMusic(
1143 _user,
1144 MTP_int(0), // offset
1145 MTP_int(kProfileMusicSliceLimit), // limit
1146 MTP_long(0) // hash
1147 )).done([=](const MTPusers_SavedMusic &result) mutable {
1148 Expects(_profileMusicProcess != nullptr);
1149
1150 auto startInfo = result.match(
1151 [](const MTPDusers_savedMusic &data) {
1152 return Data::ProfileMusicInfo{ data.vcount().v };
1153 }, [](const MTPDusers_savedMusicNotModified &data) {
1154 return Data::ProfileMusicInfo{ 0 };
1155 });
1156 if (!_profileMusicProcess->start(std::move(startInfo))) {
1157 return;
1158 }
1159
1160 handleProfileMusicSlice(result);
1161 }).send();
1162}
1163
1164void ApiWrap::handleProfileMusicSlice(const MTPusers_SavedMusic &result) {
1165 Expects(_profileMusicProcess != nullptr);

Callers 1

exportProfileMusicMethod · 0.80

Calls 5

MTP_longFunction · 0.85
MTP_intFunction · 0.50
sendMethod · 0.45
doneMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected