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