diff --git a/Constants.h b/Constants.h index a7f5a7e..d478313 100644 --- a/Constants.h +++ b/Constants.h @@ -14,6 +14,15 @@ } +#define OAUTH_CONSUMER_KEY @"JPmU8KJhiBKfpohCiWLg" +#define OAUTH_CONSUMER_SECRET @"jtfSrnDrRcUnL1nqTMcAW0055m63EMClmkxhiBjQ" +#define OAUTH_SIGNATURE_METHOD @"HMAC-SHA1" +#define OAUTH_REQUEST_TOKEN_URL @"http://twitter.com/oauth/request_token" +#define OAUTH_USER_AUTHORIZATION_URL @"http://twitter.com/oauth/authorize" +#define OAUTH_ACCESS_TOKEN_URL @"http://twitter.com/oauth/access_token" +#define OAUTH_SERVICE_NAME @"twitter.com" + +#define APP_NAME @"Twittia" #define TWEET_MAX_LENGTH 140 + (NSString *)stringFromVirtualKeyCode:(NSInteger)code; diff --git a/Controller.h b/Controller.h index b4d7b32..9217a6d 100644 --- a/Controller.h +++ b/Controller.h @@ -11,6 +11,7 @@ #import "ViewDelegate.h" #import #import "Constants.h" +#import "OAuth.h" @interface Controller : NSObject { @@ -20,6 +21,7 @@ IBOutlet NSWindow *mentionsViewWindow; IBOutlet NSMenuItem *globalHotkeyMenuItem; ViewDelegate *viewDelegate; + OAuth *oauth; } @property (retain, nonatomic) IBOutlet WebView *timelineView; @@ -28,7 +30,9 @@ @property (retain, nonatomic) IBOutlet NSWindow *mentionsViewWindow; @property (retain, nonatomic) IBOutlet NSMenuItem *globalHotkeyMenuItem; @property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate; +@property (retain, nonatomic) IBOutlet OAuth *oauth; +- (void)authentificationSucceded:(id)sender; - (void)initWebViews; - (void)initHotKeys; - (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId; diff --git a/Controller.m b/Controller.m index e7464af..5beca1b 100644 --- a/Controller.m +++ b/Controller.m @@ -12,10 +12,10 @@ @implementation Controller -@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, globalHotkeyMenuItem, viewDelegate; +@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, globalHotkeyMenuItem, viewDelegate, oauth; - (void)awakeFromNib { - [self initWebViews]; + [self initHotKeys]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; @@ -27,12 +27,20 @@ selector:@selector(sendTweet:) name:@"sendTweet" object:nil]; - + [nc addObserver:self + selector:@selector(authentificationSucceded:) + name:@"authentificationSucceded" + object:nil]; + NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; [appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; + + if ([oauth accessToken]) { + [self initWebViews]; + } } - (void)initHotKeys { @@ -60,25 +68,10 @@ if (newTweetModifierKey & optionKey) cocoaModifiers = cocoaModifiers | NSAlternateKeyMask; if (newTweetModifierKey & controlKey) cocoaModifiers = cocoaModifiers | NSControlKeyMask; if (newTweetModifierKey & cmdKey) cocoaModifiers = cocoaModifiers | NSCommandKeyMask; - - NSLog(@"%i", shiftKey); - NSInteger theNumber = cocoaModifiers; - NSMutableString *str = [NSMutableString string]; - NSInteger numberCopy = theNumber; // so you won't change your original value - for(NSInteger i = 0; i < 32 ; i++) { - // Prepend "0" or "1", depending on the bit - [str insertString:((numberCopy & 1) ? @"1" : @"0") atIndex:0]; - numberCopy >>= 1; - } - - // NSLog(@"Binary version: %@", str); - - NSLog(@"%c", kVK_ANSI_T); [globalHotkeyMenuItem setKeyEquivalent:[Constants stringFromVirtualKeyCode:newTweetKey]]; [globalHotkeyMenuItem setKeyEquivalentModifierMask:cocoaModifiers]; - /* CARBON from http://github.com/Xjs/drama-button/blob/carbon/Drama_ButtonAppDelegate.m */ EventTypeSpec eventType; @@ -97,6 +90,10 @@ /* end CARBON */ } +- (void)authentificationSucceded:(id)sender { + [self initWebViews]; +} + - (void)initWebViews { NSString *path = [[NSBundle mainBundle] resourcePath]; @@ -124,6 +121,11 @@ return NO; } ++ (BOOL)isKeyExcludedFromWebScript:(const char *)name { + return NO; +} + + #pragma mark Notifications - (IBAction)openNewTweetWindow:(id)sender { @@ -138,9 +140,15 @@ } - (void)openNewTweetWindowWithString:(NSString *)aString { - [NSApp activateIgnoringOtherApps:YES]; - MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil]; - [newTweet withString:aString]; + [NSApp activateIgnoringOtherApps:YES]; + + if ([aString hasPrefix:@"//oauth_token/"]) { + // [oauth requestAccessToken:[aString substringFromIndex:14]]; + } else { + MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil]; + [newTweet withString:aString]; + } + } - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index c118f30..fcf78f2 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -22,8 +22,9 @@ YES - + + YES @@ -775,7 +776,7 @@ 15 2 - {{235, -22}, {397, 581}} + {{712, 280}, {397, 581}} 1685586944 Twittia NSWindow @@ -842,7 +843,7 @@ 15 2 - {{235, -22}, {376, 581}} + {{1077, 328}, {376, 581}} 1685586944 Mentions NSWindow @@ -903,6 +904,97 @@ {1.79769e+308, 1.79769e+308} mentions + + 29 + 2 + {{787, 515}, {324, 89}} + 611845120 + Twitter PIN + NSPanel + + {1.79769e+308, 1.79769e+308} + + + 256 + + YES + + + 270 + {{20, 20}, {182, 49}} + + YES + + -1804468671 + 138413056 + + + LucidaGrande + 36 + 16 + + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + 3 + MAA + + + + YES + NSAllRomanInputSourcesLocaleIdentifier + + + + + + 265 + {{214, 26}, {96, 32}} + + YES + + 67239424 + 134217728 + Ok + + LucidaGrande + 13 + 1044 + + + -2038284033 + 129 + + + DQ + 200 + 25 + + + + {324, 89} + + + {{0, 0}, {1920, 1178}} + {1.79769e+308, 1.79769e+308} + twitter-pin + + + OAuth + @@ -1331,6 +1423,46 @@ 570 + + + oauth + + + + 578 + + + + twitterPINField + + + + 581 + + + + requestAccessTokenWithPIN: + + + + 582 + + + + requestAccessTokenWithPIN: + + + + 583 + + + + twitterPINPanel + + + + 584 + @@ -1973,6 +2105,58 @@ + + 571 + + + YES + + + + + + 572 + + + YES + + + + + + + 573 + + + YES + + + + + + 574 + + + + + 575 + + + YES + + + + + + 576 + + + + + 577 + + + @@ -2136,6 +2320,15 @@ 57.IBPluginDependency 57.ImportedFromIB2 57.editorWindowContentRectSynchronizationRect + 571.IBEditorWindowLastContentRect + 571.IBPluginDependency + 571.IBWindowTemplateEditedContentRect + 571.NSWindowTemplate.visibleAtLaunch + 572.IBPluginDependency + 573.IBPluginDependency + 574.IBPluginDependency + 575.IBPluginDependency + 576.IBPluginDependency 58.IBPluginDependency 58.ImportedFromIB2 72.IBPluginDependency @@ -2302,9 +2495,9 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{460, 356}, {376, 581}} + {{226, 247}, {376, 581}} com.apple.InterfaceBuilder.CocoaPlugin - {{460, 356}, {376, 581}} + {{226, 247}, {376, 581}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2314,6 +2507,15 @@ com.apple.InterfaceBuilder.CocoaPlugin {{23, 794}, {245, 183}} + {{866, 734}, {324, 89}} + com.apple.InterfaceBuilder.CocoaPlugin + {{866, 734}, {324, 89}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2350,7 +2552,7 @@ - 570 + 584 @@ -2358,6 +2560,10 @@ Controller NSObject + + authentificationSucceded: + id + YES @@ -2365,6 +2571,7 @@ globalHotkeyMenuItem mentionsView mentionsViewWindow + oauth timelineView timelineViewWindow viewDelegate @@ -2374,6 +2581,7 @@ NSMenuItem WebView NSWindow + OAuth WebView NSWindow ViewDelegate @@ -2384,6 +2592,31 @@ Controller.h + + OAuth + NSObject + + requestAccessTokenWithPIN: + id + + + YES + + YES + twitterPINField + twitterPINPanel + + + YES + NSTextField + NSPanel + + + + IBProjectSource + OAuth.h + + ViewDelegate NSObject @@ -2425,6 +2658,14 @@ YES + + NSActionCell + NSCell + + IBFrameworkSource + AppKit.framework/Headers/NSActionCell.h + + NSApplication NSResponder @@ -2476,6 +2717,30 @@ AppKit.framework/Headers/NSBrowser.h + + NSButton + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSButton.h + + + + NSButtonCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSButtonCell.h + + + + NSCell + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSCell.h + + NSControl NSView @@ -2889,6 +3154,14 @@ WebKit.framework/Headers/WebUIDelegate.h + + NSPanel + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSPanel.h + + NSResponder @@ -2917,6 +3190,22 @@ AppKit.framework/Headers/NSText.h + + NSTextField + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSTextField.h + + + + NSTextFieldCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSTextFieldCell.h + + NSTextView NSText diff --git a/OAToken+WebView.h b/OAToken+WebView.h new file mode 100644 index 0000000..5552cc3 --- /dev/null +++ b/OAToken+WebView.h @@ -0,0 +1,15 @@ +// +// OAToken+WebView.h +// Twittia 2 +// +// Created by Jeena on 02.05.10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import + + +@interface OAToken(WebView) + +@end diff --git a/OAToken+WebView.m b/OAToken+WebView.m new file mode 100644 index 0000000..b89651d --- /dev/null +++ b/OAToken+WebView.m @@ -0,0 +1,23 @@ +// +// OAToken+WebView.m +// Twittia 2 +// +// Created by Jeena on 02.05.10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "OAToken+WebView.h" + + +// this is just so the JavaScript can get the tokens. +@implementation OAToken(WebView) + ++ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { + return NO; +} + ++ (BOOL)isKeyExcludedFromWebScript:(const char *)name { + return NO; +} + +@end diff --git a/OAuth.h b/OAuth.h new file mode 100644 index 0000000..75acbe3 --- /dev/null +++ b/OAuth.h @@ -0,0 +1,33 @@ +// +// OAuth.h +// Twittia 2 +// +// Created by Jeena on 01.05.10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import +#import +#import +#import "OAToken+WebView.h" + + +@interface OAuth : NSObject { + OAToken *requestToken; + OAToken *accessToken; + OAToken *consumerToken; + OAConsumer *consumer; + IBOutlet NSTextField *twitterPINField; + IBOutlet NSPanel *twitterPINPanel; +} + +@property (nonatomic, retain) OAToken *accessToken; +@property (nonatomic, retain) OAToken *consumerToken; +@property (nonatomic, retain) IBOutlet NSTextField *twitterPINField; +@property (nonatomic, retain) IBOutlet NSPanel *twitterPINPanel; + +- (id)init; +- (void)requestAToken; +- (IBAction)requestAccessTokenWithPIN:(id)sender; + +@end diff --git a/OAuth.m b/OAuth.m new file mode 100644 index 0000000..51b60fd --- /dev/null +++ b/OAuth.m @@ -0,0 +1,151 @@ +// +// OAuth.m +// Twittia 2 +// +// Created by Jeena on 01.05.10. +// Copyright 2010 __MyCompanyName__. All rights reserved. +// + +#import "OAuth.h" +#import "Constants.h" +#import +#import +#import +#import + + +@implementation OAuth + +@synthesize accessToken, consumerToken, twitterPINField, twitterPINPanel; + ++ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { + return NO; +} + ++ (BOOL)isKeyExcludedFromWebScript:(const char *)name { + return NO; +} + +-(id)init { + if (self = [super init]) { + self.consumerToken = [[OAToken alloc] initWithKey:OAUTH_CONSUMER_KEY secret:OAUTH_CONSUMER_SECRET]; + self.accessToken = [[OAToken alloc] initWithUserDefaultsUsingServiceProviderName:OAUTH_SERVICE_NAME prefix:APP_NAME]; + } + + return self; +} + +- (void)dealloc { + [consumerToken release]; + [accessToken release]; + [consumer release]; + [super dealloc]; +} + +- (void)awakeFromNib { + if (!self.accessToken) { + [self requestAToken]; + } +} + +-(void)requestAToken { + consumer = [[OAConsumer alloc] initWithKey:OAUTH_CONSUMER_KEY secret:OAUTH_CONSUMER_SECRET]; + + NSURL *url = [NSURL URLWithString:OAUTH_REQUEST_TOKEN_URL]; + + OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url + consumer:consumer + token:nil // we don't have a Token yet + realm:nil // our service provider doesn't specify a realm + signatureProvider:nil]; // use the default method, HMAC-SHA1 + + [request setHTTPMethod:@"POST"]; + + OADataFetcher *fetcher = [[OADataFetcher alloc] init]; + + [fetcher fetchDataWithRequest:request + delegate:self + didFinishSelector:@selector(requestTokenTicket:didFinishWithData:) + didFailSelector:@selector(requestTokenTicket:didFailWithError:)]; +} + +- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data { + if (ticket.didSucceed) { + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; + requestToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody]; + + // show PIN panel + [twitterPINPanel makeKeyAndOrderFront:self]; + + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?oauth_token=%@", OAUTH_USER_AUTHORIZATION_URL, requestToken.key]]; + [[NSWorkspace sharedWorkspace] openURL:url]; + } +} + +- (void)requestTokenTicket:(OAServiceTicket *)ticket didFailWithError:(NSError *)error { + NSLog(@"ERROR: %@", error); +} + +- (void)requestAccessTokenWithPIN:(id)sender { + + [twitterPINPanel resignKeyWindow]; + [twitterPINPanel close]; + + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?oauth_verifier=%@", OAUTH_ACCESS_TOKEN_URL, [twitterPINField stringValue]]]; + + OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url + consumer:consumer + token:requestToken // we don't have a Token yet + realm:nil // our service provider doesn't specify a realm + signatureProvider:nil]; // use the default method, HMAC-SHA1 + + [request setHTTPMethod:@"POST"]; + + + OADataFetcher *fetcher = [[OADataFetcher alloc] init]; + [fetcher fetchDataWithRequest:request + delegate:self + didFinishSelector:@selector(accessTokenTicket:didFinishWithData:) + didFailSelector:@selector(requestTokenTicket:didFailWithError:)]; + + +} + +- (void)accessTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data { + if (ticket.didSucceed) { + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; + accessToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody]; + [accessToken storeInUserDefaultsWithServiceProviderName:OAUTH_SERVICE_NAME prefix:APP_NAME]; + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc postNotificationName:@"authentificationSucceded" object:self]; + + /* + NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/home_timeline.json"]; + OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url + consumer:consumer + token:accessToken + realm:nil + signatureProvider:nil]; + + OADataFetcher *fetcher = [[OADataFetcher alloc] init]; + [fetcher fetchDataWithRequest:request + delegate:self + didFinishSelector:@selector(apiTicket:didFinishWithData:) + didFailSelector:@selector(requestTokenTicket:didFailWithError:)]; + */ + } +} + +- (void)apiTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data { + if (ticket.didSucceed) { + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; + NSLog(@"%@", responseBody); + } +} + + + +@end diff --git a/OAuthConsumer.framework/Headers b/OAuthConsumer.framework/Headers new file mode 120000 index 0000000..a177d2a --- /dev/null +++ b/OAuthConsumer.framework/Headers @@ -0,0 +1 @@ +Versions/Current/Headers \ No newline at end of file diff --git a/OAuthConsumer.framework/OAuthConsumer b/OAuthConsumer.framework/OAuthConsumer new file mode 120000 index 0000000..c0f839d --- /dev/null +++ b/OAuthConsumer.framework/OAuthConsumer @@ -0,0 +1 @@ +Versions/Current/OAuthConsumer \ No newline at end of file diff --git a/OAuthConsumer.framework/Resources b/OAuthConsumer.framework/Resources new file mode 120000 index 0000000..953ee36 --- /dev/null +++ b/OAuthConsumer.framework/Resources @@ -0,0 +1 @@ +Versions/Current/Resources \ No newline at end of file diff --git a/OAuthConsumer.framework/Versions/A/Headers/NSMutableURLRequest+Parameters.h b/OAuthConsumer.framework/Versions/A/Headers/NSMutableURLRequest+Parameters.h new file mode 100644 index 0000000..13bf9af --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/NSMutableURLRequest+Parameters.h @@ -0,0 +1,35 @@ +// +// NSMutableURLRequest+Parameters.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 +#import "OARequestParameter.h" +#import "NSURL+Base.h" + + +@interface NSMutableURLRequest (OAParameterAdditions) + +- (NSArray *)parameters; +- (void)setParameters:(NSArray *)parameters; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/NSString+URLEncoding.h b/OAuthConsumer.framework/Versions/A/Headers/NSString+URLEncoding.h new file mode 100644 index 0000000..de06fe7 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/NSString+URLEncoding.h @@ -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 + + +@interface NSString (OAURLEncodingAdditions) + +- (NSString *)URLEncodedString; +- (NSString *)URLDecodedString; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/NSURL+Base.h b/OAuthConsumer.framework/Versions/A/Headers/NSURL+Base.h new file mode 100644 index 0000000..5d12b69 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/NSURL+Base.h @@ -0,0 +1,34 @@ +// +// NSURL+Base.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 + + +@interface NSURL (OABaseAdditions) + +- (NSString *)URLStringWithoutQuery; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAAsynchronousDataFetcher.h b/OAuthConsumer.framework/Versions/A/Headers/OAAsynchronousDataFetcher.h new file mode 100644 index 0000000..83089f3 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAAsynchronousDataFetcher.h @@ -0,0 +1,45 @@ +// +// OAAsynchronousDataFetcher.h +// OAuthConsumer +// +// Created by Zsombor Szabó on 12/3/08. +// +// 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 + +#import "OAMutableURLRequest.h" + +@interface OAAsynchronousDataFetcher : NSObject { + OAMutableURLRequest *request; + NSURLResponse *response; + NSURLConnection *connection; + NSMutableData *responseData; + id delegate; + SEL didFinishSelector; + SEL didFailSelector; +} + ++ (id)asynchronousFetcherWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector; +- (id)initWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector; + +- (void)start; +- (void)cancel; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAConsumer.h b/OAuthConsumer.framework/Versions/A/Headers/OAConsumer.h new file mode 100644 index 0000000..73bdab6 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAConsumer.h @@ -0,0 +1,40 @@ +// +// 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 + + +@interface OAConsumer : NSObject { +@protected + NSString *key; + NSString *secret; +} +@property(retain) NSString *key; +@property(retain) NSString *secret; + +- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OADataFetcher.h b/OAuthConsumer.framework/Versions/A/Headers/OADataFetcher.h new file mode 100644 index 0000000..f2c0240 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OADataFetcher.h @@ -0,0 +1,45 @@ +// +// OADataFetcher.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 +#import "OAMutableURLRequest.h" +#import "OAServiceTicket.h" + + +@interface OADataFetcher : NSObject { +@private + OAMutableURLRequest *request; + NSURLResponse *response; + NSURLConnection *connection; + NSError *error; + NSData *responseData; + id delegate; + SEL didFinishSelector; + SEL didFailSelector; +} + +- (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAHMAC_SHA1SignatureProvider.h b/OAuthConsumer.framework/Versions/A/Headers/OAHMAC_SHA1SignatureProvider.h new file mode 100644 index 0000000..d259c4e --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAHMAC_SHA1SignatureProvider.h @@ -0,0 +1,32 @@ +// +// 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 +#import "OASignatureProviding.h" + + +@interface OAHMAC_SHA1SignatureProvider : NSObject +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAMutableURLRequest.h b/OAuthConsumer.framework/Versions/A/Headers/OAMutableURLRequest.h new file mode 100644 index 0000000..fdf0a1a --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAMutableURLRequest.h @@ -0,0 +1,68 @@ +// +// 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 +#import "OAConsumer.h" +#import "OAToken.h" +#import "OAHMAC_SHA1SignatureProvider.h" +#import "OASignatureProviding.h" +#import "NSMutableURLRequest+Parameters.h" +#import "NSURL+Base.h" + + +@interface OAMutableURLRequest : NSMutableURLRequest { +@protected + OAConsumer *consumer; + OAToken *token; + NSString *realm; + NSString *signature; + id signatureProvider; + NSString *nonce; + NSString *timestamp; + NSMutableDictionary *extraOAuthParameters; +} +@property(readonly) NSString *signature; +@property(readonly) NSString *nonce; + +- (id)initWithURL:(NSURL *)aUrl + consumer:(OAConsumer *)aConsumer + token:(OAToken *)aToken + realm:(NSString *)aRealm +signatureProvider:(id)aProvider; + +- (id)initWithURL:(NSURL *)aUrl + consumer:(OAConsumer *)aConsumer + token:(OAToken *)aToken + realm:(NSString *)aRealm +signatureProvider:(id)aProvider + nonce:(NSString *)aNonce + timestamp:(NSString *)aTimestamp; + +- (void)prepare; + +- (void)setOAuthParameterName:(NSString*)parameterName withValue:(NSString*)parameterValue; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAPlaintextSignatureProvider.h b/OAuthConsumer.framework/Versions/A/Headers/OAPlaintextSignatureProvider.h new file mode 100644 index 0000000..96bb2f2 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAPlaintextSignatureProvider.h @@ -0,0 +1,31 @@ +// +// OAPlaintextSignatureProvider.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 +#import "OASignatureProviding.h" + +@interface OAPlaintextSignatureProvider : NSObject +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OARequestParameter.h b/OAuthConsumer.framework/Versions/A/Headers/OARequestParameter.h new file mode 100644 index 0000000..03eee3e --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OARequestParameter.h @@ -0,0 +1,45 @@ +// +// 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 +#import "NSString+URLEncoding.h" + + +@interface OARequestParameter : NSObject { +@protected + NSString *name; + NSString *value; +} +@property(retain) NSString *name; +@property(retain) NSString *value; + ++ (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue; +- (id)initWithName:(NSString *)aName value:(NSString *)aValue; +- (NSString *)URLEncodedName; +- (NSString *)URLEncodedValue; +- (NSString *)URLEncodedNameValuePair; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAServiceTicket.h b/OAuthConsumer.framework/Versions/A/Headers/OAServiceTicket.h new file mode 100644 index 0000000..69196df --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAServiceTicket.h @@ -0,0 +1,43 @@ +// +// 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 +#import "OAMutableURLRequest.h" + + +@interface OAServiceTicket : NSObject { +@private + OAMutableURLRequest *request; + NSURLResponse *response; + BOOL didSucceed; +} +@property(retain) OAMutableURLRequest *request; +@property(retain) NSURLResponse *response; +@property(assign) BOOL didSucceed; + +- (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OASignatureProviding.h b/OAuthConsumer.framework/Versions/A/Headers/OASignatureProviding.h new file mode 100644 index 0000000..0c7e4f8 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OASignatureProviding.h @@ -0,0 +1,34 @@ +// +// OASignatureProviding.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 + + +@protocol OASignatureProviding + +- (NSString *)name; +- (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAToken.h b/OAuthConsumer.framework/Versions/A/Headers/OAToken.h new file mode 100644 index 0000000..8dd331e --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAToken.h @@ -0,0 +1,41 @@ +// +// 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 + +@interface OAToken : NSObject { +@protected + NSString *key; + NSString *secret; +} +@property(retain) NSString *key; +@property(retain) NSString *secret; + +- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret; +- (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix; +- (id)initWithHTTPResponseBody:(NSString *)body; +- (int)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAToken_KeychainExtensions.h b/OAuthConsumer.framework/Versions/A/Headers/OAToken_KeychainExtensions.h new file mode 100644 index 0000000..abcb274 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAToken_KeychainExtensions.h @@ -0,0 +1,19 @@ +// +// OAToken_KeychainExtensions.h +// TouchTheFireEagle +// +// Created by Jonathan Wight on 04/04/08. +// Copyright 2008 __MyCompanyName__. All rights reserved. +// + +#import "OAToken.h" + +#import + +@interface OAToken (OAToken_KeychainExtensions) + +- (id)initWithKeychainUsingAppName:(NSString *)name serviceProviderName:(NSString *)provider; +- (int)storeInDefaultKeychainWithAppName:(NSString *)name serviceProviderName:(NSString *)provider; +- (int)storeInKeychain:(SecKeychainRef)keychain appName:(NSString *)name serviceProviderName:(NSString *)provider; + +@end diff --git a/OAuthConsumer.framework/Versions/A/Headers/OAuthConsumer.h b/OAuthConsumer.framework/Versions/A/Headers/OAuthConsumer.h new file mode 100644 index 0000000..cf9aab0 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Headers/OAuthConsumer.h @@ -0,0 +1,39 @@ +// +// 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. + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import \ No newline at end of file diff --git a/OAuthConsumer.framework/Versions/A/OAuthConsumer b/OAuthConsumer.framework/Versions/A/OAuthConsumer new file mode 100755 index 0000000..3275e1a Binary files /dev/null and b/OAuthConsumer.framework/Versions/A/OAuthConsumer differ diff --git a/OAuthConsumer.framework/Versions/A/Resources/English.lproj/InfoPlist.strings b/OAuthConsumer.framework/Versions/A/Resources/English.lproj/InfoPlist.strings new file mode 100644 index 0000000..514729a Binary files /dev/null and b/OAuthConsumer.framework/Versions/A/Resources/English.lproj/InfoPlist.strings differ diff --git a/OAuthConsumer.framework/Versions/A/Resources/Info.plist b/OAuthConsumer.framework/Versions/A/Resources/Info.plist new file mode 100644 index 0000000..23f6877 --- /dev/null +++ b/OAuthConsumer.framework/Versions/A/Resources/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + OAuthConsumer + CFBundleIdentifier + net.oauth.OAuthConsumer + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + OAuthConsumer + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 0.1.1 + + diff --git a/OAuthConsumer.framework/Versions/Current b/OAuthConsumer.framework/Versions/Current new file mode 120000 index 0000000..8c7e5a6 --- /dev/null +++ b/OAuthConsumer.framework/Versions/Current @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/Twittia 2.xcodeproj/project.pbxproj b/Twittia 2.xcodeproj/project.pbxproj index 4ace8f8..d042456 100644 --- a/Twittia 2.xcodeproj/project.pbxproj +++ b/Twittia 2.xcodeproj/project.pbxproj @@ -12,6 +12,9 @@ 1F1990C6117BCA960049BEA7 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1990C5117BCA960049BEA7 /* ApplicationServices.framework */; }; 1F3642EF118C8C35008198EF /* oauth.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F3642ED118C8C35008198EF /* oauth.js */; }; 1F3642F0118C8C35008198EF /* sha1.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F3642EE118C8C35008198EF /* sha1.js */; }; + 1F364398118CBC77008198EF /* OAuth.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F364397118CBC77008198EF /* OAuth.m */; }; + 1F36440F118CC173008198EF /* OAuthConsumer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F36440E118CC173008198EF /* OAuthConsumer.framework */; }; + 1F36465E118DA5A7008198EF /* OAToken+WebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F36465D118DA5A7008198EF /* OAToken+WebView.m */; }; 1F4673FE1180F7EA006CC37C /* TwittiaCore.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F4673E61180F654006CC37C /* TwittiaCore.js */; }; 1F4674081180F7EE006CC37C /* jQuery.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F4673E21180F519006CC37C /* jQuery.js */; }; 1F4674091180F7F3006CC37C /* jQuery-Plugins.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F4673E41180F590006CC37C /* jQuery-Plugins.js */; }; @@ -59,6 +62,11 @@ 1F1990E1117BD2650049BEA7 /* ReleaseNotes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ReleaseNotes.html; sourceTree = ""; }; 1F3642ED118C8C35008198EF /* oauth.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = oauth.js; sourceTree = ""; }; 1F3642EE118C8C35008198EF /* sha1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = sha1.js; sourceTree = ""; }; + 1F364396118CBC77008198EF /* OAuth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAuth.h; sourceTree = ""; }; + 1F364397118CBC77008198EF /* OAuth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAuth.m; sourceTree = ""; }; + 1F36440E118CC173008198EF /* OAuthConsumer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = OAuthConsumer.framework; sourceTree = ""; }; + 1F36465C118DA5A7008198EF /* OAToken+WebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OAToken+WebView.h"; sourceTree = ""; }; + 1F36465D118DA5A7008198EF /* OAToken+WebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "OAToken+WebView.m"; sourceTree = ""; }; 1F4673E21180F519006CC37C /* jQuery.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jQuery.js; sourceTree = ""; }; 1F4673E41180F590006CC37C /* jQuery-Plugins.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "jQuery-Plugins.js"; sourceTree = ""; }; 1F4673E61180F654006CC37C /* TwittiaCore.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = TwittiaCore.js; sourceTree = ""; }; @@ -93,6 +101,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 1F36440F118CC173008198EF /* OAuthConsumer.framework in Frameworks */, 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */, 1FFA37071177DAF4006C8562 /* WebKit.framework in Frameworks */, 1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */, @@ -107,6 +116,7 @@ 1058C7A6FEA54F5311CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( + 1F36440E118CC173008198EF /* OAuthConsumer.framework */, 1FE2FC92117A818D000504B0 /* Sparkle.framework */, 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */, 1FFA37061177DAF4006C8562 /* WebKit.framework */, @@ -172,8 +182,12 @@ 1FFA36D51177D879006C8562 /* ViewDelegate.m */, 2A37F4AEFDCFA73011CA2CEA /* MyDocument.h */, 2A37F4ACFDCFA73011CA2CEA /* MyDocument.m */, + 1F364396118CBC77008198EF /* OAuth.h */, + 1F364397118CBC77008198EF /* OAuth.m */, 1F77DB45118C5F1C007C7F1E /* Constants.h */, 1F77DB46118C5F1C007C7F1E /* Constants.m */, + 1F36465C118DA5A7008198EF /* OAToken+WebView.h */, + 1F36465D118DA5A7008198EF /* OAToken+WebView.m */, ); name = Classes; sourceTree = ""; @@ -286,6 +300,8 @@ 1FFA36D71177D879006C8562 /* Controller.m in Sources */, 1FFA36D81177D879006C8562 /* ViewDelegate.m in Sources */, 1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */, + 1F364398118CBC77008198EF /* OAuth.m in Sources */, + 1F36465E118DA5A7008198EF /* OAToken+WebView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -336,6 +352,7 @@ "$(inherited)", "\"$(SRCROOT)\"", "\"$(SRCROOT)/../../Desktop/mpoauthconnection-read-only/build/Release\"", + "\"$(SRCROOT)/../oauth-obj-c/OAuthConsumer/build/Release\"", ); GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; @@ -358,6 +375,7 @@ "$(inherited)", "\"$(SRCROOT)\"", "\"$(SRCROOT)/../../Desktop/mpoauthconnection-read-only/build/Release\"", + "\"$(SRCROOT)/../oauth-obj-c/OAuthConsumer/build/Release\"", ); GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/TwittiaCore.js b/TwittiaCore.js index 5529eea..93cf783 100644 --- a/TwittiaCore.js +++ b/TwittiaCore.js @@ -1,10 +1,8 @@ -function Twittia(action, oauth_key, oauth_secret) { +function Twittia(action) { this.max_length = 100; this.since_id; this.timeout = 2 * 60 * 1000; this.action = action; - this.oauth_key = oauth_key; - this.oauth_secret = oauth_secret; this.getNewData(); this.unread_mentions = 0; @@ -170,35 +168,66 @@ Twittia.prototype.getTemplate = function() { return jQuery.extend(true, {}, this.template); } + Twittia.prototype.getNewData = function(supress_new_with_timeout) { var url = "http://api.twitter.com/1/statuses/" + this.action + ".json" - url += "?count=" + this.max_length; - if(this.since_id) url += "&since_id=" + this.since_id; + var parameters = {count: this.max_length} + if(this.since_id) parameters.since_id = this.since_id + var url2 = "?count=" + this.max_length; + if(this.since_id) url2 += "&since_id=" + this.since_id; var _this = this; + + var message = { method:"GET" , action:url, parameters: parameters }; + + OAuth.completeRequest(message, + { consumerKey : controller.oauth.consumerToken.key + , consumerSecret: controller.oauth.consumerToken.secret + , token : controller.oauth.accessToken.key + , tokenSecret : controller.oauth.accessToken.secret + }); - $.ajax({ - url: url, - dataType: 'json', - success: function(data) { - _this.newStatus(data, supress_new_with_timeout); - }, - error:function (xhr, ajaxOptions, thrownError){ - alert(xhr.status); - alert(thrownError); - setTimeout(function() { _this.getNewData(supress_new_with_timeout) }, this.timeout); - } + $.ajax( + { beforeSend: function(xhr) { + xhr.setRequestHeader("Authorization", OAuth.getAuthorizationHeader("", message.parameters)); + }, + url: url + url2, + dataType: 'json', + success: function(data) { + _this.newStatus(data, supress_new_with_timeout); + }, + error:function (xhr, ajaxOptions, thrownError){ + alert(xhr.status); + alert(thrownError); + setTimeout(function() { _this.getNewData(supress_new_with_timeout) }, this.timeout); + } }); } Twittia.prototype.sendNewTweet = function(tweet, in_reply_to_status_id) { var url = "http://api.twitter.com/1/statuses/update.json"; - var _this = this; var data = "source=twittia&status=" + tweet; if(in_reply_to_status_id != '') data += "&in_reply_to_status_id=" + in_reply_to_status_id + var parameters = { source: "twittia", status: tweet }; + if(in_reply_to_status_id != '') parameters.in_reply_to_status_id = in_reply_to_status_id + + var _this = this; + + var message = { method:"POST" , action:url, parameters: parameters }; + + OAuth.completeRequest(message, + { consumerKey : controller.oauth.consumerToken.key + , consumerSecret: controller.oauth.consumerToken.secret + , token : controller.oauth.accessToken.key + , tokenSecret : controller.oauth.accessToken.secret + }); + $.ajax({ + beforeSend: function(xhr) { + xhr.setRequestHeader("Authorization", OAuth.getAuthorizationHeader("", message.parameters)); + }, url: url, type: 'POST', data: data, @@ -231,6 +260,29 @@ Twittia.prototype.retweet = function(status_id, item) { }); } +Twittia.prototype.authorizationHeader = function(method, url, params) { + if(params == undefined) + params = ''; + if(method == undefined) + method = 'GET'; + var timestamp = OAuth.timestamp(); + var nonce = OAuth.nonce(11); + var accessor = { consumerSecret: controller.oauth.consumerToken.secret, tokenSecret: controller.oauth.accessToken.secret }; + + var message = {method: method, action: url, parameters: OAuth.decodeForm(params)}; + message.parameters.push(['oauth_consumer_key',controller.oauth.consumerToken.key]); + message.parameters.push(['oauth_nonce',nonce]); + message.parameters.push(['oauth_signature_method','HMAC-SHA1']); + message.parameters.push(['oauth_timestamp',timestamp]); + message.parameters.push(['oauth_token', controller.oauth.accessToken.key]); + message.parameters.push(['oauth_version','1.0']); + message.parameters.sort() + + OAuth.SignatureMethod.sign(message, accessor); + + return OAuth.getAuthorizationHeader("", message.parameters); +} + function replaceURLWithHTMLLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; return text.replace(exp,"$1"); @@ -254,4 +306,5 @@ function loadPlugin(url) { document.getElementsByTagName("head")[0].appendChild(plugin); } + var twittia_instance; \ No newline at end of file diff --git a/Twittia_2-Info.plist b/Twittia_2-Info.plist index 538a5c6..a212f6e 100644 --- a/Twittia_2-Info.plist +++ b/Twittia_2-Info.plist @@ -40,9 +40,9 @@ CFBundleSignature ???? CFBundleVersion - 2.1.1 + 2.2.0 CFBundleShortVersionString - 2.1.1 + 2.2.0 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSMainNibFile