00001 // Copyright 2009-2010 Aurora Feint, Inc. 00002 // 00003 // Licensed under the Apache License, Version 2.0 (the "License"); 00004 // you may not use this file except in compliance with the License. 00005 // You may obtain a copy of the License at 00006 // 00007 // http://www.apache.org/licenses/LICENSE-2.0 00008 // 00009 // Unless required by applicable law or agreed to in writing, software 00010 // distributed under the License is distributed on an "AS IS" BASIS, 00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 // See the License for the specific language governing permissions and 00013 // limitations under the License. 00014 00015 #import "OFResource.h" 00016 #import "OFCallbackable.h" 00017 00018 @protocol OFChallengeSendDelegate; 00019 @class OFRequestHandle; 00020 @class OFService; 00021 @class OFChallengeDefinition; 00022 @class OFUser; 00023 00028 @interface OFChallenge : OFResource<OFCallbackable> 00029 { 00030 @private 00031 OFChallengeDefinition* challengeDefinition; 00032 OFUser* challenger; 00033 NSString* challengeDescription; 00034 NSString* userMessage; 00035 NSString* challengeDataUrl; 00036 NSString* hiddenText; //developer customization 00037 NSData* challengeData; 00038 } 00039 00046 + (void)setDelegate:(id<OFChallengeSendDelegate>)delegate; 00047 00061 - (OFChallenge*)initWithDefinition:(OFChallengeDefinition*)definition challengeDescription:(NSString*)text challengeData:(NSData*)data; 00062 00072 - (void)displayAndSendChallenge; 00073 00088 - (OFRequestHandle*)sendChallenge:(OFChallengeDefinition*)challengeDefinition 00089 toUsers:(NSArray*)userIds 00090 inResponseToChallenge:(OFChallenge*)instigatingChallenge; 00091 00109 - (OFRequestHandle*)downloadChallengeData; 00110 00114 @property (nonatomic, readonly) OFChallengeDefinition* challengeDefinition; 00115 00120 @property (nonatomic, readonly) OFUser* challenger; 00121 00125 @property (nonatomic, readonly) NSString* challengeDescription; 00126 00130 @property (nonatomic, retain) NSString* userMessage; 00131 00135 @property (nonatomic, retain) NSString* hiddenText; 00136 00140 + (NSString*)getResourceName; 00141 - (BOOL)usesChallengeData; 00142 @property (nonatomic, readonly) NSData* challengeData; 00143 @property (nonatomic, readonly) NSString* challengeDataUrl; 00144 00145 @end 00146 00152 @protocol OFChallengeSendDelegate<NSObject> 00153 @optional 00157 - (void)didSendChallenge:(OFChallenge*)challenge; 00158 00162 - (void)didFailSendChallenge:(OFChallenge*)challenge; 00163 00166 - (void)didDownloadChallengeData:(NSData*)data OFChallenge:(OFChallenge*)challenge; 00167 00170 - (void)didFailDownloadChallengeDataOFChallenge:(OFChallenge*)challenge; 00171 00172 @end