fix(omaha): manifest/urls child of updatecheck

Move the manifest and urls fields into the updatecheck field. This
matches the spec: https://code.google.com/p/omaha/wiki/ServerProtocol
This commit is contained in:
Brandon Philips 2013-04-13 21:35:44 -07:00
parent 171b7c70d7
commit 93efcffd31
2 changed files with 32 additions and 31 deletions

View file

@ -70,8 +70,6 @@ type App struct {
XMLName xml.Name `xml:"app"`
Ping *Ping `xml:"ping"`
UpdateCheck *UpdateCheck `xml:"updatecheck"`
Urls *Urls `xml:"urls"`
Manifest *Manifest `xml:"manifest"`
Event *Event `xml:"event"`
Id string `xml:"appid,attr,omitempty"`
Version string `xml:"version,attr,omitempty"`
@ -98,27 +96,29 @@ func (a *App) AddPing() *Ping {
return a.Ping
}
func (a *App) AddUrl(codebase string) *Url {
if a.Urls == nil {
a.Urls = new(Urls)
}
u := new(Url)
u.CodeBase = codebase
a.Urls.Urls = append(a.Urls.Urls, *u)
return u
}
func (a *App) AddManifest(version string) *Manifest {
a.Manifest = &Manifest{Version: version}
return a.Manifest
}
type UpdateCheck struct {
XMLName xml.Name `xml:"updatecheck"`
Urls *Urls `xml:"urls"`
Manifest *Manifest `xml:"manifest"`
TargetVersionPrefix string `xml:"targetversionprefix,attr,omitempty"`
Status string `xml:"status,attr,omitempty"`
}
func (u *UpdateCheck) AddUrl(codebase string) *Url {
if u.Urls == nil {
u.Urls = new(Urls)
}
url := new(Url)
url.CodeBase = codebase
u.Urls.Urls = append(u.Urls.Urls, *url)
return url
}
func (u *UpdateCheck) AddManifest(version string) *Manifest {
u.Manifest = &Manifest{Version: version}
return u.Manifest
}
type Ping struct {
XMLName xml.Name `xml:"ping"`
LastReportDays string `xml:"r,attr,omitempty"`

View file

@ -53,8 +53,8 @@ func ExampleOmaha_NewResponse() {
p.Status = "ok"
u := app.AddUpdateCheck()
u.Status = "ok"
app.AddUrl("http://localhost/updates")
m := app.AddManifest("9999.0.0")
u.AddUrl("http://localhost/updates")
m := u.AddManifest("9999.0.0")
m.AddPackage("+LXvjiaPkeYDLHoNKlf9qbJwvnk=", "update.gz", "67546213", true)
a := m.AddAction("postinstall")
a.ChromeOSVersion = "9999.0.0"
@ -76,18 +76,19 @@ func ExampleOmaha_NewResponse() {
// <daystart elapsed_seconds="0"></daystart>
// <app appid="{52F1B9BC-D31A-4D86-9276-CBC256AADF9A}" status="ok">
// <ping status="ok"></ping>
// <updatecheck status="ok"></updatecheck>
// <urls>
// <url codebase="http://localhost/updates"></url>
// </urls>
// <manifest version="9999.0.0">
// <packages>
// <package hash="+LXvjiaPkeYDLHoNKlf9qbJwvnk=" name="update.gz" size="67546213" required="true"></package>
// </packages>
// <actions>
// <action event="postinstall" ChromeOSVersion="9999.0.0" sha256="0VAlQW3RE99SGtSB5R4m08antAHO8XDoBMKDyxQT/Mg=" needsadmin="false" IsDelta="true"></action>
// </actions>
// </manifest>
// <updatecheck status="ok">
// <urls>
// <url codebase="http://localhost/updates"></url>
// </urls>
// <manifest version="9999.0.0">
// <packages>
// <package hash="+LXvjiaPkeYDLHoNKlf9qbJwvnk=" name="update.gz" size="67546213" required="true"></package>
// </packages>
// <actions>
// <action event="postinstall" ChromeOSVersion="9999.0.0" sha256="0VAlQW3RE99SGtSB5R4m08antAHO8XDoBMKDyxQT/Mg=" needsadmin="false" IsDelta="true"></action>
// </actions>
// </manifest>
// </updatecheck>
// </app>
// </response>
}