| 3173 | } |
| 3174 | |
| 3175 | void BookmarkManager::PrepareFileForSharing(kml::GroupIdCollection && categoriesIds, SharingHandler && handler, |
| 3176 | KmlFileType kmlFileType) |
| 3177 | { |
| 3178 | CHECK_THREAD_CHECKER(m_threadChecker, ()); |
| 3179 | ASSERT(handler, ()); |
| 3180 | if (categoriesIds.size() == 1 && IsCategoryEmpty(categoriesIds.front())) |
| 3181 | { |
| 3182 | handler(SharingResult(std::move(categoriesIds), SharingResult::Code::EmptyCategory)); |
| 3183 | return; |
| 3184 | } |
| 3185 | |
| 3186 | auto collection = PrepareToSaveBookmarks(categoriesIds); |
| 3187 | if (!collection || collection->empty()) |
| 3188 | { |
| 3189 | handler(SharingResult(std::move(categoriesIds), SharingResult::Code::FileError)); |
| 3190 | return; |
| 3191 | } |
| 3192 | |
| 3193 | if (m_testModeEnabled) |
| 3194 | { |
| 3195 | handler(GetFileForSharing(std::move(collection), kmlFileType)); |
| 3196 | } |
| 3197 | else |
| 3198 | { |
| 3199 | GetPlatform().RunTask(Platform::Thread::File, [collection = std::move(collection), handler = std::move(handler), |
| 3200 | kmlFileType = kmlFileType]() mutable |
| 3201 | { handler(GetFileForSharing(std::move(collection), kmlFileType)); }); |
| 3202 | } |
| 3203 | } |
| 3204 | |
| 3205 | void BookmarkManager::PrepareAllFilesForSharing(SharingHandler && handler) |
| 3206 | { |