FirefoxUpdater.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 __FIREFOX_UPDATER_H__
  20. #define __FIREFOX_UPDATER_H__
  21. #include "HTTPSBridge.hpp"
  22. #include <boost/shared_ptr.hpp>
  23. using namespace boost::asio;
  24. class FirefoxUpdateException : public std::exception {
  25. public:
  26. virtual const char* what() const throw() {
  27. return "Error processing firefox update request...";
  28. }
  29. };
  30. class FirefoxUpdater : public HTTPSBridge {
  31. protected:
  32. virtual ip::tcp::endpoint getRemoteEndpoint();
  33. private:
  34. std::string product;
  35. std::string version;
  36. std::string buildId;
  37. std::string buildTarget;
  38. std::string locale;
  39. std::string channel;
  40. std::string filename;
  41. ip::tcp::endpoint &destination;
  42. protected:
  43. virtual bool parseMetaRequest(std::string &request);
  44. public:
  45. FirefoxUpdater(boost::shared_ptr<ip::tcp::socket> clientSocket,
  46. ip::tcp::endpoint &destination)
  47. : HTTPSBridge(clientSocket, NULL), destination(destination)
  48. {}
  49. virtual void sendMetaUpdateResponse();
  50. void readMetaUpdateRequest();
  51. virtual void close();
  52. };
  53. #endif