This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RhpChecker.h
74 lines (56 loc) · 2.22 KB
/
RhpChecker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#import <Foundation/Foundation.h>
/* RhpChecker
Model class that connects to the Red Hot Pawn website to check the number
of games waiting for the logged in player. The login session is taken from
the system cookie store (NSCookieStorage). The user can login in Safari to
effect a login. */
// status codes
#define RHPCHECKER_OK 0
#define RHPCHECKER_DEFAULT 1000 // default or generic error
#define RHPCHECKER_COOKIE_PROBLEM 1001 // no session cookie found in cookie store
#define RHPCHECKER_CONNECTION_PROBLEM 1002 // problem connecting to site
#define RHPCHECKER_RESPONSE_PROBLEM 1003 // problem with response the site gave
#define RHPCHECKER_NEVER_CHECKED 1004 // not check attempt has yet been made
#define RHPCHECKER_OFFLINE 1005 // network connection offline
#define RHPCHECKER_NO_PERMISSION 1006 // no permission to use cookie
// protocol for completion notifications
@protocol RhpCheckerDelegate
- (void)rhpCheckerWillCheck;
- (void)rhpCheckerDidCheck;
@end
@interface RhpChecker : NSObject {
/* Result of most recent check. Status codes RHPCHECKER_xxx defined above. */
int status;
// the number of games waiting (valid only if status is OK)
int gamesWaiting;
// the logged in player name (valid only if status is OK)
NSString *playerName;
// URL request for query service (to be cached)
NSURLRequest *cachedRequest;
// the query service url
NSURL *siteQueryUrl;
// url to use when visiting site
NSURL *siteVisitUrl;
NSURL *siteLoginUrl;
// the session cookies required for login
NSSet *siteCookieNames;
// delegate for completion callback
NSObject <RhpCheckerDelegate> *delegate;
// the received data
NSMutableData *data;
// has permission to use cookie
BOOL permission;
}
@property NSObject <RhpCheckerDelegate> *delegate;
@property BOOL permission;
@property (readonly) int status;
@property (readonly) int gamesWaiting;
@property (readonly) NSString *playerName;
@property (readonly) NSURL *siteVisitUrl;
@property (readonly) NSURL *siteLoginUrl;
/* Attempt to get the number of games waiting from the site.
Always calls the "will check" and "did check" delegate methods.
Check status to see if it was successful.
Not thread safe: only one check allowed at a time. */
- (void)check;
@end