forked from organicmaps/organicmaps
Added bookmarks cloud property to the lightweight framework
This commit is contained in:
parent
f97d838969
commit
0aa1d0e7ec
5 changed files with 46 additions and 9 deletions
|
@ -50,6 +50,7 @@ std::string const kLastBookmarkType = "LastBookmarkType";
|
|||
std::string const kLastEditedBookmarkColor = "LastBookmarkColor";
|
||||
std::string const kDefaultBookmarksFileName = "Bookmarks";
|
||||
std::string const kHotelsBookmarks = "Hotels";
|
||||
std::string const kBookmarkCloudSettingsParam = "BookmarkCloudParam";
|
||||
|
||||
// Returns extension with a dot in a lower case.
|
||||
std::string GetFileExt(std::string const & filePath)
|
||||
|
@ -459,7 +460,7 @@ BookmarkManager::BookmarkManager(Callbacks && callbacks)
|
|||
: m_callbacks(std::move(callbacks))
|
||||
, m_changesTracker(*this)
|
||||
, m_needTeardown(false)
|
||||
, m_bookmarkCloud(Cloud::CloudParams("bmc.json", "bookmarks", "BookmarkCloudParam",
|
||||
, m_bookmarkCloud(Cloud::CloudParams("bmc.json", "bookmarks", std::string(kBookmarkCloudSettingsParam),
|
||||
GetBookmarksDirectory(), std::string(kKmbExtension),
|
||||
std::bind(&ConvertBeforeUploading, _1, _2),
|
||||
std::bind(&ConvertAfterDownloading, _1, _2)))
|
||||
|
@ -2416,3 +2417,11 @@ void BookmarkManager::EditSession::NotifyChanges()
|
|||
{
|
||||
m_bmManager.NotifyChanges();
|
||||
}
|
||||
|
||||
namespace lightweight
|
||||
{
|
||||
bool IsBookmarksCloudEnabled()
|
||||
{
|
||||
return Cloud::GetCloudState(kBookmarkCloudSettingsParam) == Cloud::State::Enabled;
|
||||
}
|
||||
} // namespace lightweight
|
||||
|
|
|
@ -535,3 +535,8 @@ private:
|
|||
|
||||
DISALLOW_COPY_AND_MOVE(BookmarkManager);
|
||||
};
|
||||
|
||||
namespace lightweight
|
||||
{
|
||||
bool IsBookmarksCloudEnabled();
|
||||
} //namespace lightweight
|
||||
|
|
|
@ -350,14 +350,7 @@ Cloud::Cloud(CloudParams && params)
|
|||
ASSERT(!m_params.m_restoredFileExtension.empty(), ());
|
||||
ASSERT(!m_params.m_restoringFolder.empty(), ());
|
||||
|
||||
int stateValue;
|
||||
if (!settings::Get(m_params.m_settingsParamName, stateValue))
|
||||
{
|
||||
stateValue = static_cast<int>(State::Unknown);
|
||||
settings::Set(m_params.m_settingsParamName, stateValue);
|
||||
}
|
||||
|
||||
m_state = static_cast<State>(stateValue);
|
||||
m_state = GetCloudState(m_params.m_settingsParamName);
|
||||
GetPlatform().RunTask(Platform::Thread::File, [this]() { ReadIndex(); });
|
||||
}
|
||||
|
||||
|
@ -1559,3 +1552,15 @@ void Cloud::ApplyRestoredFiles(std::string const & dirPath, RestoredFilesCollect
|
|||
FinishRestoring(SynchronizationResult::Success, {});
|
||||
});
|
||||
}
|
||||
|
||||
//static
|
||||
Cloud::State Cloud::GetCloudState(std::string const & paramName)
|
||||
{
|
||||
int stateValue;
|
||||
if (!settings::Get(paramName, stateValue))
|
||||
{
|
||||
stateValue = static_cast<int>(State::Unknown);
|
||||
settings::Set(paramName, stateValue);
|
||||
}
|
||||
return static_cast<State>(stateValue);
|
||||
}
|
||||
|
|
|
@ -282,6 +282,8 @@ public:
|
|||
|
||||
void CancelRestoring();
|
||||
|
||||
static State GetCloudState(std::string const & paramName);
|
||||
|
||||
private:
|
||||
struct RestoredFile
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "map/bookmark_manager.hpp"
|
||||
#include "map/user.hpp"
|
||||
|
||||
#include "ugc/storage.hpp"
|
||||
|
@ -16,6 +17,7 @@ enum RequestType
|
|||
REQUEST_TYPE_NUMBER_OF_UNSENT_UGC = 1u << 0,
|
||||
REQUEST_TYPE_USER_AUTH_STATUS = 1u << 1,
|
||||
REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS = 1u << 2,
|
||||
REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED = 1u << 3,
|
||||
};
|
||||
|
||||
using RequestTypeMask = unsigned;
|
||||
|
@ -51,6 +53,12 @@ public:
|
|||
request ^= REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS;
|
||||
}
|
||||
|
||||
if (request & REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED)
|
||||
{
|
||||
m_bookmarksCloudEnabled = IsBookmarksCloudEnabled();
|
||||
request ^= REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED;
|
||||
}
|
||||
|
||||
CHECK_EQUAL(request, REQUEST_TYPE_EMPTY, ("Incorrect mask type:", request));
|
||||
}
|
||||
|
||||
|
@ -62,6 +70,7 @@ private:
|
|||
bool m_userAuthStatus = false;
|
||||
size_t m_numberOfUnsentUGC = 0;
|
||||
size_t m_numberOfUnsentEdits = 0;
|
||||
bool m_bookmarksCloudEnabled = false;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -84,4 +93,11 @@ auto Framework::Get<REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS>() const
|
|||
ASSERT(m_request & REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS, (m_request));
|
||||
return m_numberOfUnsentEdits;
|
||||
}
|
||||
|
||||
template<>
|
||||
auto Framework::Get<REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED>() const
|
||||
{
|
||||
ASSERT(m_request & REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED, (m_request));
|
||||
return m_bookmarksCloudEnabled;
|
||||
}
|
||||
} // namespace lightweight
|
||||
|
|
Loading…
Add table
Reference in a new issue