UpdateManager.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2002-2009 Moxie Marlinspike
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 3 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  17. * USA
  18. */
  19. #ifndef __UPDATE_MANAGER_H__
  20. #define __UPDATE_MANAGER_H__
  21. #include <string>
  22. #include <list>
  23. #include <boost/asio.hpp>
  24. using namespace boost::asio;
  25. class UpdateManager {
  26. private:
  27. static UpdateManager* updateManager;
  28. std::list<boost::asio::ip::address> updateAddresses;
  29. std::list<boost::asio::ip::address> addonsAddresses;
  30. std::string updatePath;
  31. std::string addonPath;
  32. std::string addonHash;
  33. bool isAddressInList(ip::tcp::endpoint &endpoint, std::list<boost::asio::ip::address> addresses);
  34. UpdateManager() {}
  35. public:
  36. static UpdateManager* getInstance();
  37. void initialize(std::string &updatePath, std::string &addonPath, std::string &addonHash);
  38. bool isUpdatableRequest(std::string &buildId, std::string &buildTarget);
  39. bool isUpdateTarget(boost::asio::ip::tcp::endpoint &endpoint);
  40. bool isAddonTarget(ip::tcp::endpoint &endpoint);
  41. void getUpdatePath(std::string &buildTarget, std::string &result);
  42. std::string getAddonPath();
  43. std::string getAddonHash();
  44. };
  45. #endif