OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium OS 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 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 |
| 12 // This gathers local system information and prepares info used by the |
| 13 // Omaha request action. |
| 14 |
| 15 namespace chromeos_update_engine { |
| 16 |
| 17 // This struct encapsulates the data Omaha gets for the request. |
| 18 // These strings in this struct should not be XML escaped. |
| 19 struct OmahaRequestParams { |
| 20 OmahaRequestParams() |
| 21 : os_platform(kOsPlatform), os_version(kOsVersion), app_id(kAppId) {} |
| 22 OmahaRequestParams(const std::string& in_machine_id, |
| 23 const std::string& in_user_id, |
| 24 const std::string& in_os_platform, |
| 25 const std::string& in_os_version, |
| 26 const std::string& in_os_sp, |
| 27 const std::string& in_os_board, |
| 28 const std::string& in_app_id, |
| 29 const std::string& in_app_version, |
| 30 const std::string& in_app_lang, |
| 31 const std::string& in_app_track, |
| 32 const std::string& in_update_url) |
| 33 : machine_id(in_machine_id), |
| 34 user_id(in_user_id), |
| 35 os_platform(in_os_platform), |
| 36 os_version(in_os_version), |
| 37 os_sp(in_os_sp), |
| 38 os_board(in_os_board), |
| 39 app_id(in_app_id), |
| 40 app_version(in_app_version), |
| 41 app_lang(in_app_lang), |
| 42 app_track(in_app_track), |
| 43 update_url(in_update_url) {} |
| 44 |
| 45 std::string machine_id; |
| 46 std::string user_id; |
| 47 std::string os_platform; |
| 48 std::string os_version; |
| 49 std::string os_sp; |
| 50 std::string os_board; |
| 51 std::string app_id; |
| 52 std::string app_version; |
| 53 std::string app_lang; |
| 54 std::string app_track; |
| 55 |
| 56 std::string update_url; |
| 57 |
| 58 // Suggested defaults |
| 59 static const char* const kAppId; |
| 60 static const char* const kOsPlatform; |
| 61 static const char* const kOsVersion; |
| 62 static const char* const kUpdateUrl; |
| 63 }; |
| 64 |
| 65 class OmahaRequestDeviceParams : public OmahaRequestParams { |
| 66 public: |
| 67 explicit OmahaRequestDeviceParams() {} |
| 68 |
| 69 // Initializes all the data in the object. Returns true on success, |
| 70 // false otherwise. |
| 71 bool Init(); |
| 72 |
| 73 // For unit-tests. |
| 74 void set_root(const std::string& root) { root_ = root; } |
| 75 |
| 76 private: |
| 77 // Gets a machine-local ID (for now, first MAC address we find). |
| 78 bool GetMachineId(std::string* out_id) const; |
| 79 |
| 80 // Fetches the value for a given key from |
| 81 // /mnt/stateful_partition/etc/lsb-release if possible. Failing that, |
| 82 // it looks for the key in /etc/lsb-release. |
| 83 std::string GetLsbValue(const std::string& key, |
| 84 const std::string& default_value) const; |
| 85 |
| 86 // Gets the machine type (e.g. "i686"). |
| 87 std::string GetMachineType() const; |
| 88 |
| 89 // When reading files, prepend root_ to the paths. Useful for testing. |
| 90 std::string root_; |
| 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(OmahaRequestDeviceParams); |
| 93 }; |
| 94 |
| 95 } // namespace chromeos_update_engine |
| 96 |
| 97 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ |
OLD | NEW |