/core/externals/update-engine/Core/KSServer.h

http://macfuse.googlecode.com/ · C Header · 88 lines · 22 code · 14 blank · 52 comment · 0 complexity · 65614e3744f660ba8d35d63fd03a53a6 MD5 · raw file

  1. // Copyright 2008 Google Inc.
  2. //
  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
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  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.
  14. #import <Foundation/Foundation.h>
  15. @class KSUpdateEngine;
  16. // KSServer
  17. //
  18. // *Abstract* class for dealing with specific types of "UpdateEngine servers".
  19. // Subclasses will contain all of the information specific to a given
  20. // UpdateEngine server type. Subclasses should be able to create one or more
  21. // NSURLRequest objects for a specific server from the list of tickets. They
  22. // must also be able to convert from an NSURLResponse and a blob of data into an
  23. // array of KSUpdateInfos representing the response from the server in a server
  24. // agnostic way. A "KSServer" represents a specific instance (because of the
  25. // URL) of some type of server.
  26. //
  27. // See also KSUpdateInfo.h
  28. @interface KSServer : NSObject {
  29. @private
  30. NSURL *url_;
  31. NSDictionary *params_;
  32. KSUpdateEngine *engine_;
  33. }
  34. // Initializes the KSSever instance with the specified |url| and nil params.
  35. - (id)initWithURL:(NSURL *)url;
  36. // The |url| is the address where the server resides,
  37. // and |params| is an optional dictionary of values associated with this server
  38. // instance. |params| can be any dictionary of key/value pairs. There are no
  39. // standard or required keys, and they're only interpreted by the specific
  40. // KSServer subclass. KSServer subclasses that require specific keys must
  41. // document those keys. The |url| argument is required, |params| is optional.
  42. - (id)initWithURL:(NSURL *)url params:(NSDictionary *)params;
  43. // Designated initializer. Like -initWithURL:params, but also pass in
  44. // the UpdateEngine that's controlling the whole process. This is so
  45. // we can return server-specific information via a delegate method.
  46. - (id)initWithURL:(NSURL *)url params:(NSDictionary *)params
  47. engine:(KSUpdateEngine *)engine;
  48. // Returns the URL of this server.
  49. - (NSURL *)url;
  50. // Returns the parameters used when creating this server instance.
  51. // Returns nil if they were not provided.
  52. - (NSDictionary *)params;
  53. // Returns the update engine that is responsible for the current update.
  54. // Returns nil if it was not provided.
  55. - (KSUpdateEngine *)engine;
  56. // Returns an array of NSURLRequest objects for the given |tickets|.
  57. // Array may contain only one request, or may be nil.
  58. - (NSArray *)requestsForTickets:(NSArray *)tickets;
  59. // Returns an array of KSUpdateInfo dictionaries representing the results from a
  60. // server in a server agnostic way. The keys for the dictionaries are declared
  61. // in KSUpdateInfo.h.
  62. // |oob| is an NSDictionary of out-of-band data, chunks of information
  63. // from the server class that are outside of the data for each
  64. // upadate.
  65. // If there is no OOB data, |*oob| will be assigned to nil. It is valid to
  66. // to pass NULL if you're not interested in OOB data.
  67. // Subclasses should override this.
  68. - (NSArray *)updateInfosForResponse:(NSURLResponse *)response
  69. data:(NSData *)data
  70. outOfBandData:(NSDictionary **)oob;
  71. // Returns a pretty-printed version of the specified response and data.
  72. - (NSString *)prettyPrintResponse:(NSURLResponse *)response
  73. data:(NSData *)data;
  74. @end