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

http://macfuse.googlecode.com/ · C Header · 99 lines · 25 code · 11 blank · 63 comment · 0 complexity · 7dec1a644e1f2af61704701f06949dc1 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. #import "KSMultiAction.h"
  16. @class KSUpdateEngine;
  17. // KSCheckAction
  18. //
  19. // This KSMultiAction runs one KSUpdateCheckAction for each unique server URL
  20. // found in a ticket. The output of all the sub-KSUpdateCheckActions is
  21. // collected and the aggregate output is set as this action's output (via its
  22. // outPipe).
  23. //
  24. // Sample usage:
  25. // KSActionProcessor *ap = ...
  26. // NSArray *tickets = ... tickets that could be for any arbitrary URLs ...
  27. //
  28. // KSAction *checker = [KSCheckAction actionWithTickets:tickets];
  29. //
  30. // [ap enqueueAction:checker];
  31. // [ap startProcessing];
  32. //
  33. // ... spin runloop until done ...
  34. // NSArray *agg = [[checker outPipe] contents];
  35. //
  36. // That last line will return an array with the aggregate output from all the
  37. // sub-KSUpdateCheckActions.
  38. //
  39. // A KSCheckAction completes "successfully" if *any* of its
  40. // sub-KSUpdateCheckActions complete successfully. They do not all need to be
  41. // successfull in order for this class to be successful. This handles the case
  42. // where one of the URLs for one of the KSUpdateCheckActions is bad but the
  43. // rest are fine. In this case, we shouldn't fail the whole operation just from
  44. // one bad URL. But in the case where the user has no internet connetion and
  45. // ALL the sub-KSUpdateCheckActions fail, we do want to report that this multi-
  46. // action failed.
  47. //
  48. @interface KSCheckAction : KSMultiAction {
  49. @private
  50. NSArray *tickets_;
  51. NSMutableArray *updateInfos_; // Output for next action
  52. NSMutableDictionary *outOfBandData_; // Output for next action
  53. NSDictionary *params_;
  54. KSUpdateEngine *engine_;
  55. BOOL wasSuccessful_;
  56. }
  57. // Returns an autoreleased KSCheckAction. See the designated initializer for
  58. // more details.
  59. + (id)actionWithTickets:(NSArray *)tickets params:(NSDictionary *)params
  60. engine:(KSUpdateEngine *)engine;
  61. + (id)actionWithTickets:(NSArray *)tickets params:(NSDictionary *)params;
  62. + (id)actionWithTickets:(NSArray *)tickets;
  63. // Designated initializer. Returns a KSCheckAction that will create
  64. // sub-KSUpdateCheckActions for each group of tickets to each unique server URL.
  65. // |tickets| must be an array of KSTicket objects. The tickets do not need to
  66. // point to the same server URL. A nil or empty array of tickets is allowed;
  67. // this action will just immediately finish running and will return an empty
  68. // output array as if no updates were available.
  69. // If specified, |params| is an NSDictionary indexed by the keys in
  70. // KSUpdateEngineParameters.h. These paramaters are passed down to
  71. // objects which may be created by this class.
  72. - (id)initWithTickets:(NSArray *)tickets params:(NSDictionary *)params
  73. engine:(KSUpdateEngine *)engine;
  74. - (id)initWithTickets:(NSArray *)tickets params:(NSDictionary *)params;
  75. - (id)initWithTickets:(NSArray *)tickets;
  76. @end
  77. // API to configure KSCheckAction instances.
  78. @interface KSCheckAction (Configuration)
  79. // Returns the KSServer Class that will be used by KSCheckAction instances. The
  80. // returned Class is guaranteed to be a subclass of KSServer. This method never
  81. // returns nil. By default, the returned class is KSPlistServer.
  82. + (Class)serverClass;
  83. // Sets the KSServer Class that KSCheckAction instances should use.
  84. // |serverClass| MUST be a subclass of the KSServer abstract class. It will be
  85. // ignored if it is not. Passing a value of nil will reset things back to its
  86. // default value.
  87. + (void)setServerClass:(Class)serverClass;
  88. @end