- flickrログアウト後にログインできなくなる問題を修正
- flickr tokenアクセス中にボタンを使用不可に
@@ -38,6 +38,7 @@ | ||
38 | 38 | |
39 | 39 | -(void) setObject:(id)obj forKey:(id)key; |
40 | 40 | -(id) objectForKey:(id)key; |
41 | +-(void) removeObjectForKey:(id)key; | |
41 | 42 | -(BOOL) synchronize; |
42 | 43 | |
43 | 44 | @end |
@@ -81,6 +81,13 @@ | ||
81 | 81 | return nil; |
82 | 82 | } |
83 | 83 | |
84 | +-(void) removeObjectForKey:(id)key | |
85 | +{ | |
86 | + if (key) { | |
87 | + [m_plist removeObjectForKey:key]; | |
88 | + } | |
89 | +} | |
90 | + | |
84 | 91 | -(BOOL) synchronize |
85 | 92 | { |
86 | 93 | return [m_plist writeToFile:m_path atomically:YES]; |
@@ -33,6 +33,7 @@ | ||
33 | 33 | NSString* _frob; |
34 | 34 | NSString* _token; |
35 | 35 | NSString* _authBtnTitle; |
36 | + BOOL _enableButton; | |
36 | 37 | } |
37 | 38 | |
38 | 39 | -(IBAction) authorization:(id)sender; |
@@ -89,6 +89,8 @@ | ||
89 | 89 | Flickr_Auth_GetToken* req = [[Flickr_Auth_GetToken alloc] initWithFrob:_frob]; |
90 | 90 | [req setDelegate:self]; |
91 | 91 | [req start]; |
92 | + | |
93 | + [self setValue:[NSNumber numberWithBool:NO] forKey:@"enableButton"]; | |
92 | 94 | } |
93 | 95 | } |
94 | 96 | } |
@@ -99,10 +101,14 @@ | ||
99 | 101 | ret = NSRunAlertPanel(LOCALIZED(@"Return to this window after you have finished the remove process on Flickr.com"), LOCALIZED(@"Once you're done, click the 'Complete Remove' button below"), LOCALIZED(@"Complete Remove"), LOCALIZED(@"Cancel"), @""); |
100 | 102 | if (ret == NSAlertDefaultReturn) { |
101 | 103 | PUUserDefaults* defaults = [PUUserDefaults standardUserDefaults]; |
102 | - [defaults setObject:nil forKey:@"Flickr_Token"]; | |
104 | + [defaults removeObjectForKey:@"Flickr_Token"]; | |
103 | 105 | [defaults synchronize]; |
104 | 106 | [FlickrRequest setToken:nil]; |
107 | + | |
105 | 108 | [self setValue:LOCALIZED(@"Login...") forKey:@"authBtnTitle"]; |
109 | + | |
110 | + // frobを再取得 | |
111 | + [self login]; | |
106 | 112 | } |
107 | 113 | } |
108 | 114 | } |
@@ -128,6 +134,7 @@ | ||
128 | 134 | if (xml && [xml isKindOfClass:[NSXMLDocument class]]) { |
129 | 135 | [self setValue:[[xml rootElement] objectValueForXPath:@"/rsp/frob" error:nil] forKey:@"frob"]; |
130 | 136 | } |
137 | + [self setValue:[NSNumber numberWithBool:YES] forKey:@"enableButton"]; | |
131 | 138 | } else if ([request isKindOfClass:[Flickr_Auth_GetToken class]]) { |
132 | 139 | // token 取得 |
133 | 140 | if (xml && [xml isKindOfClass:[NSXMLDocument class]]) { |
@@ -138,6 +145,7 @@ | ||
138 | 145 | [FlickrRequest setToken:_token]; |
139 | 146 | [self setValue:LOCALIZED(@"Logout...") forKey:@"authBtnTitle"]; |
140 | 147 | } |
148 | + [self setValue:[NSNumber numberWithBool:YES] forKey:@"enableButton"]; | |
141 | 149 | } |
142 | 150 | } |
143 | 151 |
@@ -196,6 +204,7 @@ | ||
196 | 204 | [self setValue:token forKey:@"token"]; |
197 | 205 | [FlickrRequest setToken:_token]; |
198 | 206 | [self setValue:LOCALIZED(@"Logout...") forKey:@"authBtnTitle"]; |
207 | + [self setValue:[NSNumber numberWithBool:YES] forKey:@"enableButton"]; | |
199 | 208 | } else { |
200 | 209 | // token未取得 |
201 | 210 | // frob を取得しておく |
@@ -203,6 +212,7 @@ | ||
203 | 212 | [req setDelegate:self]; |
204 | 213 | [req start]; |
205 | 214 | [self setValue:LOCALIZED(@"Login...") forKey:@"authBtnTitle"]; |
215 | + [self setValue:[NSNumber numberWithBool:NO] forKey:@"enableButton"]; | |
206 | 216 | } |
207 | 217 | } |
208 | 218 |