mirror of https://github.com/axmolengine/axmol.git
Merge pull request #2847 from natural-law/develop
Add twitter plugin for iOS
This commit is contained in:
commit
7e36755010
|
@ -187,10 +187,7 @@
|
||||||
DSTROOT = /tmp/libPluginFlurry.dst;
|
DSTROOT = /tmp/libPluginFlurry.dst;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
|
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||||
"$(SRCROOT)/../../../protocols/include",
|
|
||||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
|
||||||
);
|
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"\"$(SRCROOT)/../platform/ios\"",
|
"\"$(SRCROOT)/../platform/ios\"",
|
||||||
|
@ -209,10 +206,7 @@
|
||||||
DSTROOT = /tmp/libPluginFlurry.dst;
|
DSTROOT = /tmp/libPluginFlurry.dst;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
|
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||||
"$(SRCROOT)/../../../protocols/include",
|
|
||||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
|
||||||
);
|
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"\"$(SRCROOT)/../platform/ios\"",
|
"\"$(SRCROOT)/../platform/ios\"",
|
||||||
|
|
|
@ -0,0 +1,385 @@
|
||||||
|
//
|
||||||
|
// FHSTwitterEngine.h
|
||||||
|
// FHSTwitterEngine
|
||||||
|
//
|
||||||
|
// Created by Nathaniel Symer on 8/22/12.
|
||||||
|
// Copyright (C) 2012 Nathaniel Symer.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// //// FHSTwitterEngine Version 1.6.1 ////
|
||||||
|
// Modified OAuthConsumer Version 1.2.2
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// FHSTwitterEngine
|
||||||
|
// The synchronous Twitter engine that doesn’t suck!!
|
||||||
|
//
|
||||||
|
|
||||||
|
// FHSTwitterEngine is Synchronous
|
||||||
|
// That means you will have to thread. Boo Hoo.
|
||||||
|
|
||||||
|
// Setup
|
||||||
|
// Just add the FHSTwitterEngine folder to you project.
|
||||||
|
|
||||||
|
// USAGE
|
||||||
|
// See README.markdown
|
||||||
|
|
||||||
|
//
|
||||||
|
// NOTE TO CONTRIBUTORS
|
||||||
|
// Use NSJSONSerialization with removeNull(). Life is easy that way.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
// These are for the dispatch_async() calls that you use to get around the synchronous-ness
|
||||||
|
#define GCDBackgroundThread dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
|
||||||
|
#define GCDMainThread dispatch_get_main_queue()
|
||||||
|
|
||||||
|
// oEmbed align modes
|
||||||
|
typedef enum {
|
||||||
|
FHSTwitterEngineAlignModeLeft,
|
||||||
|
FHSTwitterEngineAlignModeRight,
|
||||||
|
FHSTwitterEngineAlignModeCenter,
|
||||||
|
FHSTwitterEngineAlignModeNone
|
||||||
|
} FHSTwitterEngineAlignMode;
|
||||||
|
|
||||||
|
// Image sizes
|
||||||
|
typedef enum {
|
||||||
|
FHSTwitterEngineImageSizeMini, // 24px by 24px
|
||||||
|
FHSTwitterEngineImageSizeNormal, // 48x48
|
||||||
|
FHSTwitterEngineImageSizeBigger, // 73x73
|
||||||
|
FHSTwitterEngineImageSizeOriginal // original size of image
|
||||||
|
} FHSTwitterEngineImageSize;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FHSTwitterEngineResultTypeMixed,
|
||||||
|
FHSTwitterEngineResultTypeRecent,
|
||||||
|
FHSTwitterEngineResultTypePopular
|
||||||
|
} FHSTwitterEngineResultType;
|
||||||
|
|
||||||
|
// Remove NSNulls from NSDictionary and NSArray
|
||||||
|
// Credit for this function goes to Conrad Kramer
|
||||||
|
id removeNull(id rootObject);
|
||||||
|
|
||||||
|
extern NSString * const FHSProfileBackgroundColorKey;
|
||||||
|
extern NSString * const FHSProfileLinkColorKey;
|
||||||
|
extern NSString * const FHSProfileSidebarBorderColorKey;
|
||||||
|
extern NSString * const FHSProfileSidebarFillColorKey;
|
||||||
|
extern NSString * const FHSProfileTextColorKey;
|
||||||
|
|
||||||
|
extern NSString * const FHSProfileNameKey;
|
||||||
|
extern NSString * const FHSProfileURLKey;
|
||||||
|
extern NSString * const FHSProfileLocationKey;
|
||||||
|
extern NSString * const FHSProfileDescriptionKey;
|
||||||
|
|
||||||
|
@protocol FHSTwitterEngineAccessTokenDelegate <NSObject>
|
||||||
|
|
||||||
|
- (void)storeAccessToken:(NSString *)accessToken;
|
||||||
|
- (NSString *)loadAccessToken;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@class OAToken;
|
||||||
|
@class OAConsumer;
|
||||||
|
@class OAMutableURLRequest;
|
||||||
|
|
||||||
|
@interface FHSTwitterEngine : NSObject <UIWebViewDelegate>
|
||||||
|
|
||||||
|
//
|
||||||
|
// REST API
|
||||||
|
//
|
||||||
|
|
||||||
|
// statuses/update
|
||||||
|
- (NSError *)postTweet:(NSString *)tweetString;
|
||||||
|
- (NSError *)postTweet:(NSString *)tweetString inReplyTo:(NSString *)inReplyToString;
|
||||||
|
|
||||||
|
// statuses/home_timeline
|
||||||
|
- (id)getHomeTimelineSinceID:(NSString *)sinceID count:(int)count;
|
||||||
|
|
||||||
|
// help/test
|
||||||
|
- (id)testService;
|
||||||
|
|
||||||
|
// blocks/create
|
||||||
|
- (NSError *)block:(NSString *)username;
|
||||||
|
|
||||||
|
// blocks/destroy
|
||||||
|
- (NSError *)unblock:(NSString *)username;
|
||||||
|
|
||||||
|
// users/lookup
|
||||||
|
- (id)lookupUsers:(NSArray *)users areIDs:(BOOL)areIDs;
|
||||||
|
|
||||||
|
// users/search
|
||||||
|
- (id)searchUsersWithQuery:(NSString *)q andCount:(int)count;
|
||||||
|
|
||||||
|
// account/update_profile_image
|
||||||
|
- (NSError *)setProfileImageWithImageAtPath:(NSString *)file;
|
||||||
|
- (NSError *)setProfileImageWithImageData:(NSData *)data;
|
||||||
|
|
||||||
|
// account/settings GET and POST
|
||||||
|
// See FHSTwitterEngine.m For details
|
||||||
|
- (id)getUserSettings;
|
||||||
|
- (NSError *)updateSettingsWithDictionary:(NSDictionary *)settings;
|
||||||
|
|
||||||
|
// account/update_profile
|
||||||
|
// See FHSTwitterEngine.m for details
|
||||||
|
- (NSError *)updateUserProfileWithDictionary:(NSDictionary *)settings;
|
||||||
|
|
||||||
|
// account/update_profile_background_image
|
||||||
|
- (NSError *)setProfileBackgroundImageWithImageData:(NSData *)data tiled:(BOOL)isTiled;
|
||||||
|
- (NSError *)setProfileBackgroundImageWithImageAtPath:(NSString *)file tiled:(BOOL)isTiled;
|
||||||
|
- (NSError *)setUseProfileBackgroundImage:(BOOL)shouldUseProfileBackgroundImage;
|
||||||
|
|
||||||
|
// account/update_profile_colors
|
||||||
|
// See FHSTwitterEngine.m for details
|
||||||
|
// If the dictionary is nil, FHSTwitterEngine resets the values
|
||||||
|
- (NSError *)updateProfileColorsWithDictionary:(NSDictionary *)dictionary;
|
||||||
|
|
||||||
|
// account/rate_limit_status
|
||||||
|
- (id)getRateLimitStatus;
|
||||||
|
|
||||||
|
// favorites/create, favorites/destroy
|
||||||
|
- (NSError *)markTweet:(NSString *)tweetID asFavorite:(BOOL)flag;
|
||||||
|
|
||||||
|
// favorites/list
|
||||||
|
- (id)getFavoritesForUser:(NSString *)user isID:(BOOL)isID andCount:(int)count;
|
||||||
|
- (id)getFavoritesForUser:(NSString *)user isID:(BOOL)isID andCount:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
|
||||||
|
|
||||||
|
// account/verify_credentials
|
||||||
|
- (id)verifyCredentials;
|
||||||
|
|
||||||
|
// friendships/create
|
||||||
|
- (NSError *)followUser:(NSString *)user isID:(BOOL)isID;
|
||||||
|
|
||||||
|
// friendships/destroy
|
||||||
|
- (NSError *)unfollowUser:(NSString *)user isID:(BOOL)isID;
|
||||||
|
|
||||||
|
// friendships/lookup
|
||||||
|
- (id)lookupFriendshipStatusForUsers:(NSArray *)users areIDs:(BOOL)areIDs;
|
||||||
|
|
||||||
|
// friendships/incoming
|
||||||
|
- (id)getPendingIncomingFollowers;
|
||||||
|
|
||||||
|
// friendships/outgoing
|
||||||
|
- (id)getPendingOutgoingFollowers;
|
||||||
|
|
||||||
|
// friendships/update
|
||||||
|
- (NSError *)enableRetweets:(BOOL)enableRTs andDeviceNotifs:(BOOL)devNotifs forUser:(NSString *)user isID:(BOOL)isID;
|
||||||
|
|
||||||
|
// friendships/no_retweet_ids
|
||||||
|
- (id)getNoRetweetIDs;
|
||||||
|
|
||||||
|
// help/tos
|
||||||
|
- (id)getTermsOfService;
|
||||||
|
|
||||||
|
// help/privacy
|
||||||
|
- (id)getPrivacyPolicy;
|
||||||
|
|
||||||
|
// direct_messages
|
||||||
|
- (id)getDirectMessages:(int)count;
|
||||||
|
|
||||||
|
// direct_messages/destroy
|
||||||
|
- (NSError *)deleteDirectMessage:(NSString *)messageID;
|
||||||
|
|
||||||
|
// direct_messages/sent
|
||||||
|
- (id)getSentDirectMessages:(int)count;
|
||||||
|
|
||||||
|
// direct_messages/new
|
||||||
|
- (NSError *)sendDirectMessage:(NSString *)body toUser:(NSString *)user isID:(BOOL)isID;
|
||||||
|
|
||||||
|
// direct_messages/show
|
||||||
|
- (id)showDirectMessage:(NSString *)messageID;
|
||||||
|
|
||||||
|
// users/report_spam
|
||||||
|
- (NSError *)reportUserAsSpam:(NSString *)user isID:(BOOL)isID;
|
||||||
|
|
||||||
|
// help/configuration
|
||||||
|
- (id)getConfiguration;
|
||||||
|
|
||||||
|
// help/languages
|
||||||
|
- (id)getLanguages;
|
||||||
|
|
||||||
|
// blocks/blocking/ids
|
||||||
|
- (id)listBlockedIDs;
|
||||||
|
|
||||||
|
// blocks/blocking
|
||||||
|
- (id)listBlockedUsers;
|
||||||
|
|
||||||
|
// blocks/exists
|
||||||
|
- (id)authenticatedUserIsBlocking:(NSString *)user isID:(BOOL)isID;
|
||||||
|
|
||||||
|
// users/profile_image
|
||||||
|
- (id)getProfileImageForUsername:(NSString *)username andSize:(FHSTwitterEngineImageSize)size;
|
||||||
|
|
||||||
|
// statuses/user_timeline
|
||||||
|
- (id)getTimelineForUser:(NSString *)user isID:(BOOL)isID count:(int)count;
|
||||||
|
- (id)getTimelineForUser:(NSString *)user isID:(BOOL)isID count:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
|
||||||
|
|
||||||
|
// statuses/retweet
|
||||||
|
- (NSError *)retweet:(NSString *)identifier;
|
||||||
|
|
||||||
|
// statuses/oembed
|
||||||
|
- (id)oembedTweet:(NSString *)identifier maxWidth:(float)maxWidth alignmentMode:(FHSTwitterEngineAlignMode)alignmentMode;
|
||||||
|
|
||||||
|
// statuses/show
|
||||||
|
- (id)getDetailsForTweet:(NSString *)identifier;
|
||||||
|
|
||||||
|
// statuses/destroy
|
||||||
|
- (NSError *)destroyTweet:(NSString *)identifier;
|
||||||
|
|
||||||
|
// statuses/update_with_media
|
||||||
|
- (NSError *)postTweet:(NSString *)tweetString withImageData:(NSData *)theData;
|
||||||
|
- (NSError *)postTweet:(NSString *)tweetString withImageData:(NSData *)theData inReplyTo:(NSString *)irt;
|
||||||
|
|
||||||
|
// statuses/mentions_timeline
|
||||||
|
- (id)getMentionsTimelineWithCount:(int)count;
|
||||||
|
- (id)getMentionsTimelineWithCount:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
|
||||||
|
|
||||||
|
// statuses/retweets_of_me
|
||||||
|
- (id)getRetweetedTimelineWithCount:(int)count;
|
||||||
|
- (id)getRetweetedTimelineWithCount:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
|
||||||
|
|
||||||
|
// statuses/retweets
|
||||||
|
- (id)getRetweetsForTweet:(NSString *)identifier count:(int)count;
|
||||||
|
|
||||||
|
// lists/list
|
||||||
|
- (id)getListsForUser:(NSString *)user isID:(BOOL)isID;
|
||||||
|
|
||||||
|
// lists/statuses
|
||||||
|
- (id)getTimelineForListWithID:(NSString *)listID count:(int)count;
|
||||||
|
- (id)getTimelineForListWithID:(NSString *)listID count:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
|
||||||
|
- (id)getTimelineForListWithID:(NSString *)listID count:(int)count excludeRetweets:(BOOL)excludeRetweets excludeReplies:(BOOL)excludeReplies;
|
||||||
|
- (id)getTimelineForListWithID:(NSString *)listID count:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID excludeRetweets:(BOOL)excludeRetweets excludeReplies:(BOOL)excludeReplies;
|
||||||
|
|
||||||
|
// lists/members/create_all
|
||||||
|
- (NSError *)addUsersToListWithID:(NSString *)listID users:(NSArray *)users;
|
||||||
|
|
||||||
|
// lists/members/destroy_all
|
||||||
|
- (NSError *)removeUsersFromListWithID:(NSString *)listID users:(NSArray *)users;
|
||||||
|
|
||||||
|
// lists/members
|
||||||
|
- (id)listUsersInListWithID:(NSString *)listID;
|
||||||
|
|
||||||
|
// lists/update
|
||||||
|
- (NSError *)setModeOfListWithID:(NSString *)listID toPrivate:(BOOL)isPrivate;
|
||||||
|
- (NSError *)changeNameOfListWithID:(NSString *)listID toName:(NSString *)newName;
|
||||||
|
- (NSError *)changeDescriptionOfListWithID:(NSString *)listID toDescription:(NSString *)newName;
|
||||||
|
|
||||||
|
// lists/show
|
||||||
|
- (id)getListWithID:(NSString *)listID;
|
||||||
|
|
||||||
|
// lists/create
|
||||||
|
- (NSError *)createListWithName:(NSString *)name isPrivate:(BOOL)isPrivate description:(NSString *)description;
|
||||||
|
|
||||||
|
// tweets/search
|
||||||
|
- (id)searchTweetsWithQuery:(NSString *)q count:(int)count resultType:(FHSTwitterEngineResultType)resultType unil:(NSDate *)untilDate sinceID:(NSString *)sinceID maxID:(NSString *)maxID;
|
||||||
|
|
||||||
|
// followers/ids
|
||||||
|
- (id)getFollowersIDs;
|
||||||
|
|
||||||
|
// followers/list
|
||||||
|
- (id)listFollowersForUser:(NSString *)user isID:(BOOL)isID withCursor:(NSString *)cursor;
|
||||||
|
|
||||||
|
// friends/ids
|
||||||
|
- (id)getFriendsIDs;
|
||||||
|
|
||||||
|
// friends/list
|
||||||
|
- (id)listFriendsForUser:(NSString *)user isID:(BOOL)isID withCursor:(NSString *)cursor;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Login and Auth
|
||||||
|
//
|
||||||
|
|
||||||
|
// XAuth login
|
||||||
|
- (NSError *)getXAuthAccessTokenForUsername:(NSString *)username password:(NSString *)password;
|
||||||
|
|
||||||
|
// OAuth login
|
||||||
|
- (void)showOAuthLoginControllerFromViewController:(UIViewController *)sender;
|
||||||
|
- (void)showOAuthLoginControllerFromViewController:(UIViewController *)sender withCompletion:(void(^)(BOOL success))completionBlock;
|
||||||
|
|
||||||
|
// Access Token Mangement
|
||||||
|
- (void)clearAccessToken;
|
||||||
|
- (void)loadAccessToken;
|
||||||
|
- (BOOL)isAuthorized;
|
||||||
|
|
||||||
|
// Clear Keys
|
||||||
|
- (void)clearConsumer;
|
||||||
|
|
||||||
|
// sendRequest methods, use these for every request
|
||||||
|
- (NSError *)sendPOSTRequest:(OAMutableURLRequest *)request withParameters:(NSArray *)params;
|
||||||
|
- (id)sendGETRequest:(OAMutableURLRequest *)request withParameters:(NSArray *)params;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Misc Methods
|
||||||
|
//
|
||||||
|
|
||||||
|
// Date parser
|
||||||
|
- (NSDate *)getDateFromTwitterCreatedAt:(NSString *)twitterDate;
|
||||||
|
|
||||||
|
// id list generator - returns an array of id/username list strings
|
||||||
|
- (NSArray *)generateRequestStringsFromArray:(NSArray *)array;
|
||||||
|
|
||||||
|
// Temporaryily set keys
|
||||||
|
// if you don't want your keys in memory, simply use
|
||||||
|
// this method. You will have to use it before
|
||||||
|
// making any API calls.
|
||||||
|
- (void)temporarilySetConsumerKey:(NSString *)consumerKey andSecret:(NSString *)consumerSecret;
|
||||||
|
|
||||||
|
// Use to set the consumer key when using the singleton
|
||||||
|
- (void)permanentlySetConsumerKey:(NSString *)consumerKey andSecret:(NSString *)consumerSecret;
|
||||||
|
|
||||||
|
// Singleton, NEVER use the -init method. Ever.
|
||||||
|
+ (FHSTwitterEngine *)sharedEngine;
|
||||||
|
|
||||||
|
// Determines your internet status
|
||||||
|
+ (BOOL)isConnectedToInternet;
|
||||||
|
|
||||||
|
// Determines if entities should be included
|
||||||
|
@property (nonatomic, assign) BOOL includeEntities;
|
||||||
|
|
||||||
|
// Logged in user's username
|
||||||
|
@property (nonatomic, retain) NSString *loggedInUsername;
|
||||||
|
|
||||||
|
// Logged in user's Twitter ID
|
||||||
|
@property (nonatomic, retain) NSString *loggedInID;
|
||||||
|
|
||||||
|
// Will be called to store the accesstoken
|
||||||
|
@property (nonatomic, assign) id<FHSTwitterEngineAccessTokenDelegate> delegate;
|
||||||
|
|
||||||
|
// Access Token
|
||||||
|
@property (nonatomic, retain) OAToken *accessToken;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSData (Base64)
|
||||||
|
+ (NSData *)dataWithBase64EncodedString:(NSString *)string;
|
||||||
|
- (id)initWithBase64EncodedString:(NSString *)string;
|
||||||
|
- (NSString *)base64EncodingWithLineLength:(unsigned int)lineLength;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSString (FHSTwitterEngine)
|
||||||
|
- (NSString *)fhs_trimForTwitter;
|
||||||
|
- (NSString *)fhs_stringWithRange:(NSRange)range;
|
||||||
|
- (BOOL)fhs_isNumeric;
|
||||||
|
@end
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,34 @@
|
||||||
|
//
|
||||||
|
// NSString+URLEncoding.h
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
|
||||||
|
@interface NSString (OAURLEncodingAdditions)
|
||||||
|
|
||||||
|
- (NSString *)URLEncodedString;
|
||||||
|
- (NSString *)URLDecodedString;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// NSString+URLEncoding.m
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import "NSString+URLEncoding.h"
|
||||||
|
|
||||||
|
@implementation NSString (OAURLEncodingAdditions)
|
||||||
|
|
||||||
|
- (NSString *)URLEncodedString {
|
||||||
|
CFStringRef url = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8); // for some reason, releasing this is disasterous
|
||||||
|
NSString *result = (NSString *)url;
|
||||||
|
[result autorelease];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)URLDecodedString {
|
||||||
|
CFStringRef url = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, (CFStringRef)self, CFSTR(""), kCFStringEncodingUTF8);
|
||||||
|
NSString *result = (NSString *)url;
|
||||||
|
[result autorelease];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,225 @@
|
||||||
|
/*
|
||||||
|
* Base64Transcoder.c
|
||||||
|
* Base64Test
|
||||||
|
*
|
||||||
|
* Created by Jonathan Wight on Tue Mar 18 2003.
|
||||||
|
* Copyright (c) 2003 Toxic Software. All rights reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Base64TranscoderFHS.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
const u_int8_t kBase64EncodeTable_[64] = {
|
||||||
|
/* 0 */ 'A', /* 1 */ 'B', /* 2 */ 'C', /* 3 */ 'D',
|
||||||
|
/* 4 */ 'E', /* 5 */ 'F', /* 6 */ 'G', /* 7 */ 'H',
|
||||||
|
/* 8 */ 'I', /* 9 */ 'J', /* 10 */ 'K', /* 11 */ 'L',
|
||||||
|
/* 12 */ 'M', /* 13 */ 'N', /* 14 */ 'O', /* 15 */ 'P',
|
||||||
|
/* 16 */ 'Q', /* 17 */ 'R', /* 18 */ 'S', /* 19 */ 'T',
|
||||||
|
/* 20 */ 'U', /* 21 */ 'V', /* 22 */ 'W', /* 23 */ 'X',
|
||||||
|
/* 24 */ 'Y', /* 25 */ 'Z', /* 26 */ 'a', /* 27 */ 'b',
|
||||||
|
/* 28 */ 'c', /* 29 */ 'd', /* 30 */ 'e', /* 31 */ 'f',
|
||||||
|
/* 32 */ 'g', /* 33 */ 'h', /* 34 */ 'i', /* 35 */ 'j',
|
||||||
|
/* 36 */ 'k', /* 37 */ 'l', /* 38 */ 'm', /* 39 */ 'n',
|
||||||
|
/* 40 */ 'o', /* 41 */ 'p', /* 42 */ 'q', /* 43 */ 'r',
|
||||||
|
/* 44 */ 's', /* 45 */ 't', /* 46 */ 'u', /* 47 */ 'v',
|
||||||
|
/* 48 */ 'w', /* 49 */ 'x', /* 50 */ 'y', /* 51 */ 'z',
|
||||||
|
/* 52 */ '0', /* 53 */ '1', /* 54 */ '2', /* 55 */ '3',
|
||||||
|
/* 56 */ '4', /* 57 */ '5', /* 58 */ '6', /* 59 */ '7',
|
||||||
|
/* 60 */ '8', /* 61 */ '9', /* 62 */ '+', /* 63 */ '/'
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
-1 = Base64 end of data marker.
|
||||||
|
-2 = White space (tabs, cr, lf, space)
|
||||||
|
-3 = Noise (all non whitespace, non-base64 characters)
|
||||||
|
-4 = Dangerous noise
|
||||||
|
-5 = Illegal noise (null byte)
|
||||||
|
*/
|
||||||
|
|
||||||
|
const int8_t kBase64DecodeTable_[128] = {
|
||||||
|
/* 0x00 */ -5, /* 0x01 */ -3, /* 0x02 */ -3, /* 0x03 */ -3,
|
||||||
|
/* 0x04 */ -3, /* 0x05 */ -3, /* 0x06 */ -3, /* 0x07 */ -3,
|
||||||
|
/* 0x08 */ -3, /* 0x09 */ -2, /* 0x0a */ -2, /* 0x0b */ -2,
|
||||||
|
/* 0x0c */ -2, /* 0x0d */ -2, /* 0x0e */ -3, /* 0x0f */ -3,
|
||||||
|
/* 0x10 */ -3, /* 0x11 */ -3, /* 0x12 */ -3, /* 0x13 */ -3,
|
||||||
|
/* 0x14 */ -3, /* 0x15 */ -3, /* 0x16 */ -3, /* 0x17 */ -3,
|
||||||
|
/* 0x18 */ -3, /* 0x19 */ -3, /* 0x1a */ -3, /* 0x1b */ -3,
|
||||||
|
/* 0x1c */ -3, /* 0x1d */ -3, /* 0x1e */ -3, /* 0x1f */ -3,
|
||||||
|
/* ' ' */ -2, /* '!' */ -3, /* '"' */ -3, /* '#' */ -3,
|
||||||
|
/* '$' */ -3, /* '%' */ -3, /* '&' */ -3, /* ''' */ -3,
|
||||||
|
/* '(' */ -3, /* ')' */ -3, /* '*' */ -3, /* '+' */ 62,
|
||||||
|
/* ',' */ -3, /* '-' */ -3, /* '.' */ -3, /* '/' */ 63,
|
||||||
|
/* '0' */ 52, /* '1' */ 53, /* '2' */ 54, /* '3' */ 55,
|
||||||
|
/* '4' */ 56, /* '5' */ 57, /* '6' */ 58, /* '7' */ 59,
|
||||||
|
/* '8' */ 60, /* '9' */ 61, /* ':' */ -3, /* ';' */ -3,
|
||||||
|
/* '<' */ -3, /* '=' */ -1, /* '>' */ -3, /* '?' */ -3,
|
||||||
|
/* '@' */ -3, /* 'A' */ 0, /* 'B' */ 1, /* 'C' */ 2,
|
||||||
|
/* 'D' */ 3, /* 'E' */ 4, /* 'F' */ 5, /* 'G' */ 6,
|
||||||
|
/* 'H' */ 7, /* 'I' */ 8, /* 'J' */ 9, /* 'K' */ 10,
|
||||||
|
/* 'L' */ 11, /* 'M' */ 12, /* 'N' */ 13, /* 'O' */ 14,
|
||||||
|
/* 'P' */ 15, /* 'Q' */ 16, /* 'R' */ 17, /* 'S' */ 18,
|
||||||
|
/* 'T' */ 19, /* 'U' */ 20, /* 'V' */ 21, /* 'W' */ 22,
|
||||||
|
/* 'X' */ 23, /* 'Y' */ 24, /* 'Z' */ 25, /* '[' */ -3,
|
||||||
|
/* '\' */ -3, /* ']' */ -3, /* '^' */ -3, /* '_' */ -3,
|
||||||
|
/* '`' */ -3, /* 'a' */ 26, /* 'b' */ 27, /* 'c' */ 28,
|
||||||
|
/* 'd' */ 29, /* 'e' */ 30, /* 'f' */ 31, /* 'g' */ 32,
|
||||||
|
/* 'h' */ 33, /* 'i' */ 34, /* 'j' */ 35, /* 'k' */ 36,
|
||||||
|
/* 'l' */ 37, /* 'm' */ 38, /* 'n' */ 39, /* 'o' */ 40,
|
||||||
|
/* 'p' */ 41, /* 'q' */ 42, /* 'r' */ 43, /* 's' */ 44,
|
||||||
|
/* 't' */ 45, /* 'u' */ 46, /* 'v' */ 47, /* 'w' */ 48,
|
||||||
|
/* 'x' */ 49, /* 'y' */ 50, /* 'z' */ 51, /* '{' */ -3,
|
||||||
|
/* '|' */ -3, /* '}' */ -3, /* '~' */ -3, /* 0x7f */ -3
|
||||||
|
};
|
||||||
|
|
||||||
|
const u_int8_t kBits_00000011_ = 0x03;
|
||||||
|
const u_int8_t kBits_00001111_ = 0x0F;
|
||||||
|
const u_int8_t kBits_00110000_ = 0x30;
|
||||||
|
const u_int8_t kBits_00111100_ = 0x3C;
|
||||||
|
const u_int8_t kBits_00111111_ = 0x3F;
|
||||||
|
const u_int8_t kBits_11000000_ = 0xC0;
|
||||||
|
const u_int8_t kBits_11110000_ = 0xF0;
|
||||||
|
const u_int8_t kBits_11111100_ = 0xFC;
|
||||||
|
|
||||||
|
size_t EstimateBas64EncodedDataSizeFHS(size_t inDataSize) {
|
||||||
|
size_t theEncodedDataSize = (int)ceil(inDataSize / 3.0) * 4;
|
||||||
|
theEncodedDataSize = theEncodedDataSize / 72 * 74 + theEncodedDataSize % 72;
|
||||||
|
return(theEncodedDataSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t EstimateBas64DecodedDataSizeFHS(size_t inDataSize) {
|
||||||
|
size_t theDecodedDataSize = (int)ceil(inDataSize / 4.0) * 3;
|
||||||
|
//theDecodedDataSize = theDecodedDataSize / 72 * 74 + theDecodedDataSize % 72;
|
||||||
|
return(theDecodedDataSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Base64EncodeDataFHS(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize) {
|
||||||
|
|
||||||
|
size_t theEncodedDataSize = EstimateBas64EncodedDataSizeFHS(inInputDataSize);
|
||||||
|
if (*ioOutputDataSize < theEncodedDataSize) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ioOutputDataSize = theEncodedDataSize;
|
||||||
|
const u_int8_t *theInPtr = (const u_int8_t *)inInputData;
|
||||||
|
u_int32_t theInIndex = 0, theOutIndex = 0;
|
||||||
|
for (; theInIndex < (inInputDataSize / 3) * 3; theInIndex += 3) {
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_11111100_) >> 2];
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_00000011_) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000_) >> 4];
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex + 1] & kBits_00001111_) << 2 | (theInPtr[theInIndex + 2] & kBits_11000000_) >> 6];
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex + 2] & kBits_00111111_) >> 0];
|
||||||
|
|
||||||
|
if (theOutIndex % 74 == 72) {
|
||||||
|
outOutputData[theOutIndex++] = '\r';
|
||||||
|
outOutputData[theOutIndex++] = '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t theRemainingBytes = inInputDataSize - theInIndex;
|
||||||
|
|
||||||
|
if (theRemainingBytes == 1) {
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_11111100_) >> 2];
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_00000011_) << 4 | (0 & kBits_11110000_) >> 4];
|
||||||
|
outOutputData[theOutIndex++] = '=';
|
||||||
|
outOutputData[theOutIndex++] = '=';
|
||||||
|
|
||||||
|
if (theOutIndex % 74 == 72) {
|
||||||
|
outOutputData[theOutIndex++] = '\r';
|
||||||
|
outOutputData[theOutIndex++] = '\n';
|
||||||
|
}
|
||||||
|
} else if (theRemainingBytes == 2) {
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_11111100_) >> 2];
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex] & kBits_00000011_) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000_) >> 4];
|
||||||
|
outOutputData[theOutIndex++] = kBase64EncodeTable_[(theInPtr[theInIndex + 1] & kBits_00001111_) << 2 | (0 & kBits_11000000_) >> 6];
|
||||||
|
outOutputData[theOutIndex++] = '=';
|
||||||
|
|
||||||
|
if (theOutIndex % 74 == 72) {
|
||||||
|
outOutputData[theOutIndex++] = '\r';
|
||||||
|
outOutputData[theOutIndex++] = '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Base64DecodeData_(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize) {
|
||||||
|
|
||||||
|
memset(ioOutputData, '.', *ioOutputDataSize);
|
||||||
|
|
||||||
|
size_t theDecodedDataSize = EstimateBas64DecodedDataSizeFHS(inInputDataSize);
|
||||||
|
if (*ioOutputDataSize < theDecodedDataSize) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ioOutputDataSize = 0;
|
||||||
|
const u_int8_t *theInPtr = (const u_int8_t *)inInputData;
|
||||||
|
u_int8_t *theOutPtr = (u_int8_t *)ioOutputData;
|
||||||
|
size_t theInIndex = 0, theOutIndex = 0;
|
||||||
|
u_int8_t theOutputOctet;
|
||||||
|
size_t theSequence = 0;
|
||||||
|
for (; theInIndex < inInputDataSize; ) {
|
||||||
|
int8_t theSextet = 0;
|
||||||
|
|
||||||
|
int8_t theCurrentInputOctet = theInPtr[theInIndex];
|
||||||
|
theSextet = kBase64DecodeTable_[theCurrentInputOctet];
|
||||||
|
|
||||||
|
if (theSextet == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (theSextet == -2) {
|
||||||
|
theCurrentInputOctet = theInPtr[++theInIndex];
|
||||||
|
theSextet = kBase64DecodeTable_[theCurrentInputOctet];
|
||||||
|
}
|
||||||
|
|
||||||
|
while (theSextet == -3) {
|
||||||
|
theCurrentInputOctet = theInPtr[++theInIndex];
|
||||||
|
theSextet = kBase64DecodeTable_[theCurrentInputOctet];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theSequence == 0) {
|
||||||
|
theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 2 & kBits_11111100_;
|
||||||
|
} else if (theSequence == 1) {
|
||||||
|
theOutputOctet |= (theSextet >- 0 ? theSextet : 0) >> 4 & kBits_00000011_;
|
||||||
|
theOutPtr[theOutIndex++] = theOutputOctet;
|
||||||
|
} else if (theSequence == 2) {
|
||||||
|
theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 4 & kBits_11110000_;
|
||||||
|
} else if (theSequence == 3) {
|
||||||
|
theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 2 & kBits_00001111_;
|
||||||
|
theOutPtr[theOutIndex++] = theOutputOctet;
|
||||||
|
} else if (theSequence == 4) {
|
||||||
|
theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 6 & kBits_11000000_;
|
||||||
|
} else if (theSequence == 5) {
|
||||||
|
theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 0 & kBits_00111111_;
|
||||||
|
theOutPtr[theOutIndex++] = theOutputOctet;
|
||||||
|
}
|
||||||
|
|
||||||
|
theSequence = (theSequence+1)%6;
|
||||||
|
|
||||||
|
if (theSequence != 2 && theSequence != 4) {
|
||||||
|
theInIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*ioOutputDataSize = theOutIndex;
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Base64Transcoder.h
|
||||||
|
* Base64Test
|
||||||
|
*
|
||||||
|
* Created by Jonathan Wight on Tue Mar 18 2003.
|
||||||
|
* Copyright (c) 2003 Toxic Software. All rights reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
extern size_t EstimateBas64EncodedDataSizeFHS(size_t inDataSize);
|
||||||
|
extern size_t EstimateBas64DecodedDataSizeFHS(size_t inDataSize);
|
||||||
|
|
||||||
|
extern bool Base64EncodeDataFHS(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize);
|
||||||
|
extern bool Base64DecodeDataFHS(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize);
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// OAConsumer.h
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface OAConsumer : NSObject
|
||||||
|
|
||||||
|
@property (nonatomic, retain) NSString *key;
|
||||||
|
@property (nonatomic, retain) NSString *secret;
|
||||||
|
|
||||||
|
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
|
||||||
|
|
||||||
|
+ (OAConsumer *)consumerWithKey:(NSString *)aKey secret:(NSString *)aSecret;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,48 @@
|
||||||
|
//
|
||||||
|
// OAConsumer.m
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import "OAConsumer.h"
|
||||||
|
|
||||||
|
@implementation OAConsumer
|
||||||
|
|
||||||
|
+ (OAConsumer *)consumerWithKey:(NSString *)aKey secret:(NSString *)aSecret {
|
||||||
|
return [[[[self class]alloc]initWithKey:aKey secret:aSecret]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret {
|
||||||
|
if (self = [super init]) {
|
||||||
|
self.key = aKey;
|
||||||
|
self.secret = aSecret;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[self setKey:nil];
|
||||||
|
[self setSecret:nil];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// OAHMAC_SHA1SignatureProvider.h
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@protocol OASignatureProviding <NSObject>
|
||||||
|
- (NSString *)name;
|
||||||
|
- (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface OAHMAC_SHA1SignatureProvider : NSObject <OASignatureProviding>
|
||||||
|
|
||||||
|
+ (OAHMAC_SHA1SignatureProvider *)OAHMAC_SHA1SignatureProvider;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,60 @@
|
||||||
|
//
|
||||||
|
// OAHMAC_SHA1SignatureProvider.m
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import "OAHMAC_SHA1SignatureProvider.h"
|
||||||
|
#import <CommonCrypto/CommonHMAC.h>
|
||||||
|
#include "Base64TranscoderFHS.h"
|
||||||
|
|
||||||
|
@implementation OAHMAC_SHA1SignatureProvider
|
||||||
|
|
||||||
|
+ (OAHMAC_SHA1SignatureProvider *)OAHMAC_SHA1SignatureProvider {
|
||||||
|
return [[[[self class]alloc]init]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)name {
|
||||||
|
return @"HMAC-SHA1";
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret {
|
||||||
|
|
||||||
|
NSData *secretData = [secret dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
NSData *clearTextData = [text dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
unsigned char result[20];
|
||||||
|
CCHmac(kCCHmacAlgSHA1, [secretData bytes], [secretData length], [clearTextData bytes], [clearTextData length], result);
|
||||||
|
|
||||||
|
// Base64 Encoding
|
||||||
|
|
||||||
|
char base64Result[32];
|
||||||
|
size_t theResultLength = 32;
|
||||||
|
Base64EncodeDataFHS(result, 20, base64Result, &theResultLength);
|
||||||
|
NSData *theData = [NSData dataWithBytes:base64Result length:theResultLength];
|
||||||
|
|
||||||
|
NSString *base64EncodedResult = [[NSString alloc]initWithData:theData encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
|
return [base64EncodedResult autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,55 @@
|
||||||
|
//
|
||||||
|
// OAMutableURLRequest.h
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "OAConsumer.h"
|
||||||
|
#import "OAToken.h"
|
||||||
|
#import "OAHMAC_SHA1SignatureProvider.h"
|
||||||
|
|
||||||
|
@class OAServiceTicket;
|
||||||
|
|
||||||
|
@interface OAMutableURLRequest : NSMutableURLRequest
|
||||||
|
|
||||||
|
@property (nonatomic, assign) NSString *signature;
|
||||||
|
@property (nonatomic, assign) NSString *nonce;
|
||||||
|
@property (nonatomic, assign) NSString *timestamp;
|
||||||
|
|
||||||
|
+ (void)fetchDataForRequest:(OAMutableURLRequest *)request withCompletionHandler:(void(^)(OAServiceTicket *, NSData *, NSError *))block;
|
||||||
|
|
||||||
|
+ (OAMutableURLRequest *)requestWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider;
|
||||||
|
|
||||||
|
+ (OAMutableURLRequest *)requestWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken;
|
||||||
|
|
||||||
|
- (id)initWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider;
|
||||||
|
|
||||||
|
- (id)initWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider nonce:(NSString *)aNonce timestamp:(NSString *)aTimestamp;
|
||||||
|
|
||||||
|
- (void)prepare;
|
||||||
|
- (void)setOAuthParameterName:(NSString*)parameterName withValue:(NSString*)parameterValue;
|
||||||
|
- (NSArray *)parameters;
|
||||||
|
- (void)setParameters:(NSArray *)parameters;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,296 @@
|
||||||
|
//
|
||||||
|
// OAMutableURLRequest.m
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import "OAMutableURLRequest.h"
|
||||||
|
#import "OARequestParameter.h"
|
||||||
|
#import "OAServiceTicket.h"
|
||||||
|
|
||||||
|
@interface OAMutableURLRequest ()
|
||||||
|
- (void)_generateTimestamp;
|
||||||
|
- (void)_generateNonce;
|
||||||
|
- (NSString *)_signatureBaseString;
|
||||||
|
|
||||||
|
@property (nonatomic, retain) OAConsumer *consumer;
|
||||||
|
@property (nonatomic, retain) OAToken *token;
|
||||||
|
@property (nonatomic, retain) NSString *realm;
|
||||||
|
@property (nonatomic, retain) id <OASignatureProviding> signatureProvider;
|
||||||
|
@property (nonatomic, retain) NSMutableDictionary *extraOAuthParameters;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSURL (OABaseAdditions)
|
||||||
|
- (NSString *)URLStringWithoutQuery;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSURL (OABaseAdditions)
|
||||||
|
|
||||||
|
- (NSString *)URLStringWithoutQuery {
|
||||||
|
if (self.absoluteString.length == 0) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSArray *parts = [self.absoluteString componentsSeparatedByString:@"?"];
|
||||||
|
return (parts.count == 0)?nil:[parts objectAtIndex:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation OAMutableURLRequest
|
||||||
|
|
||||||
|
+ (void)fetchDataForRequest:(OAMutableURLRequest *)request withCompletionHandler:(void(^)(OAServiceTicket *, NSData *, NSError *))block {
|
||||||
|
[request prepare];
|
||||||
|
|
||||||
|
[NSURLConnection sendAsynchronousRequest:request queue:[[[NSOperationQueue alloc]init]autorelease] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
|
||||||
|
OAServiceTicket *ticket = [[[OAServiceTicket alloc]initWithRequest:request response:response didSucceed:(error == nil)]autorelease];
|
||||||
|
block(ticket, data, error);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (OAMutableURLRequest *)requestWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken {
|
||||||
|
return [[[[self class]alloc]initWithURL:aUrl consumer:aConsumer token:aToken realm:nil signatureProvider:nil]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (OAMutableURLRequest *)requestWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider {
|
||||||
|
return [[[[self class]alloc]initWithURL:aUrl consumer:aConsumer token:aToken realm:aRealm signatureProvider:aProvider]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider {
|
||||||
|
|
||||||
|
self = [super initWithURL:aUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:25];
|
||||||
|
|
||||||
|
if (self) {
|
||||||
|
[self setConsumer:aConsumer];
|
||||||
|
|
||||||
|
// empty token for Unauthorized Request Token transaction
|
||||||
|
if (aToken == nil) {
|
||||||
|
[self setToken:[OAToken token]];
|
||||||
|
} else {
|
||||||
|
[self setToken:aToken];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aRealm == nil) {
|
||||||
|
[self setRealm:@""];
|
||||||
|
} else {
|
||||||
|
[self setRealm:aRealm];
|
||||||
|
}
|
||||||
|
|
||||||
|
// default to HMAC-SHA1
|
||||||
|
if (aProvider == nil) {
|
||||||
|
[self setSignatureProvider:[OAHMAC_SHA1SignatureProvider OAHMAC_SHA1SignatureProvider]];
|
||||||
|
} else {
|
||||||
|
[self setSignatureProvider:aProvider];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self _generateTimestamp];
|
||||||
|
[self _generateNonce];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setting a timestamp and nonce to known values. Can be helpful for testing
|
||||||
|
- (id)initWithURL:(NSURL *)aUrl consumer:(OAConsumer *)aConsumer token:(OAToken *)aToken realm:(NSString *)aRealm signatureProvider:(id<OASignatureProviding, NSObject>)aProvider nonce:(NSString *)aNonce timestamp:(NSString *)aTimestamp {
|
||||||
|
|
||||||
|
self = [super initWithURL:aUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0];
|
||||||
|
|
||||||
|
if (self) {
|
||||||
|
[self setConsumer:aConsumer];
|
||||||
|
|
||||||
|
// empty token for Unauthorized Request Token transaction
|
||||||
|
if (aToken == nil) {
|
||||||
|
[self setToken:[OAToken token]];
|
||||||
|
} else {
|
||||||
|
[self setToken:aToken];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aRealm == nil) {
|
||||||
|
[self setRealm:@""];
|
||||||
|
} else {
|
||||||
|
[self setRealm:aRealm];
|
||||||
|
}
|
||||||
|
|
||||||
|
// default to HMAC-SHA1
|
||||||
|
if (aProvider == nil) {
|
||||||
|
[self setSignatureProvider:[OAHMAC_SHA1SignatureProvider OAHMAC_SHA1SignatureProvider]];
|
||||||
|
} else {
|
||||||
|
[self setSignatureProvider:aProvider];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self setTimestamp:aTimestamp];
|
||||||
|
[self setNonce:aNonce];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setOAuthParameterName:(NSString*)parameterName withValue:(NSString*)parameterValue {
|
||||||
|
|
||||||
|
if (!parameterName && !parameterValue) {
|
||||||
|
NSLog(@"%s There was not parameter name nor value specified.", __PRETTY_FUNCTION__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.extraOAuthParameters == nil) {
|
||||||
|
[self setExtraOAuthParameters:[NSMutableDictionary dictionary]];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self.extraOAuthParameters setObject:parameterValue forKey:parameterName];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)prepare {
|
||||||
|
// sign
|
||||||
|
// Secrets must be urlencoded before concatenated with '&'
|
||||||
|
// TODO: if later RSA-SHA1 support is added then a little code redesign is needed
|
||||||
|
self.signature = [self.signatureProvider signClearText:[self _signatureBaseString] withSecret:[NSString stringWithFormat:@"%@&%@", [self.consumer.secret URLEncodedString], [self.token.secret URLEncodedString]]];
|
||||||
|
|
||||||
|
// set OAuth headers
|
||||||
|
NSString *oauthToken;
|
||||||
|
|
||||||
|
if ([self.token.key isEqualToString:@""]) {
|
||||||
|
oauthToken = @"oauth_callback=\"oob\", ";
|
||||||
|
} else if (self.token.verifier.length == 0) {
|
||||||
|
oauthToken = [NSString stringWithFormat:@"oauth_token=\"%@\", ", [self.token.key URLEncodedString]];
|
||||||
|
} else {
|
||||||
|
oauthToken = [NSString stringWithFormat:@"oauth_token=\"%@\", oauth_verifier=\"%@\", ", [self.token.key URLEncodedString], [self.token.verifier URLEncodedString]];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableString *extraParameters = [NSMutableString string];
|
||||||
|
|
||||||
|
// Adding the optional parameters in sorted order isn't required by the OAuth spec, but it makes it possible to hard-code expected values in the unit tests.
|
||||||
|
for (NSString *parameterName in [[self.extraOAuthParameters allKeys]sortedArrayUsingSelector:@selector(compare:)]) {
|
||||||
|
[extraParameters appendFormat:@", %@=\"%@\"",[parameterName URLEncodedString],[[self.extraOAuthParameters objectForKey:parameterName]URLEncodedString]];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *oauthHeader = [NSString stringWithFormat:@"OAuth realm=\"%@\", oauth_consumer_key=\"%@\", %@oauth_signature_method=\"%@\", oauth_signature=\"%@\", oauth_timestamp=\"%@\", oauth_nonce=\"%@\", oauth_version=\"1.0\"%@", [self.realm URLEncodedString], [self.consumer.key URLEncodedString], oauthToken, [[self.signatureProvider name] URLEncodedString], [self.signature URLEncodedString], self.timestamp, self.nonce, extraParameters];
|
||||||
|
|
||||||
|
[self setValue:oauthHeader forHTTPHeaderField:@"Authorization"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *)parameters {
|
||||||
|
|
||||||
|
NSString *encodedParameters = nil;
|
||||||
|
|
||||||
|
if ([self.HTTPMethod isEqualToString:@"GET"] || [self.HTTPMethod isEqualToString:@"DELETE"]) {
|
||||||
|
encodedParameters = self.URL.query;
|
||||||
|
} else if ([self.HTTPMethod isEqualToString:@"POST"] || [self.HTTPMethod isEqualToString:@"PUT"]) {
|
||||||
|
encodedParameters = [[[NSString alloc]initWithData:self.HTTPBody encoding:NSASCIIStringEncoding]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodedParameters.length == 0) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSArray *encodedParameterPairs = [encodedParameters componentsSeparatedByString:@"&"];
|
||||||
|
NSMutableArray *requestParameters = [NSMutableArray arrayWithCapacity:16];
|
||||||
|
|
||||||
|
for (NSString *encodedPair in encodedParameterPairs) {
|
||||||
|
NSArray *encodedPairElements = [encodedPair componentsSeparatedByString:@"="];
|
||||||
|
OARequestParameter *parameter = [OARequestParameter requestParameterWithName:[[encodedPairElements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] value:[[encodedPairElements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||||
|
[requestParameters addObject:parameter];
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setParameters:(NSArray *)parameters {
|
||||||
|
NSMutableString *encodedParameterPairs = [NSMutableString stringWithCapacity:256];
|
||||||
|
|
||||||
|
int position = 1;
|
||||||
|
for (OARequestParameter *requestParameter in parameters) {
|
||||||
|
[encodedParameterPairs appendString:[requestParameter URLEncodedNameValuePair]];
|
||||||
|
if (position < parameters.count) {
|
||||||
|
[encodedParameterPairs appendString:@"&"];
|
||||||
|
}
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([self.HTTPMethod isEqualToString:@"GET"] || [self.HTTPMethod isEqualToString:@"DELETE"]) {
|
||||||
|
[self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@", [self.URL URLStringWithoutQuery], encodedParameterPairs]]];
|
||||||
|
} else if ([self.HTTPMethod isEqualToString:@"POST"] || [self.HTTPMethod isEqualToString:@"PUT"]) {
|
||||||
|
NSData *postData = [encodedParameterPairs dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
|
||||||
|
[self setHTTPBody:postData];
|
||||||
|
[self setValue:[NSString stringWithFormat:@"%d",postData.length] forHTTPHeaderField:@"Content-Length"];
|
||||||
|
[self setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_generateTimestamp {
|
||||||
|
[self setTimestamp:[NSString stringWithFormat:@"%ld", time(nil)]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)_generateNonce {
|
||||||
|
CFUUIDRef theUUID = CFUUIDCreate(nil);
|
||||||
|
CFStringRef string = CFUUIDCreateString(nil, theUUID);
|
||||||
|
CFRelease(theUUID);
|
||||||
|
[self setNonce:[NSString stringWithString:(NSString *)string]];
|
||||||
|
CFRelease(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)_signatureBaseString {
|
||||||
|
// OAuth Spec, Section 9.1.1 "Normalize Request Parameters"
|
||||||
|
// build a sorted array of both request parameters and OAuth header parameters
|
||||||
|
NSArray *parameters = [self parameters];
|
||||||
|
|
||||||
|
NSMutableArray *parameterPairs = [NSMutableArray arrayWithCapacity:(6+parameters.count)]; // 6 being the number of OAuth params in the Signature Base String
|
||||||
|
|
||||||
|
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_consumer_key" value:self.consumer.key]URLEncodedNameValuePair]];
|
||||||
|
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_signature_method" value:[self.signatureProvider name]] URLEncodedNameValuePair]];
|
||||||
|
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_timestamp" value:self.timestamp]URLEncodedNameValuePair]];
|
||||||
|
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_nonce" value:self.nonce]URLEncodedNameValuePair]];
|
||||||
|
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_version" value:@"1.0"]URLEncodedNameValuePair]];
|
||||||
|
|
||||||
|
if (self.token.key.length > 0) {
|
||||||
|
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_token" value:self.token.key]URLEncodedNameValuePair]];
|
||||||
|
if (self.token.verifier.length > 0) {
|
||||||
|
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_verifier" value:self.token.verifier]URLEncodedNameValuePair]];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
[parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_callback" value:@"oob"]URLEncodedNameValuePair]];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (OARequestParameter *param in parameters) {
|
||||||
|
[parameterPairs addObject:[param URLEncodedNameValuePair]];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSArray *sortedPairs = [parameterPairs sortedArrayUsingSelector:@selector(compare:)];
|
||||||
|
NSString *normalizedRequestParameters = [sortedPairs componentsJoinedByString:@"&"];
|
||||||
|
|
||||||
|
// OAuth Spec, Section 9.1.2 "Concatenate Request Elements"
|
||||||
|
NSString *ret = [NSString stringWithFormat:@"%@&%@&%@", self.HTTPMethod, [[self.URL URLStringWithoutQuery]URLEncodedString], [normalizedRequestParameters URLEncodedString]];
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[self setExtraOAuthParameters:nil];
|
||||||
|
[self setConsumer:nil];
|
||||||
|
[self setToken:nil];
|
||||||
|
[self setRealm:nil];
|
||||||
|
[self setSignatureProvider:nil];
|
||||||
|
[self setTimestamp:nil];
|
||||||
|
[self setNonce:nil];
|
||||||
|
[self setSignature:nil];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// OARequestParameter.h
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "NSString+URLEncoding.h"
|
||||||
|
|
||||||
|
@interface OARequestParameter : NSObject
|
||||||
|
|
||||||
|
@property (nonatomic, retain) NSString *name;
|
||||||
|
@property (nonatomic, retain) NSString *value;
|
||||||
|
|
||||||
|
+ (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue;
|
||||||
|
- (id)initWithName:(NSString *)aName value:(NSString *)aValue;
|
||||||
|
- (NSString *)URLEncodedName;
|
||||||
|
- (NSString *)URLEncodedValue;
|
||||||
|
- (NSString *)URLEncodedNameValuePair;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,62 @@
|
||||||
|
//
|
||||||
|
// OARequestParameter.m
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import "OARequestParameter.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation OARequestParameter
|
||||||
|
|
||||||
|
+ (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue {
|
||||||
|
return [[[[self class]alloc]initWithName:aName value:aValue]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithName:(NSString *)aName value:(NSString *)aValue {
|
||||||
|
if (self = [super init]) {
|
||||||
|
self.name = aName;
|
||||||
|
self.value = aValue;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)URLEncodedName {
|
||||||
|
return [self.name URLEncodedString];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)URLEncodedValue {
|
||||||
|
return [self.value URLEncodedString];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)URLEncodedNameValuePair {
|
||||||
|
return [NSString stringWithFormat:@"%@=%@", [self URLEncodedName], [self URLEncodedValue]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[self setName:nil];
|
||||||
|
[self setValue:nil];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// OAServiceTicket.h
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 11/5/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "OAMutableURLRequest.h"
|
||||||
|
|
||||||
|
|
||||||
|
@interface OAServiceTicket : NSObject
|
||||||
|
|
||||||
|
@property (nonatomic, retain) OAMutableURLRequest *request;
|
||||||
|
@property (nonatomic, retain) NSURLResponse *response;
|
||||||
|
@property (nonatomic, assign) BOOL didSucceed;
|
||||||
|
|
||||||
|
- (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// OAServiceTicket.m
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 11/5/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import "OAServiceTicket.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation OAServiceTicket
|
||||||
|
|
||||||
|
- (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success {
|
||||||
|
if (self = [super init]) {
|
||||||
|
self.request = aRequest;
|
||||||
|
self.response = aResponse;
|
||||||
|
self.didSucceed = success;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[self setRequest:nil];
|
||||||
|
[self setResponse:nil];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,48 @@
|
||||||
|
//
|
||||||
|
// OAToken.h
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface OAToken : NSObject
|
||||||
|
|
||||||
|
@property (nonatomic, retain) NSString *verifier;
|
||||||
|
@property (nonatomic, retain) NSString *key;
|
||||||
|
@property (nonatomic, retain) NSString *secret;
|
||||||
|
|
||||||
|
- (NSString *)pin;
|
||||||
|
- (void)setPin:(NSString *)aPin;
|
||||||
|
|
||||||
|
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
|
||||||
|
- (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
|
||||||
|
- (id)initWithHTTPResponseBody:(NSString *)body;
|
||||||
|
|
||||||
|
+ (OAToken *)token;
|
||||||
|
+ (OAToken *)tokenWithKey:(NSString *)aKey secret:(NSString *)aSecret;
|
||||||
|
+ (OAToken *)tokenWithHTTPResponseBody:(NSString *)body;
|
||||||
|
+ (OAToken *)tokenWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
|
||||||
|
|
||||||
|
- (void)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,129 @@
|
||||||
|
//
|
||||||
|
// OAToken.m
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#import "OAToken.h"
|
||||||
|
|
||||||
|
@implementation OAToken
|
||||||
|
|
||||||
|
+ (OAToken *)token {
|
||||||
|
return [[[[self class]alloc]init]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (OAToken *)tokenWithKey:(NSString *)aKey secret:(NSString *)aSecret {
|
||||||
|
return [[[[self class]alloc]initWithKey:aKey secret:aSecret]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (OAToken *)tokenWithHTTPResponseBody:(NSString *)body {
|
||||||
|
return [[[[self class]alloc]initWithHTTPResponseBody:body]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (OAToken *)tokenWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix {
|
||||||
|
return [[[[self class]alloc]initWithUserDefaultsUsingServiceProviderName:provider prefix:prefix]autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)pin {
|
||||||
|
return self.verifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setPin:(NSString *)aPin {
|
||||||
|
[self setVerifier:aPin];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)init {
|
||||||
|
if (self = [super init]) {
|
||||||
|
self.key = @"";
|
||||||
|
self.secret = @"";
|
||||||
|
self.verifier = @"";
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret {
|
||||||
|
if (self = [super init]) {
|
||||||
|
self.key = aKey;
|
||||||
|
self.secret = aSecret;
|
||||||
|
self.verifier = @"";
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithHTTPResponseBody:(NSString *)body {
|
||||||
|
if (self = [super init]) {
|
||||||
|
|
||||||
|
if (body == nil) {
|
||||||
|
body = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
NSArray *pairs = [body componentsSeparatedByString:@"&"];
|
||||||
|
|
||||||
|
for (NSString *pair in pairs) {
|
||||||
|
NSArray *elements = [pair componentsSeparatedByString:@"="];
|
||||||
|
if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token"]) {
|
||||||
|
self.key = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
} else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token_secret"]) {
|
||||||
|
self.secret = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.verifier = @"";
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix {
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
NSString *theKey = [[NSUserDefaults standardUserDefaults]stringForKey:[NSString stringWithFormat:@"OAUTH_%@_%@_KEY", prefix, provider]];
|
||||||
|
NSString *theSecret = [[NSUserDefaults standardUserDefaults]stringForKey:[NSString stringWithFormat:@"OAUTH_%@_%@_SECRET", prefix, provider]];
|
||||||
|
|
||||||
|
BOOL nokey = (theKey.length == 0);
|
||||||
|
BOOL nosecret = (theSecret.length == 0);
|
||||||
|
|
||||||
|
if ((nokey && nosecret) || (nokey || nosecret)) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.key = theKey;
|
||||||
|
self.secret = theSecret;
|
||||||
|
self.verifier = @"";
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[self setVerifier:nil];
|
||||||
|
[self setKey:nil];
|
||||||
|
[self setSecret:nil];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix {
|
||||||
|
[[NSUserDefaults standardUserDefaults]setObject:self.key forKey:[NSString stringWithFormat:@"OAUTH_%@_%@_KEY", prefix, provider]];
|
||||||
|
[[NSUserDefaults standardUserDefaults]setObject:self.secret forKey:[NSString stringWithFormat:@"OAUTH_%@_%@_SECRET", prefix, provider]];
|
||||||
|
[[NSUserDefaults standardUserDefaults]synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,37 @@
|
||||||
|
//
|
||||||
|
// OAuthConsumer.h
|
||||||
|
// OAuthConsumer
|
||||||
|
//
|
||||||
|
// Created by Jon Crosby on 10/19/07.
|
||||||
|
// Copyright 2007 Kaboomerang LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// FHSTwitterEngine OAuthConsumer Version 1.2.2
|
||||||
|
// As modified by Nate Symer (@natesymer)
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "OAToken.h"
|
||||||
|
#import "OAConsumer.h"
|
||||||
|
#import "OAMutableURLRequest.h"
|
||||||
|
#import "OARequestParameter.h"
|
||||||
|
#import "OAServiceTicket.h"
|
|
@ -0,0 +1,8 @@
|
||||||
|
//
|
||||||
|
// Prefix header for all source files of the 'PluginTwitter' target in the 'PluginTwitter' project
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
|
@ -0,0 +1,319 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 46;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
FACAD88C1762C1B500D75ADE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD88B1762C1B500D75ADE /* Foundation.framework */; };
|
||||||
|
FACAD89F1762C22300D75ADE /* SocialTwitter.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD89E1762C22300D75ADE /* SocialTwitter.m */; };
|
||||||
|
FACAD8BA1762C61A00D75ADE /* FHSTwitterEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8A51762C61A00D75ADE /* FHSTwitterEngine.m */; };
|
||||||
|
FACAD8BB1762C61A00D75ADE /* NSString+URLEncoding.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8A91762C61A00D75ADE /* NSString+URLEncoding.m */; };
|
||||||
|
FACAD8BC1762C61A00D75ADE /* Base64TranscoderFHS.c in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8AB1762C61A00D75ADE /* Base64TranscoderFHS.c */; };
|
||||||
|
FACAD8BD1762C61A00D75ADE /* OAConsumer.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8AE1762C61A00D75ADE /* OAConsumer.m */; };
|
||||||
|
FACAD8BE1762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B01762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m */; };
|
||||||
|
FACAD8BF1762C61A00D75ADE /* OAMutableURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B21762C61A00D75ADE /* OAMutableURLRequest.m */; };
|
||||||
|
FACAD8C01762C61A00D75ADE /* OARequestParameter.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B41762C61A00D75ADE /* OARequestParameter.m */; };
|
||||||
|
FACAD8C11762C61A00D75ADE /* OAServiceTicket.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B61762C61A00D75ADE /* OAServiceTicket.m */; };
|
||||||
|
FACAD8C21762C61A00D75ADE /* OAToken.m in Sources */ = {isa = PBXBuildFile; fileRef = FACAD8B81762C61A00D75ADE /* OAToken.m */; };
|
||||||
|
FACAD8C41762C64100D75ADE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD8C31762C64100D75ADE /* UIKit.framework */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
FACAD8861762C1B500D75ADE /* CopyFiles */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "include/${PRODUCT_NAME}";
|
||||||
|
dstSubfolderSpec = 16;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
FACAD8881762C1B500D75ADE /* libPluginTwitter.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginTwitter.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
FACAD88B1762C1B500D75ADE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||||
|
FACAD89D1762C22300D75ADE /* SocialTwitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialTwitter.h; sourceTree = "<group>"; };
|
||||||
|
FACAD89E1762C22300D75ADE /* SocialTwitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocialTwitter.m; sourceTree = "<group>"; };
|
||||||
|
FACAD8A41762C61A00D75ADE /* FHSTwitterEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FHSTwitterEngine.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8A51762C61A00D75ADE /* FHSTwitterEngine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FHSTwitterEngine.m; sourceTree = "<group>"; };
|
||||||
|
FACAD8A81762C61A00D75ADE /* NSString+URLEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+URLEncoding.h"; sourceTree = "<group>"; };
|
||||||
|
FACAD8A91762C61A00D75ADE /* NSString+URLEncoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+URLEncoding.m"; sourceTree = "<group>"; };
|
||||||
|
FACAD8AB1762C61A00D75ADE /* Base64TranscoderFHS.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Base64TranscoderFHS.c; sourceTree = "<group>"; };
|
||||||
|
FACAD8AC1762C61A00D75ADE /* Base64TranscoderFHS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base64TranscoderFHS.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8AD1762C61A00D75ADE /* OAConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAConsumer.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8AE1762C61A00D75ADE /* OAConsumer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAConsumer.m; sourceTree = "<group>"; };
|
||||||
|
FACAD8AF1762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAHMAC_SHA1SignatureProvider.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8B01762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAHMAC_SHA1SignatureProvider.m; sourceTree = "<group>"; };
|
||||||
|
FACAD8B11762C61A00D75ADE /* OAMutableURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAMutableURLRequest.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8B21762C61A00D75ADE /* OAMutableURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAMutableURLRequest.m; sourceTree = "<group>"; };
|
||||||
|
FACAD8B31762C61A00D75ADE /* OARequestParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OARequestParameter.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8B41762C61A00D75ADE /* OARequestParameter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OARequestParameter.m; sourceTree = "<group>"; };
|
||||||
|
FACAD8B51762C61A00D75ADE /* OAServiceTicket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAServiceTicket.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8B61762C61A00D75ADE /* OAServiceTicket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAServiceTicket.m; sourceTree = "<group>"; };
|
||||||
|
FACAD8B71762C61A00D75ADE /* OAToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAToken.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8B81762C61A00D75ADE /* OAToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAToken.m; sourceTree = "<group>"; };
|
||||||
|
FACAD8B91762C61A00D75ADE /* OAuthConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAuthConsumer.h; sourceTree = "<group>"; };
|
||||||
|
FACAD8C31762C64100D75ADE /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||||
|
FACAD8CB1762C76800D75ADE /* PluginTwitter-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PluginTwitter-Prefix.pch"; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
FACAD8851762C1B500D75ADE /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
FACAD8C41762C64100D75ADE /* UIKit.framework in Frameworks */,
|
||||||
|
FACAD88C1762C1B500D75ADE /* Foundation.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
FACAD87D1762C1B500D75ADE = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FACAD8CB1762C76800D75ADE /* PluginTwitter-Prefix.pch */,
|
||||||
|
FACAD8A31762C61A00D75ADE /* FHSTwitterEngine */,
|
||||||
|
FACAD89D1762C22300D75ADE /* SocialTwitter.h */,
|
||||||
|
FACAD89E1762C22300D75ADE /* SocialTwitter.m */,
|
||||||
|
FACAD88A1762C1B500D75ADE /* Frameworks */,
|
||||||
|
FACAD8891762C1B500D75ADE /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
FACAD8891762C1B500D75ADE /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FACAD8881762C1B500D75ADE /* libPluginTwitter.a */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
FACAD88A1762C1B500D75ADE /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FACAD8C31762C64100D75ADE /* UIKit.framework */,
|
||||||
|
FACAD88B1762C1B500D75ADE /* Foundation.framework */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
FACAD8A31762C61A00D75ADE /* FHSTwitterEngine */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FACAD8A41762C61A00D75ADE /* FHSTwitterEngine.h */,
|
||||||
|
FACAD8A51762C61A00D75ADE /* FHSTwitterEngine.m */,
|
||||||
|
FACAD8A61762C61A00D75ADE /* OAuthConsumer */,
|
||||||
|
);
|
||||||
|
path = FHSTwitterEngine;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
FACAD8A61762C61A00D75ADE /* OAuthConsumer */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FACAD8A71762C61A00D75ADE /* Categories */,
|
||||||
|
FACAD8AA1762C61A00D75ADE /* Crytpo */,
|
||||||
|
FACAD8AD1762C61A00D75ADE /* OAConsumer.h */,
|
||||||
|
FACAD8AE1762C61A00D75ADE /* OAConsumer.m */,
|
||||||
|
FACAD8AF1762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.h */,
|
||||||
|
FACAD8B01762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m */,
|
||||||
|
FACAD8B11762C61A00D75ADE /* OAMutableURLRequest.h */,
|
||||||
|
FACAD8B21762C61A00D75ADE /* OAMutableURLRequest.m */,
|
||||||
|
FACAD8B31762C61A00D75ADE /* OARequestParameter.h */,
|
||||||
|
FACAD8B41762C61A00D75ADE /* OARequestParameter.m */,
|
||||||
|
FACAD8B51762C61A00D75ADE /* OAServiceTicket.h */,
|
||||||
|
FACAD8B61762C61A00D75ADE /* OAServiceTicket.m */,
|
||||||
|
FACAD8B71762C61A00D75ADE /* OAToken.h */,
|
||||||
|
FACAD8B81762C61A00D75ADE /* OAToken.m */,
|
||||||
|
FACAD8B91762C61A00D75ADE /* OAuthConsumer.h */,
|
||||||
|
);
|
||||||
|
path = OAuthConsumer;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
FACAD8A71762C61A00D75ADE /* Categories */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FACAD8A81762C61A00D75ADE /* NSString+URLEncoding.h */,
|
||||||
|
FACAD8A91762C61A00D75ADE /* NSString+URLEncoding.m */,
|
||||||
|
);
|
||||||
|
path = Categories;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
FACAD8AA1762C61A00D75ADE /* Crytpo */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FACAD8AB1762C61A00D75ADE /* Base64TranscoderFHS.c */,
|
||||||
|
FACAD8AC1762C61A00D75ADE /* Base64TranscoderFHS.h */,
|
||||||
|
);
|
||||||
|
path = Crytpo;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
FACAD8871762C1B500D75ADE /* PluginTwitter */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = FACAD8961762C1B500D75ADE /* Build configuration list for PBXNativeTarget "PluginTwitter" */;
|
||||||
|
buildPhases = (
|
||||||
|
FACAD8841762C1B500D75ADE /* Sources */,
|
||||||
|
FACAD8851762C1B500D75ADE /* Frameworks */,
|
||||||
|
FACAD8861762C1B500D75ADE /* CopyFiles */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = PluginTwitter;
|
||||||
|
productName = PluginTwitter;
|
||||||
|
productReference = FACAD8881762C1B500D75ADE /* libPluginTwitter.a */;
|
||||||
|
productType = "com.apple.product-type.library.static";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
FACAD87F1762C1B500D75ADE /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0440;
|
||||||
|
ORGANIZATIONNAME = zhangbin;
|
||||||
|
};
|
||||||
|
buildConfigurationList = FACAD8821762C1B500D75ADE /* Build configuration list for PBXProject "PluginTwitter" */;
|
||||||
|
compatibilityVersion = "Xcode 3.2";
|
||||||
|
developmentRegion = English;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
);
|
||||||
|
mainGroup = FACAD87D1762C1B500D75ADE;
|
||||||
|
productRefGroup = FACAD8891762C1B500D75ADE /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
FACAD8871762C1B500D75ADE /* PluginTwitter */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
FACAD8841762C1B500D75ADE /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
FACAD89F1762C22300D75ADE /* SocialTwitter.m in Sources */,
|
||||||
|
FACAD8BA1762C61A00D75ADE /* FHSTwitterEngine.m in Sources */,
|
||||||
|
FACAD8BB1762C61A00D75ADE /* NSString+URLEncoding.m in Sources */,
|
||||||
|
FACAD8BC1762C61A00D75ADE /* Base64TranscoderFHS.c in Sources */,
|
||||||
|
FACAD8BD1762C61A00D75ADE /* OAConsumer.m in Sources */,
|
||||||
|
FACAD8BE1762C61A00D75ADE /* OAHMAC_SHA1SignatureProvider.m in Sources */,
|
||||||
|
FACAD8BF1762C61A00D75ADE /* OAMutableURLRequest.m in Sources */,
|
||||||
|
FACAD8C01762C61A00D75ADE /* OARequestParameter.m in Sources */,
|
||||||
|
FACAD8C11762C61A00D75ADE /* OAServiceTicket.m in Sources */,
|
||||||
|
FACAD8C21762C61A00D75ADE /* OAToken.m in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
FACAD8941762C1B500D75ADE /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||||
|
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
FACAD8951762C1B500D75ADE /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
FACAD8971762C1B500D75ADE /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
DSTROOT = /tmp/PluginTwitter.dst;
|
||||||
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
|
GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch";
|
||||||
|
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||||
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
FACAD8981762C1B500D75ADE /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
DSTROOT = /tmp/PluginTwitter.dst;
|
||||||
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
|
GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch";
|
||||||
|
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||||
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
FACAD8821762C1B500D75ADE /* Build configuration list for PBXProject "PluginTwitter" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
FACAD8941762C1B500D75ADE /* Debug */,
|
||||||
|
FACAD8951762C1B500D75ADE /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
FACAD8961762C1B500D75ADE /* Build configuration list for PBXNativeTarget "PluginTwitter" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
FACAD8971762C1B500D75ADE /* Debug */,
|
||||||
|
FACAD8981762C1B500D75ADE /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = FACAD87F1762C1B500D75ADE /* Project object */;
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#import "InterfaceSocial.h"
|
||||||
|
|
||||||
|
@interface SocialTwitter : NSObject <InterfaceSocial>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@property BOOL debug;
|
||||||
|
@property (copy, nonatomic) NSMutableDictionary* mShareInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief interfaces of protocol : InterfaceSocial
|
||||||
|
*/
|
||||||
|
- (void) configDeveloperInfo : (NSMutableDictionary*) cpInfo;
|
||||||
|
- (void) share: (NSMutableDictionary*) shareInfo;
|
||||||
|
- (void) setDebugMode: (BOOL) debug;
|
||||||
|
- (NSString*) getSDKVersion;
|
||||||
|
- (NSString*) getPluginVersion;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,142 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#import "SocialTwitter.h"
|
||||||
|
#import "FHSTwitterEngine.h"
|
||||||
|
#import "SocialWrapper.h"
|
||||||
|
|
||||||
|
#define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__);
|
||||||
|
|
||||||
|
@implementation SocialTwitter
|
||||||
|
|
||||||
|
@synthesize mShareInfo;
|
||||||
|
@synthesize debug = __debug;
|
||||||
|
|
||||||
|
- (void) configDeveloperInfo : (NSMutableDictionary*) cpInfo
|
||||||
|
{
|
||||||
|
NSString* appKey = [cpInfo objectForKey:@"TwitterKey"];
|
||||||
|
NSString* appSecret = [cpInfo objectForKey:@"TwitterSecret"];
|
||||||
|
|
||||||
|
if (nil == appKey || nil == appSecret) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:appKey andSecret:appSecret];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) share: (NSMutableDictionary*) shareInfo
|
||||||
|
{
|
||||||
|
self.mShareInfo = shareInfo;
|
||||||
|
if ([[FHSTwitterEngine sharedEngine]isAuthorized])
|
||||||
|
{
|
||||||
|
[self doShare];
|
||||||
|
} else {
|
||||||
|
UIViewController* controller = [self getCurrentRootViewController];
|
||||||
|
[[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:controller withCompletion:^(BOOL success) {
|
||||||
|
if (success) {
|
||||||
|
[self doShare];
|
||||||
|
} else {
|
||||||
|
[SocialWrapper onShareResult:self withRet:kShareFail withMsg:@"Login Failed"];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setDebugMode: (BOOL) debug
|
||||||
|
{
|
||||||
|
self.debug = debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*) getSDKVersion
|
||||||
|
{
|
||||||
|
return @"20130607";
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*) getPluginVersion
|
||||||
|
{
|
||||||
|
return @"0.2.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) doShare
|
||||||
|
{
|
||||||
|
if (nil == mShareInfo) {
|
||||||
|
[SocialWrapper onShareResult:self withRet:kShareFail withMsg:@"Shared info error"];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString* strText = [mShareInfo objectForKey:@"SharedText"];
|
||||||
|
NSString* strImagePath = [mShareInfo objectForKey:@"SharedImagePath"];
|
||||||
|
|
||||||
|
BOOL oldConfig = [UIApplication sharedApplication].networkActivityIndicatorVisible;
|
||||||
|
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
|
||||||
|
|
||||||
|
NSError* returnCode = nil;
|
||||||
|
if (nil != strImagePath) {
|
||||||
|
NSData* data = [NSData dataWithContentsOfFile:strImagePath];
|
||||||
|
returnCode = [[FHSTwitterEngine sharedEngine] postTweet:strText withImageData:data];
|
||||||
|
} else {
|
||||||
|
returnCode = [[FHSTwitterEngine sharedEngine]postTweet:strText];
|
||||||
|
}
|
||||||
|
[UIApplication sharedApplication].networkActivityIndicatorVisible = oldConfig;
|
||||||
|
|
||||||
|
if (returnCode) {
|
||||||
|
NSString* strErrorCode = [NSString stringWithFormat:@"ErrorCode %d", returnCode.code];
|
||||||
|
[SocialWrapper onShareResult:self withRet:kShareFail withMsg:strErrorCode];
|
||||||
|
} else {
|
||||||
|
[SocialWrapper onShareResult:self withRet:kShareSuccess withMsg:@"Share Succeed"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIViewController *)getCurrentRootViewController {
|
||||||
|
|
||||||
|
UIViewController *result = nil;
|
||||||
|
|
||||||
|
// Try to find the root view controller programmically
|
||||||
|
|
||||||
|
// Find the top window (that is not an alert view or other window)
|
||||||
|
UIWindow *topWindow = [[UIApplication sharedApplication] keyWindow];
|
||||||
|
if (topWindow.windowLevel != UIWindowLevelNormal)
|
||||||
|
{
|
||||||
|
NSArray *windows = [[UIApplication sharedApplication] windows];
|
||||||
|
for(topWindow in windows)
|
||||||
|
{
|
||||||
|
if (topWindow.windowLevel == UIWindowLevelNormal)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UIView *rootView = [[topWindow subviews] objectAtIndex:0];
|
||||||
|
id nextResponder = [rootView nextResponder];
|
||||||
|
|
||||||
|
if ([nextResponder isKindOfClass:[UIViewController class]])
|
||||||
|
result = nextResponder;
|
||||||
|
else if ([topWindow respondsToSelector:@selector(rootViewController)] && topWindow.rootViewController != nil)
|
||||||
|
result = topWindow.rootViewController;
|
||||||
|
else
|
||||||
|
NSAssert(NO, @"Could not find a root view controller.");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -185,10 +185,7 @@
|
||||||
DSTROOT = /tmp/libPluginUmeng.dst;
|
DSTROOT = /tmp/libPluginUmeng.dst;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
|
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||||
"$(SRCROOT)/../../../protocols/include",
|
|
||||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
|
||||||
);
|
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"\"$(SRCROOT)\"",
|
"\"$(SRCROOT)\"",
|
||||||
|
@ -207,10 +204,7 @@
|
||||||
DSTROOT = /tmp/libPluginUmeng.dst;
|
DSTROOT = /tmp/libPluginUmeng.dst;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
|
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||||
"$(SRCROOT)/../../../protocols/include",
|
|
||||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
|
||||||
);
|
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"\"$(SRCROOT)\"",
|
"\"$(SRCROOT)\"",
|
||||||
|
|
|
@ -225,14 +225,12 @@
|
||||||
FAE2753F175D9D2B00F5DA8E /* Debug */ = {
|
FAE2753F175D9D2B00F5DA8E /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
|
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
DSTROOT = /tmp/PluginWeibo.dst;
|
DSTROOT = /tmp/PluginWeibo.dst;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch";
|
GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch";
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||||
"$(SRCROOT)/../../../protocols/include",
|
|
||||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
|
||||||
);
|
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
|
@ -242,14 +240,12 @@
|
||||||
FAE27540175D9D2B00F5DA8E /* Release */ = {
|
FAE27540175D9D2B00F5DA8E /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
|
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
DSTROOT = /tmp/PluginWeibo.dst;
|
DSTROOT = /tmp/PluginWeibo.dst;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch";
|
GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch";
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||||
"$(SRCROOT)/../../../protocols/include",
|
|
||||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
|
||||||
);
|
|
||||||
OTHER_LDFLAGS = "-ObjC";
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
|
|
|
@ -80,7 +80,7 @@ PluginProtocol* PluginManager::loadPlugin(const char* name)
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
pRet = PluginFactory::getInstance()->createPlugin(name);
|
pRet = PluginFactory::getInstance()->createPlugin(name);
|
||||||
m_pluginsMap["name"] = pRet;
|
m_pluginsMap[name] = pRet;
|
||||||
}
|
}
|
||||||
} while (false);
|
} while (false);
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,25 @@ if (PluginJniHelper::getMethodInfo(t \
|
||||||
, funcName \
|
, funcName \
|
||||||
, paramCode)) \
|
, paramCode)) \
|
||||||
{ \
|
{ \
|
||||||
if (NULL != param) \
|
ret = t.env->Call##retCode##Method(pData->jobj, t.methodID, param); \
|
||||||
{ \
|
t.env->DeleteLocalRef(t.classID); \
|
||||||
ret = t.env->Call##retCode##Method(pData->jobj, t.methodID, param); \
|
} \
|
||||||
} else { \
|
return ret; \
|
||||||
ret = t.env->Call##retCode##Method(pData->jobj, t.methodID); \
|
|
||||||
} \
|
|
||||||
|
#define CALL_BASERET_JAVA_FUNC(retType, paramCode, retCode, defaultRet) \
|
||||||
|
retType ret = defaultRet; \
|
||||||
|
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); \
|
||||||
|
PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); \
|
||||||
|
return_val_if_fails(pData != NULL, ret); \
|
||||||
|
\
|
||||||
|
PluginJniMethodInfo t; \
|
||||||
|
if (PluginJniHelper::getMethodInfo(t \
|
||||||
|
, pData->jclassName.c_str() \
|
||||||
|
, funcName \
|
||||||
|
, paramCode)) \
|
||||||
|
{ \
|
||||||
|
ret = t.env->Call##retCode##Method(pData->jobj, t.methodID); \
|
||||||
t.env->DeleteLocalRef(t.classID); \
|
t.env->DeleteLocalRef(t.classID); \
|
||||||
} \
|
} \
|
||||||
return ret; \
|
return ret; \
|
||||||
|
@ -88,7 +101,7 @@ if (0 == nParamNum)
|
||||||
{ \
|
{ \
|
||||||
paramCode = "()"; \
|
paramCode = "()"; \
|
||||||
paramCode.append(jRetCode); \
|
paramCode.append(jRetCode); \
|
||||||
ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), NULL); \
|
ret = PluginUtils::callJava##retCode##FuncWithName(this, funcName); \
|
||||||
} else \
|
} else \
|
||||||
{ \
|
{ \
|
||||||
PluginParam* pRetParam = NULL; \
|
PluginParam* pRetParam = NULL; \
|
||||||
|
|
|
@ -107,7 +107,7 @@ void PluginProtocol::callFuncWithParam(const char* funcName, std::vector<PluginP
|
||||||
int nParamNum = params.size();
|
int nParamNum = params.size();
|
||||||
if (nParamNum == 0)
|
if (nParamNum == 0)
|
||||||
{
|
{
|
||||||
PluginUtils::callJavaFunctionWithName_oneParam(this, funcName, "()V", NULL);
|
PluginUtils::callJavaFunctionWithName(this, funcName);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
PluginParam* pRetParam = NULL;
|
PluginParam* pRetParam = NULL;
|
||||||
|
|
|
@ -63,12 +63,23 @@ public:
|
||||||
, funcName
|
, funcName
|
||||||
, paramCode))
|
, paramCode))
|
||||||
{
|
{
|
||||||
if (param != NULL)
|
t.env->CallVoidMethod(pData->jobj, t.methodID, param);
|
||||||
{
|
t.env->DeleteLocalRef(t.classID);
|
||||||
t.env->CallVoidMethod(pData->jobj, t.methodID, param);
|
}
|
||||||
} else {
|
}
|
||||||
t.env->CallVoidMethod(pData->jobj, t.methodID);
|
static void callJavaFunctionWithName(PluginProtocol* thiz, const char* funcName)
|
||||||
}
|
{
|
||||||
|
return_if_fails(funcName != NULL && strlen(funcName) > 0);
|
||||||
|
PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz);
|
||||||
|
return_if_fails(pData != NULL);
|
||||||
|
|
||||||
|
PluginJniMethodInfo t;
|
||||||
|
if (PluginJniHelper::getMethodInfo(t
|
||||||
|
, pData->jclassName.c_str()
|
||||||
|
, funcName
|
||||||
|
, "()V"))
|
||||||
|
{
|
||||||
|
t.env->CallVoidMethod(pData->jobj, t.methodID);
|
||||||
t.env->DeleteLocalRef(t.classID);
|
t.env->DeleteLocalRef(t.classID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +112,25 @@ public:
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
static const char* callJavaStringFuncWithName(PluginProtocol* thiz, const char* funcName)
|
||||||
|
{
|
||||||
|
const char* ret = "";
|
||||||
|
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret);
|
||||||
|
PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz);
|
||||||
|
return_val_if_fails(pData != NULL, ret);
|
||||||
|
|
||||||
|
PluginJniMethodInfo t;
|
||||||
|
if (PluginJniHelper::getMethodInfo(t
|
||||||
|
, pData->jclassName.c_str()
|
||||||
|
, funcName
|
||||||
|
, "()Ljava/lang/String;"))
|
||||||
|
{
|
||||||
|
jstring strRet = (jstring) t.env->CallObjectMethod(pData->jobj, t.methodID);
|
||||||
|
ret = PluginJniHelper::jstring2string(strRet).c_str();
|
||||||
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// methods return value is int
|
// methods return value is int
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -108,6 +138,10 @@ public:
|
||||||
{
|
{
|
||||||
CALL_BASERET_JAVA_FUNC_WITH_PARAM(int, paramCode, param, Int, 0)
|
CALL_BASERET_JAVA_FUNC_WITH_PARAM(int, paramCode, param, Int, 0)
|
||||||
}
|
}
|
||||||
|
static int callJavaIntFuncWithName(PluginProtocol* thiz, const char* funcName)
|
||||||
|
{
|
||||||
|
CALL_BASERET_JAVA_FUNC(int, "()I", Int, 0)
|
||||||
|
}
|
||||||
|
|
||||||
// methods return value is float
|
// methods return value is float
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -115,6 +149,10 @@ public:
|
||||||
{
|
{
|
||||||
CALL_BASERET_JAVA_FUNC_WITH_PARAM(float, paramCode, param, Float, 0.0f)
|
CALL_BASERET_JAVA_FUNC_WITH_PARAM(float, paramCode, param, Float, 0.0f)
|
||||||
}
|
}
|
||||||
|
static float callJavaFloatFuncWithName(PluginProtocol* thiz, const char* funcName)
|
||||||
|
{
|
||||||
|
CALL_BASERET_JAVA_FUNC(float, "()F", Float, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
// methods return value is bool
|
// methods return value is bool
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -122,6 +160,10 @@ public:
|
||||||
{
|
{
|
||||||
CALL_BASERET_JAVA_FUNC_WITH_PARAM(bool, paramCode, param, Boolean, false)
|
CALL_BASERET_JAVA_FUNC_WITH_PARAM(bool, paramCode, param, Boolean, false)
|
||||||
}
|
}
|
||||||
|
static bool callJavaBoolFuncWithName(PluginProtocol* thiz, const char* funcName)
|
||||||
|
{
|
||||||
|
CALL_BASERET_JAVA_FUNC(bool, "()Z", Boolean, false)
|
||||||
|
}
|
||||||
|
|
||||||
static void outputLog(const char* logTag, const char* pFormat, ...);
|
static void outputLog(const char* logTag, const char* pFormat, ...);
|
||||||
};
|
};
|
||||||
|
|
|
@ -61,7 +61,7 @@ if (NULL == pData) {
|
||||||
int nParamNum = params.size(); \
|
int nParamNum = params.size(); \
|
||||||
if (0 == nParamNum) \
|
if (0 == nParamNum) \
|
||||||
{ \
|
{ \
|
||||||
ret = PluginUtilsIOS::callOC##retCode##FunctionWithName_oneParam(this, funcName, NULL); \
|
ret = PluginUtilsIOS::callOC##retCode##FunctionWithName(this, funcName); \
|
||||||
} else \
|
} else \
|
||||||
{ \
|
{ \
|
||||||
PluginParam* pRetParam = NULL; \
|
PluginParam* pRetParam = NULL; \
|
||||||
|
|
|
@ -117,7 +117,7 @@ void PluginProtocol::callFuncWithParam(const char* funcName, std::vector<PluginP
|
||||||
int nParamNum = params.size();
|
int nParamNum = params.size();
|
||||||
if (0 == nParamNum)
|
if (0 == nParamNum)
|
||||||
{
|
{
|
||||||
PluginUtilsIOS::callOCFunctionWithName_oneParam(this, funcName, NULL);
|
PluginUtilsIOS::callOCFunctionWithName(this, funcName);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
PluginParam* pRetParam = NULL;
|
PluginParam* pRetParam = NULL;
|
||||||
|
|
|
@ -57,31 +57,37 @@ public:
|
||||||
@brief method don't have return value
|
@brief method don't have return value
|
||||||
*/
|
*/
|
||||||
static void callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
static void callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
||||||
|
static void callOCFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief method return int value
|
@brief method return int value
|
||||||
*/
|
*/
|
||||||
static int callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
static int callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
||||||
|
static int callOCIntFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief method return float value
|
@brief method return float value
|
||||||
*/
|
*/
|
||||||
static float callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
static float callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
||||||
|
static float callOCFloatFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief method return bool value
|
@brief method return bool value
|
||||||
*/
|
*/
|
||||||
static bool callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
static bool callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
||||||
|
static bool callOCBoolFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief method return string value
|
@brief method return string value
|
||||||
*/
|
*/
|
||||||
static const char* callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
static const char* callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
||||||
|
static const char* callOCStringFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
|
||||||
|
|
||||||
static void outputLog(const char* pFormat, ...);
|
static void outputLog(const char* pFormat, ...);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static id callRetFunction(PluginProtocol* pPlugin, const char* funcName, id param);
|
static id callRetFunctionWithParam(PluginProtocol* pPlugin, const char* funcName, id param);
|
||||||
|
static id callRetFunction(PluginProtocol* pPlugin, const char* funcName);
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace cocos2d { namespace plugin {
|
}} // namespace cocos2d { namespace plugin {
|
||||||
|
|
|
@ -172,16 +172,31 @@ void PluginUtilsIOS::callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, co
|
||||||
id pOCObj = pData->obj;
|
id pOCObj = pData->obj;
|
||||||
|
|
||||||
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
|
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
|
||||||
if (param != nil) {
|
strFuncName = [strFuncName stringByAppendingString:@":"];
|
||||||
strFuncName = [strFuncName stringByAppendingString:@":"];
|
|
||||||
}
|
|
||||||
SEL selector = NSSelectorFromString(strFuncName);
|
SEL selector = NSSelectorFromString(strFuncName);
|
||||||
if ([pOCObj respondsToSelector:selector]) {
|
if ([pOCObj respondsToSelector:selector]) {
|
||||||
if (param == nil) {
|
[pOCObj performSelector:selector withObject:param];
|
||||||
[pOCObj performSelector:selector];
|
} else {
|
||||||
} else {
|
outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
|
||||||
[pOCObj performSelector:selector withObject:param];
|
}
|
||||||
}
|
} else {
|
||||||
|
PluginUtilsIOS::outputLog("Plugin %s not right initilized", pPlugin->getPluginName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginUtilsIOS::callOCFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
|
||||||
|
{
|
||||||
|
return_if_fails(funcName != NULL && strlen(funcName) > 0);
|
||||||
|
|
||||||
|
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin);
|
||||||
|
if (pData) {
|
||||||
|
id pOCObj = pData->obj;
|
||||||
|
|
||||||
|
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
|
||||||
|
SEL selector = NSSelectorFromString(strFuncName);
|
||||||
|
if ([pOCObj respondsToSelector:selector]) {
|
||||||
|
[pOCObj performSelector:selector];
|
||||||
} else {
|
} else {
|
||||||
outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
|
outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
|
||||||
}
|
}
|
||||||
|
@ -192,14 +207,33 @@ void PluginUtilsIOS::callOCFunctionWithName_oneParam(PluginProtocol* pPlugin, co
|
||||||
|
|
||||||
int PluginUtilsIOS::callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
int PluginUtilsIOS::callOCIntFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
||||||
{
|
{
|
||||||
int ret = (NSInteger)callRetFunction(pPlugin, funcName, param);
|
NSNumber* num = (NSNumber*) callRetFunctionWithParam(pPlugin, funcName, param);
|
||||||
|
int ret = [num integerValue];
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PluginUtilsIOS::callOCIntFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
|
||||||
|
{
|
||||||
|
NSNumber* num = (NSNumber*) callRetFunction(pPlugin, funcName);
|
||||||
|
int ret = [num integerValue];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PluginUtilsIOS::callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
float PluginUtilsIOS::callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
||||||
{
|
{
|
||||||
float ret = 0.0f;
|
float ret = 0.0f;
|
||||||
NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName, param);
|
NSNumber* pRet = (NSNumber*)callRetFunctionWithParam(pPlugin, funcName, param);
|
||||||
|
if (nil != pRet) {
|
||||||
|
ret = [pRet floatValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
float PluginUtilsIOS::callOCFloatFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
|
||||||
|
{
|
||||||
|
float ret = 0.0f;
|
||||||
|
NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName);
|
||||||
if (nil != pRet) {
|
if (nil != pRet) {
|
||||||
ret = [pRet floatValue];
|
ret = [pRet floatValue];
|
||||||
}
|
}
|
||||||
|
@ -210,7 +244,18 @@ float PluginUtilsIOS::callOCFloatFunctionWithName_oneParam(PluginProtocol* pPlug
|
||||||
bool PluginUtilsIOS::callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
bool PluginUtilsIOS::callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName, param);
|
NSNumber* pRet = (NSNumber*)callRetFunctionWithParam(pPlugin, funcName, param);
|
||||||
|
if (nil != pRet) {
|
||||||
|
ret = [pRet boolValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PluginUtilsIOS::callOCBoolFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
NSNumber* pRet = (NSNumber*)callRetFunction(pPlugin, funcName);
|
||||||
if (nil != pRet) {
|
if (nil != pRet) {
|
||||||
ret = [pRet boolValue];
|
ret = [pRet boolValue];
|
||||||
}
|
}
|
||||||
|
@ -221,7 +266,7 @@ bool PluginUtilsIOS::callOCBoolFunctionWithName_oneParam(PluginProtocol* pPlugin
|
||||||
const char* PluginUtilsIOS::callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
const char* PluginUtilsIOS::callOCStringFunctionWithName_oneParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
||||||
{
|
{
|
||||||
const char* ret = "";
|
const char* ret = "";
|
||||||
NSString* pRet = (NSString*)callRetFunction(pPlugin, funcName, param);
|
NSString* pRet = (NSString*)callRetFunctionWithParam(pPlugin, funcName, param);
|
||||||
if (nil != pRet) {
|
if (nil != pRet) {
|
||||||
ret = [pRet UTF8String];
|
ret = [pRet UTF8String];
|
||||||
}
|
}
|
||||||
|
@ -229,7 +274,18 @@ const char* PluginUtilsIOS::callOCStringFunctionWithName_oneParam(PluginProtocol
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
id PluginUtilsIOS::callRetFunction(PluginProtocol* pPlugin, const char* funcName, id param)
|
const char* PluginUtilsIOS::callOCStringFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
|
||||||
|
{
|
||||||
|
const char* ret = "";
|
||||||
|
NSString* pRet = (NSString*)callRetFunction(pPlugin, funcName);
|
||||||
|
if (nil != pRet) {
|
||||||
|
ret = [pRet UTF8String];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
id PluginUtilsIOS::callRetFunction(PluginProtocol* pPlugin, const char* funcName)
|
||||||
{
|
{
|
||||||
id ret = nil;
|
id ret = nil;
|
||||||
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret);
|
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret);
|
||||||
|
@ -239,16 +295,33 @@ id PluginUtilsIOS::callRetFunction(PluginProtocol* pPlugin, const char* funcName
|
||||||
id pOCObj = pData->obj;
|
id pOCObj = pData->obj;
|
||||||
|
|
||||||
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
|
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
|
||||||
if (param != nil) {
|
|
||||||
strFuncName = [strFuncName stringByAppendingString:@":"];
|
|
||||||
}
|
|
||||||
SEL selector = NSSelectorFromString(strFuncName);
|
SEL selector = NSSelectorFromString(strFuncName);
|
||||||
if ([pOCObj respondsToSelector:selector]) {
|
if ([pOCObj respondsToSelector:selector]) {
|
||||||
if (param == nil) {
|
ret = [pOCObj performSelector:selector];
|
||||||
ret = [pOCObj performSelector:selector];
|
} else {
|
||||||
} else {
|
outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
|
||||||
ret = [pOCObj performSelector:selector withObject:param];
|
}
|
||||||
}
|
} else {
|
||||||
|
PluginUtilsIOS::outputLog("Plugin %s not right initilized", pPlugin->getPluginName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
id PluginUtilsIOS::callRetFunctionWithParam(PluginProtocol* pPlugin, const char* funcName, id param)
|
||||||
|
{
|
||||||
|
id ret = nil;
|
||||||
|
return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret);
|
||||||
|
|
||||||
|
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin);
|
||||||
|
if (pData) {
|
||||||
|
id pOCObj = pData->obj;
|
||||||
|
|
||||||
|
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
|
||||||
|
strFuncName = [strFuncName stringByAppendingString:@":"];
|
||||||
|
SEL selector = NSSelectorFromString(strFuncName);
|
||||||
|
if ([pOCObj respondsToSelector:selector]) {
|
||||||
|
ret = [pOCObj performSelector:selector withObject:param];
|
||||||
} else {
|
} else {
|
||||||
outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
|
outputLog("Can't find function '%s' in class '%s'", [strFuncName UTF8String], pData->className.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@
|
||||||
FA09A318168ADBC2008C1C7B /* Project object */ = {
|
FA09A318168ADBC2008C1C7B /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastUpgradeCheck = 0440;
|
LastUpgradeCheck = 0460;
|
||||||
ORGANIZATIONNAME = zhangbin;
|
ORGANIZATIONNAME = zhangbin;
|
||||||
};
|
};
|
||||||
buildConfigurationList = FA09A31B168ADBC2008C1C7B /* Build configuration list for PBXProject "PluginProtocol" */;
|
buildConfigurationList = FA09A31B168ADBC2008C1C7B /* Build configuration list for PBXProject "PluginProtocol" */;
|
||||||
|
@ -219,6 +219,9 @@
|
||||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
@ -245,6 +248,9 @@
|
||||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = YES;
|
COPY_PHASE_STRIP = YES;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
D4EF949C15BD2D8E00D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949B15BD2D8E00D803EB /* Icon-114.png */; };
|
D4EF949C15BD2D8E00D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949B15BD2D8E00D803EB /* Icon-114.png */; };
|
||||||
D4EF949E15BD2D9600D803EB /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949D15BD2D9600D803EB /* Icon-72.png */; };
|
D4EF949E15BD2D9600D803EB /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949D15BD2D9600D803EB /* Icon-72.png */; };
|
||||||
D4EF94A015BD2D9800D803EB /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949F15BD2D9800D803EB /* Icon-144.png */; };
|
D4EF94A015BD2D9800D803EB /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF949F15BD2D9800D803EB /* Icon-144.png */; };
|
||||||
|
FACAD8F61763061F00D75ADE /* libPluginTwitter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */; };
|
||||||
|
FACAD8F81763070D00D75ADE /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */; };
|
||||||
FAE27583175DEC8600F5DA8E /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27580175DEC8600F5DA8E /* background.png */; };
|
FAE27583175DEC8600F5DA8E /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27580175DEC8600F5DA8E /* background.png */; };
|
||||||
FAE27584175DEC8600F5DA8E /* twitter.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FAE27581175DEC8600F5DA8E /* twitter.jpeg */; };
|
FAE27584175DEC8600F5DA8E /* twitter.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FAE27581175DEC8600F5DA8E /* twitter.jpeg */; };
|
||||||
FAE27585175DEC8600F5DA8E /* weibo.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27582175DEC8600F5DA8E /* weibo.png */; };
|
FAE27585175DEC8600F5DA8E /* weibo.png in Resources */ = {isa = PBXBuildFile; fileRef = FAE27582175DEC8600F5DA8E /* weibo.png */; };
|
||||||
|
@ -46,6 +48,13 @@
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
FACAD8F41762DC3A00D75ADE /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */;
|
||||||
|
proxyType = 2;
|
||||||
|
remoteGlobalIDString = FACAD8881762C1B500D75ADE;
|
||||||
|
remoteInfo = PluginTwitter;
|
||||||
|
};
|
||||||
FAE2757E175DEC0D00F5DA8E /* PBXContainerItemProxy */ = {
|
FAE2757E175DEC0D00F5DA8E /* PBXContainerItemProxy */ = {
|
||||||
isa = PBXContainerItemProxy;
|
isa = PBXContainerItemProxy;
|
||||||
containerPortal = FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */;
|
containerPortal = FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */;
|
||||||
|
@ -112,6 +121,8 @@
|
||||||
D4EF949D15BD2D9600D803EB /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "../proj.ios/Icon-72.png"; sourceTree = "<group>"; };
|
D4EF949D15BD2D9600D803EB /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "../proj.ios/Icon-72.png"; sourceTree = "<group>"; };
|
||||||
D4EF949F15BD2D9800D803EB /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-144.png"; path = "../proj.ios/Icon-144.png"; sourceTree = "<group>"; };
|
D4EF949F15BD2D9800D803EB /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-144.png"; path = "../proj.ios/Icon-144.png"; sourceTree = "<group>"; };
|
||||||
D4F9F37B12E54555005CA6D2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
|
D4F9F37B12E54555005CA6D2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
|
||||||
|
FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginTwitter.xcodeproj; path = ../../../plugins/twitter/proj.ios/PluginTwitter.xcodeproj; sourceTree = "<group>"; };
|
||||||
|
FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
||||||
FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; };
|
FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; };
|
||||||
FAE27580175DEC8600F5DA8E /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = "<group>"; };
|
FAE27580175DEC8600F5DA8E /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = "<group>"; };
|
||||||
FAE27581175DEC8600F5DA8E /* twitter.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = twitter.jpeg; sourceTree = "<group>"; };
|
FAE27581175DEC8600F5DA8E /* twitter.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = twitter.jpeg; sourceTree = "<group>"; };
|
||||||
|
@ -128,6 +139,8 @@
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
FACAD8F81763070D00D75ADE /* SystemConfiguration.framework in Frameworks */,
|
||||||
|
FACAD8F61763061F00D75ADE /* libPluginTwitter.a in Frameworks */,
|
||||||
FAE275A1175DEEF500F5DA8E /* AudioToolbox.framework in Frameworks */,
|
FAE275A1175DEEF500F5DA8E /* AudioToolbox.framework in Frameworks */,
|
||||||
FAE27598175DEE1900F5DA8E /* libcocos2dx.a in Frameworks */,
|
FAE27598175DEE1900F5DA8E /* libcocos2dx.a in Frameworks */,
|
||||||
FAE27599175DEE1900F5DA8E /* libPluginProtocol.a in Frameworks */,
|
FAE27599175DEE1900F5DA8E /* libPluginProtocol.a in Frameworks */,
|
||||||
|
@ -223,6 +236,8 @@
|
||||||
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
|
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
FACAD8F71763070D00D75ADE /* SystemConfiguration.framework */,
|
||||||
|
FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */,
|
||||||
FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */,
|
FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */,
|
||||||
FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */,
|
FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */,
|
||||||
FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */,
|
FAE27577175DEC0C00F5DA8E /* cocos2dx.xcodeproj */,
|
||||||
|
@ -273,6 +288,14 @@
|
||||||
path = ../Resources;
|
path = ../Resources;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
FACAD8EE1762DC3A00D75ADE /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
FAE27578175DEC0C00F5DA8E /* Products */ = {
|
FAE27578175DEC0C00F5DA8E /* Products */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
@ -346,6 +369,10 @@
|
||||||
ProductGroup = FAE27587175DED1700F5DA8E /* Products */;
|
ProductGroup = FAE27587175DED1700F5DA8E /* Products */;
|
||||||
ProjectRef = FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */;
|
ProjectRef = FAE27586175DED1700F5DA8E /* PluginProtocol.xcodeproj */;
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ProductGroup = FACAD8EE1762DC3A00D75ADE /* Products */;
|
||||||
|
ProjectRef = FACAD8ED1762DC3A00D75ADE /* PluginTwitter.xcodeproj */;
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ProductGroup = FAE27590175DED2300F5DA8E /* Products */;
|
ProductGroup = FAE27590175DED2300F5DA8E /* Products */;
|
||||||
ProjectRef = FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */;
|
ProjectRef = FAE2758F175DED2300F5DA8E /* PluginWeibo.xcodeproj */;
|
||||||
|
@ -359,6 +386,13 @@
|
||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
|
|
||||||
/* Begin PBXReferenceProxy section */
|
/* Begin PBXReferenceProxy section */
|
||||||
|
FACAD8F51762DC3A00D75ADE /* libPluginTwitter.a */ = {
|
||||||
|
isa = PBXReferenceProxy;
|
||||||
|
fileType = archive.ar;
|
||||||
|
path = libPluginTwitter.a;
|
||||||
|
remoteRef = FACAD8F41762DC3A00D75ADE /* PBXContainerItemProxy */;
|
||||||
|
sourceTree = BUILT_PRODUCTS_DIR;
|
||||||
|
};
|
||||||
FAE2757F175DEC0D00F5DA8E /* libcocos2dx.a */ = {
|
FAE2757F175DEC0D00F5DA8E /* libcocos2dx.a */ = {
|
||||||
isa = PBXReferenceProxy;
|
isa = PBXReferenceProxy;
|
||||||
fileType = archive.ar;
|
fileType = archive.ar;
|
||||||
|
@ -430,8 +464,8 @@
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||||
|
@ -457,13 +491,13 @@
|
||||||
"\"$(SRCROOT)/../../../protocols/include",
|
"\"$(SRCROOT)/../../../protocols/include",
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = Info.plist;
|
INFOPLIST_FILE = Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
||||||
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\"";
|
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\"";
|
||||||
OTHER_CFLAGS = "-O2";
|
OTHER_CFLAGS = "-O2";
|
||||||
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
|
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
|
||||||
PRODUCT_NAME = HelloSocial;
|
PRODUCT_NAME = HelloSocial;
|
||||||
PROVISIONING_PROFILE = "";
|
PROVISIONING_PROFILE = "34B6E084-2760-4B9B-94CE-0998083C95F5";
|
||||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
|
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "34B6E084-2760-4B9B-94CE-0998083C95F5";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
USER_HEADER_SEARCH_PATHS = "";
|
USER_HEADER_SEARCH_PATHS = "";
|
||||||
|
@ -475,8 +509,8 @@
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
COPY_PHASE_STRIP = YES;
|
COPY_PHASE_STRIP = YES;
|
||||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
@ -500,12 +534,12 @@
|
||||||
"\"$(SRCROOT)/../../../protocols/include",
|
"\"$(SRCROOT)/../../../protocols/include",
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = Info.plist;
|
INFOPLIST_FILE = Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
||||||
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\"";
|
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\"";
|
||||||
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
|
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
|
||||||
PRODUCT_NAME = HelloSocial;
|
PRODUCT_NAME = HelloSocial;
|
||||||
PROVISIONING_PROFILE = "";
|
PROVISIONING_PROFILE = "34B6E084-2760-4B9B-94CE-0998083C95F5";
|
||||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
|
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "34B6E084-2760-4B9B-94CE-0998083C95F5";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
USER_HEADER_SEARCH_PATHS = "";
|
USER_HEADER_SEARCH_PATHS = "";
|
||||||
|
@ -517,12 +551,12 @@
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
GCC_C_LANGUAGE_STANDARD = c99;
|
GCC_C_LANGUAGE_STANDARD = c99;
|
||||||
GCC_VERSION = "";
|
GCC_VERSION = "";
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
PROVISIONING_PROFILE = "0C43CFE2-55C4-429A-9A03-BFB76D31630B";
|
|
||||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "0C43CFE2-55C4-429A-9A03-BFB76D31630B";
|
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
VALID_ARCHS = "armv6 armv7 i386";
|
VALID_ARCHS = "armv6 armv7 i386";
|
||||||
};
|
};
|
||||||
|
@ -532,13 +566,13 @@
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
GCC_C_LANGUAGE_STANDARD = c99;
|
GCC_C_LANGUAGE_STANDARD = c99;
|
||||||
GCC_VERSION = "";
|
GCC_VERSION = "";
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||||
PROVISIONING_PROFILE = "0C43CFE2-55C4-429A-9A03-BFB76D31630B";
|
|
||||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "DB6844BA-2943-44DB-B10A-3A3F0E8A52B8";
|
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
VALID_ARCHS = "armv6 armv7 i386";
|
VALID_ARCHS = "armv6 armv7 i386";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue