PageRenderTime 167ms CodeModel.GetById 13ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/viewer_components/updater/llupdaterservice.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 108 lines | 60 code | 17 blank | 31 comment | 0 complexity | 6c9ed8789dd2622e17095c926fae21ed MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llupdaterservice.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_UPDATERSERVICE_H
  26. #define LL_UPDATERSERVICE_H
  27. #include <boost/shared_ptr.hpp>
  28. #include <boost/function.hpp>
  29. class LLUpdaterServiceImpl;
  30. class LLUpdaterService
  31. {
  32. public:
  33. class UsageError: public std::runtime_error
  34. {
  35. public:
  36. UsageError(const std::string& msg) : std::runtime_error(msg) {}
  37. };
  38. // Name of the event pump through which update events will be delivered.
  39. static std::string const & pumpName(void);
  40. // Returns true if an update has been completely downloaded and is now ready to install.
  41. static bool updateReadyToInstall(void);
  42. // Type codes for events posted by this service. Stored the event's 'type' element.
  43. enum eUpdaterEvent {
  44. INVALID,
  45. DOWNLOAD_COMPLETE,
  46. DOWNLOAD_ERROR,
  47. INSTALL_ERROR,
  48. PROGRESS,
  49. STATE_CHANGE
  50. };
  51. enum eUpdaterState {
  52. INITIAL,
  53. CHECKING_FOR_UPDATE,
  54. TEMPORARY_ERROR,
  55. DOWNLOADING,
  56. INSTALLING,
  57. UP_TO_DATE,
  58. TERMINAL,
  59. FAILURE
  60. };
  61. LLUpdaterService();
  62. ~LLUpdaterService();
  63. void initialize(const std::string& protocol_version,
  64. const std::string& url,
  65. const std::string& path,
  66. const std::string& channel,
  67. const std::string& version);
  68. void setCheckPeriod(unsigned int seconds);
  69. void setBandwidthLimit(U64 bytesPerSecond);
  70. void startChecking(bool install_if_ready = false);
  71. void stopChecking();
  72. bool isChecking();
  73. eUpdaterState getState();
  74. typedef boost::function<void (void)> app_exit_callback_t;
  75. template <typename F>
  76. void setAppExitCallback(F const &callable)
  77. {
  78. app_exit_callback_t aecb = callable;
  79. setImplAppExitCallback(aecb);
  80. }
  81. // If an update is or has been downloaded, this method will return the
  82. // version string for that update. An empty string will be returned
  83. // otherwise.
  84. std::string updatedVersion(void);
  85. private:
  86. boost::shared_ptr<LLUpdaterServiceImpl> mImpl;
  87. void setImplAppExitCallback(app_exit_callback_t aecb);
  88. };
  89. // Returns the full version as a string.
  90. std::string const & ll_get_version(void);
  91. #endif // LL_UPDATERSERVICE_H