blob: bb2275d2f78e58389702854bb1348b7ebd18e888 [file] [log] [blame]
Darin Petkova4a8a8c2010-07-15 22:21:12 -07001// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
rspangler@google.com49fdf182009-10-10 00:57:34 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Darin Petkov6a5b3222010-07-13 14:55:28 -07005#include "update_engine/omaha_request_action.h"
Darin Petkov85ced132010-09-01 10:20:56 -07006
Andrew de los Reyes08c4e272010-04-15 14:02:17 -07007#include <inttypes.h>
Darin Petkov85ced132010-09-01 10:20:56 -07008
rspangler@google.com49fdf182009-10-10 00:57:34 +00009#include <sstream>
10
Darin Petkov85ced132010-09-01 10:20:56 -070011#include <base/string_number_conversions.h>
12#include <base/string_util.h>
13#include <base/time.h>
14#include <base/logging.h>
rspangler@google.com49fdf182009-10-10 00:57:34 +000015#include <libxml/parser.h>
16#include <libxml/xpath.h>
17#include <libxml/xpathInternals.h>
18
19#include "update_engine/action_pipe.h"
Darin Petkova4a8a8c2010-07-15 22:21:12 -070020#include "update_engine/omaha_request_params.h"
Darin Petkov1cbd78f2010-07-29 12:38:34 -070021#include "update_engine/prefs_interface.h"
adlr@google.comc98a7ed2009-12-04 18:54:03 +000022#include "update_engine/utils.h"
rspangler@google.com49fdf182009-10-10 00:57:34 +000023
Darin Petkov1cbd78f2010-07-29 12:38:34 -070024using base::Time;
25using base::TimeDelta;
rspangler@google.com49fdf182009-10-10 00:57:34 +000026using std::string;
27
28namespace chromeos_update_engine {
29
rspangler@google.com49fdf182009-10-10 00:57:34 +000030namespace {
31
32const string kGupdateVersion("ChromeOSUpdateEngine-0.1.0.0");
33
34// This is handy for passing strings into libxml2
35#define ConstXMLStr(x) (reinterpret_cast<const xmlChar*>(x))
36
37// These are for scoped_ptr_malloc, which is like scoped_ptr, but allows
38// a custom free() function to be specified.
39class ScopedPtrXmlDocFree {
40 public:
41 inline void operator()(void* x) const {
42 xmlFreeDoc(reinterpret_cast<xmlDoc*>(x));
43 }
44};
45class ScopedPtrXmlFree {
46 public:
47 inline void operator()(void* x) const {
48 xmlFree(x);
49 }
50};
51class ScopedPtrXmlXPathObjectFree {
52 public:
53 inline void operator()(void* x) const {
54 xmlXPathFreeObject(reinterpret_cast<xmlXPathObject*>(x));
55 }
56};
57class ScopedPtrXmlXPathContextFree {
58 public:
59 inline void operator()(void* x) const {
60 xmlXPathFreeContext(reinterpret_cast<xmlXPathContext*>(x));
61 }
62};
63
Darin Petkov1cbd78f2010-07-29 12:38:34 -070064// Returns true if |ping_days| has a value that needs to be sent,
65// false otherwise.
66bool ShouldPing(int ping_days) {
67 return ping_days > 0 || ping_days == OmahaRequestAction::kNeverPinged;
68}
69
70// Returns an XML ping element attribute assignment with attribute
71// |name| and value |ping_days| if |ping_days| has a value that needs
72// to be sent, or an empty string otherwise.
73string GetPingAttribute(const string& name, int ping_days) {
74 if (ShouldPing(ping_days)) {
75 return StringPrintf(" %s=\"%d\"", name.c_str(), ping_days);
76 }
77 return "";
78}
79
80// Returns an XML ping element if any of the elapsed days need to be
81// sent, or an empty string otherwise.
82string GetPingBody(int ping_active_days, int ping_roll_call_days) {
83 string ping_active = GetPingAttribute("a", ping_active_days);
84 string ping_roll_call = GetPingAttribute("r", ping_roll_call_days);
85 if (!ping_active.empty() || !ping_roll_call.empty()) {
86 return StringPrintf(" <o:ping%s%s></o:ping>\n",
87 ping_active.c_str(),
88 ping_roll_call.c_str());
89 }
90 return "";
91}
92
Darin Petkov0dc8e9a2010-07-14 14:51:57 -070093string FormatRequest(const OmahaEvent* event,
Darin Petkov1cbd78f2010-07-29 12:38:34 -070094 const OmahaRequestParams& params,
95 int ping_active_days,
Darin Petkov95508da2011-01-05 12:42:29 -080096 int ping_roll_call_days,
97 PrefsInterface* prefs) {
Darin Petkov0dc8e9a2010-07-14 14:51:57 -070098 string body;
99 if (event == NULL) {
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700100 body = GetPingBody(ping_active_days, ping_roll_call_days) +
101 " <o:updatecheck></o:updatecheck>\n";
Darin Petkov95508da2011-01-05 12:42:29 -0800102 // If this is the first update check after a reboot following a previous
103 // update, generate an event containing the previous version number. If the
104 // previous version preference file doesn't exist the event is still
105 // generated with a previous version of 0.0.0.0 -- this is relevant for
106 // older clients or new installs.
107 string prev_version;
108 if (!prefs->GetString(kPrefsPreviousVersion, &prev_version)) {
109 prev_version = "0.0.0.0";
110 }
111 if (!prev_version.empty()) {
112 body += StringPrintf(
113 " <o:event eventtype=\"%d\" eventresult=\"%d\" "
114 "previousversion=\"%s\"></o:event>\n",
115 OmahaEvent::kTypeUpdateComplete,
116 OmahaEvent::kResultSuccessReboot,
117 prev_version.c_str());
118 LOG_IF(WARNING, !prefs->SetString(kPrefsPreviousVersion, ""))
119 << "Unable to reset the previous version.";
120 }
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700121 } else {
Darin Petkove17f86b2010-07-20 09:12:01 -0700122 // The error code is an optional attribute so append it only if
123 // the result is not success.
124 string error_code;
125 if (event->result != OmahaEvent::kResultSuccess) {
126 error_code = StringPrintf(" errorcode=\"%d\"", event->error_code);
127 }
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700128 body = StringPrintf(
Darin Petkove17f86b2010-07-20 09:12:01 -0700129 " <o:event eventtype=\"%d\" eventresult=\"%d\"%s></o:event>\n",
130 event->type, event->result, error_code.c_str());
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700131 }
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700132 return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
133 "<o:gupdate xmlns:o=\"http://www.google.com/update2/request\" "
134 "version=\"" + XmlEncode(kGupdateVersion) + "\" "
135 "updaterversion=\"" + XmlEncode(kGupdateVersion) + "\" "
136 "protocol=\"2.0\" ismachine=\"1\">\n"
rspangler@google.com49fdf182009-10-10 00:57:34 +0000137 " <o:os version=\"" + XmlEncode(params.os_version) + "\" platform=\"" +
138 XmlEncode(params.os_platform) + "\" sp=\"" +
139 XmlEncode(params.os_sp) + "\"></o:os>\n"
140 " <o:app appid=\"" + XmlEncode(params.app_id) + "\" version=\"" +
141 XmlEncode(params.app_version) + "\" "
142 "lang=\"" + XmlEncode(params.app_lang) + "\" track=\"" +
Andrew de los Reyes37c20322010-06-30 13:27:19 -0700143 XmlEncode(params.app_track) + "\" board=\"" +
Darin Petkovfbb40092010-07-29 17:05:50 -0700144 XmlEncode(params.os_board) + "\" hardware_class=\"" +
145 XmlEncode(params.hardware_class) + "\" delta_okay=\"" +
Andrew de los Reyes3f0303a2010-07-15 22:35:35 -0700146 (params.delta_okay ? "true" : "false") + "\">\n" + body +
rspangler@google.com49fdf182009-10-10 00:57:34 +0000147 " </o:app>\n"
148 "</o:gupdate>\n";
149}
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700150
rspangler@google.com49fdf182009-10-10 00:57:34 +0000151} // namespace {}
152
153// Encodes XML entities in a given string with libxml2. input must be
154// UTF-8 formatted. Output will be UTF-8 formatted.
155string XmlEncode(const string& input) {
Darin Petkov6a5b3222010-07-13 14:55:28 -0700156 // // TODO(adlr): if allocating a new xmlDoc each time is taking up too much
157 // // cpu, considering creating one and caching it.
158 // scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> xml_doc(
159 // xmlNewDoc(ConstXMLStr("1.0")));
160 // if (!xml_doc.get()) {
161 // LOG(ERROR) << "Unable to create xmlDoc";
162 // return "";
163 // }
rspangler@google.com49fdf182009-10-10 00:57:34 +0000164 scoped_ptr_malloc<xmlChar, ScopedPtrXmlFree> str(
165 xmlEncodeEntitiesReentrant(NULL, ConstXMLStr(input.c_str())));
166 return string(reinterpret_cast<const char *>(str.get()));
167}
168
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700169OmahaRequestAction::OmahaRequestAction(PrefsInterface* prefs,
170 const OmahaRequestParams& params,
Darin Petkova4a8a8c2010-07-15 22:21:12 -0700171 OmahaEvent* event,
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700172 HttpFetcher* http_fetcher)
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700173 : prefs_(prefs),
174 params_(params),
Darin Petkova4a8a8c2010-07-15 22:21:12 -0700175 event_(event),
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700176 http_fetcher_(http_fetcher),
177 ping_active_days_(0),
178 ping_roll_call_days_(0) {}
rspangler@google.com49fdf182009-10-10 00:57:34 +0000179
Darin Petkov6a5b3222010-07-13 14:55:28 -0700180OmahaRequestAction::~OmahaRequestAction() {}
rspangler@google.com49fdf182009-10-10 00:57:34 +0000181
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700182// Calculates the value to use for the ping days parameter.
183int OmahaRequestAction::CalculatePingDays(const string& key) {
184 int days = kNeverPinged;
185 int64_t last_ping = 0;
186 if (prefs_->GetInt64(key, &last_ping) && last_ping >= 0) {
187 days = (Time::Now() - Time::FromInternalValue(last_ping)).InDays();
188 if (days < 0) {
189 // If |days| is negative, then the system clock must have jumped
190 // back in time since the ping was sent. Mark the value so that
191 // it doesn't get sent to the server but we still update the
192 // last ping daystart preference. This way the next ping time
193 // will be correct, hopefully.
194 days = kPingTimeJump;
195 LOG(WARNING) <<
196 "System clock jumped back in time. Resetting ping daystarts.";
197 }
198 }
199 return days;
200}
201
202void OmahaRequestAction::InitPingDays() {
203 // We send pings only along with update checks, not with events.
204 if (IsEvent()) {
205 return;
206 }
207 // TODO(petkov): Figure a way to distinguish active use pings
208 // vs. roll call pings. Currently, the two pings are identical. A
209 // fix needs to change this code as well as UpdateLastPingDays.
210 ping_active_days_ = CalculatePingDays(kPrefsLastActivePingDay);
211 ping_roll_call_days_ = CalculatePingDays(kPrefsLastRollCallPingDay);
212}
213
Darin Petkov6a5b3222010-07-13 14:55:28 -0700214void OmahaRequestAction::PerformAction() {
rspangler@google.com49fdf182009-10-10 00:57:34 +0000215 http_fetcher_->set_delegate(this);
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700216 InitPingDays();
217 string request_post(FormatRequest(event_.get(),
218 params_,
219 ping_active_days_,
Darin Petkov95508da2011-01-05 12:42:29 -0800220 ping_roll_call_days_,
221 prefs_));
rspangler@google.com49fdf182009-10-10 00:57:34 +0000222 http_fetcher_->SetPostData(request_post.data(), request_post.size());
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700223 LOG(INFO) << "Posting an Omaha request to " << params_.update_url;
Andrew de los Reyesf98bff82010-05-06 13:33:25 -0700224 LOG(INFO) << "Request: " << request_post;
Andrew de los Reyesf9714432010-05-04 10:21:23 -0700225 http_fetcher_->BeginTransfer(params_.update_url);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000226}
227
Darin Petkov6a5b3222010-07-13 14:55:28 -0700228void OmahaRequestAction::TerminateProcessing() {
rspangler@google.com49fdf182009-10-10 00:57:34 +0000229 http_fetcher_->TerminateTransfer();
230}
231
232// We just store the response in the buffer. Once we've received all bytes,
233// we'll look in the buffer and decide what to do.
Darin Petkov6a5b3222010-07-13 14:55:28 -0700234void OmahaRequestAction::ReceivedBytes(HttpFetcher *fetcher,
235 const char* bytes,
236 int length) {
rspangler@google.com49fdf182009-10-10 00:57:34 +0000237 response_buffer_.reserve(response_buffer_.size() + length);
238 response_buffer_.insert(response_buffer_.end(), bytes, bytes + length);
239}
240
241namespace {
rspangler@google.com49fdf182009-10-10 00:57:34 +0000242// If non-NULL response, caller is responsible for calling xmlXPathFreeObject()
243// on the returned object.
244// This code is roughly based on the libxml tutorial at:
245// http://xmlsoft.org/tutorial/apd.html
246xmlXPathObject* GetNodeSet(xmlDoc* doc, const xmlChar* xpath,
247 const xmlChar* ns, const xmlChar* ns_url) {
248 xmlXPathObject* result = NULL;
249
250 scoped_ptr_malloc<xmlXPathContext, ScopedPtrXmlXPathContextFree> context(
251 xmlXPathNewContext(doc));
252 if (!context.get()) {
253 LOG(ERROR) << "xmlXPathNewContext() returned NULL";
254 return NULL;
255 }
256 if (xmlXPathRegisterNs(context.get(), ns, ns_url) < 0) {
257 LOG(ERROR) << "xmlXPathRegisterNs() returned error";
258 return NULL;
259 }
260
261 result = xmlXPathEvalExpression(xpath, context.get());
262
263 if (result == NULL) {
264 LOG(ERROR) << "xmlXPathEvalExpression returned error";
265 return NULL;
266 }
267 if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
268 LOG(INFO) << "xpath not found in doc";
269 xmlXPathFreeObject(result);
270 return NULL;
271 }
272 return result;
273}
274
275// Returns the string value of a named attribute on a node, or empty string
276// if no such node exists. If the attribute exists and has a value of
277// empty string, there's no way to distinguish that from the attribute
278// not existing.
279string XmlGetProperty(xmlNode* node, const char* name) {
280 if (!xmlHasProp(node, ConstXMLStr(name)))
281 return "";
282 scoped_ptr_malloc<xmlChar, ScopedPtrXmlFree> str(
283 xmlGetProp(node, ConstXMLStr(name)));
284 string ret(reinterpret_cast<const char *>(str.get()));
285 return ret;
286}
287
288// Parses a 64 bit base-10 int from a string and returns it. Returns 0
289// on error. If the string contains "0", that's indistinguishable from
290// error.
291off_t ParseInt(const string& str) {
292 off_t ret = 0;
Andrew de los Reyes08c4e272010-04-15 14:02:17 -0700293 int rc = sscanf(str.c_str(), "%" PRIi64, &ret);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000294 if (rc < 1) {
295 // failure
296 return 0;
297 }
298 return ret;
299}
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700300
301// Update the last ping day preferences based on the server daystart
302// response. Returns true on success, false otherwise.
303bool UpdateLastPingDays(xmlDoc* doc, PrefsInterface* prefs) {
304 static const char kNamespace[] = "x";
305 static const char kDaystartNodeXpath[] = "/x:gupdate/x:daystart";
306 static const char kNsUrl[] = "http://www.google.com/update2/response";
307
308 scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
309 xpath_nodeset(GetNodeSet(doc,
310 ConstXMLStr(kDaystartNodeXpath),
311 ConstXMLStr(kNamespace),
312 ConstXMLStr(kNsUrl)));
313 TEST_AND_RETURN_FALSE(xpath_nodeset.get());
314 xmlNodeSet* nodeset = xpath_nodeset->nodesetval;
315 TEST_AND_RETURN_FALSE(nodeset && nodeset->nodeNr >= 1);
316 xmlNode* daystart_node = nodeset->nodeTab[0];
317 TEST_AND_RETURN_FALSE(xmlHasProp(daystart_node,
318 ConstXMLStr("elapsed_seconds")));
319
320 int64_t elapsed_seconds = 0;
Chris Masone790e62e2010-08-12 10:41:18 -0700321 TEST_AND_RETURN_FALSE(base::StringToInt64(XmlGetProperty(daystart_node,
322 "elapsed_seconds"),
323 &elapsed_seconds));
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700324 TEST_AND_RETURN_FALSE(elapsed_seconds >= 0);
325
326 // Remember the local time that matches the server's last midnight
327 // time.
328 Time daystart = Time::Now() - TimeDelta::FromSeconds(elapsed_seconds);
329 prefs->SetInt64(kPrefsLastActivePingDay, daystart.ToInternalValue());
330 prefs->SetInt64(kPrefsLastRollCallPingDay, daystart.ToInternalValue());
331 return true;
332}
rspangler@google.com49fdf182009-10-10 00:57:34 +0000333} // namespace {}
334
335// If the transfer was successful, this uses libxml2 to parse the response
336// and fill in the appropriate fields of the output object. Also, notifies
337// the processor that we're done.
Darin Petkov6a5b3222010-07-13 14:55:28 -0700338void OmahaRequestAction::TransferComplete(HttpFetcher *fetcher,
339 bool successful) {
rspangler@google.com49fdf182009-10-10 00:57:34 +0000340 ScopedActionCompleter completer(processor_, this);
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700341 LOG(INFO) << "Omaha request response: " << string(response_buffer_.begin(),
342 response_buffer_.end());
343
344 // Events are best effort transactions -- assume they always succeed.
345 if (IsEvent()) {
346 CHECK(!HasOutputPipe()) << "No output pipe allowed for event requests.";
Darin Petkovc1a8b422010-07-19 11:34:49 -0700347 completer.set_code(kActionCodeSuccess);
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700348 return;
349 }
350
Andrew de los Reyesf98bff82010-05-06 13:33:25 -0700351 if (!successful) {
Darin Petkov0dc8e9a2010-07-14 14:51:57 -0700352 LOG(ERROR) << "Omaha request network transfer failed.";
Darin Petkovedc522e2010-11-05 09:35:17 -0700353 int code = GetHTTPResponseCode();
354 // Makes sure we send sane error values.
355 if (code < 0 || code >= 1000) {
356 code = 999;
357 }
358 completer.set_code(static_cast<ActionExitCode>(
359 kActionCodeOmahaRequestHTTPResponseBase + code));
rspangler@google.com49fdf182009-10-10 00:57:34 +0000360 return;
Andrew de los Reyesf98bff82010-05-06 13:33:25 -0700361 }
rspangler@google.com49fdf182009-10-10 00:57:34 +0000362 if (!HasOutputPipe()) {
363 // Just set success to whether or not the http transfer succeeded,
364 // which must be true at this point in the code.
Darin Petkovc1a8b422010-07-19 11:34:49 -0700365 completer.set_code(kActionCodeSuccess);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000366 return;
367 }
368
369 // parse our response and fill the fields in the output object
370 scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc(
371 xmlParseMemory(&response_buffer_[0], response_buffer_.size()));
372 if (!doc.get()) {
373 LOG(ERROR) << "Omaha response not valid XML";
Darin Petkovedc522e2010-11-05 09:35:17 -0700374 completer.set_code(response_buffer_.empty() ?
375 kActionCodeOmahaRequestEmptyResponseError :
376 kActionCodeOmahaRequestXMLParseError);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000377 return;
378 }
379
Darin Petkov1cbd78f2010-07-29 12:38:34 -0700380 // If a ping was sent, update the last ping day preferences based on
381 // the server daystart response.
382 if (ShouldPing(ping_active_days_) ||
383 ShouldPing(ping_roll_call_days_) ||
384 ping_active_days_ == kPingTimeJump ||
385 ping_roll_call_days_ == kPingTimeJump) {
386 LOG_IF(ERROR, !UpdateLastPingDays(doc.get(), prefs_))
387 << "Failed to update the last ping day preferences!";
388 }
389
rspangler@google.com49fdf182009-10-10 00:57:34 +0000390 static const char* kNamespace("x");
391 static const char* kUpdatecheckNodeXpath("/x:gupdate/x:app/x:updatecheck");
392 static const char* kNsUrl("http://www.google.com/update2/response");
393
394 scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
395 xpath_nodeset(GetNodeSet(doc.get(),
396 ConstXMLStr(kUpdatecheckNodeXpath),
397 ConstXMLStr(kNamespace),
398 ConstXMLStr(kNsUrl)));
399 if (!xpath_nodeset.get()) {
Darin Petkovedc522e2010-11-05 09:35:17 -0700400 completer.set_code(kActionCodeOmahaRequestNoUpdateCheckNode);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000401 return;
402 }
403 xmlNodeSet* nodeset = xpath_nodeset->nodesetval;
404 CHECK(nodeset) << "XPath missing NodeSet";
405 CHECK_GE(nodeset->nodeNr, 1);
406
407 xmlNode* updatecheck_node = nodeset->nodeTab[0];
408 // get status
409 if (!xmlHasProp(updatecheck_node, ConstXMLStr("status"))) {
410 LOG(ERROR) << "Response missing status";
Darin Petkovedc522e2010-11-05 09:35:17 -0700411 completer.set_code(kActionCodeOmahaRequestNoUpdateCheckStatus);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000412 return;
413 }
414
Darin Petkov6a5b3222010-07-13 14:55:28 -0700415 OmahaResponse output_object;
Darin Petkov85ced132010-09-01 10:20:56 -0700416 base::StringToInt(XmlGetProperty(updatecheck_node, "PollInterval"),
417 &output_object.poll_interval);
418 const string status(XmlGetProperty(updatecheck_node, "status"));
rspangler@google.com49fdf182009-10-10 00:57:34 +0000419 if (status == "noupdate") {
420 LOG(INFO) << "No update.";
421 output_object.update_exists = false;
422 SetOutputObject(output_object);
Darin Petkovc1a8b422010-07-19 11:34:49 -0700423 completer.set_code(kActionCodeSuccess);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000424 return;
425 }
426
427 if (status != "ok") {
428 LOG(ERROR) << "Unknown status: " << status;
Darin Petkovedc522e2010-11-05 09:35:17 -0700429 completer.set_code(kActionCodeOmahaRequestBadUpdateCheckStatus);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000430 return;
431 }
432
433 // In best-effort fashion, fetch the rest of the expected attributes
434 // from the updatecheck node, then return the object
435 output_object.update_exists = true;
Darin Petkovc1a8b422010-07-19 11:34:49 -0700436 completer.set_code(kActionCodeSuccess);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000437
438 output_object.display_version =
439 XmlGetProperty(updatecheck_node, "DisplayVersion");
440 output_object.codebase = XmlGetProperty(updatecheck_node, "codebase");
441 output_object.more_info_url = XmlGetProperty(updatecheck_node, "MoreInfo");
Darin Petkovd22cb292010-09-29 10:02:29 -0700442 output_object.hash = XmlGetProperty(updatecheck_node, "sha256");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000443 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size"));
444 output_object.needs_admin =
445 XmlGetProperty(updatecheck_node, "needsadmin") == "true";
446 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true";
Andrew de los Reyes3270f742010-07-15 22:28:14 -0700447 output_object.is_delta =
448 XmlGetProperty(updatecheck_node, "IsDelta") == "true";
Darin Petkov6c118642010-10-21 12:06:30 -0700449 output_object.deadline = XmlGetProperty(updatecheck_node, "deadline");
rspangler@google.com49fdf182009-10-10 00:57:34 +0000450 SetOutputObject(output_object);
rspangler@google.com49fdf182009-10-10 00:57:34 +0000451}
452
453}; // namespace chromeos_update_engine