facade.cpp 737 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "mtproto/facade.h"
  8. #include "storage/localstorage.h"
  9. #include "core/application.h"
  10. #include "main/main_account.h"
  11. namespace MTP {
  12. namespace details {
  13. namespace {
  14. int PauseLevel = 0;
  15. rpl::event_stream<> Unpaused;
  16. } // namespace
  17. bool paused() {
  18. return PauseLevel > 0;
  19. }
  20. void pause() {
  21. ++PauseLevel;
  22. }
  23. void unpause() {
  24. --PauseLevel;
  25. if (!PauseLevel) {
  26. Unpaused.fire({});
  27. }
  28. }
  29. rpl::producer<> unpaused() {
  30. return Unpaused.events();
  31. }
  32. } // namespace details
  33. } // namespace MTP