]>
Commit | Line | Data |
---|---|---|
bac41a7b A |
1 | /* |
2 | * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. | |
3 | * | |
4 | * The contents of this file constitute Original Code as defined in and are | |
5 | * subject to the Apple Public Source License Version 1.2 (the 'License'). | |
6 | * You may not use this file except in compliance with the License. Please obtain | |
7 | * a copy of the License at http://www.apple.com/publicsource and read it before | |
8 | * using this file. | |
9 | * | |
10 | * This Original Code and all software distributed under the License are | |
11 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS | |
12 | * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT | |
13 | * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | |
14 | * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the | |
15 | * specific language governing rights and limitations under the License. | |
16 | */ | |
17 | ||
18 | ||
19 | // | |
20 | // observer - notification client for network events | |
21 | // | |
22 | #ifndef _H_OBSERVER | |
23 | #define _H_OBSERVER | |
24 | ||
25 | #include <Security/utilities.h> | |
26 | ||
27 | ||
28 | namespace Security { | |
29 | namespace Network { | |
30 | ||
31 | ||
32 | class Transfer; | |
33 | ||
34 | ||
35 | // | |
36 | // An Observer object has a set (bitmask) of events it is interested in. | |
37 | // Observers are registered with Transfer and Manager objects to take effect. | |
38 | // | |
39 | class Observer { | |
40 | public: | |
41 | virtual ~Observer(); | |
42 | ||
43 | public: | |
44 | enum { | |
45 | noEvents = 0x000000, // mask for no events | |
46 | transferStarting = 0x000001, // starting transfer operation | |
47 | transferComplete = 0x000002, // successfully finished | |
48 | transferFailed = 0x000004, // failed somehow | |
49 | connectEvent = 0x000800, // transport level connection done or failed | |
50 | protocolSend = 0x001000, // low-level protocol message sent | |
51 | protocolReceive = 0x002000, // low-level protocol message received | |
52 | ||
53 | //@@@ questionable | |
54 | resourceFound = 0x000008, // resource found, OK to continue | |
55 | downloading = 0x000010, // downloading in progress | |
56 | aborting = 0x000020, // abort in progress | |
57 | dataAvailable = 0x000040, // data ready to go | |
58 | systemEvent = 0x000080, // ??? | |
59 | percentEvent = 0x000100, // a >= 1% data move has occurred | |
60 | periodicEvent = 0x000200, // call every so often (.25 sec) | |
61 | propertyChangedEvent = 0x000400, | |
62 | resultCodeReady = 0x004000, // result code has been received by HTTP | |
63 | uploading = 0x008000, // uploading | |
64 | ||
65 | allEvents = 0xFFFFFFFF // mask for all events | |
66 | }; | |
67 | typedef uint32 Event, Events; | |
68 | ||
69 | void setEvents(Events mask) { mEventMask = mask; } | |
70 | Events getEvents() const { return mEventMask; } | |
71 | bool wants(Events events) const { return mEventMask & events; } | |
72 | ||
73 | virtual void observe(Events events, Transfer *xfer, const void *info = NULL) = 0; | |
74 | ||
75 | private: | |
76 | Events mEventMask; | |
77 | }; | |
78 | ||
79 | ||
80 | } // end namespace Network | |
81 | } // end namespace Security | |
82 | ||
83 | ||
df0e469f | 84 | #endif /* _H_OBSERVER */ |