Merge lp:~rockstar/ubuntuone-ios-music/kill-deps into lp:ubuntuone-ios-music
- kill-deps
- Merge into trunk
Proposed by
Paul Hummer
Status: | Merged |
---|---|
Approved by: | Paul Hummer |
Approved revision: | 239 |
Merged at revision: | 239 |
Proposed branch: | lp:~rockstar/ubuntuone-ios-music/kill-deps |
Merge into: | lp:ubuntuone-ios-music |
Diff against target: |
482 lines (+7/-356) 7 files modified
Other Sources/U1MusicAppDelegate.m (+3/-15) U1Music.xcodeproj/project.pbxproj (+0/-6) U1Music_Prefix.pch (+0/-1) utilities/SFHFKeychainUtils.h (+0/-41) utilities/SFHFKeychainUtils.m (+0/-272) utilities/Subsonic.h (+0/-1) utilities/Subsonic.m (+4/-20) |
To merge this branch: | bzr merge lp:~rockstar/ubuntuone-ios-music/kill-deps |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zachery Bir | Approve | ||
Review via email: mp+126340@code.launchpad.net |
Commit message
Kill the need for SFHFKeychainUtils
Description of the change
This branch requires the changes in https:/
Kill the need for SFHFKeychainUtils
To post a comment you must log in.
Revision history for this message
Zachery Bir (urbanape) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Other Sources/U1MusicAppDelegate.m' |
2 | --- Other Sources/U1MusicAppDelegate.m 2012-09-20 04:09:46 +0000 |
3 | +++ Other Sources/U1MusicAppDelegate.m 2012-09-25 21:30:30 +0000 |
4 | @@ -42,11 +42,11 @@ |
5 | #import "U1LocalMusicServer.h" |
6 | #import "U1MigrationViewController.h" |
7 | #import "UOSSOCredentialsViewController.h" |
8 | +#import "UOAuthManager.h" |
9 | |
10 | @interface U1MusicAppDelegate () <UOSSOCredentialsViewControllerDelegate> |
11 | @property (retain) UOSSOCredentialsViewController *loginController; |
12 | @property (retain) U1LocalMusicServer *musicServer; |
13 | -- (void)parseQueryCredentials:(NSURL*)anURL; |
14 | - (BOOL)configureUsernamePassword; |
15 | - (void)presentLoginView; |
16 | - (void)prepareTestFlight; |
17 | @@ -145,27 +145,15 @@ |
18 | [self presentLoginView]; |
19 | } |
20 | |
21 | -- (void)parseQueryCredentials:(NSURL*)anURL |
22 | -{ |
23 | - URLQueryStringParser *queryStringParser = [[URLQueryStringParser alloc] initWithURL:anURL]; |
24 | - NSString *user = [queryStringParser queryStringValueForKey:@"u"]; |
25 | - NSString *pass = [queryStringParser queryStringValueForKey:@"p"]; |
26 | - |
27 | - if (user != nil && pass != nil) |
28 | - { |
29 | - [[Subsonic sharedSubsonic] storeUsername:user password:pass]; |
30 | - } |
31 | -} |
32 | - |
33 | - (BOOL)configureUsernamePassword |
34 | { |
35 | BOOL needToRetrieveCredentials = NO; |
36 | |
37 | - NSString *username = [SFHFKeychainUtils getPasswordForUsername:UBUNTU_ONE_DUMMY_USER_NAME andServiceName:UBUNTU_ONE_SERVICE_NAME error:nil]; |
38 | + NSString *username = [[UOAuthManager sharedAuthManager] subsonicUsername]; |
39 | if (username) |
40 | { |
41 | [[Subsonic sharedSubsonic] setDefaultUserName:username]; |
42 | - [[Subsonic sharedSubsonic] setDefaultPassword:[SFHFKeychainUtils getPasswordForUsername:username andServiceName:UBUNTU_ONE_SERVICE_NAME error:nil]]; |
43 | + [[Subsonic sharedSubsonic] setDefaultPassword:[[UOAuthManager sharedAuthManager] subsonicPassword]]; |
44 | } |
45 | else |
46 | { |
47 | |
48 | === modified file 'U1Music.xcodeproj/project.pbxproj' |
49 | --- U1Music.xcodeproj/project.pbxproj 2012-09-20 04:07:45 +0000 |
50 | +++ U1Music.xcodeproj/project.pbxproj 2012-09-25 21:30:30 +0000 |
51 | @@ -171,7 +171,6 @@ |
52 | 93DFFE54135D72420061F29F /* NSManagedObjectContext+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DFFE53135D72420061F29F /* NSManagedObjectContext+Additions.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
53 | 93EE2AF0124993F100E7E060 /* ArtistListParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 93EE2AEF124993F100E7E060 /* ArtistListParser.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
54 | 93EE2BA31249F33D00E7E060 /* ArtistParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 93EE2BA21249F33D00E7E060 /* ArtistParser.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
55 | - 93F334471247F9DE006C6707 /* SFHFKeychainUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 93F334461247F9DE006C6707 /* SFHFKeychainUtils.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
56 | 93F3344D1247FA0B006C6707 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 93F3344C1247FA0B006C6707 /* Reachability.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
57 | 93F334521247FA2C006C6707 /* Album.m in Sources */ = {isa = PBXBuildFile; fileRef = 93F3344F1247FA2C006C6707 /* Album.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
58 | 93F334531247FA2C006C6707 /* Artist.m in Sources */ = {isa = PBXBuildFile; fileRef = 93F334511247FA2C006C6707 /* Artist.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
59 | @@ -503,8 +502,6 @@ |
60 | 93EE2AEF124993F100E7E060 /* ArtistListParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ArtistListParser.m; sourceTree = "<group>"; }; |
61 | 93EE2BA11249F33D00E7E060 /* ArtistParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArtistParser.h; sourceTree = "<group>"; }; |
62 | 93EE2BA21249F33D00E7E060 /* ArtistParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ArtistParser.m; sourceTree = "<group>"; }; |
63 | - 93F334451247F9DE006C6707 /* SFHFKeychainUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SFHFKeychainUtils.h; sourceTree = "<group>"; }; |
64 | - 93F334461247F9DE006C6707 /* SFHFKeychainUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SFHFKeychainUtils.m; sourceTree = "<group>"; }; |
65 | 93F3344B1247FA0B006C6707 /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = "<group>"; }; |
66 | 93F3344C1247FA0B006C6707 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = "<group>"; }; |
67 | 93F3344E1247FA2C006C6707 /* Album.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Album.h; sourceTree = "<group>"; }; |
68 | @@ -986,8 +983,6 @@ |
69 | 93F334741247FB9F006C6707 /* AudioStreamer.m */, |
70 | 93F3344B1247FA0B006C6707 /* Reachability.h */, |
71 | 93F3344C1247FA0B006C6707 /* Reachability.m */, |
72 | - 93F334451247F9DE006C6707 /* SFHFKeychainUtils.h */, |
73 | - 93F334461247F9DE006C6707 /* SFHFKeychainUtils.m */, |
74 | 93BC52A5124C1E6900B7587C /* StreamingPlayer.h */, |
75 | 93BC52A6124C1E6900B7587C /* StreamingPlayer.m */, |
76 | 93D6B5491252CE57007880B0 /* URLQueryStringParser.h */, |
77 | @@ -1395,7 +1390,6 @@ |
78 | 936F20681227364200070F43 /* Playlist.m in Sources */, |
79 | 936F209012273D9000070F43 /* Song.m in Sources */, |
80 | 936F230A12284D1900070F43 /* NamedTextFieldCell.m in Sources */, |
81 | - 93F334471247F9DE006C6707 /* SFHFKeychainUtils.m in Sources */, |
82 | 93F3344D1247FA0B006C6707 /* Reachability.m in Sources */, |
83 | 93F334521247FA2C006C6707 /* Album.m in Sources */, |
84 | 93F334531247FA2C006C6707 /* Artist.m in Sources */, |
85 | |
86 | === modified file 'U1Music_Prefix.pch' |
87 | --- U1Music_Prefix.pch 2012-02-10 17:38:18 +0000 |
88 | +++ U1Music_Prefix.pch 2012-09-25 21:30:30 +0000 |
89 | @@ -16,7 +16,6 @@ |
90 | #import "MOC.h" |
91 | #import "NSManagedObjectContext+Additions.h" |
92 | #import "NSString+Extras.h" |
93 | - #import "SFHFKeychainUtils.h" |
94 | #import "TestFlight.h" |
95 | #define RELEASE_SAFELY(__obj) [__obj release], __obj = nil; |
96 | |
97 | |
98 | === removed file 'utilities/SFHFKeychainUtils.h' |
99 | --- utilities/SFHFKeychainUtils.h 2010-09-20 20:32:15 +0000 |
100 | +++ utilities/SFHFKeychainUtils.h 1970-01-01 00:00:00 +0000 |
101 | @@ -1,41 +0,0 @@ |
102 | -// |
103 | -// SFHFKeychainUtils.h |
104 | -// |
105 | -// Created by Buzz Andersen on 10/20/08. |
106 | -// Based partly on code by Jonathan Wight, Jon Crosby, and Mike Malone. |
107 | -// Copyright 2008 Sci-Fi Hi-Fi. All rights reserved. |
108 | -// |
109 | -// Permission is hereby granted, free of charge, to any person |
110 | -// obtaining a copy of this software and associated documentation |
111 | -// files (the "Software"), to deal in the Software without |
112 | -// restriction, including without limitation the rights to use, |
113 | -// copy, modify, merge, publish, distribute, sublicense, and/or sell |
114 | -// copies of the Software, and to permit persons to whom the |
115 | -// Software is furnished to do so, subject to the following |
116 | -// conditions: |
117 | -// |
118 | -// The above copyright notice and this permission notice shall be |
119 | -// included in all copies or substantial portions of the Software. |
120 | -// |
121 | -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
122 | -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
123 | -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
124 | -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
125 | -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
126 | -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
127 | -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
128 | -// OTHER DEALINGS IN THE SOFTWARE. |
129 | -// |
130 | - |
131 | -#import <UIKit/UIKit.h> |
132 | - |
133 | - |
134 | -@interface SFHFKeychainUtils : NSObject { |
135 | - |
136 | -} |
137 | - |
138 | -+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error; |
139 | -+ (BOOL) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error; |
140 | -+ (BOOL) deleteItemForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error; |
141 | - |
142 | -@end |
143 | \ No newline at end of file |
144 | |
145 | === removed file 'utilities/SFHFKeychainUtils.m' |
146 | --- utilities/SFHFKeychainUtils.m 2010-09-24 05:34:15 +0000 |
147 | +++ utilities/SFHFKeychainUtils.m 1970-01-01 00:00:00 +0000 |
148 | @@ -1,272 +0,0 @@ |
149 | -// |
150 | -// SFHFKeychainUtils.m |
151 | -// |
152 | -// Created by Buzz Andersen on 10/20/08. |
153 | -// Based partly on code by Jonathan Wight, Jon Crosby, and Mike Malone. |
154 | -// Copyright 2008 Sci-Fi Hi-Fi. All rights reserved. |
155 | -// |
156 | -// Permission is hereby granted, free of charge, to any person |
157 | -// obtaining a copy of this software and associated documentation |
158 | -// files (the "Software"), to deal in the Software without |
159 | -// restriction, including without limitation the rights to use, |
160 | -// copy, modify, merge, publish, distribute, sublicense, and/or sell |
161 | -// copies of the Software, and to permit persons to whom the |
162 | -// Software is furnished to do so, subject to the following |
163 | -// conditions: |
164 | -// |
165 | -// The above copyright notice and this permission notice shall be |
166 | -// included in all copies or substantial portions of the Software. |
167 | -// |
168 | -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
169 | -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
170 | -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
171 | -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
172 | -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
173 | -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
174 | -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
175 | -// OTHER DEALINGS IN THE SOFTWARE. |
176 | -// |
177 | - |
178 | -#import "SFHFKeychainUtils.h" |
179 | -#import <Security/Security.h> |
180 | - |
181 | -static NSString *SFHFKeychainUtilsErrorDomain = @"SFHFKeychainUtilsErrorDomain"; |
182 | - |
183 | -@implementation SFHFKeychainUtils |
184 | - |
185 | - |
186 | -+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error { |
187 | - if (!username || !serviceName) { |
188 | - if (error != nil) { |
189 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil]; |
190 | - } |
191 | - return nil; |
192 | - } |
193 | - |
194 | - if (error != nil) { |
195 | - *error = nil; |
196 | - } |
197 | - |
198 | - // Set up a query dictionary with the base query attributes: item type (generic), username, and service |
199 | - |
200 | - NSArray *keys = [[[NSArray alloc] initWithObjects: (NSString *) kSecClass, kSecAttrAccount, kSecAttrService, nil] autorelease]; |
201 | - NSArray *objects = [[[NSArray alloc] initWithObjects: (NSString *) kSecClassGenericPassword, username, serviceName, nil] autorelease]; |
202 | - |
203 | - NSMutableDictionary *query = [[[NSMutableDictionary alloc] initWithObjects: objects forKeys: keys] autorelease]; |
204 | - |
205 | - // First do a query for attributes, in case we already have a Keychain item with no password data set. |
206 | - // One likely way such an incorrect item could have come about is due to the previous (incorrect) |
207 | - // version of this code (which set the password as a generic attribute instead of password data). |
208 | - |
209 | - NSDictionary *attributeResult = NULL; |
210 | - NSMutableDictionary *attributeQuery = [query mutableCopy]; |
211 | - [attributeQuery setObject: (id) kCFBooleanTrue forKey:(id) kSecReturnAttributes]; |
212 | - OSStatus status = SecItemCopyMatching((CFDictionaryRef) attributeQuery, (CFTypeRef *) &attributeResult); |
213 | - |
214 | - [attributeResult release]; |
215 | - [attributeQuery release]; |
216 | - |
217 | - if (status != noErr) { |
218 | - // No existing item found--simply return nil for the password |
219 | - if (error != nil && status != errSecItemNotFound) { |
220 | - //Only return an error if a real exception happened--not simply for "not found." |
221 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil]; |
222 | - } |
223 | - |
224 | - return nil; |
225 | - } |
226 | - |
227 | - // We have an existing item, now query for the password data associated with it. |
228 | - |
229 | - NSData *resultData = nil; |
230 | - NSMutableDictionary *passwordQuery = [query mutableCopy]; |
231 | - [passwordQuery setObject: (id) kCFBooleanTrue forKey: (id) kSecReturnData]; |
232 | - |
233 | - status = SecItemCopyMatching((CFDictionaryRef) passwordQuery, (CFTypeRef *) &resultData); |
234 | - |
235 | - [resultData autorelease]; |
236 | - [passwordQuery release]; |
237 | - |
238 | - if (status != noErr) { |
239 | - if (status == errSecItemNotFound) { |
240 | - // We found attributes for the item previously, but no password now, so return a special error. |
241 | - // Users of this API will probably want to detect this error and prompt the user to |
242 | - // re-enter their credentials. When you attempt to store the re-entered credentials |
243 | - // using storeUsername:andPassword:forServiceName:updateExisting:error |
244 | - // the old, incorrect entry will be deleted and a new one with a properly encrypted |
245 | - // password will be added. |
246 | - if (error != nil) { |
247 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -1999 userInfo: nil]; |
248 | - } |
249 | - } |
250 | - else { |
251 | - // Something else went wrong. Simply return the normal Keychain API error code. |
252 | - if (error != nil) { |
253 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil]; |
254 | - } |
255 | - } |
256 | - |
257 | - return nil; |
258 | - } |
259 | - |
260 | - NSString *password = nil; |
261 | - |
262 | - if (resultData) { |
263 | - password = [[NSString alloc] initWithData: resultData encoding: NSUTF8StringEncoding]; |
264 | - } |
265 | - else { |
266 | - // There is an existing item, but we weren't able to get password data for it for some reason, |
267 | - // Possibly as a result of an item being incorrectly entered by the previous code. |
268 | - // Set the -1999 error so the code above us can prompt the user again. |
269 | - if (error != nil) { |
270 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -1999 userInfo: nil]; |
271 | - } |
272 | - } |
273 | - |
274 | - return [password autorelease]; |
275 | -} |
276 | - |
277 | -+ (BOOL) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error |
278 | -{ |
279 | - if (!username || !password || !serviceName) |
280 | - { |
281 | - if (error != nil) |
282 | - { |
283 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil]; |
284 | - } |
285 | - return NO; |
286 | - } |
287 | - |
288 | - // See if we already have a password entered for these credentials. |
289 | - NSError *getError = nil; |
290 | - NSString *existingPassword = [SFHFKeychainUtils getPasswordForUsername: username andServiceName: serviceName error:&getError]; |
291 | - |
292 | - if ([getError code] == -1999) |
293 | - { |
294 | - // There is an existing entry without a password properly stored (possibly as a result of the previous incorrect version of this code. |
295 | - // Delete the existing item before moving on entering a correct one. |
296 | - |
297 | - getError = nil; |
298 | - |
299 | - [self deleteItemForUsername: username andServiceName: serviceName error: &getError]; |
300 | - |
301 | - if ([getError code] != noErr) |
302 | - { |
303 | - if (error != nil) |
304 | - { |
305 | - *error = getError; |
306 | - } |
307 | - return NO; |
308 | - } |
309 | - } |
310 | - else if ([getError code] != noErr) |
311 | - { |
312 | - if (error != nil) |
313 | - { |
314 | - *error = getError; |
315 | - } |
316 | - return NO; |
317 | - } |
318 | - |
319 | - if (error != nil) |
320 | - { |
321 | - *error = nil; |
322 | - } |
323 | - |
324 | - OSStatus status = noErr; |
325 | - |
326 | - if (existingPassword) |
327 | - { |
328 | - // We have an existing, properly entered item with a password. |
329 | - // Update the existing item. |
330 | - |
331 | - if (![existingPassword isEqualToString:password] && updateExisting) |
332 | - { |
333 | - //Only update if we're allowed to update existing. If not, simply do nothing. |
334 | - |
335 | - NSArray *keys = [[[NSArray alloc] initWithObjects: (NSString *) kSecClass, |
336 | - kSecAttrService, |
337 | - kSecAttrLabel, |
338 | - kSecAttrAccount, |
339 | - nil] autorelease]; |
340 | - |
341 | - NSArray *objects = [[[NSArray alloc] initWithObjects: (NSString *) kSecClassGenericPassword, |
342 | - serviceName, |
343 | - serviceName, |
344 | - username, |
345 | - nil] autorelease]; |
346 | - |
347 | - NSDictionary *query = [[[NSDictionary alloc] initWithObjects: objects forKeys: keys] autorelease]; |
348 | - |
349 | - status = SecItemUpdate((CFDictionaryRef) query, (CFDictionaryRef) [NSDictionary dictionaryWithObject: [password dataUsingEncoding: NSUTF8StringEncoding] forKey: (NSString *) kSecValueData]); |
350 | - } |
351 | - } |
352 | - else |
353 | - { |
354 | - // No existing entry (or an existing, improperly entered, and therefore now |
355 | - // deleted, entry). Create a new entry. |
356 | - |
357 | - NSArray *keys = [[[NSArray alloc] initWithObjects: (NSString *) kSecClass, |
358 | - kSecAttrService, |
359 | - kSecAttrLabel, |
360 | - kSecAttrAccount, |
361 | - kSecValueData, |
362 | - nil] autorelease]; |
363 | - |
364 | - NSArray *objects = [[[NSArray alloc] initWithObjects: (NSString *) kSecClassGenericPassword, |
365 | - serviceName, |
366 | - serviceName, |
367 | - username, |
368 | - [password dataUsingEncoding: NSUTF8StringEncoding], |
369 | - nil] autorelease]; |
370 | - |
371 | - NSDictionary *query = [[[NSDictionary alloc] initWithObjects: objects forKeys: keys] autorelease]; |
372 | - |
373 | - status = SecItemAdd((CFDictionaryRef) query, NULL); |
374 | - } |
375 | - |
376 | - if (error != nil && status != noErr) |
377 | - { |
378 | - // Something went wrong with adding the new item. Return the Keychain error code. |
379 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil]; |
380 | - |
381 | - return NO; |
382 | - } |
383 | - |
384 | - return YES; |
385 | -} |
386 | - |
387 | -+ (BOOL) deleteItemForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error |
388 | -{ |
389 | - if (!username || !serviceName) |
390 | - { |
391 | - if (error != nil) |
392 | - { |
393 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: -2000 userInfo: nil]; |
394 | - } |
395 | - return NO; |
396 | - } |
397 | - |
398 | - if (error != nil) |
399 | - { |
400 | - *error = nil; |
401 | - } |
402 | - |
403 | - NSArray *keys = [[[NSArray alloc] initWithObjects: (NSString *) kSecClass, kSecAttrAccount, kSecAttrService, kSecReturnAttributes, nil] autorelease]; |
404 | - NSArray *objects = [[[NSArray alloc] initWithObjects: (NSString *) kSecClassGenericPassword, username, serviceName, kCFBooleanTrue, nil] autorelease]; |
405 | - |
406 | - NSDictionary *query = [[[NSDictionary alloc] initWithObjects: objects forKeys: keys] autorelease]; |
407 | - |
408 | - OSStatus status = SecItemDelete((CFDictionaryRef) query); |
409 | - |
410 | - if (error != nil && status != noErr) |
411 | - { |
412 | - *error = [NSError errorWithDomain: SFHFKeychainUtilsErrorDomain code: status userInfo: nil]; |
413 | - |
414 | - return NO; |
415 | - } |
416 | - |
417 | - return YES; |
418 | -} |
419 | - |
420 | -@end |
421 | \ No newline at end of file |
422 | |
423 | === modified file 'utilities/Subsonic.h' |
424 | --- utilities/Subsonic.h 2011-11-05 00:42:21 +0000 |
425 | +++ utilities/Subsonic.h 2012-09-25 21:30:30 +0000 |
426 | @@ -47,5 +47,4 @@ |
427 | - (NSURL *)getStreamingURLForSongId:(NSString*)songId; |
428 | - (NSURL *)buildURLWithBase:(NSString *)baseURL action:(NSString *)action parameters:(NSArray *)extraParameters; |
429 | - (void)removeCredentials; |
430 | -- (void)storeUsername:(NSString*)username password:(NSString*)password; |
431 | @end |
432 | |
433 | === modified file 'utilities/Subsonic.m' |
434 | --- utilities/Subsonic.m 2011-11-05 00:42:21 +0000 |
435 | +++ utilities/Subsonic.m 2012-09-25 21:30:30 +0000 |
436 | @@ -24,6 +24,7 @@ |
437 | #include <arpa/inet.h> |
438 | #import "NSMutableArray+Extras.h" |
439 | #import "Reachability.h" |
440 | +#import "UOAuthManager.h" |
441 | |
442 | @interface Subsonic () |
443 | @property (readwrite, retain) Reachability *reachability; |
444 | @@ -62,10 +63,10 @@ |
445 | |
446 | - (BOOL)hasCredentials |
447 | { |
448 | - NSString *username = [SFHFKeychainUtils getPasswordForUsername:UBUNTU_ONE_DUMMY_USER_NAME andServiceName:UBUNTU_ONE_SERVICE_NAME error:nil]; |
449 | + NSString *username = [[UOAuthManager sharedAuthManager] subsonicUsername]; |
450 | if (username) |
451 | { |
452 | - NSString *password = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:UBUNTU_ONE_SERVICE_NAME error:nil]; |
453 | + NSString *password = [[UOAuthManager sharedAuthManager] subsonicPassword]; |
454 | return (password != nil); |
455 | } |
456 | else |
457 | @@ -76,24 +77,7 @@ |
458 | |
459 | - (void)removeCredentials |
460 | { |
461 | - NSString *username = [[SFHFKeychainUtils getPasswordForUsername:UBUNTU_ONE_DUMMY_USER_NAME andServiceName:UBUNTU_ONE_SERVICE_NAME error:nil] retain]; |
462 | - |
463 | - if (username) |
464 | - { |
465 | - [SFHFKeychainUtils deleteItemForUsername:UBUNTU_ONE_DUMMY_USER_NAME andServiceName:UBUNTU_ONE_SERVICE_NAME error:nil]; |
466 | - [SFHFKeychainUtils deleteItemForUsername:username andServiceName:UBUNTU_ONE_SERVICE_NAME error:nil]; |
467 | - } |
468 | - |
469 | - [username release]; |
470 | -} |
471 | - |
472 | -- (void)storeUsername:(NSString*)username password:(NSString*)password |
473 | -{ |
474 | - [SFHFKeychainUtils storeUsername:UBUNTU_ONE_DUMMY_USER_NAME andPassword:username forServiceName:UBUNTU_ONE_SERVICE_NAME updateExisting:YES error:nil]; |
475 | - [SFHFKeychainUtils storeUsername:username andPassword:password forServiceName:UBUNTU_ONE_SERVICE_NAME updateExisting:YES error:nil]; |
476 | - |
477 | - self.defaultUserName = username; |
478 | - self.defaultPassword = password; |
479 | + [[UOAuthManager sharedAuthManager] clearSubsonicCredentials]; |
480 | } |
481 | |
482 | - (NSURL *)getStreamingURLForSongId:(NSString*)songId |