├── .gitignore ├── .gitmodules ├── README.mdown ├── iOSSocial ├── Headers │ ├── Facebook │ │ ├── FacebookService.h │ │ ├── FacebookUser.h │ │ ├── LocalFacebookUser.h │ │ ├── facebook_trans.png │ │ └── facebook_trans@2x.png │ ├── Flickr │ │ ├── Flickr.h │ │ ├── FlickrUser.h │ │ ├── LocalFlickrUser.h │ │ └── flickr-logo.png │ ├── Foursquare │ │ ├── Foursquare.h │ │ ├── FoursquareUser.h │ │ ├── LocalFoursquareUser.h │ │ └── foursquare_trans.png │ ├── Instagram │ │ ├── Instagram.h │ │ ├── InstagramUser.h │ │ ├── LocalInstagramUser.h │ │ └── instagram_trans.png │ ├── OAuth │ │ ├── iOSSocialOAuth.h │ │ ├── iOSSocialServiceOAuth1Provider.h │ │ ├── iOSSocialServiceOAuth1ProviderConstants.h │ │ ├── iOSSocialServiceOAuth2Provider.h │ │ └── iOSSocialServiceOAuth2ProviderConstants.h │ ├── Tumblr │ │ ├── LocalTumblrUser.h │ │ ├── Tumblr.h │ │ ├── TumblrUser.h │ │ └── tumblr-logo.png │ ├── Twitter │ │ ├── LocalTwitterUser.h │ │ ├── Twitter.h │ │ ├── TwitterUser.h │ │ └── twitter-logo.png │ ├── iOSSRequest.h │ ├── iOSSService.h │ ├── iOSServicesDataSource.h │ ├── iOSSocialConstants.h │ ├── iOSSocialLocalUser.h │ ├── iOSSocialServicesStore.h │ └── iOSSocialUser.h ├── InstaBeta │ ├── CIMG2891.JPG │ ├── InstaBeta.xcodeproj │ │ └── project.pbxproj │ ├── InstaBeta │ │ ├── InstaBeta-Info.plist │ │ ├── InstaBeta-Prefix.pch │ │ ├── InstaBetaAppDelegate.h │ │ ├── InstaBetaAppDelegate.m │ │ ├── InstaBetaViewController.h │ │ ├── InstaBetaViewController.m │ │ ├── en.lproj │ │ │ ├── InfoPlist.strings │ │ │ ├── InstaBetaViewController_iPad.xib │ │ │ └── InstaBetaViewController_iPhone.xib │ │ └── main.m │ └── InstaBetaTests │ │ ├── InstaBetaTests-Info.plist │ │ ├── InstaBetaTests.h │ │ ├── InstaBetaTests.m │ │ └── en.lproj │ │ └── InfoPlist.strings ├── iOSSocial.xcodeproj │ └── project.pbxproj ├── iOSSocial.xcworkspace │ └── contents.xcworkspacedata ├── iOSSocial │ ├── Facebook │ │ ├── FacebookService.h │ │ ├── FacebookService.m │ │ ├── FacebookUser+Private.h │ │ ├── FacebookUser.h │ │ ├── FacebookUser.m │ │ ├── LocalFacebookUser.h │ │ ├── LocalFacebookUser.m │ │ ├── facebook_trans.png │ │ └── facebook_trans@2x.png │ ├── Flickr │ │ ├── Flickr.h │ │ ├── Flickr.m │ │ ├── FlickrUser+Private.h │ │ ├── FlickrUser.h │ │ ├── FlickrUser.m │ │ ├── LocalFlickrUser.h │ │ ├── LocalFlickrUser.m │ │ └── flickr-logo.png │ ├── Foursquare │ │ ├── Foursquare.h │ │ ├── Foursquare.m │ │ ├── FoursquareUser+Private.h │ │ ├── FoursquareUser.h │ │ ├── FoursquareUser.m │ │ ├── LocalFoursquareUser.h │ │ ├── LocalFoursquareUser.m │ │ └── foursquare_trans.png │ ├── Instagram │ │ ├── Instagram.h │ │ ├── Instagram.m │ │ ├── InstagramUser+Private.h │ │ ├── InstagramUser.h │ │ ├── InstagramUser.m │ │ ├── LocalInstagramUser.h │ │ ├── LocalInstagramUser.m │ │ └── instagram_trans.png │ ├── OAuth │ │ ├── GTMOAuthAuthentication+Additions.h │ │ ├── GTMOAuthAuthentication+Additions.m │ │ ├── iOSSocialOAuth.h │ │ ├── iOSSocialServiceOAuth1Provider.h │ │ ├── iOSSocialServiceOAuth1Provider.m │ │ ├── iOSSocialServiceOAuth1ProviderConstants.h │ │ ├── iOSSocialServiceOAuth2Provider.h │ │ ├── iOSSocialServiceOAuth2Provider.m │ │ └── iOSSocialServiceOAuth2ProviderConstants.h │ ├── Tumblr │ │ ├── LocalTumblrUser.h │ │ ├── LocalTumblrUser.m │ │ ├── Tumblr.h │ │ ├── Tumblr.m │ │ ├── TumblrUser+Private.h │ │ ├── TumblrUser.h │ │ ├── TumblrUser.m │ │ └── tumblr-logo.png │ ├── Twitter │ │ ├── LocalTwitterUser.h │ │ ├── LocalTwitterUser.m │ │ ├── LocalTwitterUserLegacy.h │ │ ├── LocalTwitterUserLegacy.m │ │ ├── Twitter.h │ │ ├── Twitter.m │ │ ├── TwitterUser+Private.h │ │ ├── TwitterUser.h │ │ ├── TwitterUser.m │ │ ├── TwitterUserLegacy+Private.h │ │ ├── TwitterUserLegacy.h │ │ ├── TwitterUserLegacy.m │ │ └── twitter-logo.png │ ├── Utilities │ │ ├── Connection │ │ │ ├── iOSSRequest.h │ │ │ └── iOSSRequest.m │ │ ├── Keychain │ │ │ ├── KeychainItemWrapper.h │ │ │ └── KeychainItemWrapper.m │ │ └── Log │ │ │ ├── iOSSLog.h │ │ │ └── iOSSLog.m │ ├── iOSSServiceTableViewCell.h │ ├── iOSSServiceTableViewCell.m │ ├── iOSServicesDataSource.h │ ├── iOSServicesDataSource.m │ ├── iOSSocial-Prefix.pch │ ├── iOSSocial.h │ ├── iOSSocial.m │ ├── iOSSocialAccountTableViewCell.h │ ├── iOSSocialAccountTableViewCell.m │ ├── iOSSocialConstants.h │ ├── iOSSocialLocalUser.h │ ├── iOSSocialLocalUser.m │ ├── iOSSocialServicesStore.h │ ├── iOSSocialServicesStore.m │ ├── iOSSocialUser.h │ └── iOSSocialUser.m └── iOSSocialTests │ ├── en.lproj │ └── InfoPlist.strings │ ├── iOSSocialTests-Info.plist │ ├── iOSSocialTests.h │ └── iOSSocialTests.m └── prp ├── PRPSmartTableViewCell.h └── PRPSmartTableViewCell.m /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | iOSSocial/iOSSocial.xcodeproj/project.xcworkspace/ 3 | iOSSocial/iOSSocial.xcodeproj/xcuserdata/ 4 | iOSSocial/build/ 5 | iOSSocial/output/ 6 | iOSSocial/InstaBeta/InstaBeta.xcodeproj/xcuserdat/ 7 | iOSSocial/InstaBeta/InstaBeta.xcodeproj/project.xcworkspace/ 8 | iOSSocial/InstaBeta/InstaBeta.xcodeproj/xcuserdata/ 9 | iOSSocial/iOSSocial.xcworkspace/.LSOverride 10 | iOSSocial/iOSSocial.xcworkspace/xcuserdata/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gtm-oauth"] 2 | path = gtm-oauth 3 | url = git@github.com:chris124/gtm-oauth.git 4 | [submodule "gtm-oauth2"] 5 | path = gtm-oauth2 6 | url = git@github.com:chris124/gtm-oauth2.git 7 | [submodule "gtm-http-fetcher"] 8 | path = gtm-http-fetcher 9 | url = git@github.com:chris124/gtm-http-fetcher.git 10 | [submodule "asi-http-request"] 11 | path = asi-http-request 12 | url = git@github.com:chris124/asi-http-request.git 13 | [submodule "facebook-ios-sdk"] 14 | path = facebook-ios-sdk 15 | url = git@github.com:chris124/facebook-ios-sdk.git 16 | [submodule "iOSSocialViewControllers"] 17 | path = iOSSocialViewControllers 18 | url = git@github.com:chris124/iOSSocialViewControllers.git 19 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Facebook/FacebookService.h: -------------------------------------------------------------------------------- 1 | // 2 | // FacebookService.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 9/29/11. 6 | // Copyright (c) 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialServicesStore.h" 11 | 12 | @interface FacebookService : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Facebook/FacebookUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // FacebookUser.h 3 | // MadRaces 4 | // 5 | // Created by Christopher White on 7/5/11. 6 | // Copyright 2011 Betaworks. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialUser.h" 11 | #import "iOSSocialConstants.h" 12 | 13 | @class UIImage; 14 | //typedef void(^LoadPhotoHandler)(UIImage *photo, NSError *error); 15 | 16 | @interface FacebookUser : NSObject 17 | 18 | //cwnote: should alias be copied? 19 | @property(nonatomic, readonly, retain) NSString *userID; // Invariant user identifier. 20 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 21 | @property(nonatomic, readonly, retain) NSString *firstName; // The user's first name 22 | @property(nonatomic, readonly, retain) NSString *lastName; // The user's last name 23 | @property(nonatomic, readonly, retain) NSString *email; // The user's last name 24 | @property(nonatomic, readonly) BOOL isFriend; // True if this user is a friend of the local user 25 | 26 | - (id)initWithDictionary:(NSDictionary*)userDictionary; 27 | 28 | // Asynchronously load the player's photo. Error will be nil on success. 29 | // Possible reasons for error: 30 | // 1. Communications failure 31 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 32 | 33 | @end 34 | 35 | // Notification will be posted whenever the user details changes. The object of the notification will be the user. 36 | //extern NSString *UserDidChangeNotificationName; 37 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Facebook/LocalFacebookUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocalFacebookUser.h 3 | // MadRaces 4 | // 5 | // Created by Christopher White on 7/5/11. 6 | // Copyright 2011 Betaworks. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FacebookUser.h" 11 | #import "iOSSocialLocalUser.h" 12 | 13 | 14 | //typedef void(^AuthenticationHandler)(NSError *error); 15 | typedef void(^FindFriendsHandler)(NSArray *friends, NSError *error); 16 | typedef void(^LoadUsersHandler)(NSArray *users, NSError *error); 17 | typedef void(^CreatePhotoAlbumHandler)(NSError *error); 18 | typedef void(^LoadPhotoAlbumsHandler)(NSArray *photoAlbums, NSError *error); 19 | 20 | @interface LocalFacebookUser : FacebookUser { 21 | } 22 | 23 | // Obtain the LocalFacebookUser object. 24 | // The user is only available for offline use until logged in. 25 | // A temporary use is created if no account is set up. 26 | + (LocalFacebookUser *)localFacebookUser; 27 | 28 | + (void)setLocalFacebookUser:(LocalFacebookUser *)theLocalFacebookUser; 29 | 30 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 31 | /* 32 | // Authenticate the user for access to user details. This may present UI to the user if necessary to login or create an account. The user must be authenticated in order to use other APIs. This should be called for each launch of the application as soon as the UI is ready. 33 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. Facebook UI may be presented during this authentication. Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 34 | // Possible reasons for error: 35 | // 1. Communications problem 36 | // 2. User credentials invalid 37 | // 3. User cancelled 38 | - (void)authenticateUserPermissions:(NSArray*)permissions 39 | withCompletionHandler:(AuthenticationHandler)completionHandler; 40 | */ 41 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 42 | // The user must be authenticated in order to use other APIs. 43 | // This should be called for each launch of the application as soon as the UI is ready. 44 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 45 | // Instagram UI may be presented during this authentication. 46 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 47 | // The authorization screen, if needed, is show modally so pass in the current view controller. 48 | // Possible reasons for error: 49 | // 1. Communications problem 50 | // 2. User credentials invalid 51 | // 3. User cancelled 52 | - (void)authenticateFromViewController:(UIViewController*)vc 53 | withCompletionHandler:(AuthenticationHandler)completionHandler; 54 | 55 | - (NSString*)oAuthAccessToken; 56 | 57 | - (NSString*)oAuthAccessTokenSecret; 58 | 59 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 60 | 61 | //remove all stored OAuth info from the keychain and reset state in memory 62 | - (void)logout; 63 | 64 | - (BOOL)handleOpenURL:(NSURL *)url; 65 | 66 | @property(nonatomic, readonly, retain) NSArray *friends; // Array of user identifiers of friends for the local user. Not valid until loadFriendsWithCompletionHandler: has completed. 67 | 68 | // Asynchronously load the friends list as an array of user identifiers. Calls completionHandler when finished. Error will be nil on success. 69 | // Possible reasons for error: 70 | // 1. Communications problem 71 | // 2. Unauthenticated player 72 | - (void)loadFriendsWithCompletionHandler:(FindFriendsHandler)completionHandler; 73 | 74 | // Load the users for the identifiers provided. The array contains FacebookUser objects. Error will be nil on success. 75 | // Possible reasons for error: 76 | // 1. Unauthenticated local user 77 | // 2. Communications failure 78 | // 3. Invalid user identifier 79 | - (void)loadUsersForIdentifiers:(NSArray *)identifiers 80 | withCompletionHandler:(LoadUsersHandler)completionHandler; 81 | 82 | // Create a photo album for the user. The array contains photos to add to the album at time of creation. This can be nil. Error will be nil on success. 83 | // Possible reasons for error: 84 | // 1. Unauthenticated local user 85 | // 2. Communications failure 86 | // 3. Invalid user identifier 87 | - (void)createPhotoAlbumWithName:(NSString*)name 88 | message:(NSString*)message 89 | photos:(NSArray*)photos 90 | withCompletionHandler:(CreatePhotoAlbumHandler)completionHandler; 91 | 92 | // Asynchronously load the photo albums of the user as an array of FacebookPhotoAlbum objects. Error will be nil on success. 93 | // Possible reasons for error: 94 | // 1. Unauthenticated local user 95 | // 2. Communications failure 96 | // 3. Invalid user identifier 97 | - (void)loadPhotoAlbumsWithCompletionHandler:(LoadPhotoAlbumsHandler)completionHandler; 98 | 99 | @end 100 | 101 | // Notification will be posted whenever authentication status changes. 102 | //extern NSString *UserAuthenticationDidChangeNotificationName; 103 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Facebook/facebook_trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/Headers/Facebook/facebook_trans.png -------------------------------------------------------------------------------- /iOSSocial/Headers/Facebook/facebook_trans@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/Headers/Facebook/facebook_trans@2x.png -------------------------------------------------------------------------------- /iOSSocial/Headers/Flickr/Flickr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Flickr.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialServiceOAuth1Provider.h" 11 | #import "iOSSocialServicesStore.h" 12 | 13 | @interface Flickr : iOSSocialServiceOAuth1Provider 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Flickr/FlickrUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // FlickrUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialUser.h" 11 | #import "iOSSocialConstants.h" 12 | 13 | @interface FlickrUser : NSObject 14 | 15 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 16 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 17 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 18 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 19 | 20 | // Asynchronously load the users's photo. Error will be nil on success. 21 | // Possible reasons for error: 22 | // 1. Communications failure 23 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Flickr/LocalFlickrUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocalFlickrUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "FlickrUser.h" 12 | #import "iOSSocialServiceOAuth1ProviderConstants.h" 13 | #import "iOSSocialLocalUser.h" 14 | 15 | typedef void(^FlickrAuthenticationHandler)(NSError *error); 16 | typedef void(^PostPhotoDataHandler)(NSString *photoID, NSError *error); 17 | typedef void(^PhotoInfoDataHandler)(NSDictionary *photoInfo, NSError *error); 18 | typedef void(^UserPhotosDataHandler)(NSDictionary *photos, NSError *error); 19 | typedef void(^PhotoSizesDataHandler)(NSDictionary *photoInfo, NSError *error); 20 | 21 | @interface LocalFlickrUser : FlickrUser 22 | 23 | // Obtain the LocalFlickrUser object. 24 | // The user is only available for offline use until logged in. 25 | // A temporary use is created if no account is set up. 26 | + (LocalFlickrUser *)localFlickrUser; 27 | 28 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 29 | 30 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 31 | // The user must be authenticated in order to use other APIs. 32 | // This should be called for each launch of the application as soon as the UI is ready. 33 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 34 | // Flickr UI may be presented during this authentication. 35 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 36 | // The authorization screen, if needed, is show modally so pass in the current view controller. 37 | // Possible reasons for error: 38 | // 1. Communications problem 39 | // 2. User credentials invalid 40 | // 3. User cancelled 41 | - (void)authenticateFromViewController:(UIViewController*)vc 42 | withCompletionHandler:(AuthenticationHandler)completionHandler; 43 | 44 | - (NSString*)oAuthAccessToken; 45 | 46 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 47 | 48 | - (NSString*)oAuthAccessTokenSecret; 49 | 50 | //remove all stored OAuth info from the keychain and reset state in memory 51 | - (void)logout; 52 | 53 | - (void)getUserPhotosWithCompletionHandler:(UserPhotosDataHandler)completionHandler; 54 | 55 | - (void)postPhotoData:(NSData*)imageData 56 | withFileName:(NSString *)fileName 57 | andParams:(NSDictionary*)photoParams 58 | andCompletionHandler:(PostPhotoDataHandler)completionHandler; 59 | 60 | - (void)getInfoForPhotoWithId:(NSString*)photoID andCompletionHandler:(PhotoInfoDataHandler)completionHandler; 61 | - (void)getPhotoSizesForPhotoWithId:(NSString*)photoID andCompletionHandler:(PhotoSizesDataHandler)completionHandler; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Flickr/flickr-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/Headers/Flickr/flickr-logo.png -------------------------------------------------------------------------------- /iOSSocial/Headers/Foursquare/Foursquare.h: -------------------------------------------------------------------------------- 1 | // 2 | // Foursquare.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialServiceOAuth2Provider.h" 11 | #import "iOSSocialServicesStore.h" 12 | 13 | 14 | @interface Foursquare : iOSSocialServiceOAuth2Provider 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Foursquare/FoursquareUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // FoursquareUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialUser.h" 11 | #import "iOSSocialConstants.h" 12 | 13 | 14 | @interface FoursquareUser : NSObject 15 | 16 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 17 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 18 | @property(nonatomic, readonly, retain) NSString *firstName; // The user's first name 19 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 20 | 21 | // Asynchronously load the users's photo. Error will be nil on success. 22 | // Possible reasons for error: 23 | // 1. Communications failure 24 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Foursquare/LocalFoursquareUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocalFoursquareUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "FoursquareUser.h" 12 | #import "iOSSocialServiceOAuth2ProviderConstants.h" 13 | #import "iOSSocialLocalUser.h" 14 | 15 | typedef void(^FoursquareAuthenticationHandler)(NSError *error); 16 | 17 | @interface LocalFoursquareUser : FoursquareUser 18 | 19 | // Obtain the LocalFoursquareUser object. 20 | // The user is only available for offline use until logged in. 21 | // A temporary use is created if no account is set up. 22 | + (LocalFoursquareUser *)localFoursquareUser; 23 | 24 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 25 | 26 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 27 | // The user must be authenticated in order to use other APIs. 28 | // This should be called for each launch of the application as soon as the UI is ready. 29 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 30 | // Foursquare UI may be presented during this authentication. 31 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 32 | // The authorization screen, if needed, is show modally so pass in the current view controller. 33 | // Possible reasons for error: 34 | // 1. Communications problem 35 | // 2. User credentials invalid 36 | // 3. User cancelled 37 | - (void)authenticateFromViewController:(UIViewController*)vc 38 | withCompletionHandler:(AuthenticationHandler)completionHandler; 39 | 40 | - (NSString*)oAuthAccessToken; 41 | 42 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 43 | 44 | - (NSString*)oAuthAccessTokenSecret; 45 | 46 | //remove all stored OAuth info from the keychain and reset state in memory 47 | - (void)logout; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Foursquare/foursquare_trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/Headers/Foursquare/foursquare_trans.png -------------------------------------------------------------------------------- /iOSSocial/Headers/Instagram/Instagram.h: -------------------------------------------------------------------------------- 1 | // 2 | // Instagram.h 3 | // InstaBeta 4 | // 5 | // Created by Christopher White on 7/14/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialServiceOAuth2Provider.h" 11 | #import "iOSSocialServicesStore.h" 12 | 13 | @interface Instagram : iOSSocialServiceOAuth2Provider 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Instagram/InstagramUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // InstagramUser.h 3 | // InstaBeta 4 | // 5 | // Created by Christopher White on 7/14/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "iOSSocialUser.h" 12 | #import "iOSSocialConstants.h" 13 | 14 | @class InstagramMediaCollection; 15 | 16 | typedef void(^FetchMediaHandler)(InstagramMediaCollection *collection, NSError *error); 17 | 18 | @class InstagramUserCollection; 19 | 20 | typedef void(^FetchUsersHandler)(NSArray *users, NSError *error); 21 | 22 | @interface InstagramUser : NSObject 23 | 24 | //cwnote: should alias be copied? 25 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 26 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 27 | @property(nonatomic, readonly, retain) NSString *firstName; // The user's first name 28 | @property(nonatomic, readonly, retain) NSString *lastName; // The user's last name 29 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 30 | @property(nonatomic, readonly, retain) NSString *bio; // The user's biography 31 | @property(nonatomic, readonly, retain) NSString *website; // The user's website 32 | @property(nonatomic, readonly, assign) NSInteger mediaCount; // The user's total number of media 33 | @property(nonatomic, readonly, assign) NSInteger followsCount; // The user's number of people they follow 34 | @property(nonatomic, readonly, assign) NSInteger followedByCount; // The user's total number of followers 35 | //@property(nonatomic, readonly) BOOL isFriend; // True if this user is a friend of the local user 36 | 37 | /** 38 | * The user source that the user belongs to. 39 | */ 40 | //@property (nonatomic, assign) id userSource; 41 | 42 | // Initialize a user with a dictionary object. The definition for the dictionary can be found here: 43 | // http://instagram.com/developer/endpoints/users/ 44 | // Here is the example for those too lazy to go to the URL :D 45 | /* 46 | { 47 | "id": "1574083", 48 | "username": "snoopdogg", 49 | "first_name": "Snoop", 50 | "last_name": "Dogg", 51 | "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg", 52 | "bio": "This is my bio", 53 | "website": "http://snoopdogg.com", 54 | "counts: { 55 | "media": 1320, 56 | "follows": 420, 57 | "followed_by": 3410 58 | } 59 | } 60 | */ 61 | - (id)initWithDictionary:(NSDictionary*)userDictionary; 62 | 63 | // Asynchronously load the users's photo. Error will be nil on success. 64 | // Possible reasons for error: 65 | // 1. Communications failure 66 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 67 | 68 | - (void)fetchUserDataWithCompletionHandler:(FetchUserDataHandler)completionHandler; 69 | 70 | - (void)fetchFollowedByWithCompletionHandler:(FetchUsersHandler)completionHandler; 71 | 72 | //search for a user...q and count param 73 | + (void)searchUsersWithCompletionHandler:(FetchUsersHandler)completionHandler; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Instagram/LocalInstagramUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocalInstagramUser.h 3 | // InstaBeta 4 | // 5 | // Created by Christopher White on 7/14/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "InstagramUser.h" 12 | #import "iOSSocialServiceOAuth2ProviderConstants.h" 13 | #import "iOSSocialLocalUser.h" 14 | 15 | typedef void(^InstagramAuthenticationHandler)(NSError *error); 16 | 17 | @interface LocalInstagramUser : InstagramUser 18 | 19 | // Obtain the LocalInstagramUser object. 20 | // The user is only available for offline use until logged in. 21 | // A temporary use is created if no account is set up. 22 | + (LocalInstagramUser *)localInstagramUser; 23 | 24 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 25 | 26 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 27 | // The user must be authenticated in order to use other APIs. 28 | // This should be called for each launch of the application as soon as the UI is ready. 29 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 30 | // Instagram UI may be presented during this authentication. 31 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 32 | // The authorization screen, if needed, is show modally so pass in the current view controller. 33 | // Possible reasons for error: 34 | // 1. Communications problem 35 | // 2. User credentials invalid 36 | // 3. User cancelled 37 | - (void)authenticateFromViewController:(UIViewController*)vc 38 | withCompletionHandler:(AuthenticationHandler)completionHandler; 39 | 40 | - (NSString*)oAuthAccessToken; 41 | 42 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 43 | 44 | - (NSString*)oAuthAccessTokenSecret; 45 | 46 | //remove all stored OAuth info from the keychain and reset state in memory 47 | - (void)logout; 48 | 49 | - (void)fetchRelationshipToUser; 50 | 51 | - (void)fetchRequestedBy; 52 | 53 | - (void)modifyRelationshipToUser; 54 | 55 | // These methods make it easy to interact with the instagram app on the user's device. 56 | + (void)instagram; 57 | + (void)camera; 58 | + (void)tagWithName:(NSString*)name; 59 | + (void)userWithName:(NSString*)name; 60 | + (void)locationWithID:(NSString*)locationID; 61 | + (void)mediaWithID:(NSString*)mediaID; 62 | + (void)editPhotoWithURL:(NSURL*)url 63 | andMenuFromView:(UIView*)view; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Instagram/instagram_trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/Headers/Instagram/instagram_trans.png -------------------------------------------------------------------------------- /iOSSocial/Headers/OAuth/iOSSocialOAuth.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialOAuth.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 8/28/11. 6 | // Copyright (c) 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #ifndef iOSSocial_iOSSocialOAuth_h 10 | #define iOSSocial_iOSSocialOAuth_h 11 | 12 | typedef void(^AuthorizationHandler)(id theAuth, NSDictionary *userInfo, NSError *error); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /iOSSocial/Headers/OAuth/iOSSocialServiceOAuth1Provider.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialServiceOAuth1Provider.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "iOSSocialOAuth.h" 12 | 13 | @class GTMOAuthAuthenticationWithAdditions; 14 | @interface iOSSocialServiceOAuth1Provider : NSObject 15 | 16 | - (id)initWithDictionary:(NSDictionary*)dictionary; 17 | 18 | - (GTMOAuthAuthenticationWithAdditions*)checkAuthenticationForKeychainItemName:(NSString*)theKeychainItemName; 19 | 20 | - (void)assignOAuthParams:(NSDictionary*)params; 21 | 22 | - (void)authorizeFromViewController:(UIViewController*)vc 23 | forAuth:(GTMOAuthAuthenticationWithAdditions*)theAuth 24 | andKeychainItemName:(NSString*)theKeychainItemName 25 | andCookieDomain:(NSString*)cookieDomain 26 | withCompletionHandler:(AuthorizationHandler)completionHandler; 27 | 28 | - (void)logout:(GTMOAuthAuthenticationWithAdditions*)theAuth forKeychainItemName:(NSString*)theKeychainItemName; 29 | 30 | - (NSString*)apiKey; 31 | 32 | - (NSString*)apiSecret; 33 | 34 | + (id)JSONFromData:(NSData*)data; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /iOSSocial/Headers/OAuth/iOSSocialServiceOAuth1ProviderConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialServiceOAuth1ProviderConstants.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #ifndef iOSSocial_iOSSocialServiceOAuth1ProviderConstants_h 10 | #define iOSSocial_iOSSocialServiceOAuth1ProviderConstants_h 11 | 12 | // OAuth Params Dictionary Keys 13 | static NSString *const kSMOAuth1ClientID = @"clientID"; 14 | static NSString *const kSMOAuth1ClientSecret = @"clientSecret"; 15 | // This has to match the callback URL you setup on the provider's site for your app 16 | // or you will get an OAuth error! 17 | // You can make up an arbitrary redirectURI. The controller will watch for 18 | // the server to redirect the web view to this URI, but this URI will not be 19 | // loaded, so it need not be for any actual web page. 20 | static NSString *const kSMOAuth1RedirectURI = @"redirectURI"; 21 | // Make this a unique name. Incorporate the name of your app. 22 | // Note: this should perhaps be internalized. 23 | static NSString *const kSMOAuth1KeychainItemName = @"keychainItemName"; 24 | 25 | static NSString *const kSMOAuth1RequestTokenURL = @"requestTokenURL"; 26 | 27 | static NSString *const kSMOAuth1AuthorizeURL = @"authorizeURL"; 28 | 29 | static NSString *const kSMOAuth1AccessTokenURL = @"accessTokenURL"; 30 | 31 | static NSString *const kSMOAuth1ServiceProviderName = @"serviceProviderName"; 32 | 33 | static NSString *const kSMOAuth1Scope = @"scope"; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /iOSSocial/Headers/OAuth/iOSSocialServiceOAuth2Provider.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialServiceOAuth2Provider.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "iOSSocialOAuth.h" 12 | 13 | @class GTMOAuth2Authentication; 14 | @class GTMOAuthAuthenticationWithAdditions; 15 | @interface iOSSocialServiceOAuth2Provider : NSObject 16 | 17 | // See iOSSocialServiceOAuth2ProviderConstants.h for the Keys for this dictionary. 18 | - (id)initWithDictionary:(NSDictionary*)dictionary; 19 | 20 | - (GTMOAuth2Authentication*)checkAuthenticationForKeychainItemName:(NSString*)theKeychainItemName; 21 | 22 | - (void)assignOAuthParams:(NSDictionary*)params; 23 | 24 | - (void)authorizeFromViewController:(UIViewController*)vc 25 | forAuth:(GTMOAuth2Authentication*)theAuth 26 | andKeychainItemName:(NSString*)theKeychainItemName 27 | andCookieDomain:(NSString*)cookieDomain 28 | withCompletionHandler:(AuthorizationHandler)completionHandler; 29 | 30 | - (void)logout:(GTMOAuth2Authentication*)theAuth forKeychainItemName:(NSString*)theKeychainItemName; 31 | 32 | - (NSString*)apiKey; 33 | 34 | - (NSString*)apiSecret; 35 | 36 | + (id)JSONFromData:(NSData*)data; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /iOSSocial/Headers/OAuth/iOSSocialServiceOAuth2ProviderConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialServiceOAuth2ProviderConstants.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #ifndef iOSSocial_iOSSocialServiceOAuth2ProviderConstants_h 10 | #define iOSSocial_iOSSocialServiceOAuth2ProviderConstants_h 11 | 12 | // OAuth Params Dictionary Keys 13 | static NSString *const kSMOAuth2ClientID = @"clientID"; 14 | static NSString *const kSMOAuth2ClientSecret = @"clientSecret"; 15 | // This has to match the callback URL you setup on the provider's site for your app 16 | // or you will get an OAuth error! 17 | // You can make up an arbitrary redirectURI. The controller will watch for 18 | // the server to redirect the web view to this URI, but this URI will not be 19 | // loaded, so it need not be for any actual web page. 20 | static NSString *const kSMOAuth2RedirectURI = @"redirectURI"; 21 | // Make this a unique name. Incorporate the name of your app. 22 | // Note: this should perhaps be internalized. 23 | static NSString *const kSMOAuth2KeychainItemName = @"keychainItemName"; 24 | 25 | static NSString *const kSMOAuth2AuthorizeURL = @"authorizeURL"; 26 | 27 | static NSString *const kSMOAuth2AccessTokenURL = @"accessTokenURL"; 28 | 29 | static NSString *const kSMOAuth2ServiceProviderName = @"serviceProviderName"; 30 | 31 | static NSString *const kSMOAuth2Scope = @"scope"; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Tumblr/LocalTumblrUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocalTumblrUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "TumblrUser.h" 12 | #import "iOSSocialServiceOAuth1ProviderConstants.h" 13 | #import "iOSSocialLocalUser.h" 14 | 15 | typedef void(^TumblrAuthenticationHandler)(NSError *error); 16 | 17 | @interface LocalTumblrUser : TumblrUser 18 | 19 | // Obtain the LocalTumblrUser object. 20 | // The user is only available for offline use until logged in. 21 | // A temporary use is created if no account is set up. 22 | + (LocalTumblrUser *)localTumblrUser; 23 | 24 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 25 | 26 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 27 | // The user must be authenticated in order to use other APIs. 28 | // This should be called for each launch of the application as soon as the UI is ready. 29 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 30 | // Tumblr UI may be presented during this authentication. 31 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 32 | // The authorization screen, if needed, is show modally so pass in the current view controller. 33 | // Possible reasons for error: 34 | // 1. Communications problem 35 | // 2. User credentials invalid 36 | // 3. User cancelled 37 | - (void)authenticateFromViewController:(UIViewController*)vc 38 | withCompletionHandler:(AuthenticationHandler)completionHandler; 39 | 40 | - (NSString*)oAuthAccessToken; 41 | 42 | //remove all stored OAuth info from the keychain and reset state in memory 43 | - (void)logout; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Tumblr/Tumblr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Tumblr.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialServiceOAuth1Provider.h" 11 | #import "iOSSocialServicesStore.h" 12 | 13 | @interface Tumblr : iOSSocialServiceOAuth1Provider 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Tumblr/TumblrUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // TumblrUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialUser.h" 11 | #import "iOSSocialConstants.h" 12 | 13 | @interface TumblrUser : NSObject 14 | 15 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 16 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 17 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 18 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 19 | 20 | // Asynchronously load the users's photo. Error will be nil on success. 21 | // Possible reasons for error: 22 | // 1. Communications failure 23 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Tumblr/tumblr-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/Headers/Tumblr/tumblr-logo.png -------------------------------------------------------------------------------- /iOSSocial/Headers/Twitter/LocalTwitterUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocalTwitterUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "TwitterUser.h" 12 | #import "iOSSocialServiceOAuth1ProviderConstants.h" 13 | #import "iOSSocialLocalUser.h" 14 | 15 | typedef void(^TwitterAuthenticationHandler)(NSError *error); 16 | 17 | @interface LocalTwitterUser : TwitterUser 18 | 19 | // Obtain the LocalTwitterUser object. 20 | // The user is only available for offline use until logged in. 21 | // A temporary use is created if no account is set up. 22 | + (LocalTwitterUser *)localTwitterUser; 23 | 24 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 25 | 26 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 27 | // The user must be authenticated in order to use other APIs. 28 | // This should be called for each launch of the application as soon as the UI is ready. 29 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 30 | // Twitter UI may be presented during this authentication. 31 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 32 | // The authorization screen, if needed, is show modally so pass in the current view controller. 33 | // Possible reasons for error: 34 | // 1. Communications problem 35 | // 2. User credentials invalid 36 | // 3. User cancelled 37 | - (void)authenticateFromViewController:(UIViewController*)vc 38 | withCompletionHandler:(AuthenticationHandler)completionHandler; 39 | 40 | - (NSString*)oAuthAccessToken; 41 | 42 | //remove all stored OAuth info from the keychain and reset state in memory 43 | - (void)logout; 44 | 45 | - (void)postTweet; 46 | - (void)postTweetWithMedia; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Twitter/Twitter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Twitter.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialServiceOAuth1Provider.h" 11 | #import "iOSSocialServicesStore.h" 12 | 13 | @interface Twitter : iOSSocialServiceOAuth1Provider 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Twitter/TwitterUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // TwitterUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "iOSSocialUser.h" 11 | #import "iOSSocialConstants.h" 12 | 13 | @interface TwitterUser : NSObject 14 | 15 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 16 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 17 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 18 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 19 | 20 | // Asynchronously load the users's photo. Error will be nil on success. 21 | // Possible reasons for error: 22 | // 1. Communications failure 23 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /iOSSocial/Headers/Twitter/twitter-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/Headers/Twitter/twitter-logo.png -------------------------------------------------------------------------------- /iOSSocial/Headers/iOSSRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSRequest.h 3 | // InstaBeta 4 | // 5 | // Created by Christopher White on 7/21/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | enum iOSSRequestMethod { 13 | iOSSRequestMethodGET, 14 | iOSSRequestMethodPOST, 15 | iOSSRequestMethodDELETE 16 | }; 17 | typedef enum iOSSRequestMethod iOSSRequestMethod; 18 | 19 | //typedef void(^iOSSRequestHandler)(NSString *responseString, NSError *error); 20 | typedef void(^iOSSRequestHandler)(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error); 21 | 22 | @interface iOSSRequest : NSObject { 23 | } 24 | 25 | - (id)initWithURL:(NSURL *)url 26 | parameters:(NSDictionary *)parameters 27 | requestMethod:(iOSSRequestMethod)requestMethod; 28 | 29 | @property(nonatomic, readonly, retain) NSDictionary *parameters; 30 | @property(nonatomic, readonly, assign) iOSSRequestMethod requestMethod; 31 | @property(nonatomic, readonly, retain) NSURL *URL; 32 | 33 | - (void)addMultiPartData:(NSData *)data 34 | withName:(NSString *)name 35 | type:(NSString *)type; 36 | 37 | - (void)performRequestWithHandler:(iOSSRequestHandler)handler; 38 | 39 | @end -------------------------------------------------------------------------------- /iOSSocial/Headers/iOSSService.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSService.h 3 | // PhotoStream 4 | // 5 | // Created by Christopher White on 8/4/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol iOSSocialLocalUserProtocol; 12 | @protocol iOSSServiceProtocol 13 | 14 | @property(nonatomic, readonly, retain) NSString *name; 15 | @property(nonatomic, readonly, retain) NSURL *photoUrl; 16 | @property(nonatomic, readonly, retain) id localUser; 17 | 18 | - (id)initWithDictionary:(NSDictionary*)serviceDictionary; 19 | 20 | @property(nonatomic, readonly, getter=isConnected) BOOL connected; // Authentication state 21 | 22 | @end 23 | 24 | @interface iOSSService : NSObject 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /iOSSocial/Headers/iOSServicesDataSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSServicesDataSource.h 3 | // PhotoStream 4 | // 5 | // Created by Christopher White on 8/4/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface iOSServicesDataSource : NSObject { 13 | } 14 | 15 | @property(nonatomic, retain) NSString *message; 16 | @property(nonatomic, assign) BOOL displayDoneButton; 17 | 18 | - (id)initWithServicesFilter:(NSArray*)filter; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /iOSSocial/Headers/iOSSocialConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialConstants.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 8/28/11. 6 | // Copyright (c) 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | #import 9 | 10 | typedef void(^LoadPhotoHandler)(UIImage *photo, NSError *error); 11 | -------------------------------------------------------------------------------- /iOSSocial/Headers/iOSSocialLocalUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialLocalUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "iOSSocialConstants.h" 12 | 13 | typedef void(^AuthenticationHandler)(NSError *error); 14 | 15 | @protocol iOSSocialLocalUserProtocol 16 | 17 | @required 18 | 19 | - (id)initWithDictionary:(NSDictionary*)dictionary; 20 | 21 | - (id)initWithUUID:(NSString*)uuid; 22 | 23 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 24 | 25 | @property(nonatomic, readonly, retain) NSString *username; 26 | @property(nonatomic, readonly, retain) NSString *servicename; 27 | @property(nonatomic, readonly, retain) NSString *uuidString; 28 | 29 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 30 | // The user must be authenticated in order to use some other APIs (on a per-service basis). 31 | // This should be called for each launch of the application as soon as the UI is ready. 32 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 33 | // The UI may be presented during this authentication. 34 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 35 | // The authorization screen, if needed, is show modally so pass in the current view controller. 36 | // Possible reasons for error: 37 | // 1. Communications problem 38 | // 2. User credentials invalid 39 | // 3. User cancelled 40 | - (void)authenticateFromViewController:(UIViewController*)vc 41 | withCompletionHandler:(AuthenticationHandler)completionHandler; 42 | 43 | - (NSString*)oAuthAccessToken; 44 | 45 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 46 | 47 | - (NSString*)oAuthAccessTokenSecret; 48 | 49 | //remove all stored OAuth info from the keychain and reset state in memory 50 | - (void)logout; 51 | 52 | - (NSString*)userId; 53 | 54 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 55 | 56 | @optional 57 | 58 | - (NSURL*)authorizedURL:(NSURL*)theURL; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /iOSSocial/Headers/iOSSocialServicesStore.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialServicesStore.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 8/28/11. 6 | // Copyright (c) 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "iOSSocialOAuth.h" 12 | 13 | @class GTMOAuthAuthenticationWithAdditions; 14 | @class GTMOAuth2Authentication; 15 | @protocol iOSSocialLocalUserProtocol; 16 | 17 | @protocol iOSSocialServiceProtocol 18 | 19 | @required 20 | 21 | @property(nonatomic, readonly, retain) NSString *name; 22 | @property(nonatomic, readonly, retain) UIImage *logoImage; 23 | @property(nonatomic, readonly, assign) BOOL primary; 24 | 25 | + (id)sharedService; 26 | 27 | // This must be called before calling any of the non-class methods on a service otherwise it will cause an assertion. 28 | // See iOSSocialServiceOAuth2ProviderConstants.h or iOSSocialServiceOAuthProviderConstants.h for the Keys for this dictionary. 29 | - (void)assignOAuthParams:(NSDictionary*)params asPrimary:(BOOL)isPrimary; 30 | 31 | - (id)localUser; 32 | 33 | - (id)localUserWithDictionary:(NSDictionary*)dictionary; 34 | 35 | - (id)localUserWithUUID:(NSString*)uuid; 36 | 37 | - (NSString*)apiKey; 38 | 39 | - (NSString*)apiSecret; 40 | 41 | @optional 42 | 43 | - (NSString*)apiScope; 44 | 45 | - (void)authorizeFromViewController:(UIViewController*)vc 46 | forAuth:(id)theAuth 47 | andKeychainItemName:(NSString*)theKeychainItemName 48 | andCookieDomain:(NSString*)cookieDomain 49 | withCompletionHandler:(AuthorizationHandler)completionHandler; 50 | 51 | - (void)logout:(id)theAuth forKeychainItemName:(NSString*)theKeychainItemName; 52 | 53 | - (id)checkAuthenticationForKeychainItemName:(NSString*)theKeychainItemName; 54 | 55 | + (id)JSONFromData:(NSData*)data; 56 | 57 | @end 58 | 59 | @interface iOSSocialServicesStore : NSObject 60 | 61 | @property(nonatomic, readonly, retain) NSMutableArray *services; 62 | @property(nonatomic, readonly, retain) NSMutableArray *accounts; 63 | @property(nonatomic, readonly, retain) id defaultAccount; 64 | 65 | + (iOSSocialServicesStore*)sharedServiceStore; 66 | 67 | - (id)serviceWithType:(NSString*)serviceName; 68 | 69 | - (id)accountWithType:(NSString*)accountName; 70 | 71 | - (id)accountWithDictionary:(NSDictionary*)accountDictionary; 72 | 73 | - (void)registerService:(id)theService; 74 | 75 | - (void)registerAccount:(id)theAccount; 76 | 77 | - (void)unregisterAccount:(id)theAccount; 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /iOSSocial/Headers/iOSSocialUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialUser.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | typedef void(^FetchUserDataHandler)(NSError *error); 13 | 14 | @protocol iOSSocialUserProtocol 15 | 16 | - (id)initWithDictionary:(NSDictionary*)userDictionary; 17 | 18 | @end -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/CIMG2891.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/InstaBeta/CIMG2891.JPG -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBeta/InstaBeta-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFiles 12 | 13 | CFBundleIdentifier 14 | com.betaworks.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleURLTypes 26 | 27 | 28 | CFBundleURLName 29 | 30 | CFBundleURLSchemes 31 | 32 | fb[appID][URLSuffix]://authorize 33 | fb[appID][URLSuffix] 34 | 35 | 36 | 37 | CFBundleVersion 38 | 1.0 39 | LSRequiresIPhoneOS 40 | 41 | UISupportedInterfaceOrientations 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | UISupportedInterfaceOrientations~ipad 48 | 49 | UIInterfaceOrientationPortrait 50 | UIInterfaceOrientationPortraitUpsideDown 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBeta/InstaBeta-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'InstaBeta' target in the 'InstaBeta' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBeta/InstaBetaAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // InstaBetaAppDelegate.h 3 | // InstaBeta 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class InstaBetaViewController; 12 | 13 | @interface InstaBetaAppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) InstaBetaViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBeta/InstaBetaViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // InstaBetaViewController.h 3 | // InstaBeta 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface InstaBetaViewController : UIViewController 13 | 14 | - (IBAction)servicesButtonPressed:(id)sender; 15 | - (IBAction)actionButtonPressed:(id)sender; 16 | @property (strong, nonatomic) IBOutlet UIButton *actionButton; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBeta/InstaBetaViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // InstaBetaViewController.m 3 | // InstaBeta 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import "InstaBetaViewController.h" 10 | #import "iOSSocialLocalUser.h" 11 | #import "iOSSocialServicesStore.h" 12 | #import "iOSSServicesViewController.h" 13 | 14 | @interface InstaBetaViewController () 15 | 16 | @property(nonatomic, retain) id localUser; 17 | 18 | @end 19 | 20 | @implementation InstaBetaViewController 21 | @synthesize actionButton; 22 | 23 | @synthesize localUser; 24 | 25 | - (void)didReceiveMemoryWarning 26 | { 27 | [super didReceiveMemoryWarning]; 28 | // Release any cached data, images, etc that aren't in use. 29 | } 30 | 31 | #pragma mark - View lifecycle 32 | 33 | // Implement loadView to create a view hierarchy programmatically, without using a nib. 34 | - (void)loadView 35 | { 36 | [super loadView]; 37 | } 38 | 39 | - (void)viewDidLoad 40 | { 41 | [super viewDidLoad]; 42 | // Do any additional setup after loading the view, typically from a nib. 43 | } 44 | 45 | - (void)viewDidUnload 46 | { 47 | [self setActionButton:nil]; 48 | [self setActionButton:nil]; 49 | [super viewDidUnload]; 50 | // Release any retained subviews of the main view. 51 | // e.g. self.myOutlet = nil; 52 | } 53 | 54 | - (void)viewWillAppear:(BOOL)animated 55 | { 56 | [super viewWillAppear:animated]; 57 | } 58 | 59 | - (void)viewDidAppear:(BOOL)animated 60 | { 61 | [super viewDidAppear:animated]; 62 | } 63 | 64 | - (void)viewWillDisappear:(BOOL)animated 65 | { 66 | [super viewWillDisappear:animated]; 67 | } 68 | 69 | - (void)viewDidDisappear:(BOOL)animated 70 | { 71 | [super viewDidDisappear:animated]; 72 | } 73 | 74 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 75 | { 76 | // Return YES for supported orientations 77 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 78 | return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 79 | } else { 80 | return YES; 81 | } 82 | } 83 | 84 | - (IBAction)servicesButtonPressed:(id)sender 85 | { 86 | iOSSServicesViewController *iossServicesViewController = [[iOSSServicesViewController alloc] init]; 87 | 88 | [iossServicesViewController presentModallyFromViewController:self 89 | withAccountHandler:^(id theLocalUser) { 90 | [[iOSSocialServicesStore sharedServiceStore] unregisterAccount:theLocalUser]; 91 | [theLocalUser logout]; 92 | theLocalUser = nil; 93 | [iossServicesViewController refreshUI]; 94 | } 95 | withServiceConnectedHandler:^(id theLocalUser) { 96 | [[iOSSocialServicesStore sharedServiceStore] registerAccount:theLocalUser]; 97 | [iossServicesViewController refreshUI]; 98 | 99 | } 100 | withCompletionHandler:^{ 101 | [self dismissModalViewControllerAnimated:YES]; 102 | } 103 | ]; 104 | } 105 | 106 | - (IBAction)actionButtonPressed:(id)sender 107 | { 108 | if (!self.localUser) { 109 | self.localUser = [[iOSSocialServicesStore sharedServiceStore] defaultAccount]; 110 | } 111 | 112 | //cwnote: update readme for iOSSocial to show this use case 113 | if (![self.localUser isAuthenticated] ) { 114 | [self.localUser authenticateFromViewController:self 115 | withCompletionHandler:^(NSError *error){ 116 | if (error) { 117 | } else { 118 | [[iOSSocialServicesStore sharedServiceStore] registerAccount:self.localUser]; 119 | } 120 | }]; 121 | } else { 122 | [[iOSSocialServicesStore sharedServiceStore] unregisterAccount:self.localUser]; 123 | [self.localUser logout]; 124 | self.localUser = nil; 125 | } 126 | } 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBeta/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBeta/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // InstaBeta 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "InstaBetaAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([InstaBetaAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBetaTests/InstaBetaTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.betaworks.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBetaTests/InstaBetaTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // InstaBetaTests.h 3 | // InstaBetaTests 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface InstaBetaTests : SenTestCase 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBetaTests/InstaBetaTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // InstaBetaTests.m 3 | // InstaBetaTests 4 | // 5 | // Created by Christopher White on 7/26/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import "InstaBetaTests.h" 10 | 11 | @implementation InstaBetaTests 12 | 13 | - (void)setUp 14 | { 15 | [super setUp]; 16 | 17 | // Set-up code here. 18 | } 19 | 20 | - (void)tearDown 21 | { 22 | // Tear-down code here. 23 | 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample 28 | { 29 | STFail(@"Unit tests are not implemented yet in InstaBetaTests"); 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /iOSSocial/InstaBeta/InstaBetaTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Facebook/FacebookService.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #import 19 | #import "iOSSocialServicesStore.h" 20 | 21 | @interface FacebookService : NSObject 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Facebook/FacebookService.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "FacebookService.h" 18 | #import "iOSSLog.h" 19 | #import "LocalFacebookUser.h" 20 | #import "iOSSocialServiceOAuth2ProviderConstants.h" 21 | 22 | @interface FacebookService () 23 | 24 | @property(nonatomic, readwrite, assign) BOOL primary; 25 | @property(nonatomic, retain) NSString *theApiKey; 26 | @property(nonatomic, retain) NSString *theApiSecret; 27 | @property(nonatomic, retain) NSString *theApiScope; 28 | @property(nonatomic, retain) NSString *theURLSchemeSuffix; 29 | @property(nonatomic, readwrite, retain) NSString *keychainItemName; 30 | 31 | @end 32 | 33 | static FacebookService *facebookService = nil; 34 | 35 | @implementation FacebookService 36 | 37 | @synthesize name; 38 | @synthesize logoImage; 39 | @synthesize primary; 40 | @synthesize theApiKey; 41 | @synthesize theApiSecret; 42 | @synthesize theApiScope; 43 | @synthesize theURLSchemeSuffix; 44 | @synthesize keychainItemName; 45 | 46 | + (id)sharedService; 47 | { 48 | @synchronized(self) { 49 | if(facebookService == nil) { 50 | facebookService = [[super allocWithZone:NULL] init]; 51 | } 52 | } 53 | return facebookService; 54 | } 55 | 56 | - (id)init 57 | { 58 | self = [super init]; 59 | if (self) { 60 | } 61 | 62 | return self; 63 | } 64 | 65 | - (void)assignOAuthParams:(NSDictionary*)params asPrimary:(BOOL)isPrimary 66 | { 67 | self.theApiKey = [params objectForKey:kSMOAuth2ClientID]; 68 | self.theApiSecret = [params objectForKey:kSMOAuth2ClientSecret]; 69 | self.theApiScope = [params objectForKey:kSMOAuth2Scope]; 70 | self.theURLSchemeSuffix = [params objectForKey:kSMOAuth2URLSchemeSuffix]; 71 | self.keychainItemName = [params objectForKey:kSMOAuth2KeychainItemName]; 72 | 73 | self.primary = isPrimary; 74 | 75 | [[iOSSocialServicesStore sharedServiceStore] registerService:self]; 76 | } 77 | 78 | - (NSString*)name 79 | { 80 | return @"Facebook"; 81 | } 82 | 83 | - (NSString*)apiKey 84 | { 85 | return self.theApiKey; 86 | } 87 | 88 | - (NSString*)urlSchemeSuffix 89 | { 90 | return self.theURLSchemeSuffix; 91 | } 92 | 93 | - (NSString*)apiSecret 94 | { 95 | return self.theApiSecret; 96 | } 97 | 98 | - (NSString*)apiScope 99 | { 100 | return self.theApiScope; 101 | } 102 | 103 | - (UIImage*)logoImage 104 | { 105 | NSURL *logoURL = [[NSBundle mainBundle] URLForResource:@"facebook_trans" withExtension:@"png"]; 106 | UIImage *theLogoImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:logoURL]]; 107 | return theLogoImage; 108 | } 109 | 110 | - (NSString*)serviceKeychainItemName 111 | { 112 | return self.keychainItemName; 113 | } 114 | 115 | - (id)localUser 116 | { 117 | return [LocalFacebookUser localFacebookUser]; 118 | } 119 | 120 | - (id)localUserWithDictionary:(NSDictionary*)dictionary 121 | { 122 | LocalFacebookUser *theUser = [[LocalFacebookUser alloc] initWithDictionary:dictionary]; 123 | [LocalFacebookUser setLocalFacebookUser:theUser]; 124 | return theUser; 125 | } 126 | 127 | - (id)localUserWithIdentifier:(NSString*)identifier 128 | { 129 | LocalFacebookUser *theUser = [[LocalFacebookUser alloc] initWithIdentifier:identifier]; 130 | [LocalFacebookUser setLocalFacebookUser:theUser]; 131 | return theUser; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Facebook/FacebookUser+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @interface FacebookUser () 18 | 19 | @property(nonatomic, readwrite, retain) NSDictionary *userDictionary; 20 | @property(nonatomic, readwrite, retain) NSString *userID; 21 | @property(nonatomic, readwrite, retain) NSString *alias; 22 | @property(nonatomic, readwrite, retain) NSString *firstName; 23 | @property(nonatomic, readwrite, retain) NSString *lastName; 24 | @property(nonatomic, readwrite, retain) NSString *email; 25 | @property(nonatomic, readwrite, retain) NSString *profilePictureURL; 26 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 27 | @property(nonatomic, readwrite, retain) Facebook *facebook; 28 | 29 | @end 30 | 31 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Facebook/FacebookUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialUser.h" 19 | #import "iOSSocialConstants.h" 20 | 21 | @class UIImage; 22 | //typedef void(^LoadPhotoHandler)(UIImage *photo, NSError *error); 23 | 24 | @interface FacebookUser : NSObject 25 | 26 | //cwnote: should alias be copied? 27 | @property(nonatomic, readonly, retain) NSString *userID; // Invariant user identifier. 28 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 29 | @property(nonatomic, readonly, retain) NSString *firstName; // The user's first name 30 | @property(nonatomic, readonly, retain) NSString *lastName; // The user's last name 31 | @property(nonatomic, readonly, retain) NSString *email; // The user's last name 32 | @property(nonatomic, readonly) BOOL isFriend; // True if this user is a friend of the local user 33 | 34 | - (id)initWithDictionary:(NSDictionary*)userDictionary; 35 | 36 | // Asynchronously load the player's photo. Error will be nil on success. 37 | // Possible reasons for error: 38 | // 1. Communications failure 39 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 40 | 41 | @end 42 | 43 | // Notification will be posted whenever the user details changes. The object of the notification will be the user. 44 | //extern NSString *UserDidChangeNotificationName; 45 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Facebook/LocalFacebookUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "FacebookUser.h" 19 | #import "iOSSocialLocalUser.h" 20 | 21 | 22 | //typedef void(^AuthenticationHandler)(NSError *error); 23 | typedef void(^FindFriendsHandler)(NSArray *friends, NSError *error); 24 | typedef void(^LoadUsersHandler)(NSArray *users, NSError *error); 25 | typedef void(^CreatePhotoAlbumHandler)(NSError *error); 26 | typedef void(^LoadPhotoAlbumsHandler)(NSArray *photoAlbums, NSError *error); 27 | typedef void(^CompletionHandler)(NSError *error); 28 | 29 | @interface LocalFacebookUser : FacebookUser { 30 | } 31 | 32 | // Obtain the LocalFacebookUser object. 33 | // The user is only available for offline use until logged in. 34 | // A temporary use is created if no account is set up. 35 | + (LocalFacebookUser *)localFacebookUser; 36 | 37 | + (void)setLocalFacebookUser:(LocalFacebookUser *)theLocalFacebookUser; 38 | 39 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 40 | /* 41 | // Authenticate the user for access to user details. This may present UI to the user if necessary to login or create an account. The user must be authenticated in order to use other APIs. This should be called for each launch of the application as soon as the UI is ready. 42 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. Facebook UI may be presented during this authentication. Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 43 | // Possible reasons for error: 44 | // 1. Communications problem 45 | // 2. User credentials invalid 46 | // 3. User cancelled 47 | - (void)authenticateUserPermissions:(NSArray*)permissions 48 | withCompletionHandler:(AuthenticationHandler)completionHandler; 49 | */ 50 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 51 | // The user must be authenticated in order to use other APIs. 52 | // This should be called for each launch of the application as soon as the UI is ready. 53 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 54 | // Instagram UI may be presented during this authentication. 55 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 56 | // The authorization screen, if needed, is show modally so pass in the current view controller. 57 | // Possible reasons for error: 58 | // 1. Communications problem 59 | // 2. User credentials invalid 60 | // 3. User cancelled 61 | - (void)authenticateFromViewController:(UIViewController*)vc 62 | withCompletionHandler:(AuthenticationHandler)completionHandler; 63 | 64 | - (NSString*)oAuthAccessToken; 65 | 66 | - (NSString*)oAuthAccessTokenSecret; 67 | 68 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 69 | 70 | //remove all stored OAuth info from the keychain and reset state in memory 71 | - (void)logout; 72 | 73 | - (BOOL)handleOpenURL:(NSURL *)url; 74 | 75 | @property(nonatomic, readonly, retain) NSArray *friends; // Array of user identifiers of friends for the local user. Not valid until loadFriendsWithCompletionHandler: has completed. 76 | 77 | // Asynchronously load the friends list as an array of user identifiers. Calls completionHandler when finished. Error will be nil on success. 78 | // Possible reasons for error: 79 | // 1. Communications problem 80 | // 2. Unauthenticated player 81 | - (void)loadFriendsWithCompletionHandler:(FindFriendsHandler)completionHandler; 82 | 83 | // Load the users for the identifiers provided. The array contains FacebookUser objects. Error will be nil on success. 84 | // Possible reasons for error: 85 | // 1. Unauthenticated local user 86 | // 2. Communications failure 87 | // 3. Invalid user identifier 88 | - (void)loadUsersForIdentifiers:(NSArray *)identifiers 89 | withCompletionHandler:(LoadUsersHandler)completionHandler; 90 | 91 | // Create a photo album for the user. The array contains photos to add to the album at time of creation. This can be nil. Error will be nil on success. 92 | // Possible reasons for error: 93 | // 1. Unauthenticated local user 94 | // 2. Communications failure 95 | // 3. Invalid user identifier 96 | - (void)createPhotoAlbumWithName:(NSString*)name 97 | message:(NSString*)message 98 | photos:(NSArray*)photos 99 | withCompletionHandler:(CreatePhotoAlbumHandler)completionHandler; 100 | 101 | // Asynchronously load the photo albums of the user as an array of FacebookPhotoAlbum objects. Error will be nil on success. 102 | // Possible reasons for error: 103 | // 1. Unauthenticated local user 104 | // 2. Communications failure 105 | // 3. Invalid user identifier 106 | - (void)loadPhotoAlbumsWithCompletionHandler:(LoadPhotoAlbumsHandler)completionHandler; 107 | 108 | - (void)postStatusUpdate:(NSMutableDictionary*)params 109 | withCompletionHandler:(CompletionHandler)completionHandler; 110 | 111 | @end 112 | 113 | // Notification will be posted whenever authentication status changes. 114 | //extern NSString *UserAuthenticationDidChangeNotificationName; 115 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Facebook/facebook_trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/iOSSocial/Facebook/facebook_trans.png -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Facebook/facebook_trans@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/iOSSocial/Facebook/facebook_trans@2x.png -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Flickr/Flickr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialServiceOAuth1Provider.h" 19 | #import "iOSSocialServicesStore.h" 20 | 21 | @interface Flickr : iOSSocialServiceOAuth1Provider 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Flickr/Flickr.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "Flickr.h" 18 | #import "iOSSLog.h" 19 | #import "LocalFlickrUser.h" 20 | 21 | @interface Flickr () 22 | 23 | @property(nonatomic, readwrite, assign) BOOL primary; 24 | 25 | @end 26 | 27 | static Flickr *FlickrService = nil; 28 | 29 | @implementation Flickr 30 | 31 | @synthesize name; 32 | @synthesize logoImage; 33 | @synthesize primary; 34 | @synthesize keychainItemName; 35 | 36 | + (id)sharedService; 37 | { 38 | @synchronized(self) { 39 | if(FlickrService == nil) { 40 | FlickrService = [[super allocWithZone:NULL] init]; 41 | } 42 | } 43 | return FlickrService; 44 | } 45 | 46 | - (id)init 47 | { 48 | self = [super init]; 49 | if (self) { 50 | // Initialization code here. 51 | } 52 | 53 | return self; 54 | } 55 | 56 | - (void)assignOAuthParams:(NSDictionary*)params asPrimary:(BOOL)isPrimary 57 | { 58 | [super assignOAuthParams:params]; 59 | 60 | self.primary = isPrimary; 61 | 62 | [[iOSSocialServicesStore sharedServiceStore] registerService:self]; 63 | } 64 | 65 | - (NSString*)name 66 | { 67 | return @"Flickr"; 68 | } 69 | 70 | - (UIImage*)logoImage 71 | { 72 | NSURL *logoURL = [[NSBundle mainBundle] URLForResource:@"flickr-logo" withExtension:@"png"]; 73 | UIImage *theLogoImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:logoURL]]; 74 | return theLogoImage; 75 | } 76 | 77 | - (NSString*)serviceKeychainItemName 78 | { 79 | return self.keychainItemName; 80 | } 81 | 82 | - (id)localUser 83 | { 84 | return [[LocalFlickrUser alloc] init]; 85 | } 86 | 87 | - (id)localUserWithDictionary:(NSDictionary*)dictionary 88 | { 89 | LocalFlickrUser *theUser = [[LocalFlickrUser alloc] initWithDictionary:dictionary]; 90 | return theUser; 91 | } 92 | 93 | - (id)localUserWithIdentifier:(NSString*)identifier 94 | { 95 | return [[LocalFlickrUser alloc] initWithIdentifier:identifier]; 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Flickr/FlickrUser+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @interface FlickrUser () 18 | 19 | @property(nonatomic, readwrite, retain) NSDictionary *userDictionary; 20 | @property(nonatomic, readwrite, retain) NSString *userID; 21 | @property(nonatomic, readwrite, retain) NSString *alias; 22 | @property(nonatomic, readwrite, retain) NSString *profilePictureURL; // The user's last name 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Flickr/FlickrUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialUser.h" 19 | #import "iOSSocialConstants.h" 20 | 21 | @interface FlickrUser : NSObject 22 | 23 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 24 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 25 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 26 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 27 | 28 | // Asynchronously load the users's photo. Error will be nil on success. 29 | // Possible reasons for error: 30 | // 1. Communications failure 31 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Flickr/FlickrUser.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "FlickrUser.h" 18 | #import "FlickrUser+Private.h" 19 | #import "iOSSRequest.h" 20 | 21 | @interface FlickrUser () 22 | 23 | @property(nonatomic, copy) LoadPhotoHandler loadPhotoHandler; 24 | 25 | @end 26 | 27 | @implementation FlickrUser 28 | 29 | @synthesize userDictionary; 30 | @synthesize userID; 31 | @synthesize alias; 32 | @synthesize fetchUserDataHandler; 33 | @synthesize loadPhotoHandler; 34 | @synthesize profilePictureURL; 35 | 36 | - (id)init 37 | { 38 | self = [super init]; 39 | if (self) { 40 | // Initialization code here. 41 | } 42 | 43 | return self; 44 | } 45 | 46 | - (id)initWithDictionary:(NSDictionary*)theUserDictionary 47 | { 48 | self = [self init]; 49 | if (self) { 50 | // Initialization code here. 51 | self.userDictionary = theUserDictionary; 52 | } 53 | 54 | return self; 55 | } 56 | 57 | - (void)setUserDictionary:(NSDictionary *)theUserDictionary 58 | { 59 | userDictionary = theUserDictionary; 60 | 61 | NSDictionary *personDictionary = [theUserDictionary objectForKey:@"person"]; 62 | if (personDictionary) { 63 | // 64 | self.userID = [personDictionary objectForKey:@"id"]; 65 | NSDictionary *usernameDictionary = [personDictionary objectForKey:@"username"]; 66 | if (usernameDictionary) { 67 | self.alias = [usernameDictionary objectForKey:@"_content"]; 68 | } 69 | } else { 70 | self.userID = [theUserDictionary objectForKey:@"id"]; 71 | //self.profilePictureURL = [theUserDictionary objectForKey:@"profile_image_url_https"]; 72 | NSString *username = [theUserDictionary objectForKey:@"username"]; 73 | if (username) { 74 | self.alias = username; 75 | } 76 | } 77 | } 78 | 79 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler 80 | { 81 | self.loadPhotoHandler = completionHandler; 82 | 83 | NSString *urlString = self.profilePictureURL; 84 | NSURL *url = [NSURL URLWithString:urlString]; 85 | 86 | iOSSRequest *request = [[iOSSRequest alloc] initWithURL:url 87 | parameters:nil 88 | requestMethod:iOSSRequestMethodGET]; 89 | 90 | [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 91 | if (error) { 92 | if (self.loadPhotoHandler) { 93 | self.loadPhotoHandler(nil, error); 94 | self.loadPhotoHandler = nil; 95 | } 96 | } else { 97 | UIImage *image = [UIImage imageWithData:responseData]; 98 | 99 | if (self.loadPhotoHandler) { 100 | self.loadPhotoHandler(image, nil); 101 | self.loadPhotoHandler = nil; 102 | } 103 | } 104 | }]; 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Flickr/LocalFlickrUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "FlickrUser.h" 20 | #import "iOSSocialServiceOAuth1ProviderConstants.h" 21 | #import "iOSSocialLocalUser.h" 22 | 23 | typedef void(^FlickrAuthenticationHandler)(NSError *error); 24 | typedef void(^PostPhotoDataHandler)(NSString *photoID, NSError *error); 25 | typedef void(^PhotoInfoDataHandler)(NSDictionary *photoInfo, NSError *error); 26 | typedef void(^UserPhotosDataHandler)(NSDictionary *photos, NSError *error); 27 | typedef void(^PhotoSizesDataHandler)(NSDictionary *photoInfo, NSError *error); 28 | 29 | @interface LocalFlickrUser : FlickrUser 30 | 31 | // Obtain the LocalFlickrUser object. 32 | // The user is only available for offline use until logged in. 33 | // A temporary use is created if no account is set up. 34 | + (LocalFlickrUser *)localFlickrUser; 35 | 36 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 37 | 38 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 39 | // The user must be authenticated in order to use other APIs. 40 | // This should be called for each launch of the application as soon as the UI is ready. 41 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 42 | // Flickr UI may be presented during this authentication. 43 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 44 | // The authorization screen, if needed, is show modally so pass in the current view controller. 45 | // Possible reasons for error: 46 | // 1. Communications problem 47 | // 2. User credentials invalid 48 | // 3. User cancelled 49 | - (UIViewController*)authenticateFromViewController:(UIViewController*)vc 50 | withCompletionHandler:(AuthenticationHandler)completionHandler; 51 | 52 | - (NSString*)oAuthAccessToken; 53 | 54 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 55 | 56 | - (NSString*)oAuthAccessTokenSecret; 57 | 58 | //remove all stored OAuth info from the keychain and reset state in memory 59 | - (void)logout; 60 | 61 | - (void)getUserPhotosWithCompletionHandler:(UserPhotosDataHandler)completionHandler; 62 | 63 | - (void)postPhotoData:(NSData*)imageData 64 | withFileName:(NSString *)fileName 65 | andParams:(NSDictionary*)photoParams 66 | andCompletionHandler:(PostPhotoDataHandler)completionHandler; 67 | 68 | - (void)getInfoForPhotoWithId:(NSString*)photoID andCompletionHandler:(PhotoInfoDataHandler)completionHandler; 69 | - (void)getPhotoSizesForPhotoWithId:(NSString*)photoID andCompletionHandler:(PhotoSizesDataHandler)completionHandler; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Flickr/flickr-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/iOSSocial/Flickr/flickr-logo.png -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Foursquare/Foursquare.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialServiceOAuth2Provider.h" 19 | #import "iOSSocialServicesStore.h" 20 | 21 | 22 | @interface Foursquare : iOSSocialServiceOAuth2Provider 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Foursquare/Foursquare.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "Foursquare.h" 18 | #import "iOSSLog.h" 19 | #import "LocalFoursquareUser.h" 20 | 21 | 22 | @interface Foursquare () 23 | 24 | @property(nonatomic, readwrite, assign) BOOL primary; 25 | 26 | @end 27 | 28 | static Foursquare *foursquareService = nil; 29 | 30 | @implementation Foursquare 31 | 32 | @synthesize name; 33 | @synthesize logoImage; 34 | @synthesize primary; 35 | 36 | + (id)sharedService; 37 | { 38 | @synchronized(self) { 39 | if(foursquareService == nil) { 40 | foursquareService = [[super allocWithZone:NULL] init]; 41 | } 42 | } 43 | return foursquareService; 44 | } 45 | 46 | - (id)init 47 | { 48 | self = [super init]; 49 | if (self) { 50 | } 51 | 52 | return self; 53 | } 54 | 55 | - (void)assignOAuthParams:(NSDictionary*)params asPrimary:(BOOL)isPrimary 56 | { 57 | [super assignOAuthParams:params]; 58 | 59 | self.primary = isPrimary; 60 | 61 | [[iOSSocialServicesStore sharedServiceStore] registerService:self]; 62 | } 63 | 64 | - (NSString*)name 65 | { 66 | return @"Foursquare"; 67 | } 68 | 69 | - (UIImage*)logoImage 70 | { 71 | NSURL *logoURL = [[NSBundle mainBundle] URLForResource:@"foursquare_trans" withExtension:@"png"]; 72 | UIImage *theLogoImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:logoURL]]; 73 | return theLogoImage; 74 | } 75 | 76 | - (NSString*)serviceKeychainItemName 77 | { 78 | return self.keychainItemName; 79 | } 80 | 81 | - (id)localUser 82 | { 83 | return [[LocalFoursquareUser alloc] init]; 84 | } 85 | 86 | - (id)localUserWithDictionary:(NSDictionary*)dictionary 87 | { 88 | LocalFoursquareUser *theUser = [[LocalFoursquareUser alloc] initWithDictionary:dictionary]; 89 | return theUser; 90 | } 91 | 92 | - (id)localUserWithIdentifier:(NSString*)identifier 93 | { 94 | return [[LocalFoursquareUser alloc] initWithIdentifier:identifier]; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Foursquare/FoursquareUser+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @interface FoursquareUser () 18 | 19 | @property(nonatomic, readwrite, retain) NSDictionary *userDictionary; 20 | @property(nonatomic, readwrite, retain) NSString *userID; 21 | @property(nonatomic, readwrite, retain) NSString *alias; 22 | @property(nonatomic, readwrite, retain) NSString *firstName; 23 | @property(nonatomic, readwrite, retain) NSString *profilePictureURL; 24 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Foursquare/FoursquareUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialUser.h" 19 | #import "iOSSocialConstants.h" 20 | 21 | 22 | @interface FoursquareUser : NSObject 23 | 24 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 25 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 26 | @property(nonatomic, readonly, retain) NSString *firstName; // The user's first name 27 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 28 | 29 | // Asynchronously load the users's photo. Error will be nil on success. 30 | // Possible reasons for error: 31 | // 1. Communications failure 32 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Foursquare/FoursquareUser.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "FoursquareUser.h" 18 | #import "FoursquareUser+Private.h" 19 | #import "iOSSRequest.h" 20 | 21 | @interface FoursquareUser () 22 | 23 | @property(nonatomic, copy) LoadPhotoHandler loadPhotoHandler; 24 | 25 | @end 26 | 27 | 28 | @implementation FoursquareUser 29 | 30 | @synthesize userDictionary; 31 | @synthesize userID; 32 | @synthesize alias; 33 | @synthesize firstName; 34 | @synthesize fetchUserDataHandler; 35 | @synthesize profilePictureURL; 36 | @synthesize loadPhotoHandler; 37 | 38 | - (id)init 39 | { 40 | self = [super init]; 41 | if (self) { 42 | // Initialization code here. 43 | } 44 | 45 | return self; 46 | } 47 | 48 | - (id)initWithDictionary:(NSDictionary*)theUserDictionary 49 | { 50 | self = [self init]; 51 | if (self) { 52 | // Initialization code here. 53 | self.userDictionary = theUserDictionary; 54 | } 55 | 56 | return self; 57 | } 58 | 59 | - (void)setUserDictionary:(NSDictionary *)theUserDictionary 60 | { 61 | userDictionary = theUserDictionary; 62 | 63 | NSDictionary *responseDict = [theUserDictionary objectForKey:@"response"]; 64 | if (responseDict) { 65 | NSDictionary *userDict = [responseDict objectForKey:@"user"]; 66 | if (userDict) { 67 | self.userID = [userDict objectForKey:@"id"]; 68 | self.alias = [userDict objectForKey:@"firstName"]; 69 | self.firstName = [userDict objectForKey:@"firstName"]; 70 | self.profilePictureURL = [userDict objectForKey:@"photo"]; 71 | } 72 | } 73 | } 74 | 75 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler 76 | { 77 | self.loadPhotoHandler = completionHandler; 78 | 79 | NSString *urlString = self.profilePictureURL; 80 | NSURL *url = [NSURL URLWithString:urlString]; 81 | 82 | iOSSRequest *request = [[iOSSRequest alloc] initWithURL:url 83 | parameters:nil 84 | requestMethod:iOSSRequestMethodGET]; 85 | 86 | [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 87 | if (error) { 88 | if (self.loadPhotoHandler) { 89 | self.loadPhotoHandler(nil, error); 90 | self.loadPhotoHandler = nil; 91 | } 92 | } else { 93 | UIImage *image = [UIImage imageWithData:responseData]; 94 | 95 | if (self.loadPhotoHandler) { 96 | self.loadPhotoHandler(image, nil); 97 | self.loadPhotoHandler = nil; 98 | } 99 | } 100 | }]; 101 | } 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Foursquare/LocalFoursquareUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "FoursquareUser.h" 20 | #import "iOSSocialServiceOAuth2ProviderConstants.h" 21 | #import "iOSSocialLocalUser.h" 22 | 23 | typedef void(^FoursquareAuthenticationHandler)(NSError *error); 24 | 25 | @interface LocalFoursquareUser : FoursquareUser 26 | 27 | // Obtain the LocalFoursquareUser object. 28 | // The user is only available for offline use until logged in. 29 | // A temporary use is created if no account is set up. 30 | + (LocalFoursquareUser *)localFoursquareUser; 31 | 32 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 33 | 34 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 35 | // The user must be authenticated in order to use other APIs. 36 | // This should be called for each launch of the application as soon as the UI is ready. 37 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 38 | // Foursquare UI may be presented during this authentication. 39 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 40 | // The authorization screen, if needed, is show modally so pass in the current view controller. 41 | // Possible reasons for error: 42 | // 1. Communications problem 43 | // 2. User credentials invalid 44 | // 3. User cancelled 45 | - (UIViewController*)authenticateFromViewController:(UIViewController*)vc 46 | withCompletionHandler:(AuthenticationHandler)completionHandler; 47 | 48 | - (NSString*)oAuthAccessToken; 49 | 50 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 51 | 52 | - (NSString*)oAuthAccessTokenSecret; 53 | 54 | //remove all stored OAuth info from the keychain and reset state in memory 55 | - (void)logout; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Foursquare/foursquare_trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/iOSSocial/Foursquare/foursquare_trans.png -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Instagram/Instagram.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialServiceOAuth2Provider.h" 19 | #import "iOSSocialServicesStore.h" 20 | 21 | @interface Instagram : iOSSocialServiceOAuth2Provider 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Instagram/Instagram.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "Instagram.h" 18 | #import "iOSSLog.h" 19 | #import "LocalInstagramUser.h" 20 | 21 | 22 | @interface Instagram () 23 | 24 | @property(nonatomic, readwrite, assign) BOOL primary; 25 | 26 | @end 27 | 28 | static Instagram *instagramService = nil; 29 | 30 | @implementation Instagram 31 | 32 | @synthesize name; 33 | @synthesize logoImage; 34 | @synthesize primary; 35 | 36 | + (id)sharedService; 37 | { 38 | @synchronized(self) { 39 | if(instagramService == nil) { 40 | instagramService = [[super allocWithZone:NULL] init]; 41 | } 42 | } 43 | return instagramService; 44 | } 45 | 46 | - (id)init 47 | { 48 | self = [super init]; 49 | if (self) { 50 | } 51 | 52 | return self; 53 | } 54 | 55 | - (void)assignOAuthParams:(NSDictionary*)params asPrimary:(BOOL)isPrimary 56 | { 57 | [super assignOAuthParams:params]; 58 | 59 | self.primary = isPrimary; 60 | 61 | [[iOSSocialServicesStore sharedServiceStore] registerService:self]; 62 | } 63 | 64 | - (NSString*)name 65 | { 66 | return @"Instagram"; 67 | } 68 | 69 | - (UIImage*)logoImage 70 | { 71 | NSURL *logoURL = [[NSBundle mainBundle] URLForResource:@"instagram_trans" withExtension:@"png"]; 72 | UIImage *theLogoImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:logoURL]]; 73 | return theLogoImage; 74 | } 75 | 76 | - (NSString*)serviceKeychainItemName 77 | { 78 | return self.keychainItemName; 79 | } 80 | 81 | - (id)localUser 82 | { 83 | return [[LocalInstagramUser alloc] init]; 84 | } 85 | 86 | - (id)localUserWithDictionary:(NSDictionary*)dictionary 87 | { 88 | LocalInstagramUser *theUser = [[LocalInstagramUser alloc] initWithDictionary:dictionary]; 89 | return theUser; 90 | } 91 | 92 | - (id)localUserWithIdentifier:(NSString*)identifier 93 | { 94 | return [[LocalInstagramUser alloc] initWithIdentifier:identifier]; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Instagram/InstagramUser+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @interface InstagramUser () 18 | 19 | @property(nonatomic, readwrite, retain) NSDictionary *userDictionary; 20 | @property(nonatomic, readwrite, retain) NSString *userID; 21 | @property(nonatomic, readwrite, retain) NSString *alias; 22 | @property(nonatomic, readwrite, retain) NSString *firstName; 23 | @property(nonatomic, readwrite, retain) NSString *lastName; 24 | @property(nonatomic, readwrite, retain) NSString *profilePictureURL; 25 | @property(nonatomic, readwrite, retain) NSString *bio; 26 | @property(nonatomic, readwrite, retain) NSString *website; 27 | @property(nonatomic, readwrite, assign) NSInteger mediaCount; 28 | @property(nonatomic, readwrite, assign) NSInteger followsCount; 29 | @property(nonatomic, readwrite, assign) NSInteger followedByCount; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Instagram/InstagramUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "iOSSocialUser.h" 20 | #import "iOSSocialConstants.h" 21 | 22 | 23 | @interface InstagramUser : NSObject 24 | 25 | //cwnote: should alias be copied? 26 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 27 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 28 | @property(nonatomic, readonly, retain) NSString *firstName; // The user's first name 29 | @property(nonatomic, readonly, retain) NSString *lastName; // The user's last name 30 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 31 | @property(nonatomic, readonly, retain) NSString *bio; // The user's biography 32 | @property(nonatomic, readonly, retain) NSString *website; // The user's website 33 | @property(nonatomic, readonly, assign) NSInteger mediaCount; // The user's total number of media 34 | @property(nonatomic, readonly, assign) NSInteger followsCount; // The user's number of people they follow 35 | @property(nonatomic, readonly, assign) NSInteger followedByCount; // The user's total number of followers 36 | //@property(nonatomic, readonly) BOOL isFriend; // True if this user is a friend of the local user 37 | 38 | /** 39 | * The user source that the user belongs to. 40 | */ 41 | //@property (nonatomic, assign) id userSource; 42 | 43 | // Initialize a user with a dictionary object. The definition for the dictionary can be found here: 44 | // http://instagram.com/developer/endpoints/users/ 45 | // Here is the example for those too lazy to go to the URL :D 46 | /* 47 | { 48 | "id": "1574083", 49 | "username": "snoopdogg", 50 | "first_name": "Snoop", 51 | "last_name": "Dogg", 52 | "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg", 53 | "bio": "This is my bio", 54 | "website": "http://snoopdogg.com", 55 | "counts: { 56 | "media": 1320, 57 | "follows": 420, 58 | "followed_by": 3410 59 | } 60 | } 61 | */ 62 | - (id)initWithDictionary:(NSDictionary*)userDictionary; 63 | 64 | // Asynchronously load the users's photo. Error will be nil on success. 65 | // Possible reasons for error: 66 | // 1. Communications failure 67 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Instagram/InstagramUser.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "InstagramUser.h" 18 | #import "InstagramUser+Private.h" 19 | #import "Instagram.h" 20 | #import "iOSSRequest.h" 21 | 22 | @interface InstagramUser () 23 | 24 | @property(nonatomic, copy) LoadPhotoHandler loadPhotoHandler; 25 | 26 | @end 27 | 28 | @implementation InstagramUser 29 | 30 | @synthesize userDictionary; 31 | @synthesize userID; 32 | @synthesize alias; 33 | @synthesize firstName; 34 | @synthesize lastName; 35 | @synthesize profilePictureURL; 36 | @synthesize bio; 37 | @synthesize website; 38 | @synthesize mediaCount; 39 | @synthesize followsCount; 40 | @synthesize followedByCount; 41 | @synthesize loadPhotoHandler; 42 | 43 | - (id)init 44 | { 45 | self = [super init]; 46 | if (self) { 47 | // Initialization code here. 48 | } 49 | 50 | return self; 51 | } 52 | 53 | - (id)initWithDictionary:(NSDictionary*)theUserDictionary 54 | { 55 | self = [self init]; 56 | if (self) { 57 | // Initialization code here. 58 | self.userDictionary = theUserDictionary; 59 | } 60 | 61 | return self; 62 | } 63 | 64 | - (void)setUserDictionary:(NSDictionary *)theUserDictionary 65 | { 66 | userDictionary = theUserDictionary; 67 | 68 | self.userID = [theUserDictionary objectForKey:@"id"]; 69 | self.alias = [theUserDictionary objectForKey:@"username"]; 70 | self.firstName = [theUserDictionary objectForKey:@"first_name"]; 71 | self.lastName = [theUserDictionary objectForKey:@"last_name"]; 72 | self.profilePictureURL = [theUserDictionary objectForKey:@"profile_picture"]; 73 | self.bio = [theUserDictionary objectForKey:@"bio"]; 74 | self.website = [theUserDictionary objectForKey:@"website"]; 75 | 76 | NSDictionary *counts = [userDictionary objectForKey:@"counts"]; 77 | if (counts) { 78 | //self.mediaCount = [counts objectForKey:@"media"]; 79 | //self.followsCount = [counts objectForKey:@"follows"]; 80 | //self.followedByCount = [counts objectForKey:@"followed_by"]; 81 | } 82 | 83 | } 84 | 85 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler 86 | { 87 | self.loadPhotoHandler = completionHandler; 88 | 89 | NSString *urlString = self.profilePictureURL; 90 | NSURL *url = [NSURL URLWithString:urlString]; 91 | 92 | iOSSRequest *request = [[iOSSRequest alloc] initWithURL:url 93 | parameters:nil 94 | requestMethod:iOSSRequestMethodGET]; 95 | 96 | [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 97 | if (error) { 98 | if (self.loadPhotoHandler) { 99 | self.loadPhotoHandler(nil, error); 100 | self.loadPhotoHandler = nil; 101 | } 102 | } else { 103 | UIImage *image = [UIImage imageWithData:responseData]; 104 | 105 | if (self.loadPhotoHandler) { 106 | self.loadPhotoHandler(image, nil); 107 | self.loadPhotoHandler = nil; 108 | } 109 | } 110 | }]; 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Instagram/LocalInstagramUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "InstagramUser.h" 20 | #import "iOSSocialServiceOAuth2ProviderConstants.h" 21 | #import "iOSSocialLocalUser.h" 22 | 23 | @class InstagramMediaCollection; 24 | 25 | typedef void(^FetchMediaHandler)(NSDictionary *dictionary, NSError *error); 26 | 27 | @class InstagramUserCollection; 28 | 29 | typedef void(^FetchUsersHandler)(NSArray *users, NSError *error); 30 | 31 | typedef void(^InstagramAuthenticationHandler)(NSError *error); 32 | 33 | 34 | @interface LocalInstagramUser : InstagramUser 35 | 36 | // Obtain the LocalInstagramUser object. 37 | // The user is only available for offline use until logged in. 38 | // A temporary use is created if no account is set up. 39 | + (LocalInstagramUser *)localInstagramUser; 40 | 41 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 42 | 43 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 44 | // The user must be authenticated in order to use other APIs. 45 | // This should be called for each launch of the application as soon as the UI is ready. 46 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 47 | // Instagram UI may be presented during this authentication. 48 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 49 | // The authorization screen, if needed, is show modally so pass in the current view controller. 50 | // Possible reasons for error: 51 | // 1. Communications problem 52 | // 2. User credentials invalid 53 | // 3. User cancelled 54 | - (UIViewController*)authenticateFromViewController:(UIViewController*)vc 55 | withCompletionHandler:(AuthenticationHandler)completionHandler; 56 | 57 | - (NSString*)oAuthAccessToken; 58 | 59 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 60 | 61 | - (NSString*)oAuthAccessTokenSecret; 62 | 63 | //remove all stored OAuth info from the keychain and reset state in memory 64 | - (void)logout; 65 | 66 | - (void)fetchRelationshipToUser; 67 | 68 | - (void)fetchRequestedBy; 69 | 70 | - (void)modifyRelationshipToUser; 71 | 72 | // These methods make it easy to interact with the instagram app on the user's device. 73 | + (void)instagram; 74 | + (void)camera; 75 | + (void)tagWithName:(NSString*)name; 76 | + (void)userWithName:(NSString*)name; 77 | + (void)locationWithID:(NSString*)locationID; 78 | + (void)mediaWithID:(NSString*)mediaID; 79 | + (void)editPhotoWithURL:(NSURL*)url 80 | andMenuFromView:(UIView*)view; 81 | 82 | - (void)fetchUserDataWithCompletionHandler:(FetchUserDataHandler)completionHandler; 83 | 84 | - (void)fetchRecentMediaWithCompletionHandler:(FetchMediaHandler)completionHandler; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Instagram/instagram_trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/iOSSocial/Instagram/instagram_trans.png -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/OAuth/GTMOAuthAuthentication+Additions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "GTMOAuthAuthentication.h" 19 | 20 | @interface GTMOAuthAuthenticationWithAdditions : GTMOAuthAuthentication 21 | 22 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 23 | @property(nonatomic, readonly, retain) NSString *username; // The user's alias 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/OAuth/GTMOAuthAuthentication+Additions.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "GTMOAuthAuthentication+Additions.h" 18 | 19 | @interface GTMOAuthAuthentication () 20 | 21 | - (void)setKeysForResponseDictionary:(NSDictionary *)dict; 22 | 23 | @end 24 | 25 | static NSString *const kOAuth1TwitterUserIDKey = @"user_id"; 26 | static NSString *const kOAuth1TwitterUserNameKey = @"screen_name"; 27 | static NSString *const kOAuth1FlickrUserIDKey = @"user_nsid"; 28 | static NSString *const kOAuth1FlickrUserNameKey = @"username"; 29 | 30 | @interface GTMOAuthAuthenticationWithAdditions () 31 | 32 | @property(nonatomic, readwrite, retain) NSString *userID; // User identifier. 33 | @property(nonatomic, readwrite, retain) NSString *username; // The user's alias 34 | 35 | @end 36 | 37 | @implementation GTMOAuthAuthenticationWithAdditions 38 | 39 | @synthesize userID; 40 | @synthesize username; 41 | 42 | - (id)init 43 | { 44 | self = [super init]; 45 | if (self) { 46 | // Initialization code here. 47 | } 48 | 49 | return self; 50 | } 51 | 52 | - (void)setKeysForResponseDictionary:(NSDictionary *)dict 53 | { 54 | [super setKeysForResponseDictionary:dict]; 55 | 56 | //Try Twitter 57 | NSString *newUserID = [dict objectForKey:kOAuth1TwitterUserIDKey]; 58 | if (newUserID) { 59 | [self setUserID:newUserID]; 60 | } 61 | 62 | NSString *newUsername = [dict objectForKey:kOAuth1TwitterUserNameKey]; 63 | if (newUsername) { 64 | [self setUsername:newUsername]; 65 | } 66 | 67 | //Try Flickr 68 | newUserID = [dict objectForKey:kOAuth1FlickrUserIDKey]; 69 | if (newUserID) { 70 | [self setUserID:newUserID]; 71 | } 72 | 73 | newUsername = [dict objectForKey:kOAuth1FlickrUserNameKey]; 74 | if (newUsername) { 75 | [self setUsername:newUsername]; 76 | } 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/OAuth/iOSSocialOAuth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef iOSSocial_iOSSocialOAuth_h 18 | #define iOSSocial_iOSSocialOAuth_h 19 | 20 | typedef void(^AuthorizationHandler)(id theAuth, NSDictionary *userInfo, NSError *error); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/OAuth/iOSSocialServiceOAuth1Provider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "iOSSocialOAuth.h" 20 | 21 | @class GTMOAuthAuthenticationWithAdditions; 22 | @interface iOSSocialServiceOAuth1Provider : NSObject 23 | 24 | @property(nonatomic, readonly, retain) NSString *keychainItemName; 25 | 26 | - (id)initWithDictionary:(NSDictionary*)dictionary; 27 | 28 | - (id)checkAuthenticationForKeychainItemName:(NSString*)theKeychainItemName; 29 | 30 | - (void)assignOAuthParams:(NSDictionary*)params; 31 | 32 | - (UIViewController*)authorizeFromViewController:(UIViewController*)vc 33 | forAuth:(id)theAuth 34 | andKeychainItemName:(NSString*)theKeychainItemName 35 | andCookieDomain:(NSString*)cookieDomain 36 | withCompletionHandler:(AuthorizationHandler)completionHandler; 37 | 38 | - (void)logout:(GTMOAuthAuthenticationWithAdditions*)theAuth forKeychainItemName:(NSString*)theKeychainItemName; 39 | 40 | - (NSString*)apiKey; 41 | 42 | - (NSString*)apiSecret; 43 | 44 | + (id)JSONFromData:(NSData*)data; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/OAuth/iOSSocialServiceOAuth1ProviderConstants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef iOSSocial_iOSSocialServiceOAuth1ProviderConstants_h 18 | #define iOSSocial_iOSSocialServiceOAuth1ProviderConstants_h 19 | 20 | // OAuth Params Dictionary Keys 21 | static NSString *const kSMOAuth1ClientID = @"clientID"; 22 | static NSString *const kSMOAuth1ClientSecret = @"clientSecret"; 23 | // This has to match the callback URL you setup on the provider's site for your app 24 | // or you will get an OAuth error! 25 | // You can make up an arbitrary redirectURI. The controller will watch for 26 | // the server to redirect the web view to this URI, but this URI will not be 27 | // loaded, so it need not be for any actual web page. 28 | static NSString *const kSMOAuth1RedirectURI = @"redirectURI"; 29 | // Make this a unique name. Incorporate the name of your app. 30 | // Note: this should perhaps be internalized. 31 | static NSString *const kSMOAuth1KeychainItemName = @"keychainItemName"; 32 | 33 | static NSString *const kSMOAuth1RequestTokenURL = @"requestTokenURL"; 34 | 35 | static NSString *const kSMOAuth1AuthorizeURL = @"authorizeURL"; 36 | 37 | static NSString *const kSMOAuth1AccessTokenURL = @"accessTokenURL"; 38 | 39 | static NSString *const kSMOAuth1ServiceProviderName = @"serviceProviderName"; 40 | 41 | static NSString *const kSMOAuth1Scope = @"scope"; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/OAuth/iOSSocialServiceOAuth2Provider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "iOSSocialOAuth.h" 20 | 21 | @class GTMOAuth2Authentication; 22 | @class GTMOAuthAuthenticationWithAdditions; 23 | @interface iOSSocialServiceOAuth2Provider : NSObject 24 | 25 | @property(nonatomic, readonly, retain) NSString *keychainItemName; 26 | 27 | // See iOSSocialServiceOAuth2ProviderConstants.h for the Keys for this dictionary. 28 | - (id)initWithDictionary:(NSDictionary*)dictionary; 29 | 30 | - (id)checkAuthenticationForKeychainItemName:(NSString*)theKeychainItemName; 31 | 32 | - (void)assignOAuthParams:(NSDictionary*)params; 33 | 34 | - (UIViewController*)authorizeFromViewController:(UIViewController*)vc 35 | forAuth:(GTMOAuth2Authentication*)theAuth 36 | andKeychainItemName:(NSString*)theKeychainItemName 37 | andCookieDomain:(NSString*)cookieDomain 38 | withCompletionHandler:(AuthorizationHandler)completionHandler; 39 | 40 | - (void)logout:(GTMOAuth2Authentication*)theAuth forKeychainItemName:(NSString*)theKeychainItemName; 41 | 42 | - (NSString*)apiKey; 43 | 44 | - (NSString*)apiSecret; 45 | 46 | + (id)JSONFromData:(NSData*)data; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/OAuth/iOSSocialServiceOAuth2ProviderConstants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef iOSSocial_iOSSocialServiceOAuth2ProviderConstants_h 18 | #define iOSSocial_iOSSocialServiceOAuth2ProviderConstants_h 19 | 20 | // OAuth Params Dictionary Keys 21 | static NSString *const kSMOAuth2ClientID = @"clientID"; 22 | static NSString *const kSMOAuth2ClientSecret = @"clientSecret"; 23 | // This has to match the callback URL you setup on the provider's site for your app 24 | // or you will get an OAuth error! 25 | // You can make up an arbitrary redirectURI. The controller will watch for 26 | // the server to redirect the web view to this URI, but this URI will not be 27 | // loaded, so it need not be for any actual web page. 28 | static NSString *const kSMOAuth2RedirectURI = @"redirectURI"; 29 | // Make this a unique name. Incorporate the name of your app. 30 | // Note: this should perhaps be internalized. 31 | static NSString *const kSMOAuth2KeychainItemName = @"keychainItemName"; 32 | 33 | static NSString *const kSMOAuth2AuthorizeURL = @"authorizeURL"; 34 | 35 | static NSString *const kSMOAuth2AccessTokenURL = @"accessTokenURL"; 36 | 37 | static NSString *const kSMOAuth2ServiceProviderName = @"serviceProviderName"; 38 | 39 | static NSString *const kSMOAuth2Scope = @"scope"; 40 | 41 | static NSString *const kSMOAuth2URLSchemeSuffix = @"urlSchemeSuffix"; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Tumblr/LocalTumblrUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "TumblrUser.h" 20 | #import "iOSSocialServiceOAuth1ProviderConstants.h" 21 | #import "iOSSocialLocalUser.h" 22 | 23 | typedef void(^TumblrAuthenticationHandler)(NSError *error); 24 | 25 | @interface LocalTumblrUser : TumblrUser 26 | 27 | // Obtain the LocalTumblrUser object. 28 | // The user is only available for offline use until logged in. 29 | // A temporary use is created if no account is set up. 30 | + (LocalTumblrUser *)localTumblrUser; 31 | 32 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 33 | 34 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 35 | // The user must be authenticated in order to use other APIs. 36 | // This should be called for each launch of the application as soon as the UI is ready. 37 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 38 | // Tumblr UI may be presented during this authentication. 39 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 40 | // The authorization screen, if needed, is show modally so pass in the current view controller. 41 | // Possible reasons for error: 42 | // 1. Communications problem 43 | // 2. User credentials invalid 44 | // 3. User cancelled 45 | - (void)authenticateFromViewController:(UIViewController*)vc 46 | withCompletionHandler:(AuthenticationHandler)completionHandler; 47 | 48 | - (NSString*)oAuthAccessToken; 49 | 50 | //remove all stored OAuth info from the keychain and reset state in memory 51 | - (void)logout; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Tumblr/Tumblr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialServiceOAuth1Provider.h" 19 | #import "iOSSocialServicesStore.h" 20 | 21 | @interface Tumblr : iOSSocialServiceOAuth1Provider 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Tumblr/Tumblr.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "Tumblr.h" 18 | #import "iOSSLog.h" 19 | #import "LocalTumblrUser.h" 20 | 21 | @interface Tumblr () 22 | 23 | @property(nonatomic, readwrite, assign) BOOL primary; 24 | 25 | @end 26 | 27 | static Tumblr *TumblrService = nil; 28 | 29 | @implementation Tumblr 30 | 31 | @synthesize name; 32 | @synthesize logoImage; 33 | @synthesize primary; 34 | 35 | + (id)sharedService; 36 | { 37 | @synchronized(self) { 38 | if(TumblrService == nil) { 39 | TumblrService = [[super allocWithZone:NULL] init]; 40 | } 41 | } 42 | return TumblrService; 43 | } 44 | 45 | - (id)init 46 | { 47 | self = [super init]; 48 | if (self) { 49 | // Initialization code here. 50 | } 51 | 52 | return self; 53 | } 54 | 55 | - (void)assignOAuthParams:(NSDictionary*)params asPrimary:(BOOL)isPrimary 56 | { 57 | [super assignOAuthParams:params]; 58 | 59 | self.primary = isPrimary; 60 | 61 | [[iOSSocialServicesStore sharedServiceStore] registerService:self]; 62 | } 63 | 64 | - (NSString*)name 65 | { 66 | return @"Tumblr"; 67 | } 68 | 69 | - (UIImage*)logoImage 70 | { 71 | NSURL *logoURL = [[NSBundle mainBundle] URLForResource:@"tumblr-logo" withExtension:@"png"]; 72 | UIImage *theLogoImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:logoURL]]; 73 | return theLogoImage; 74 | } 75 | 76 | - (NSString*)serviceKeychainItemName 77 | { 78 | return self.keychainItemName; 79 | } 80 | 81 | - (id)localUser 82 | { 83 | return [[LocalTumblrUser alloc] init]; 84 | } 85 | 86 | - (id)localUserWithDictionary:(NSDictionary*)dictionary 87 | { 88 | LocalTumblrUser *theUser = [[LocalTumblrUser alloc] initWithDictionary:dictionary]; 89 | return theUser; 90 | } 91 | 92 | - (id)localUserWithIdentifier:(NSString*)identifier 93 | { 94 | return [[LocalTumblrUser alloc] initWithIdentifier:identifier]; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Tumblr/TumblrUser+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @interface TumblrUser () 18 | 19 | @property(nonatomic, readwrite, retain) NSDictionary *userDictionary; 20 | @property(nonatomic, readwrite, retain) NSString *userID; 21 | @property(nonatomic, readwrite, retain) NSString *alias; 22 | @property(nonatomic, readwrite, retain) NSString *profilePictureURL; // The user's last name 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Tumblr/TumblrUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialUser.h" 19 | #import "iOSSocialConstants.h" 20 | 21 | @interface TumblrUser : NSObject 22 | 23 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 24 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 25 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 26 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 27 | 28 | // Asynchronously load the users's photo. Error will be nil on success. 29 | // Possible reasons for error: 30 | // 1. Communications failure 31 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Tumblr/TumblrUser.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "TumblrUser.h" 18 | #import "TumblrUser+Private.h" 19 | #import "iOSSRequest.h" 20 | 21 | @interface TumblrUser () 22 | 23 | @property(nonatomic, copy) LoadPhotoHandler loadPhotoHandler; 24 | 25 | @end 26 | 27 | @implementation TumblrUser 28 | 29 | @synthesize userDictionary; 30 | @synthesize userID; 31 | @synthesize alias; 32 | @synthesize fetchUserDataHandler; 33 | @synthesize loadPhotoHandler; 34 | @synthesize profilePictureURL; 35 | 36 | - (id)init 37 | { 38 | self = [super init]; 39 | if (self) { 40 | // Initialization code here. 41 | } 42 | 43 | return self; 44 | } 45 | 46 | - (id)initWithDictionary:(NSDictionary*)theUserDictionary 47 | { 48 | self = [self init]; 49 | if (self) { 50 | // Initialization code here. 51 | self.userDictionary = theUserDictionary; 52 | } 53 | 54 | return self; 55 | } 56 | 57 | - (void)setUserDictionary:(NSDictionary *)theUserDictionary 58 | { 59 | userDictionary = theUserDictionary; 60 | 61 | NSDictionary *response = [theUserDictionary objectForKey:@"response"]; 62 | NSDictionary *user = [response objectForKey:@"user"]; 63 | 64 | NSString *username = [user objectForKey:@"name"]; 65 | if (username) { 66 | self.alias = username; 67 | } 68 | } 69 | 70 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler 71 | { 72 | //cwnote: fix this!!! 73 | /* 74 | self.loadPhotoHandler = completionHandler; 75 | 76 | NSString *urlString = self.profilePictureURL; 77 | NSURL *url = [NSURL URLWithString:urlString]; 78 | 79 | iOSSRequest *request = [[iOSSRequest alloc] initWithURL:url 80 | parameters:nil 81 | requestMethod:iOSSRequestMethodGET]; 82 | 83 | [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 84 | if (error) { 85 | if (self.loadPhotoHandler) { 86 | self.loadPhotoHandler(nil, error); 87 | self.loadPhotoHandler = nil; 88 | } 89 | } else { 90 | UIImage *image = [UIImage imageWithData:responseData]; 91 | 92 | if (self.loadPhotoHandler) { 93 | self.loadPhotoHandler(image, nil); 94 | self.loadPhotoHandler = nil; 95 | } 96 | } 97 | }]; 98 | */ 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Tumblr/tumblr-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/iOSSocial/Tumblr/tumblr-logo.png -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/LocalTwitterUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "TwitterUser.h" 20 | #import "iOSSocialServiceOAuth1ProviderConstants.h" 21 | #import "iOSSocialLocalUser.h" 22 | 23 | 24 | @interface LocalTwitterUser : TwitterUser 25 | 26 | // Obtain the LocalTwitterUser object. 27 | // The user is only available for offline use until logged in. 28 | // A temporary use is created if no account is set up. 29 | + (LocalTwitterUser *)localTwitterUser; 30 | 31 | + (void)setLocalTwitterUser:(LocalTwitterUser *)theLocalTwitterUser; 32 | 33 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 34 | 35 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 36 | // The user must be authenticated in order to use other APIs. 37 | // This should be called for each launch of the application as soon as the UI is ready. 38 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 39 | // Twitter UI may be presented during this authentication. 40 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 41 | // The authorization screen, if needed, is show modally so pass in the current view controller. 42 | // Possible reasons for error: 43 | // 1. Communications problem 44 | // 2. User credentials invalid 45 | // 3. User cancelled 46 | - (UIViewController*)authenticateFromViewController:(UIViewController*)vc 47 | withCompletionHandler:(AuthenticationHandler)completionHandler; 48 | 49 | - (NSString*)oAuthAccessToken; 50 | 51 | //remove all stored OAuth info from the keychain and reset state in memory 52 | - (void)logout; 53 | 54 | - (void)postTweetFromViewController:(UIViewController*)viewController 55 | withParams:(NSDictionary*)params 56 | withCompletionHandler:(FetchUserDataHandler)completionHandler; 57 | - (void)postTweetWithParams:(NSDictionary*)params 58 | withCompletionHandler:(FetchUserDataHandler)completionHandler; 59 | - (void)postTweetWithMedia; 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/LocalTwitterUserLegacy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "TwitterUserLegacy.h" 20 | #import "iOSSocialServiceOAuth1ProviderConstants.h" 21 | #import "iOSSocialLocalUser.h" 22 | 23 | 24 | @interface LocalTwitterUserLegacy : TwitterUserLegacy 25 | 26 | // Obtain the LocalTwitterUser object. 27 | // The user is only available for offline use until logged in. 28 | // A temporary use is created if no account is set up. 29 | + (LocalTwitterUserLegacy *)localTwitterUser; 30 | 31 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 32 | 33 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 34 | // The user must be authenticated in order to use other APIs. 35 | // This should be called for each launch of the application as soon as the UI is ready. 36 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 37 | // Twitter UI may be presented during this authentication. 38 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 39 | // The authorization screen, if needed, is show modally so pass in the current view controller. 40 | // Possible reasons for error: 41 | // 1. Communications problem 42 | // 2. User credentials invalid 43 | // 3. User cancelled 44 | - (UIViewController*)authenticateFromViewController:(UIViewController*)vc 45 | withCompletionHandler:(AuthenticationHandler)completionHandler; 46 | 47 | - (NSString*)oAuthAccessToken; 48 | 49 | //remove all stored OAuth info from the keychain and reset state in memory 50 | - (void)logout; 51 | 52 | - (void)postTweetWithParams:(NSDictionary*)params 53 | withCompletionHandler:(FetchUserDataHandler)completionHandler; 54 | - (void)postTweetWithMedia; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/Twitter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialServiceOAuth1Provider.h" 19 | #import "iOSSocialServicesStore.h" 20 | 21 | @interface Twitter : iOSSocialServiceOAuth1Provider 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/Twitter.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "Twitter.h" 18 | #import "iOSSLog.h" 19 | #import "LocalTwitterUser.h" 20 | #import "LocalTwitterUserLegacy.h" 21 | #import 22 | 23 | @interface Twitter () 24 | 25 | @property(nonatomic, readwrite, assign) BOOL primary; 26 | @property(nonatomic, retain) ACAccountStore *accountStore; 27 | @property(nonatomic, copy) AuthorizationHandler authorizationHandler; 28 | 29 | @end 30 | 31 | static Twitter *twitterService = nil; 32 | 33 | @implementation Twitter 34 | 35 | @synthesize name; 36 | @synthesize logoImage; 37 | @synthesize primary; 38 | @synthesize accountStore; 39 | @synthesize authorizationHandler; 40 | 41 | + (id)sharedService; 42 | { 43 | @synchronized(self) { 44 | if(twitterService == nil) { 45 | twitterService = [[super allocWithZone:NULL] init]; 46 | } 47 | } 48 | return twitterService; 49 | } 50 | 51 | - (id)init 52 | { 53 | self = [super init]; 54 | if (self) { 55 | // Initialization code here. 56 | if ([ACAccountStore class]) { 57 | self.accountStore = [[ACAccountStore alloc] init]; 58 | } 59 | } 60 | 61 | return self; 62 | } 63 | 64 | - (void)assignOAuthParams:(NSDictionary*)params asPrimary:(BOOL)isPrimary 65 | { 66 | [super assignOAuthParams:params]; 67 | 68 | self.primary = isPrimary; 69 | 70 | [[iOSSocialServicesStore sharedServiceStore] registerService:self]; 71 | } 72 | 73 | - (NSString*)name 74 | { 75 | return @"Twitter"; 76 | } 77 | 78 | - (UIImage*)logoImage 79 | { 80 | NSURL *logoURL = [[NSBundle mainBundle] URLForResource:@"twitter-logo" withExtension:@"png"]; 81 | UIImage *theLogoImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:logoURL]]; 82 | return theLogoImage; 83 | } 84 | 85 | - (NSString*)serviceKeychainItemName 86 | { 87 | return self.keychainItemName; 88 | } 89 | 90 | - (void)setAccountStoreAccounts { 91 | ACAccountType *accountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 92 | NSArray *twitterAccounts = [self.accountStore accountsWithAccountType:accountType]; 93 | if (!twitterAccounts.count) { 94 | if (self.authorizationHandler) { 95 | NSError *error = [NSError errorWithDomain:@"Twitter" code:1 userInfo:nil]; 96 | self.authorizationHandler(nil, nil, error); 97 | self.authorizationHandler = nil; 98 | } 99 | } else { 100 | if (self.authorizationHandler) { 101 | ACAccount *account = [twitterAccounts objectAtIndex:0]; 102 | 103 | NSDictionary *userDictionary = [NSDictionary dictionaryWithObject:account.username forKey:@"username"]; 104 | NSDictionary *userInfoDictionary = [NSDictionary dictionaryWithObject:userDictionary forKey:@"user"]; 105 | 106 | self.authorizationHandler(account, userInfoDictionary, nil); 107 | self.authorizationHandler = nil; 108 | } 109 | } 110 | } 111 | 112 | - (id)checkAuthenticationForKeychainItemName:(NSString*)theKeychainItemName 113 | { 114 | ACAccount *account = nil; 115 | if (theKeychainItemName) { 116 | account = [self.accountStore accountWithIdentifier:theKeychainItemName]; 117 | } 118 | 119 | return account; 120 | } 121 | 122 | - (id)checkAuthenticationForLegacyKeychainItemName:(NSString*)theKeychainItemName 123 | { 124 | return [super checkAuthenticationForKeychainItemName:theKeychainItemName]; 125 | } 126 | 127 | - (UIViewController*)authorizeFromViewController:(UIViewController *)vc 128 | forAuth:(id)theAuth 129 | andKeychainItemName:(NSString *)theKeychainItemName 130 | andCookieDomain:(NSString *)cookieDomain 131 | withCompletionHandler:(AuthorizationHandler)completionHandler 132 | { 133 | self.authorizationHandler = completionHandler; 134 | /* 135 | if ([ACAccountStore class]) { 136 | 137 | ACAccountType *accountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 138 | 139 | [self.accountStore requestAccessToAccountsWithType:accountType 140 | withCompletionHandler:^(BOOL granted, NSError *error) { 141 | if (error) { 142 | if (self.authorizationHandler) { 143 | self.authorizationHandler(nil, nil, error); 144 | self.authorizationHandler = nil; 145 | } 146 | } else { 147 | if (granted) { 148 | dispatch_async(dispatch_get_main_queue(), ^{ 149 | [self setAccountStoreAccounts]; 150 | }); 151 | } else { 152 | if (self.authorizationHandler) { 153 | NSError *error = [NSError errorWithDomain:@"Twitter" code:2 userInfo:nil]; 154 | self.authorizationHandler(nil, nil, error); 155 | self.authorizationHandler = nil; 156 | } 157 | } 158 | } 159 | }]; 160 | } else { 161 | */ 162 | return [super authorizeFromViewController:vc forAuth:theAuth andKeychainItemName:theKeychainItemName andCookieDomain:cookieDomain withCompletionHandler:completionHandler]; 163 | //} 164 | } 165 | 166 | - (id)localUser 167 | { 168 | return [LocalTwitterUser localTwitterUser]; 169 | } 170 | 171 | - (id)localUserWithDictionary:(NSDictionary*)dictionary 172 | { 173 | LocalTwitterUser *theUser = [[LocalTwitterUser alloc] initWithDictionary:dictionary]; 174 | [LocalTwitterUser setLocalTwitterUser:theUser]; 175 | return theUser; 176 | } 177 | 178 | - (id)localUserWithIdentifier:(NSString*)identifier 179 | { 180 | LocalTwitterUser *theUser = [[LocalTwitterUser alloc] initWithIdentifier:identifier]; 181 | [LocalTwitterUser setLocalTwitterUser:theUser]; 182 | return theUser; 183 | } 184 | 185 | - (id)legacyLocalUser 186 | { 187 | return [[LocalTwitterUserLegacy alloc] init]; 188 | } 189 | 190 | - (id)legacyLocalUserWithDictionary:(NSDictionary*)dictionary 191 | { 192 | return [[LocalTwitterUserLegacy alloc] initWithDictionary:dictionary]; 193 | } 194 | 195 | - (id)legacyLocalUserWithIdentifier:(NSString*)identifier 196 | { 197 | return [[LocalTwitterUserLegacy alloc] initWithIdentifier:identifier]; 198 | } 199 | 200 | @end 201 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/TwitterUser+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @interface TwitterUser () 18 | 19 | @property(nonatomic, readwrite, retain) NSDictionary *userDictionary; 20 | @property(nonatomic, readwrite, retain) NSString *userID; 21 | @property(nonatomic, readwrite, retain) NSString *alias; 22 | @property(nonatomic, readwrite, retain) NSString *profilePictureURL; // The user's last name 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/TwitterUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialUser.h" 19 | #import "iOSSocialConstants.h" 20 | 21 | @interface TwitterUser : NSObject 22 | 23 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 24 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 25 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 26 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 27 | 28 | // Asynchronously load the users's photo. Error will be nil on success. 29 | // Possible reasons for error: 30 | // 1. Communications failure 31 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/TwitterUser.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "TwitterUser.h" 18 | #import "TwitterUser+Private.h" 19 | #import "iOSSRequest.h" 20 | 21 | @interface TwitterUser () 22 | 23 | @property(nonatomic, copy) LoadPhotoHandler loadPhotoHandler; 24 | 25 | @end 26 | 27 | @implementation TwitterUser 28 | 29 | @synthesize userDictionary; 30 | @synthesize userID; 31 | @synthesize alias; 32 | @synthesize fetchUserDataHandler; 33 | @synthesize loadPhotoHandler; 34 | @synthesize profilePictureURL; 35 | 36 | - (id)init 37 | { 38 | self = [super init]; 39 | if (self) { 40 | // Initialization code here. 41 | } 42 | 43 | return self; 44 | } 45 | 46 | - (id)initWithDictionary:(NSDictionary*)theUserDictionary 47 | { 48 | self = [self init]; 49 | if (self) { 50 | // Initialization code here. 51 | self.userDictionary = theUserDictionary; 52 | } 53 | 54 | return self; 55 | } 56 | 57 | - (void)setUserDictionary:(NSDictionary *)theUserDictionary 58 | { 59 | NSMutableDictionary *newUserDictionary = [NSMutableDictionary dictionary]; 60 | 61 | NSString *theUserID = [theUserDictionary objectForKey:@"id"]; 62 | if (theUserID) { 63 | self.userID = theUserID; 64 | [newUserDictionary setObject:self.userID forKey:@"id"]; 65 | } 66 | 67 | NSString *theProfilePictureURL = [theUserDictionary objectForKey:@"profile_image_url_https"]; 68 | if (theProfilePictureURL) { 69 | self.profilePictureURL = theProfilePictureURL; 70 | [newUserDictionary setObject:self.profilePictureURL forKey:@"profile_image_url_https"]; 71 | } 72 | NSString *theUsername = [theUserDictionary objectForKey:@"username"]; 73 | if (theUsername) { 74 | self.alias = theUsername; 75 | [newUserDictionary setObject:self.alias forKey:@"username"]; 76 | } else { 77 | self.alias = [theUserDictionary objectForKey:@"screen_name"]; 78 | [newUserDictionary setObject:self.alias forKey:@"screen_name"]; 79 | } 80 | 81 | userDictionary = newUserDictionary; 82 | } 83 | 84 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler 85 | { 86 | self.loadPhotoHandler = completionHandler; 87 | 88 | NSString *urlString = self.profilePictureURL; 89 | NSURL *url = [NSURL URLWithString:urlString]; 90 | 91 | iOSSRequest *request = [[iOSSRequest alloc] initWithURL:url 92 | parameters:nil 93 | requestMethod:iOSSRequestMethodGET]; 94 | 95 | [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 96 | if (error) { 97 | if (self.loadPhotoHandler) { 98 | self.loadPhotoHandler(nil, error); 99 | self.loadPhotoHandler = nil; 100 | } 101 | } else { 102 | UIImage *image = [UIImage imageWithData:responseData]; 103 | 104 | if (self.loadPhotoHandler) { 105 | self.loadPhotoHandler(image, nil); 106 | self.loadPhotoHandler = nil; 107 | } 108 | } 109 | }]; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/TwitterUserLegacy+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // TwitterUserLegacy+Private.h 3 | // iOSSocial 4 | // 5 | // Created by Christopher White on 7/22/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | @interface TwitterUserLegacy () 10 | 11 | @property(nonatomic, readwrite, retain) NSDictionary *userDictionary; 12 | @property(nonatomic, readwrite, retain) NSString *userID; 13 | @property(nonatomic, readwrite, retain) NSString *alias; 14 | @property(nonatomic, readwrite, retain) NSString *profilePictureURL; // The user's last name 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/TwitterUserLegacy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "iOSSocialUser.h" 19 | #import "iOSSocialConstants.h" 20 | 21 | @interface TwitterUserLegacy : NSObject 22 | 23 | @property(nonatomic, readonly, retain) NSString *userID; // User identifier. 24 | @property(nonatomic, readonly, retain) NSString *alias; // The user's alias 25 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; // The user's last name 26 | @property(nonatomic, copy) FetchUserDataHandler fetchUserDataHandler; 27 | 28 | // Asynchronously load the users's photo. Error will be nil on success. 29 | // Possible reasons for error: 30 | // 1. Communications failure 31 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/TwitterUserLegacy.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "TwitterUserLegacy.h" 18 | #import "TwitterUserLegacy+Private.h" 19 | #import "iOSSRequest.h" 20 | 21 | @interface TwitterUserLegacy () 22 | 23 | @property(nonatomic, copy) LoadPhotoHandler loadPhotoHandler; 24 | 25 | @end 26 | 27 | @implementation TwitterUserLegacy 28 | 29 | @synthesize userDictionary; 30 | @synthesize userID; 31 | @synthesize alias; 32 | @synthesize fetchUserDataHandler; 33 | @synthesize loadPhotoHandler; 34 | @synthesize profilePictureURL; 35 | 36 | - (id)init 37 | { 38 | self = [super init]; 39 | if (self) { 40 | // Initialization code here. 41 | } 42 | 43 | return self; 44 | } 45 | 46 | - (id)initWithDictionary:(NSDictionary*)theUserDictionary 47 | { 48 | self = [self init]; 49 | if (self) { 50 | // Initialization code here. 51 | self.userDictionary = theUserDictionary; 52 | } 53 | 54 | return self; 55 | } 56 | 57 | - (void)setUserDictionary:(NSDictionary *)theUserDictionary 58 | { 59 | NSMutableDictionary *newUserDictionary = [NSMutableDictionary dictionary]; 60 | 61 | NSString *theUserID = [theUserDictionary objectForKey:@"id"]; 62 | if (theUserID) { 63 | self.userID = theUserID; 64 | [newUserDictionary setObject:self.userID forKey:@"id"]; 65 | } 66 | 67 | NSString *theProfilePictureURL = [theUserDictionary objectForKey:@"profile_image_url_https"]; 68 | if (theProfilePictureURL) { 69 | self.profilePictureURL = theProfilePictureURL; 70 | [newUserDictionary setObject:self.profilePictureURL forKey:@"profile_image_url_https"]; 71 | } 72 | NSString *theUsername = [theUserDictionary objectForKey:@"username"]; 73 | if (theUsername) { 74 | self.alias = theUsername; 75 | [newUserDictionary setObject:self.alias forKey:@"username"]; 76 | } else { 77 | self.alias = [theUserDictionary objectForKey:@"screen_name"]; 78 | [newUserDictionary setObject:self.alias forKey:@"screen_name"]; 79 | } 80 | 81 | userDictionary = newUserDictionary; 82 | } 83 | 84 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler 85 | { 86 | self.loadPhotoHandler = completionHandler; 87 | 88 | NSString *urlString = self.profilePictureURL; 89 | NSURL *url = [NSURL URLWithString:urlString]; 90 | 91 | iOSSRequest *request = [[iOSSRequest alloc] initWithURL:url 92 | parameters:nil 93 | requestMethod:iOSSRequestMethodGET]; 94 | 95 | [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 96 | if (error) { 97 | if (self.loadPhotoHandler) { 98 | self.loadPhotoHandler(nil, error); 99 | self.loadPhotoHandler = nil; 100 | } 101 | } else { 102 | UIImage *image = [UIImage imageWithData:responseData]; 103 | 104 | if (self.loadPhotoHandler) { 105 | self.loadPhotoHandler(image, nil); 106 | self.loadPhotoHandler = nil; 107 | } 108 | } 109 | }]; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Twitter/twitter-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chris124/iOSSocial/45f5382698a9687aa6f4d0c5e0b15fe7f6a06510/iOSSocial/iOSSocial/Twitter/twitter-logo.png -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Utilities/Connection/iOSSRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "ASIOARequest.h" 19 | 20 | enum iOSSRequestMethod { 21 | iOSSRequestMethodGET, 22 | iOSSRequestMethodPOST, 23 | iOSSRequestMethodDELETE 24 | }; 25 | typedef enum iOSSRequestMethod iOSSRequestMethod; 26 | 27 | //typedef void(^iOSSRequestHandler)(NSString *responseString, NSError *error); 28 | typedef void(^iOSSRequestHandler)(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error); 29 | 30 | @interface iOSSRequest : NSObject { 31 | } 32 | 33 | - (id)initWithURL:(NSURL *)url 34 | parameters:(NSDictionary *)parameters 35 | requestMethod:(iOSSRequestMethod)requestMethod; 36 | 37 | @property(nonatomic, readonly, retain) NSDictionary *parameters; 38 | @property(nonatomic, readonly, assign) iOSSRequestMethod requestMethod; 39 | @property(nonatomic, readonly, retain) NSURL *URL; 40 | @property(nonatomic, retain) NSDictionary *oauth_params; 41 | 42 | - (void)performRequestWithHandler:(iOSSRequestHandler)handler; 43 | 44 | - (void)addFile:(NSString*)filePath forKey:(NSString *)key; 45 | 46 | - (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key; 47 | 48 | @end -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Utilities/Connection/iOSSRequest.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "iOSSRequest.h" 18 | //#import "UIApplication+iOSSNetworkActivity.h" 19 | #import "ASIFormDataRequest.h" 20 | #import "ASIOARequest.h" 21 | 22 | @interface iOSSRequest () { 23 | NSDictionary *_parameters; 24 | iOSSRequestMethod _requestMethod; 25 | NSURL *_URL; 26 | } 27 | 28 | @property(nonatomic, readwrite, retain) NSDictionary *parameters; 29 | @property(nonatomic, readwrite, assign) iOSSRequestMethod requestMethod; 30 | @property(nonatomic, readwrite, retain) NSURL *URL; 31 | @property(nonatomic, copy) iOSSRequestHandler requestHandler; 32 | @property(nonatomic, retain) ASIOARequest *request; 33 | @property(nonatomic, retain) NSMutableArray *files; 34 | @property(nonatomic, retain) NSMutableArray *data; 35 | 36 | @end 37 | 38 | @implementation iOSSRequest 39 | 40 | @synthesize parameters=_parameters; 41 | @synthesize requestMethod=_requestMethod; 42 | @synthesize URL=_URL; 43 | @synthesize requestHandler; 44 | @synthesize request; 45 | @synthesize oauth_params; 46 | @synthesize files; 47 | @synthesize data; 48 | 49 | - (id)init 50 | { 51 | self = [super init]; 52 | if (self) { 53 | // Initialization code here. 54 | } 55 | 56 | return self; 57 | } 58 | 59 | - (id)initWithURL:(NSURL *)url 60 | parameters:(NSDictionary *)parameters 61 | requestMethod:(iOSSRequestMethod)requestMethod 62 | { 63 | self = [self init]; 64 | if (self) { 65 | // Initialization code here. 66 | _URL = url; 67 | _parameters = parameters; 68 | _requestMethod = requestMethod; 69 | } 70 | 71 | return self; 72 | } 73 | 74 | - (void)performRequestWithHandler:(iOSSRequestHandler)handler 75 | { 76 | self.requestHandler = handler; 77 | 78 | iOSSRequest *theRequest = self; 79 | 80 | switch (self.requestMethod) { 81 | case iOSSRequestMethodGET: 82 | { 83 | self.request = [ASIOARequest requestWithURL:self.URL]; 84 | self.request.delegate = self; 85 | self.request.requestMethod = @"GET"; 86 | 87 | if (self.oauth_params) { 88 | self.request.oauthParams = self.oauth_params; 89 | } 90 | 91 | self.request.completionBlock = ^(void) { 92 | if (theRequest.requestHandler) { 93 | theRequest.requestHandler([theRequest.request responseData], nil, theRequest.request.error); 94 | } 95 | }; 96 | 97 | [self.request setFailedBlock:^(void) { 98 | NSLog(@"failed"); 99 | if (theRequest.requestHandler) { 100 | theRequest.requestHandler(nil, nil, theRequest.request.error); 101 | } 102 | } ]; 103 | 104 | [self.request startAsynchronous]; 105 | } 106 | break; 107 | 108 | case iOSSRequestMethodPOST: 109 | { 110 | self.request = [ASIOARequest requestWithURL:self.URL]; 111 | self.request.delegate = self; 112 | self.request.requestMethod = @"POST"; 113 | 114 | NSArray *keys = [self.parameters allKeys]; 115 | for (NSString *key in keys) { 116 | [self.request addPostValue:[self.parameters objectForKey:key] forKey:key]; 117 | } 118 | 119 | for (NSDictionary *fileDictionary in self.files) { 120 | [self.request addFile:[fileDictionary objectForKey:@"path"] forKey:[fileDictionary objectForKey:@"key"]]; 121 | } 122 | 123 | self.files = nil; 124 | 125 | for (NSDictionary *dataDictionary in self.data) { 126 | [self.request addData:[dataDictionary objectForKey:@"data"] 127 | withFileName:[dataDictionary objectForKey:@"fileName"] 128 | andContentType:[dataDictionary objectForKey:@"contentType"] 129 | forKey:[dataDictionary objectForKey:@"key"]]; 130 | } 131 | 132 | self.data = nil; 133 | 134 | if (self.oauth_params) { 135 | self.request.oauthParams = self.oauth_params; 136 | } 137 | 138 | self.request.completionBlock = ^(void) { 139 | if (theRequest.requestHandler) { 140 | theRequest.requestHandler([theRequest.request responseData], nil, theRequest.request.error); 141 | } 142 | }; 143 | 144 | [self.request setFailedBlock:^(void) { 145 | NSLog(@"failed"); 146 | if (theRequest.requestHandler) { 147 | theRequest.requestHandler(nil, nil, theRequest.request.error); 148 | } 149 | } ]; 150 | 151 | [self.request startAsynchronous]; 152 | } 153 | break; 154 | 155 | case iOSSRequestMethodDELETE: 156 | { 157 | 158 | } 159 | break; 160 | 161 | default: 162 | break; 163 | } 164 | 165 | //cwnote: make sure we POP! 166 | //[[UIApplication sharedApplication] ioss_pushNetworkActivity]; 167 | } 168 | 169 | - (void)addFile:(NSString*)filePath forKey:(NSString *)key 170 | { 171 | if (nil == self.files) { 172 | self.files = [NSMutableArray array]; 173 | } 174 | 175 | NSDictionary *fileDictionary = [NSDictionary dictionaryWithObjectsAndKeys:filePath, @"path", key, @"key", nil]; 176 | [self.files addObject:fileDictionary]; 177 | } 178 | 179 | - (void)addData:(id)theData withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key 180 | { 181 | if (nil == self.data) { 182 | self.data = [NSMutableArray array]; 183 | } 184 | 185 | NSDictionary *dataDictionary = [NSDictionary dictionaryWithObjectsAndKeys:theData, @"data", fileName, @"fileName", contentType, @"contentType", key, @"key", nil]; 186 | [self.data addObject:dataDictionary]; 187 | } 188 | 189 | @end 190 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Utilities/Keychain/KeychainItemWrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: KeychainItemWrapper.h 3 | Abstract: 4 | Objective-C wrapper for accessing a single keychain item. 5 | 6 | Version: 1.2 7 | 8 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 9 | Inc. ("Apple") in consideration of your agreement to the following 10 | terms, and your use, installation, modification or redistribution of 11 | this Apple software constitutes acceptance of these terms. If you do 12 | not agree with these terms, please do not use, install, modify or 13 | redistribute this Apple software. 14 | 15 | In consideration of your agreement to abide by the following terms, and 16 | subject to these terms, Apple grants you a personal, non-exclusive 17 | license, under Apple's copyrights in this original Apple software (the 18 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 19 | Software, with or without modifications, in source and/or binary forms; 20 | provided that if you redistribute the Apple Software in its entirety and 21 | without modifications, you must retain this notice and the following 22 | text and disclaimers in all such redistributions of the Apple Software. 23 | Neither the name, trademarks, service marks or logos of Apple Inc. may 24 | be used to endorse or promote products derived from the Apple Software 25 | without specific prior written permission from Apple. Except as 26 | expressly stated in this notice, no other rights or licenses, express or 27 | implied, are granted by Apple herein, including but not limited to any 28 | patent rights that may be infringed by your derivative works or by other 29 | works in which the Apple Software may be incorporated. 30 | 31 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 32 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 33 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 34 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 35 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 36 | 37 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 38 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 39 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 40 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 41 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 42 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 43 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 44 | POSSIBILITY OF SUCH DAMAGE. 45 | 46 | Copyright (C) 2010 Apple Inc. All Rights Reserved. 47 | 48 | */ 49 | 50 | #import 51 | 52 | /* 53 | The KeychainItemWrapper class is an abstraction layer for the iPhone Keychain communication. It is merely a 54 | simple wrapper to provide a distinct barrier between all the idiosyncracies involved with the Keychain 55 | CF/NS container objects. 56 | */ 57 | @interface KeychainItemWrapper : NSObject 58 | { 59 | NSMutableDictionary *keychainItemData; // The actual keychain item data backing store. 60 | NSMutableDictionary *genericPasswordQuery; // A placeholder for the generic keychain item query used to locate the item. 61 | } 62 | 63 | @property (nonatomic, retain) NSMutableDictionary *keychainItemData; 64 | @property (nonatomic, retain) NSMutableDictionary *genericPasswordQuery; 65 | 66 | // Designated initializer. 67 | - (id)initWithIdentifier: (NSString *)identifier accessGroup:(NSString *) accessGroup; 68 | - (void)setObject:(id)inObject forKey:(id)key; 69 | - (id)objectForKey:(id)key; 70 | 71 | // Initializes and resets the default generic keychain item data. 72 | - (void)resetKeychainItem; 73 | 74 | @end -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Utilities/Log/iOSSLog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | void iOSDebug(const char *fileName, int lineNumber, NSString *fmt, ...); 18 | 19 | #ifdef IOSSDEBUG 20 | #define iOSSLog(format...) iOSDebug(__FILE__, __LINE__, format) 21 | #else 22 | #define iOSSLog(format...) 23 | #endif 24 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/Utilities/Log/iOSSLog.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "iOSSLog.h" 18 | 19 | void iOSDebug(const char *fileName, int lineNumber, NSString *fmt, ...) 20 | { 21 | va_list args; 22 | va_start(args, fmt); 23 | 24 | static NSDateFormatter *debugFormatter = nil; 25 | if (debugFormatter == nil) { 26 | debugFormatter = [[NSDateFormatter alloc] init]; 27 | [debugFormatter setDateFormat:@"yyyyMMdd.HH:mm:ss"]; 28 | } 29 | 30 | NSString *msg = [[NSString alloc] initWithFormat:fmt arguments:args]; 31 | NSString *filePath = [[NSString alloc] initWithUTF8String:fileName]; 32 | NSString *timestamp = [NSDateFormatter localizedStringFromDate:[NSDate date] 33 | dateStyle:kCFDateFormatterFullStyle 34 | timeStyle:kCFDateFormatterFullStyle]; 35 | 36 | NSDictionary *info = [[NSBundle mainBundle] infoDictionary]; 37 | NSString *appName = [info objectForKey:(NSString *)kCFBundleNameKey]; 38 | fprintf(stdout, "%s %s[%s:%d] %s\n", 39 | [timestamp UTF8String], 40 | [appName UTF8String], 41 | [[filePath lastPathComponent] UTF8String], 42 | lineNumber, 43 | [msg UTF8String]); 44 | 45 | va_end(args); 46 | } 47 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSServiceTableViewCell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "PRPSmartTableViewCell.h" 18 | 19 | @protocol iOSSocialServiceProtocol; 20 | @interface iOSSServiceTableViewCell : PRPSmartTableViewCell 21 | 22 | @property(nonatomic, retain) id service; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSServiceTableViewCell.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "iOSSServiceTableViewCell.h" 18 | #import "iOSSocialLocalUser.h" 19 | #import "iOSSocialServicesStore.h" 20 | 21 | @interface iOSSServiceTableViewCell () { 22 | id _service; 23 | } 24 | 25 | @end 26 | 27 | @implementation iOSSServiceTableViewCell 28 | 29 | @synthesize service=_service; 30 | 31 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 32 | { 33 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 34 | if (self) { 35 | // Initialization code 36 | } 37 | return self; 38 | } 39 | 40 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated 41 | { 42 | [super setSelected:selected animated:animated]; 43 | 44 | // Configure the view for the selected state 45 | } 46 | 47 | + (id)cellForTableView:(UITableView *)tableView 48 | { 49 | NSString *cellID = [self cellIdentifier]; 50 | UITableViewCell *cell = [tableView 51 | dequeueReusableCellWithIdentifier:cellID]; 52 | if (cell == nil) { 53 | cell = [[self alloc] initWithCellIdentifier:cellID]; 54 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 55 | } 56 | return cell; 57 | } 58 | 59 | 60 | - (id)initWithCellIdentifier:(NSString *)cellID 61 | { 62 | return [self initWithStyle:UITableViewCellStyleSubtitle 63 | reuseIdentifier:cellID]; 64 | } 65 | 66 | - (void)setService:(id)theService 67 | { 68 | _service = theService; 69 | 70 | UIImageView *logoImageView = (UIImageView*)[self viewWithTag:1]; 71 | if (!logoImageView) { 72 | logoImageView = [[UIImageView alloc] initWithImage:self.service.logoImage]; 73 | [logoImageView setTag:1]; 74 | [logoImageView setFrame:CGRectMake(5.0f, 5.0f, 25.0f, 25.0f)]; 75 | [self.contentView addSubview:logoImageView]; 76 | } 77 | logoImageView.image = self.service.logoImage; 78 | 79 | UILabel *nameLabel = (UILabel*)[self viewWithTag:2]; 80 | if (!nameLabel) { 81 | nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(logoImageView.frame.origin.x+logoImageView.frame.size.width+10.0f, 5.0f, 150.0f, 15.0f)]; 82 | [nameLabel setTag:2]; 83 | nameLabel.font = [UIFont systemFontOfSize:10.0f]; 84 | nameLabel.backgroundColor = [UIColor clearColor]; 85 | [self.contentView addSubview:nameLabel]; 86 | } 87 | 88 | nameLabel.text = [NSString stringWithFormat:@"%@", self.service.name]; 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSServicesDataSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | 20 | @interface iOSServicesDataSource : NSObject { 21 | } 22 | 23 | @property(nonatomic, retain) NSString *message; 24 | @property(nonatomic, assign) BOOL displayDoneButton; 25 | 26 | - (id)initWithServicesFilter:(NSArray*)filter; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSServicesDataSource.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "iOSServicesDataSource.h" 18 | #import "iOSSLog.h" 19 | #import "iOSSServiceTableViewCell.h" 20 | #import "iOSSocialServicesStore.h" 21 | #import "iOSSocialAccountTableViewCell.h" 22 | 23 | 24 | @interface iOSServicesDataSource () 25 | 26 | @property(nonatomic, retain) NSMutableArray *services; 27 | 28 | @end 29 | 30 | @implementation iOSServicesDataSource 31 | 32 | @synthesize message; 33 | @synthesize displayDoneButton; 34 | @synthesize services; 35 | 36 | - (id)init 37 | { 38 | self = [super init]; 39 | if (self) { 40 | // Initialization code here. 41 | } 42 | 43 | return self; 44 | } 45 | 46 | - (id)initWithServicesFilter:(NSArray*)filter 47 | { 48 | self = [self init]; 49 | if (self) { 50 | 51 | self.services = [NSMutableArray arrayWithArray:filter]; 52 | } 53 | 54 | return self; 55 | } 56 | 57 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 58 | { 59 | switch (section) { 60 | case 0: 61 | return @"YOUR ACCOUNTS"; 62 | case 1: 63 | return @"ADD AN ACCOUNT"; 64 | default: 65 | iOSSLog(@"Unexpected section (%d)", section); break; 66 | } 67 | 68 | return nil; 69 | } 70 | 71 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 72 | { 73 | // Return the number of sections. 74 | if (self.displayDoneButton) { 75 | return 3; 76 | } 77 | return 2; 78 | } 79 | 80 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 81 | { 82 | NSInteger rowsInSection = 0; 83 | 84 | if (self.displayDoneButton) { 85 | //return for each section 86 | switch (section) { 87 | case 0: 88 | rowsInSection = [[iOSSocialServicesStore sharedServiceStore].accounts count]; 89 | break; 90 | case 1: 91 | rowsInSection = [self.services count]; 92 | break; 93 | case 2: 94 | rowsInSection = 1; 95 | break; 96 | default: 97 | break; 98 | } 99 | } else { 100 | //return for each section 101 | switch (section) { 102 | case 0: 103 | rowsInSection = [[iOSSocialServicesStore sharedServiceStore].accounts count]; 104 | break; 105 | case 1: 106 | rowsInSection = [self.services count]; 107 | break; 108 | default: 109 | break; 110 | } 111 | } 112 | return rowsInSection; 113 | } 114 | 115 | // Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier: 116 | // Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls) 117 | 118 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 119 | { 120 | UITableViewCell *theCell = nil; 121 | 122 | if (self.displayDoneButton) { 123 | switch (indexPath.section) { 124 | case 0: 125 | { 126 | id localUser = [[iOSSocialServicesStore sharedServiceStore].accounts objectAtIndex:[indexPath row]]; 127 | 128 | iOSSocialAccountTableViewCell *cell = [iOSSocialAccountTableViewCell cellForTableView:tableView]; 129 | cell.localUser = localUser; 130 | 131 | theCell = cell; 132 | } 133 | break; 134 | case 1: 135 | { 136 | id service = [self.services objectAtIndex:[indexPath row]]; 137 | 138 | iOSSServiceTableViewCell *cell = [iOSSServiceTableViewCell cellForTableView:tableView]; 139 | cell.service = service; 140 | 141 | theCell = cell; 142 | } 143 | break; 144 | case 2: 145 | { 146 | static NSString *CellIdentifier = @"Cell"; 147 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 148 | if (cell == nil) { 149 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 150 | } 151 | cell.textLabel.text = @"Done"; 152 | 153 | theCell = cell; 154 | } 155 | break; 156 | default: 157 | break; 158 | } 159 | } else { 160 | switch (indexPath.section) { 161 | case 0: 162 | { 163 | id localUser = [[iOSSocialServicesStore sharedServiceStore].accounts objectAtIndex:[indexPath row]]; 164 | 165 | iOSSocialAccountTableViewCell *cell = [iOSSocialAccountTableViewCell cellForTableView:tableView]; 166 | cell.localUser = localUser; 167 | 168 | theCell = cell; 169 | } 170 | break; 171 | case 1: 172 | { 173 | id service = [self.services objectAtIndex:[indexPath row]]; 174 | 175 | iOSSServiceTableViewCell *cell = [iOSSServiceTableViewCell cellForTableView:tableView]; 176 | cell.service = service; 177 | 178 | theCell = cell; 179 | } 180 | break; 181 | default: 182 | break; 183 | } 184 | } 185 | 186 | return theCell; 187 | } 188 | 189 | @end 190 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocial-Prefix.pch: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifdef __OBJC__ 18 | #import 19 | #endif 20 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "InstagramUser.h" 19 | #import "LocalInstagramUser.h" 20 | #import "iOSSLog.h" -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocial.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "iOSSocial.h" 18 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocialAccountTableViewCell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "PRPSmartTableViewCell.h" 18 | 19 | @protocol iOSSocialLocalUserProtocol; 20 | @interface iOSSocialAccountTableViewCell : PRPSmartTableViewCell 21 | 22 | @property(nonatomic, retain) id localUser; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocialAccountTableViewCell.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "iOSSocialAccountTableViewCell.h" 18 | #import "iOSSocialLocalUser.h" 19 | 20 | @interface iOSSocialAccountTableViewCell () { 21 | id _localUser; 22 | } 23 | 24 | @end 25 | 26 | @implementation iOSSocialAccountTableViewCell 27 | 28 | @synthesize localUser=_localUser; 29 | 30 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 31 | { 32 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 33 | if (self) { 34 | // Initialization code 35 | } 36 | return self; 37 | } 38 | 39 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated 40 | { 41 | [super setSelected:selected animated:animated]; 42 | 43 | // Configure the view for the selected state 44 | } 45 | 46 | + (id)cellForTableView:(UITableView *)tableView 47 | { 48 | NSString *cellID = [self cellIdentifier]; 49 | UITableViewCell *cell = [tableView 50 | dequeueReusableCellWithIdentifier:cellID]; 51 | if (cell == nil) { 52 | cell = [[self alloc] initWithCellIdentifier:cellID]; 53 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 54 | } 55 | return cell; 56 | } 57 | 58 | 59 | - (id)initWithCellIdentifier:(NSString *)cellID 60 | { 61 | return [self initWithStyle:UITableViewCellStyleSubtitle 62 | reuseIdentifier:cellID]; 63 | } 64 | 65 | - (void)setLocalUser:(id)theLocalUser 66 | { 67 | _localUser = theLocalUser; 68 | 69 | UIImageView *logoImageView = (UIImageView*)[self viewWithTag:1]; 70 | if (!logoImageView) { 71 | logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5.0f, 5.0f, 25.0f, 25.0f)]; 72 | [logoImageView setTag:1]; 73 | [self.contentView addSubview:logoImageView]; 74 | } 75 | 76 | [self.localUser loadPhotoWithCompletionHandler:^(UIImage *photo, NSError *error) { 77 | logoImageView.image = photo; 78 | }]; 79 | 80 | UILabel *nameLabel = (UILabel*)[self viewWithTag:2]; 81 | if (!nameLabel) { 82 | nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(logoImageView.frame.origin.x+logoImageView.frame.size.width+10.0f, 5.0f, 150.0f, 15.0f)]; 83 | [nameLabel setTag:2]; 84 | nameLabel.font = [UIFont systemFontOfSize:10.0f]; 85 | nameLabel.backgroundColor = [UIColor clearColor]; 86 | [self.contentView addSubview:nameLabel]; 87 | } 88 | 89 | nameLabel.text = [NSString stringWithFormat:@"%@", self.localUser.username]; 90 | 91 | UILabel *serviceLabel = (UILabel*)[self viewWithTag:3]; 92 | if (!serviceLabel) { 93 | serviceLabel = [[UILabel alloc] initWithFrame:CGRectMake(logoImageView.frame.origin.x+logoImageView.frame.size.width+10.0f, nameLabel.frame.origin.y+nameLabel.frame.size.height+5.0f, 150.0f, 15.0f)]; 94 | [serviceLabel setTag:3]; 95 | serviceLabel.font = [UIFont systemFontOfSize:10.0f]; 96 | serviceLabel.backgroundColor = [UIColor clearColor]; 97 | [self.contentView addSubview:serviceLabel]; 98 | } 99 | 100 | if ([self.localUser isAuthenticated]) { 101 | serviceLabel.text = [NSString stringWithFormat:@"Connected to %@", self.localUser.servicename]; 102 | } else { 103 | serviceLabel.text = [NSString stringWithFormat:@"Disconnected from %@", self.localUser.servicename]; 104 | } 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocialConstants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | typedef void(^LoadPhotoHandler)(UIImage *photo, NSError *error); 20 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocialLocalUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "iOSSocialConstants.h" 20 | 21 | typedef void(^AuthenticationHandler)(NSError *error); 22 | 23 | @protocol iOSSocialLocalUserProtocol 24 | 25 | @required 26 | 27 | - (id)initWithDictionary:(NSDictionary*)dictionary; 28 | 29 | - (id)initWithIdentifier:(NSString*)identifier; 30 | 31 | @property(nonatomic, readonly, getter=isAuthenticated) BOOL authenticated; // Authentication state 32 | 33 | @property(nonatomic, readonly, retain) NSString *username; 34 | @property(nonatomic, readonly, retain) NSString *servicename; 35 | @property(nonatomic, readonly, retain) NSString *identifier; 36 | @property(nonatomic, readonly, retain) NSString *profilePictureURL; 37 | 38 | // Authenticate the user for access to user details. This may present a UI to the user if necessary to login or create an account. 39 | // The user must be authenticated in order to use some other APIs (on a per-service basis). 40 | // This should be called for each launch of the application as soon as the UI is ready. 41 | // Authentication happens automatically on return to foreground, and the completion handler will be called again. 42 | // The UI may be presented during this authentication. 43 | // Apps should check the local user's authenticated and user ID properties to determine if the local user has changed. 44 | // The authorization screen, if needed, is show modally so pass in the current view controller. 45 | // Possible reasons for error: 46 | // 1. Communications problem 47 | // 2. User credentials invalid 48 | // 3. User cancelled 49 | - (UIViewController*)authenticateFromViewController:(UIViewController*)vc 50 | withCompletionHandler:(AuthenticationHandler)completionHandler; 51 | 52 | - (NSString*)oAuthAccessToken; 53 | 54 | - (NSTimeInterval)oAuthAccessTokenExpirationDate; 55 | 56 | - (NSString*)oAuthAccessTokenSecret; 57 | 58 | //remove all stored OAuth info from the keychain and reset state in memory 59 | - (void)logout; 60 | 61 | - (NSString*)userId; 62 | 63 | - (void)loadPhotoWithCompletionHandler:(LoadPhotoHandler)completionHandler; 64 | 65 | @optional 66 | 67 | - (NSURL*)authorizedURL:(NSURL*)theURL; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocialLocalUser.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "iOSSocialLocalUser.h" 18 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocialServicesStore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #import 19 | #import "iOSSocialOAuth.h" 20 | 21 | @class GTMOAuthAuthenticationWithAdditions; 22 | @class GTMOAuth2Authentication; 23 | @protocol iOSSocialLocalUserProtocol; 24 | 25 | @protocol iOSSocialServiceProtocol 26 | 27 | @required 28 | 29 | @property(nonatomic, readonly, retain) NSString *name; 30 | @property(nonatomic, readonly, retain) UIImage *logoImage; 31 | @property(nonatomic, readonly, assign) BOOL primary; 32 | 33 | + (id)sharedService; 34 | 35 | // This must be called before calling any of the non-class methods on a service otherwise it will cause an assertion. 36 | // See iOSSocialServiceOAuth2ProviderConstants.h or iOSSocialServiceOAuthProviderConstants.h for the Keys for this dictionary. 37 | - (void)assignOAuthParams:(NSDictionary*)params asPrimary:(BOOL)isPrimary; 38 | 39 | - (id)localUser; 40 | 41 | - (id)localUserWithDictionary:(NSDictionary*)dictionary; 42 | 43 | - (id)localUserWithIdentifier:(NSString*)uuid; 44 | 45 | - (NSString*)apiKey; 46 | 47 | - (NSString*)apiSecret; 48 | 49 | - (NSString*)serviceKeychainItemName; 50 | 51 | @optional 52 | 53 | - (NSString*)apiScope; 54 | 55 | - (UIViewController*)authorizeFromViewController:(UIViewController*)vc 56 | forAuth:(id)theAuth 57 | andKeychainItemName:(NSString*)theKeychainItemName 58 | andCookieDomain:(NSString*)cookieDomain 59 | withCompletionHandler:(AuthorizationHandler)completionHandler; 60 | 61 | - (void)logout:(id)theAuth forKeychainItemName:(NSString*)theKeychainItemName; 62 | 63 | - (id)checkAuthenticationForKeychainItemName:(NSString*)theKeychainItemName; 64 | 65 | + (id)JSONFromData:(NSData*)data; 66 | 67 | - (NSString*)urlSchemeSuffix; 68 | 69 | //for twitter pre-iOS 5 70 | - (id)legacyLocalUser; 71 | 72 | - (id)legacyLocalUserWithDictionary:(NSDictionary*)dictionary; 73 | 74 | - (id)legacyLocalUserWithIdentifier:(NSString*)uuid; 75 | 76 | - (id)checkAuthenticationForLegacyKeychainItemName:(NSString*)theKeychainItemName; 77 | 78 | @end 79 | 80 | @interface iOSSocialServicesStore : NSObject 81 | 82 | @property(nonatomic, readonly, retain) NSMutableArray *services; 83 | @property(nonatomic, readonly, retain) NSMutableArray *accounts; 84 | @property(nonatomic, readonly, retain) id defaultAccount; 85 | 86 | + (iOSSocialServicesStore*)sharedServiceStore; 87 | 88 | - (id)serviceWithType:(NSString*)serviceName; 89 | 90 | - (id)accountWithType:(NSString*)accountName; 91 | 92 | - (id)accountWithDictionary:(NSDictionary*)accountDictionary; 93 | 94 | - (void)registerService:(id)theService; 95 | 96 | - (void)registerAccount:(id)theAccount; 97 | 98 | - (void)unregisterAccount:(id)theAccount; 99 | 100 | - (void)unregisterAccounts; 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocialUser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | 20 | typedef void(^FetchUserDataHandler)(NSError *error); 21 | 22 | @protocol iOSSocialUserProtocol 23 | 24 | - (id)initWithDictionary:(NSDictionary*)userDictionary; 25 | 26 | @end -------------------------------------------------------------------------------- /iOSSocial/iOSSocial/iOSSocialUser.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Mad Races, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "iOSSocialUser.h" -------------------------------------------------------------------------------- /iOSSocial/iOSSocialTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocialTests/iOSSocialTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ___VARIABLE_bundleIdentifierPrefix:bundleIdentifier___.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocialTests/iOSSocialTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialTests.h 3 | // iOSSocialTests 4 | // 5 | // Created by Christopher White on 7/15/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface iOSSocialTests : SenTestCase 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /iOSSocial/iOSSocialTests/iOSSocialTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // iOSSocialTests.m 3 | // iOSSocialTests 4 | // 5 | // Created by Christopher White on 7/15/11. 6 | // Copyright 2011 Mad Races, Inc. All rights reserved. 7 | // 8 | 9 | #import "iOSSocialTests.h" 10 | 11 | @implementation iOSSocialTests 12 | 13 | - (void)setUp 14 | { 15 | [super setUp]; 16 | 17 | // Set-up code here. 18 | } 19 | 20 | - (void)tearDown 21 | { 22 | // Tear-down code here. 23 | 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample 28 | { 29 | STFail(@"Unit tests are not implemented yet in iOSSocialTests"); 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /prp/PRPSmartTableViewCell.h: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "iOS Recipes", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/cdirec for more book information. 8 | ***/ 9 | #import 10 | 11 | @interface PRPSmartTableViewCell : UITableViewCell {} 12 | 13 | + (id)cellForTableView:(UITableView *)tableView; 14 | + (NSString *)cellIdentifier; 15 | 16 | - (id)initWithCellIdentifier:(NSString *)cellID; 17 | 18 | @end -------------------------------------------------------------------------------- /prp/PRPSmartTableViewCell.m: -------------------------------------------------------------------------------- 1 | /*** 2 | * Excerpted from "iOS Recipes", 3 | * published by The Pragmatic Bookshelf. 4 | * Copyrights apply to this code. It may not be used to create training material, 5 | * courses, books, articles, and the like. Contact us if you are in doubt. 6 | * We make no guarantees that this code is fit for any purpose. 7 | * Visit http://www.pragmaticprogrammer.com/titles/cdirec for more book information. 8 | ***/ 9 | #import "PRPSmartTableViewCell.h" 10 | 11 | @implementation PRPSmartTableViewCell 12 | 13 | + (NSString *)cellIdentifier { 14 | return NSStringFromClass([self class]); 15 | } 16 | 17 | + (id)cellForTableView:(UITableView *)tableView { 18 | NSString *cellID = [self cellIdentifier]; 19 | UITableViewCell *cell = [tableView 20 | dequeueReusableCellWithIdentifier:cellID]; 21 | if (cell == nil) { 22 | cell = [[self alloc] initWithCellIdentifier:cellID]; 23 | } 24 | return cell; 25 | } 26 | 27 | 28 | - (id)initWithCellIdentifier:(NSString *)cellID { 29 | return [self initWithStyle:UITableViewCellStyleSubtitle 30 | reuseIdentifier:cellID]; 31 | } 32 | 33 | @end --------------------------------------------------------------------------------