PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

C++ Header | 88 lines | 22 code | 14 blank | 52 comment | 0 complexity | 65614e3744f660ba8d35d63fd03a53a6 MD5 | raw file
 1// Copyright 2008 Google Inc.
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
15#import <Foundation/Foundation.h>
18@class KSUpdateEngine;
20// KSServer
22// *Abstract* class for dealing with specific types of "UpdateEngine servers".
23// Subclasses will contain all of the information specific to a given
24// UpdateEngine server type. Subclasses should be able to create one or more
25// NSURLRequest objects for a specific server from the list of tickets. They
26// must also be able to convert from an NSURLResponse and a blob of data into an
27// array of KSUpdateInfos representing the response from the server in a server
28// agnostic way. A "KSServer" represents a specific instance (because of the
29// URL) of some type of server.
31// See also KSUpdateInfo.h
32@interface KSServer : NSObject {
33 @private
34  NSURL *url_;
35  NSDictionary *params_;
36  KSUpdateEngine *engine_;
39// Initializes the KSSever instance with the specified |url| and nil params.
40- (id)initWithURL:(NSURL *)url;
42// The |url| is the address where the server resides,
43// and |params| is an optional dictionary of values associated with this server
44// instance. |params| can be any dictionary of key/value pairs. There are no
45// standard or required keys, and they're only interpreted by the specific
46// KSServer subclass. KSServer subclasses that require specific keys must
47// document those keys. The |url| argument is required, |params| is optional.
48- (id)initWithURL:(NSURL *)url params:(NSDictionary *)params;
50// Designated initializer.  Like -initWithURL:params, but also pass in
51// the UpdateEngine that's controlling the whole process.  This is so
52// we can return server-specific information via a delegate method.
53- (id)initWithURL:(NSURL *)url params:(NSDictionary *)params
54           engine:(KSUpdateEngine *)engine;
56// Returns the URL of this server.
57- (NSURL *)url;
59// Returns the parameters used when creating this server instance.
60// Returns nil if they were not provided.
61- (NSDictionary *)params;
63// Returns the update engine that is responsible for the current update.
64// Returns nil if it was not provided.
65- (KSUpdateEngine *)engine;
67// Returns an array of NSURLRequest objects for the given |tickets|.
68// Array may contain only one request, or may be nil.
69- (NSArray *)requestsForTickets:(NSArray *)tickets;
71// Returns an array of KSUpdateInfo dictionaries representing the results from a
72// server in a server agnostic way. The keys for the dictionaries are declared
73// in KSUpdateInfo.h.
74// |oob| is an NSDictionary of out-of-band data, chunks of information
75// from the server class that are outside of the data for each
76// upadate.
77// If there is no OOB data, |*oob| will be assigned to nil.  It is valid to
78// to pass NULL if you're not interested in OOB data.
79// Subclasses should override this.
80- (NSArray *)updateInfosForResponse:(NSURLResponse *)response
81                               data:(NSData *)data
82                      outOfBandData:(NSDictionary **)oob;
84// Returns a pretty-printed version of the specified response and data.
85- (NSString *)prettyPrintResponse:(NSURLResponse *)response
86                             data:(NSData *)data;