diff --git a/storage/storage.cpp b/storage/storage.cpp index 4b65959552..aca35ea81c 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -1130,7 +1130,9 @@ void Storage::GetNodeAttrs(TCountryId const & countryId, NodeAttrs & nodeAttrs) Country const & nodeValue = node->Value(); nodeAttrs.m_mwmCounter = nodeValue.GetSubtreeMwmCounter(); nodeAttrs.m_mwmSize = nodeValue.GetSubtreeMwmSizeBytes(); - nodeAttrs.m_status = NodeStatus(*node); + TStatusAndError statusAndErr = ParseStatus(NodeStatus(*node)); + nodeAttrs.m_status = statusAndErr.first; + nodeAttrs.m_error = statusAndErr.second; // @TODO(bykoianko) NodeAttrs::m_nodeLocalName should be in local language. nodeAttrs.m_nodeLocalName = countryId; } diff --git a/storage/storage.hpp b/storage/storage.hpp index bf0fe550b5..8c3933a56f 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -22,7 +22,8 @@ namespace storage struct NodeAttrs { NodeAttrs() : m_mwmCounter(0), m_localMwmCounter(0), m_mwmSize(0), m_localMwmSize(0), - m_downloadingMwmSize(0), m_downloadingProgress(0), m_status(TStatus::EUndefined) {} + m_downloadingMwmSize(0), m_downloadingProgress(0), + m_status(TNodeStatus::Undefined), m_error(TErrNodeStatus::NoError) {} /// If the node is expandable (a big country) |m_mwmCounter| is number of mwm files (leaves) /// belongs to the node. If the node isn't expandable |m_mapsDownloaded| == 1. uint32_t m_mwmCounter; @@ -62,7 +63,8 @@ struct NodeAttrs /// |m_downloadingProgress| == 0. uint8_t m_downloadingProgress; - TStatus m_status; + TNodeStatus m_status; + TErrNodeStatus m_error; }; /// This class is used for downloading, updating and deleting maps. diff --git a/storage/storage_defines.cpp b/storage/storage_defines.cpp index 8f22f67e20..861304f7c2 100644 --- a/storage/storage_defines.cpp +++ b/storage/storage_defines.cpp @@ -28,4 +28,69 @@ string DebugPrint(TStatus status) return string("EMixed"); } } + +string DebugPrint(TNodeStatus status) +{ + switch (status) + { + case TNodeStatus::Undefined: + return string("Undefined"); + case TNodeStatus::Error: + return string("Error"); + case TNodeStatus::OnDisk: + return string("OnDisk"); + case TNodeStatus::NotDownloaded: + return string("NotDownloaded"); + case TNodeStatus::Downloading: + return string("Downloading"); + case TNodeStatus::InQueue: + return string("InQueue"); + case TNodeStatus::OnDiskOutOfDate: + return string("OnDiskOutOfDate"); + case TNodeStatus::Mixed: + return string("Mixed"); + } +} + +string DebugPrint(TErrNodeStatus status) +{ + switch (status) + { + case TErrNodeStatus::NoError: + return string("NoError"); + case TErrNodeStatus::UnknownError: + return string("UnknownError"); + case TErrNodeStatus::OutOfMemFailed: + return string("OutOfMemFailed"); + case TErrNodeStatus::NoInetConnection: + return string("NoInetConnection"); + } +} + +TStatusAndError ParseStatus(TStatus innerStatus) +{ + switch (innerStatus) + { + case TStatus::EUndefined: + return TStatusAndError(TNodeStatus::Undefined, TErrNodeStatus::NoError); + case TStatus::EOnDisk: + return TStatusAndError(TNodeStatus::OnDisk, TErrNodeStatus::NoError); + case TStatus::ENotDownloaded: + return TStatusAndError(TNodeStatus::NotDownloaded, TErrNodeStatus::NoError); + case TStatus::EDownloadFailed: + return TStatusAndError(TNodeStatus::Error, TErrNodeStatus::NoInetConnection); + case TStatus::EDownloading: + return TStatusAndError(TNodeStatus::Downloading, TErrNodeStatus::NoError); + case TStatus::EInQueue: + return TStatusAndError(TNodeStatus::InQueue, TErrNodeStatus::NoError); + case TStatus::EUnknown: + return TStatusAndError(TNodeStatus::Error, TErrNodeStatus::UnknownError); + case TStatus::EOnDiskOutOfDate: + return TStatusAndError(TNodeStatus::OnDiskOutOfDate, TErrNodeStatus::NoError); + case TStatus::EOutOfMemFailed: + return TStatusAndError(TNodeStatus::Error, TErrNodeStatus::OutOfMemFailed); + case TStatus::EMixed: + return TStatusAndError(TNodeStatus::Mixed, TErrNodeStatus::NoError); + } +} } // namespace storage diff --git a/storage/storage_defines.hpp b/storage/storage_defines.hpp index 918d383807..06d63d3551 100644 --- a/storage/storage_defines.hpp +++ b/storage/storage_defines.hpp @@ -9,7 +9,7 @@ namespace storage { - /// Used in GUI + /// Inner status which is used inside Storage class enum class TStatus : uint8_t { EUndefined = 0, @@ -23,10 +23,34 @@ namespace storage EOutOfMemFailed, /**< Downloading failed because it's not enough memory */ EMixed, /**< Descendants of a group node have different statuses. */ }; - string DebugPrint(TStatus status); - typedef pair LocalAndRemoteSizeT; + enum class TNodeStatus + { + Undefined, + Error, /**< An error happened while downloading */ + OnDisk, /**< Downloaded mwm(s) is up to date. No need to update it. */ + NotDownloaded, /**< Mwm can be download but not downloaded yet. */ + Downloading, /**< Downloading a new mwm or updating an old one. */ + InQueue, /**< A mwm is waiting for downloading in the queue. */ + OnDiskOutOfDate, /**< An update for a downloaded mwm is ready according to counties.txt. */ + Mixed, /**< Descendants of a group node have different statuses. */ + }; + string DebugPrint(TNodeStatus status); + + enum class TErrNodeStatus + { + NoError, + UnknownError, /**< Downloading failed because of unknown error. */ + OutOfMemFailed, /**< Downloading failed because it's not enough memory */ + NoInetConnection, /**< Downloading failed because internet connection was interrupted */ + }; + string DebugPrint(TErrNodeStatus status); + + using TStatusAndError = pair; + using LocalAndRemoteSizeT = pair; + + TStatusAndError ParseStatus(TStatus innerStatus); } // namespace storage using TDownloadFn = function;