{"action":"created","comment":{"url":"https://api.github.com/repos/mapsme/omim/pulls/comments/46974646","id":46974646,"diff_hunk":"@@ -0,0 +1,195 @@\n+#pragma once\n+\n+#include \"geometry/point2d.hpp\"\n+\n+#include \"std/string.hpp\"\n+#include \"std/vector.hpp\"\n+\n+namespace storage\n+{\n+/// This class is responsible for downloading, updating and deleting maps.\n+/// It represents the interface which can be used by clients (Android/iOS).\n+class MapDownloader\n+{\n+public:\n+\n+  /// \\brief Contains all properties for an mwm on the server.\n+  struct ServerMwmAttr\n+  {\n+    size_t m_mwmSize;\n+  };\n+\n+  /// \\brief This enume discribs statuses of downloaded mwms.\n+  enum class ClientMwmStatus\n+  {\n+    UpToDate,  /**< Downloaded mwm is up to date. No need update it. */\n+    DownloadingInProcess,  /**< Downloading a new mwm is in process */\n+    DownloadWasPaused,  /**< Downloading was paused or stopped by some reasons. E.g lost connection. */\n+    NeedsToUpdate,  /**< An update for downloaded mwm is ready according to county_attributes.txt. */\n+    UpdatingInProcess,  /**< Downloading a mwm for update is in process */\n+    UpdateWasPaused,  /**< Downloading a mwm for update paused or stopped by some reasons. */\n+  };\n+\n+  /// \\brief Contains all properties for a downloaded mwm.\n+  struct ClientMwmAttr\n+  {\n+    size_t m_mwmSize;\n+    size_t m_mwmVersion;\n+    /// A number for 0 to 100. It reflects downloading progress in case of\n+    /// downloading and updating mwm.\n+    unsigned char m_downloadingProgress;\n+    ClientMwmStatus m_status;\n+  };\n+\n+  /// \\brief Contains all properties for groups mwm.\n+  struct ClientMwmGroupAttr\n+  {\n+    /// Size of all mwms which are downloaded in a group.\n+    size_t m_mwmGroupSize;\n+    /// A number for 0 to 100. It reflects downloading progress of a group in case of\n+    /// downloading and updating one of mwm in the group.\n+    unsigned char m_downloadingProgress;\n+    ClientMwmStatus m_status;\n+  };\n+\n+  /// \\brief Map downloader list can contain two kinds of items:\n+  /// * mwm\n+  /// * groups of mwm like counties\n+  enum class ListItemType\n+  {\n+    NotItem,  /**< Reflects the situation when an incorrect mwmID is passed to GetItemType() */\n+    Mwm,  /**< Mwm item of map downloader. */\n+    MwmGroup  /**< Mwm group item (e.g a bin country) of map downloader. */\n+  };\n+\n+  /// \\brief Error code of MapDownloader.\n+  enum class ErrorCode\n+  {\n+    NoError, /**< An operation was finished without errors. */\n+    MwmIdNotCorrect,  /**< Incorrect mwm id or incorrect mwm group id is passed to a method. */\n+    NotEnoughSpace,  /**< No space on flash memory to download a file. */\n+    NoInternetConnection,  /**< No internet connection. */\n+    NoFile,  /**< No file on flash memory. I.e. the mwm you tried to delete not available. */\n+    UpdateNotAvailable,  /**< A try of update for a mwm which does not have any updates. */\n+    MwmIsNotDownloading,  /**< A try of cancelation mwm downloading in case the mwm is not being downloaded */\n+    MwmHasNotDownloaded,  /**< A try of deletion a mwm in case the mwm is not downloaded */\n+  };\n+\n+  /// \\brief Information for update all mwm button.\n+  struct UpdateInfo\n+  {\n+    size_t m_mwmToUpdateCounter;\n+    size_t m_sizeToUpdateBytes;\n+  };\n+\n+  /// \\brief This structure should be implemented by a client. Methods of this stucture\n+  /// is called by MapDownloader in some appropriate time.\n+  struct StatusCallbacks\n+  {\n+    /// \\brief This method is a callback. It is called by MapDownloader when status of mwm\n+    /// or a group of mwm is changed. If it's method is called for a mwm it'll be called for\n+    /// every its parent and grand parets.\n+    /// \\param mwmId mwm id or mwm group id which status has been changed.\n+    virtual void OnStatusChanged(string const & mwmId) = 0;\n+    /// \\brief It is called when an error happend while async operation.\n+    virtual void OnError(ErrorCode errCode) = 0;\n+  };\n+\n+  /// \\brief Initializing MapDownloader. Initializing mwm hierarchy graph based on county_hierarchy.txt\n+  /// and mwm attributes (like size, version and so on) based on county_attributes.txt and\n+  /// downloaded mwm(s).\n+  MapDownloader(string const & countryHierarchyFile, string const & countryAttributesFile,\n+                string const & mwmDir);\n+\n+  /// \\brief Returns root id (group id or mwm id) of the county tree.\n+  string const GetRootId() const;\n+  /// \\brief Returns children ids (group ids or mwm ids) by a parent. For example GetChildren(GetRootId())\n+  /// returns all counties ids. It's the content of map downloader list by default.\n+  vector<string> const GetChildren(string const & parent) const;\n+  /// \\brief Returns children ids (group ids or mwm ids) by a parent for downloaded mwms.\n+  /// The result of the method is composed in a special way because of design requirements.\n+  /// If a direct child (of parent) contains two or more downloaded mwms the direct child id will be add to result.\n+  /// If a direct child (of parent) contains one downloaded mwm the mwm id will be add to result.\n+  /// If there's no downloaded mwms contained by a direct child the direct child id will not be add to result.\n+  /// Returns an empty vector if parent some unknown string.\n+  vector<string> const GetDownloadedChildren(string const & parent) const;\n+\n+  /// \\brief Returns mwm ids by position in mercator. Find all mwms which are closest to position.\n+  /// Returns an empty vector if position is not valid.\n+  vector<string> const FindMwmsByPosition(m2::PointD const & position) const;\n+  /// \\brief Returns mwm ids by a region name in a locale language. Finds in world mwm with name.\n+  /// Returns an empty vector if nothing found with name.\n+  vector<string> const FindMwmsByName(string const & name) const;\n+\n+  /// \\brief Returns current version for mwms which are available on the server.\n+  /// That means the version is written in county_attributes.txt\n+  size_t GetMwmServerVersion() const;\n+  /// \\brief Returns true if the mwm with mwmId (or one of mwm in the group)\n+  /// has been downloaded and false othewise.\n+  /// Returns false if mwmId is an unknown string.\n+  bool hasMwmDownloaded(string const & mwmId) const;","path":"storage/map_downloader.hpp","position":130,"original_position":130,"commit_id":"9e65b445f28de29d81ee9845b20c6f244296bb36","original_commit_id":"9e65b445f28de29d81ee9845b20c6f244296bb36","user":{"login":"bykoianko","id":1768114,"avatar_url":"https://avatars.githubusercontent.com/u/1768114?v=3","gravatar_id":"","url":"https://api.github.com/users/bykoianko","html_url":"https://github.com/bykoianko","followers_url":"https://api.github.com/users/bykoianko/followers","following_url":"https://api.github.com/users/bykoianko/following{/other_user}","gists_url":"https://api.github.com/users/bykoianko/gists{/gist_id}","starred_url":"https://api.github.com/users/bykoianko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bykoianko/subscriptions","organizations_url":"https://api.github.com/users/bykoianko/orgs","repos_url":"https://api.github.com/users/bykoianko/repos","events_url":"https://api.github.com/users/bykoianko/events{/privacy}","received_events_url":"https://api.github.com/users/bykoianko/received_events","type":"User","site_admin":false},"body":"Да. Спасибо!","created_at":"2015-12-08T16:19:56Z","updated_at":"2015-12-08T16:19:56Z","html_url":"https://github.com/mapsme/omim/pull/896#discussion_r46974646","pull_request_url":"https://api.github.com/repos/mapsme/omim/pulls/896","_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments/46974646"},"html":{"href":"https://github.com/mapsme/omim/pull/896#discussion_r46974646"},"pull_request":{"href":"https://api.github.com/repos/mapsme/omim/pulls/896"}}},"pull_request":{"url":"https://api.github.com/repos/mapsme/omim/pulls/896","id":52986054,"html_url":"https://github.com/mapsme/omim/pull/896","diff_url":"https://github.com/mapsme/omim/pull/896.diff","patch_url":"https://github.com/mapsme/omim/pull/896.patch","issue_url":"https://api.github.com/repos/mapsme/omim/issues/896","number":896,"state":"open","locked":false,"title":"[DO NOT MERGE] Map downloader programming interface.","user":{"login":"bykoianko","id":1768114,"avatar_url":"https://avatars.githubusercontent.com/u/1768114?v=3","gravatar_id":"","url":"https://api.github.com/users/bykoianko","html_url":"https://github.com/bykoianko","followers_url":"https://api.github.com/users/bykoianko/followers","following_url":"https://api.github.com/users/bykoianko/following{/other_user}","gists_url":"https://api.github.com/users/bykoianko/gists{/gist_id}","starred_url":"https://api.github.com/users/bykoianko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bykoianko/subscriptions","organizations_url":"https://api.github.com/users/bykoianko/orgs","repos_url":"https://api.github.com/users/bykoianko/repos","events_url":"https://api.github.com/users/bykoianko/events{/privacy}","received_events_url":"https://api.github.com/users/bykoianko/received_events","type":"User","site_admin":false},"body":"https://trello.com/c/1pDSwweA/2159--\r\n\r\nПодготовлен программный интерфейс загрузчика и описание с подробными комментариями.\r\nЯ готовлю следующим коммитом фейковоую реализацию методов загрузчика. Чтоб коллеги по платформам могли его использовать. А пока можно комментировать интерфейс.\r\n\r\nПодробная документация: https://docs.google.com/document/d/1Dvl2r0RzA3MeHYa4UqKjrZLNWicRUOyBMGi_RIeZAE0/edit\r\n\r\nОсобо прошу посмотреть @yunikkk @igrechuhin @vng @deathbaba \r\n","created_at":"2015-12-08T14:22:15Z","updated_at":"2015-12-08T16:19:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"76b629ad71805115241c74bfc6e2153b37eda10b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mapsme/omim/pulls/896/commits","review_comments_url":"https://api.github.com/repos/mapsme/omim/pulls/896/comments","review_comment_url":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapsme/omim/issues/896/comments","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/9e65b445f28de29d81ee9845b20c6f244296bb36","head":{"label":"bykoianko:map-downloader-new-downloader-programming-interface","ref":"map-downloader-new-downloader-programming-interface","sha":"9e65b445f28de29d81ee9845b20c6f244296bb36","user":{"login":"bykoianko","id":1768114,"avatar_url":"https://avatars.githubusercontent.com/u/1768114?v=3","gravatar_id":"","url":"https://api.github.com/users/bykoianko","html_url":"https://github.com/bykoianko","followers_url":"https://api.github.com/users/bykoianko/followers","following_url":"https://api.github.com/users/bykoianko/following{/other_user}","gists_url":"https://api.github.com/users/bykoianko/gists{/gist_id}","starred_url":"https://api.github.com/users/bykoianko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bykoianko/subscriptions","organizations_url":"https://api.github.com/users/bykoianko/orgs","repos_url":"https://api.github.com/users/bykoianko/repos","events_url":"https://api.github.com/users/bykoianko/events{/privacy}","received_events_url":"https://api.github.com/users/bykoianko/received_events","type":"User","site_admin":false},"repo":{"id":43428862,"name":"omim","full_name":"bykoianko/omim","owner":{"login":"bykoianko","id":1768114,"avatar_url":"https://avatars.githubusercontent.com/u/1768114?v=3","gravatar_id":"","url":"https://api.github.com/users/bykoianko","html_url":"https://github.com/bykoianko","followers_url":"https://api.github.com/users/bykoianko/followers","following_url":"https://api.github.com/users/bykoianko/following{/other_user}","gists_url":"https://api.github.com/users/bykoianko/gists{/gist_id}","starred_url":"https://api.github.com/users/bykoianko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bykoianko/subscriptions","organizations_url":"https://api.github.com/users/bykoianko/orgs","repos_url":"https://api.github.com/users/bykoianko/repos","events_url":"https://api.github.com/users/bykoianko/events{/privacy}","received_events_url":"https://api.github.com/users/bykoianko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bykoianko/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":true,"url":"https://api.github.com/repos/bykoianko/omim","forks_url":"https://api.github.com/repos/bykoianko/omim/forks","keys_url":"https://api.github.com/repos/bykoianko/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bykoianko/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bykoianko/omim/teams","hooks_url":"https://api.github.com/repos/bykoianko/omim/hooks","issue_events_url":"https://api.github.com/repos/bykoianko/omim/issues/events{/number}","events_url":"https://api.github.com/repos/bykoianko/omim/events","assignees_url":"https://api.github.com/repos/bykoianko/omim/assignees{/user}","branches_url":"https://api.github.com/repos/bykoianko/omim/branches{/branch}","tags_url":"https://api.github.com/repos/bykoianko/omim/tags","blobs_url":"https://api.github.com/repos/bykoianko/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bykoianko/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bykoianko/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/bykoianko/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bykoianko/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/bykoianko/omim/languages","stargazers_url":"https://api.github.com/repos/bykoianko/omim/stargazers","contributors_url":"https://api.github.com/repos/bykoianko/omim/contributors","subscribers_url":"https://api.github.com/repos/bykoianko/omim/subscribers","subscription_url":"https://api.github.com/repos/bykoianko/omim/subscription","commits_url":"https://api.github.com/repos/bykoianko/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/bykoianko/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/bykoianko/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/bykoianko/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/bykoianko/omim/contents/{+path}","compare_url":"https://api.github.com/repos/bykoianko/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bykoianko/omim/merges","archive_url":"https://api.github.com/repos/bykoianko/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bykoianko/omim/downloads","issues_url":"https://api.github.com/repos/bykoianko/omim/issues{/number}","pulls_url":"https://api.github.com/repos/bykoianko/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/bykoianko/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/bykoianko/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bykoianko/omim/labels{/name}","releases_url":"https://api.github.com/repos/bykoianko/omim/releases{/id}","created_at":"2015-09-30T11:21:20Z","updated_at":"2015-09-30T11:23:30Z","pushed_at":"2015-12-08T14:11:16Z","git_url":"git://github.com/bykoianko/omim.git","ssh_url":"git@github.com:bykoianko/omim.git","clone_url":"https://github.com/bykoianko/omim.git","svn_url":"https://github.com/bykoianko/omim","homepage":null,"size":1902335,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mapsme:map-downloader","ref":"map-downloader","sha":"dc20a9db68d96b34b747b2cee4de88e6e0d8ae84","user":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"repo":{"id":42798033,"name":"omim","full_name":"mapsme/omim","owner":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapsme/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":false,"url":"https://api.github.com/repos/mapsme/omim","forks_url":"https://api.github.com/repos/mapsme/omim/forks","keys_url":"https://api.github.com/repos/mapsme/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapsme/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapsme/omim/teams","hooks_url":"https://api.github.com/repos/mapsme/omim/hooks","issue_events_url":"https://api.github.com/repos/mapsme/omim/issues/events{/number}","events_url":"https://api.github.com/repos/mapsme/omim/events","assignees_url":"https://api.github.com/repos/mapsme/omim/assignees{/user}","branches_url":"https://api.github.com/repos/mapsme/omim/branches{/branch}","tags_url":"https://api.github.com/repos/mapsme/omim/tags","blobs_url":"https://api.github.com/repos/mapsme/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapsme/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapsme/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapsme/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/mapsme/omim/languages","stargazers_url":"https://api.github.com/repos/mapsme/omim/stargazers","contributors_url":"https://api.github.com/repos/mapsme/omim/contributors","subscribers_url":"https://api.github.com/repos/mapsme/omim/subscribers","subscription_url":"https://api.github.com/repos/mapsme/omim/subscription","commits_url":"https://api.github.com/repos/mapsme/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapsme/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapsme/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapsme/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapsme/omim/contents/{+path}","compare_url":"https://api.github.com/repos/mapsme/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapsme/omim/merges","archive_url":"https://api.github.com/repos/mapsme/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapsme/omim/downloads","issues_url":"https://api.github.com/repos/mapsme/omim/issues{/number}","pulls_url":"https://api.github.com/repos/mapsme/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/mapsme/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/mapsme/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapsme/omim/labels{/name}","releases_url":"https://api.github.com/repos/mapsme/omim/releases{/id}","created_at":"2015-09-20T02:57:13Z","updated_at":"2015-12-07T21:50:58Z","pushed_at":"2015-12-08T16:15:14Z","git_url":"git://github.com/mapsme/omim.git","ssh_url":"git@github.com:mapsme/omim.git","clone_url":"https://github.com/mapsme/omim.git","svn_url":"https://github.com/mapsme/omim","homepage":null,"size":1939108,"stargazers_count":1517,"watchers_count":1517,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":187,"mirror_url":null,"open_issues_count":70,"forks":187,"open_issues":70,"watchers":1517,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/896"},"html":{"href":"https://github.com/mapsme/omim/pull/896"},"issue":{"href":"https://api.github.com/repos/mapsme/omim/issues/896"},"comments":{"href":"https://api.github.com/repos/mapsme/omim/issues/896/comments"},"review_comments":{"href":"https://api.github.com/repos/mapsme/omim/pulls/896/comments"},"review_comment":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapsme/omim/pulls/896/commits"},"statuses":{"href":"https://api.github.com/repos/mapsme/omim/statuses/9e65b445f28de29d81ee9845b20c6f244296bb36"}}}}