machine_deal.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. //
  5. // Library functions related to the OEM Deal Confirmation Code.
  6. #ifndef RLZ_WIN_LIB_MACHINE_DEAL_H_
  7. #define RLZ_WIN_LIB_MACHINE_DEAL_H_
  8. #include "rlz/lib/rlz_enums.h"
  9. namespace rlz_lib {
  10. class MachineDealCode {
  11. public:
  12. // Set the OEM Deal Confirmation Code (DCC). This information is used for RLZ
  13. // initalization. Must have write access to HKLM - SYSTEM or admin, unless
  14. // rlz_lib::CreateMachineState() has been successfully called.
  15. static bool Set(const char* dcc);
  16. // Get the OEM Deal Confirmation Code from the registry. Used to ping
  17. // the server.
  18. static bool Get(AccessPoint point,
  19. char* dcc,
  20. int dcc_size,
  21. const wchar_t* sid = nullptr);
  22. // Parses a ping response, checks if it is valid and sets the machine DCC
  23. // from the response. The response should also contain the current value of
  24. // the DCC to be considered valid.
  25. // Write access to HKLM (system / admin) needed, unless
  26. // rlz_lib::CreateMachineState() has been successfully called.
  27. static bool SetFromPingResponse(const char* response);
  28. // Gets the new DCC to set from a ping response. Returns true if the ping
  29. // response is valid. Sets has_new_dcc true if there is a new DCC value.
  30. static bool GetNewCodeFromPingResponse(const char* response,
  31. bool* has_new_dcc,
  32. char* new_dcc,
  33. int new_dcc_size);
  34. // Get the DCC cgi argument string to append to a daily or financial ping.
  35. static bool GetAsCgi(char* cgi, int cgi_size);
  36. // Get the machine code.
  37. static bool Get(char* dcc, int dcc_size);
  38. protected:
  39. // Clear the DCC value. Only for testing purposes.
  40. // Requires write access to HKLM, unless rlz_lib::CreateMachineState() has
  41. // been successfully called.
  42. static bool Clear();
  43. MachineDealCode() {}
  44. ~MachineDealCode() {}
  45. };
  46. } // namespace rlz_lib
  47. #endif // RLZ_WIN_LIB_MACHINE_DEAL_H_