![]() |
Ignite Tools
|
00001 /* 00002 Copyright 2009-2011 Urban Airship Inc. All rights reserved. 00003 00004 Redistribution and use in source and binary forms, with or without 00005 modification, are permitted provided that the following conditions are met: 00006 00007 1. Redistributions of source code must retain the above copyright notice, this 00008 list of conditions and the following disclaimer. 00009 00010 2. Redistributions in binaryform must reproduce the above copyright notice, 00011 this list of conditions and the following disclaimer in the documentation 00012 and/or other materials provided withthe distribution. 00013 00014 THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC``AS IS'' AND ANY EXPRESS OR 00015 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00016 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 00017 EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00018 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00019 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00020 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00021 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00022 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00023 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 00026 #import <Foundation/Foundation.h> 00027 #import "UAObservable.h" 00028 #import "UA_ASIHTTPRequest.h" 00029 #import "UASubscriptionAlertProtocol.h" 00030 00031 typedef enum _UAUserState { 00032 UAUserStateEmpty = 0, 00033 UAUserStateNoEmail = 1, 00034 UAUserStateWithEmail = 2, 00035 UAUserStateInRecovery = 3, 00036 UAUserStateCreating = 4 00037 } UAUserState; 00038 00039 @protocol UAUserObserver <NSObject> 00040 @optional 00041 00042 // Notified when user created or modified, not including recovery 00043 - (void)userUpdated; 00044 - (void)userUpdateFailed; 00045 00046 // Notified during recovering process 00047 - (void)userRecoveryStarted; 00048 - (void)userRecoveryFinished; 00049 - (void)userRecoveryFailed; 00050 00051 - (void)userRetrieveStarted; 00052 - (void)userRetrieveFinished; 00053 - (void)userRetrieveFailed; 00054 @end 00055 00056 @interface UAUser : UAObservable { 00057 00058 @private 00059 BOOL initialized; 00060 NSString *username; 00061 NSString *password; 00062 NSString *email; 00063 NSString *url; 00064 NSString *alias; 00065 NSMutableSet *tags; 00066 00067 UAUserState userState; 00068 00069 //recovery 00070 NSString *recoveryEmail; 00071 NSString *recoveryStatusUrl; 00072 NSTimer *recoveryPoller; 00073 BOOL inRecovery; 00074 BOOL recoveryStarted; 00075 BOOL sentRecoveryEmail; 00076 BOOL retrievingUser; 00077 00078 BOOL isObservingDeviceToken; 00079 00080 //creation flag 00081 BOOL creatingUser; 00082 00083 } 00084 00085 @property (retain, nonatomic) NSString *recoveryEmail; 00086 @property (retain, nonatomic) NSString *recoveryStatusUrl; 00087 @property (retain, nonatomic) NSTimer *recoveryPoller; 00088 00089 // Public interface 00090 @property (assign, readonly, nonatomic) UAUserState userState; 00091 @property (retain, nonatomic) NSString *username; 00092 @property (retain, nonatomic) NSString *password; 00093 @property (retain, nonatomic) NSString *email; 00094 @property (retain, nonatomic) NSString *url; 00095 @property (retain, nonatomic) NSString *alias; 00096 @property (retain, nonatomic) NSMutableSet *tags; 00097 00098 + (UAUser *)defaultUser; 00099 - (BOOL)defaultUserCreated; 00100 - (BOOL)setUserEmail:(NSString *)address; 00101 - (void)startRecovery; 00102 - (void)cancelRecovery; 00103 00104 // Private interface 00105 @property (assign, nonatomic) BOOL inRecovery; 00106 @property (assign, nonatomic) BOOL recoveryStarted; 00107 @property (assign, nonatomic) BOOL sentRecoveryEmail; 00108 @property (assign, nonatomic) BOOL retrievingUser; 00109 00110 //Specifies a default PRE-EXISTING username and password to use in the case a new user would 00111 //otherwise be created by [UAUser defaultUser] 00112 + (void)setDefaultUsername:(NSString *)defaultUsername withPassword:(NSString *)defaultPassword; 00113 00114 - (void)initializeUser; 00115 - (void)loadUser; 00116 00117 - (void)createUser; 00118 - (void)createUserWithEmail:(NSString *)value; 00119 - (void)modifyUserWithEmail:(NSString *)value; 00120 00121 - (void)retrieveUser; 00122 00123 - (void)startRecoveryPoller; 00124 - (void)stopRecoveryPoller; 00125 - (void)checkRecoveryStatus:(NSTimer *)timer; 00126 00127 - (void)didMergeWithUser:(NSDictionary *)userData; 00128 00129 - (void)saveUserData; 00130 - (void)updateUserState; 00131 - (void)notifyObserversUserUpdated; 00132 00133 - (void)requestWentWrong:(UA_ASIHTTPRequest*)request; 00134 - (void)userRequestWentWrong:(UA_ASIHTTPRequest*)request; 00135 00136 00137 - (void)updateUserWithDelegate:(id)delegate finish:(SEL)finishSelector fail:(SEL)failSelector; 00138 - (NSMutableDictionary*)createUserDictionary; 00139 00140 @end