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

http://macfuse.googlecode.com/ · Objective C · 96 lines · 58 code · 19 blank · 19 comment · 4 complexity · 72405ae712f99a3c61b57a392f3120d5 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 "KSServer.h"
  15. #import "KSUpdateEngine.h"
  16. @implementation KSServer
  17. - (id)init {
  18. return [self initWithURL:nil];
  19. }
  20. - (id)initWithURL:(NSURL *)url {
  21. return [self initWithURL:url params:nil];
  22. }
  23. - (id)initWithURL:(NSURL *)url params:(NSDictionary *)params {
  24. return [self initWithURL:url params:params engine:nil];
  25. }
  26. - (id)initWithURL:(NSURL *)url params:(NSDictionary *)params
  27. engine:(KSUpdateEngine *)engine {
  28. if ((self = [super init])) {
  29. if (url == nil) {
  30. [self release];
  31. return nil;
  32. }
  33. url_ = [url retain];
  34. params_ = [params copy];
  35. engine_ = [engine retain];
  36. }
  37. return self;
  38. }
  39. - (void)dealloc {
  40. [url_ release];
  41. [params_ release];
  42. [engine_ release];
  43. [super dealloc];
  44. }
  45. - (NSURL *)url {
  46. return url_;
  47. }
  48. - (NSDictionary *)params {
  49. return params_;
  50. }
  51. - (KSUpdateEngine *)engine {
  52. return engine_;
  53. }
  54. - (NSString *)description {
  55. return [NSString stringWithFormat:@"<%@:%p url=%@, params=%@>",
  56. [self class], self, url_, params_];
  57. }
  58. //
  59. // "Abstract" methods.
  60. //
  61. // Subclasses to override.
  62. - (NSArray *)requestsForTickets:(NSArray *)tickets {
  63. return nil;
  64. }
  65. // Subclasses can override if they supply OOB information. Otherwise
  66. // the default will turn around and use -updateInfosForResponse:data
  67. - (NSArray *)updateInfosForResponse:(NSURLResponse *)response
  68. data:(NSData *)data
  69. outOfBandData:(NSDictionary **)oob {
  70. if (oob) *oob = NULL;
  71. return nil;
  72. }
  73. - (NSString *)prettyPrintResponse:(NSURLResponse *)response
  74. data:(NSData *)data {
  75. return nil;
  76. }
  77. @end