PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

C++ Header | 91 lines | 27 code | 14 blank | 50 comment | 0 complexity | 0e9556d9f5b9c6faf7581cf08e63e5fd 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>
16#import "KSAction.h"
18@class KSFetcherFactory;
19@class KSServer;
20@class GDataHTTPFetcher;
21@class KSFetcherFactory;
23// The KSUpdateCheckAction class checks for updates.  Its input consists of:
24// - a KSServer which encapsulates the server communication;
25// - an array of tickets, represting local installs which may need
26//   updating; and
27// - an optional fetcher factory which encapsulates a
28//   request/response (e.g. loading of a URL request).
29// All tickets must point to the same server URL.
31// If there are updates to perform, the KSUpdateCheckAction will take
32// the KSActions generated by its KSServer, presumably
33// KSUpdateActions, and place them on it's own action processor.  This
34// class will finish (call the KSActionProcessor's
35// finishedProcessing:successfully:) when done deciding what to do,
36// which may be before its "child" KSUpdateActions have completed.
38// This class is the only interface that KSUpdateEngine will use for
39// server communication.  It is expected that KSUpdateEngine will create a
40// KSUpdateCheckAction for each unique server URL seen in a ticket
41// store.
42@interface KSUpdateCheckAction : KSAction {
43 @private
44  KSFetcherFactory *fetcherFactory_;
45  KSServer *server_;
46  NSArray *tickets_;
48  // Array of fetchers we have created.  Size of this array is the
49  // number of outstanding requests.
50  NSMutableArray *fetchers_;
52  // If any request is unsucessful, this is set to NO.
53  BOOL allSuccessful_;
55  id delegate_;  // weak
58+ (id)checkerWithServer:(KSServer *)server tickets:(NSArray *)tickets;
60// Calls through to designated initializer with a new instance of
61// GDataHTTPFetcher.  This is the standard initailizer that you will
62// almost always want to use.  |tickets|, an array of KSTickets, are
63// required to all point to the same server URL.
64- (id)initWithServer:(KSServer *)server tickets:(NSArray *)tickets;
66// Designated initializer. Can be useful because a mock fetcher can be
67// "injected" into the instance when testing.
68- (id)initWithFetcherFactory:(KSFetcherFactory *)fetcherFactory
69                      server:(KSServer *)server
70                     tickets:(NSArray *)tickets;
72// Return the number of outstanding requests.  Servers may have
73// more than one outstanding request each.
74- (int)outstandingRequests;
76// Getter and setter for this object's optional delegate. See
77// KSUpdateCheckActionDelegateMethods below for details about the callbacks
78// that the delegate can receive.
79- (id)delegate;
80- (void)setDelegate:(id)delegate;
85// Protocol for a delegate which receives error messages.  Currently
86// fetcher errors are logged and thrown away.  (An error here has the
87// functional meaning "do nothing more".)  Use of a delegate with this
88// protocol in KSUpdateCheckAction is optional.
89@interface KSUpdateCheckAction (KSUpdateCheckActionDelegateMethods)
90- (void)fetcher:(GDataHTTPFetcher *)fetcher failedWithError:(NSError *)error;