PageRenderTime 35ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/viewer_components/updater/llupdatedownloader.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 94 lines | 29 code | 19 blank | 46 comment | 0 complexity | e52700deb6249c581d6ebde2b2ff8028 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llupdatedownloader.h
  3. *
  4. * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  5. * Second Life Viewer Source Code
  6. * Copyright (C) 2010, Linden Research, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License only.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  23. * $/LicenseInfo$
  24. */
  25. #ifndef LL_UPDATE_DOWNLOADER_H
  26. #define LL_UPDATE_DOWNLOADER_H
  27. #include <string>
  28. #include <boost/shared_ptr.hpp>
  29. #include "lluri.h"
  30. //
  31. // An asynchronous download service for fetching updates.
  32. //
  33. class LLUpdateDownloader
  34. {
  35. public:
  36. class Client;
  37. class Implementation;
  38. // Returns the path to the download marker file containing details of the
  39. // latest download.
  40. static std::string downloadMarkerPath(void);
  41. LLUpdateDownloader(Client & client);
  42. // Cancel any in progress download; a no op if none is in progress. The
  43. // client will not receive a complete or error callback.
  44. void cancel(void);
  45. // Start a new download.
  46. void download(LLURI const & uri,
  47. std::string const & hash,
  48. std::string const & updateVersion,
  49. bool required=false);
  50. // Returns true if a download is in progress.
  51. bool isDownloading(void);
  52. // Resume a partial download.
  53. void resume(void);
  54. // Set a limit on the dowload rate.
  55. void setBandwidthLimit(U64 bytesPerSecond);
  56. private:
  57. boost::shared_ptr<Implementation> mImplementation;
  58. };
  59. //
  60. // An interface to be implemented by clients initiating a update download.
  61. //
  62. class LLUpdateDownloader::Client {
  63. public:
  64. // The download has completed successfully.
  65. // data is a map containing the following items:
  66. // url - source (remote) location
  67. // hash - the md5 sum that should match the installer file.
  68. // path - destination (local) location
  69. // required - boolean indicating if this is a required update.
  70. // size - the size of the installer in bytes
  71. virtual void downloadComplete(LLSD const & data) = 0;
  72. // The download failed.
  73. virtual void downloadError(std::string const & message) = 0;
  74. };
  75. #endif