diff --git a/Appcast.xml b/Appcast.xml index 92ba43a..e36d0ff 100755 --- a/Appcast.xml +++ b/Appcast.xml @@ -6,15 +6,15 @@ Most recent changes with links to updates. en - Version 2.1.2 + Version 2.2.0 10.5.0 http://jeenaparadies.net/twittia/ReleaseNotes.html - Tue, 04 May 2010 10:05:22 +0200 - + Sun, 16 May 2010 12:39:02 +0200 + diff --git a/Constants.h b/Constants.h index a7f5a7e..99ab1e7 100644 --- a/Constants.h +++ b/Constants.h @@ -3,7 +3,7 @@ // Twittia 2 // // Created by Jeena on 01.05.10. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Licence: BSD (see attached LICENCE.txt file). // #import @@ -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/Constants.m b/Constants.m index 0cc9e39..67a3dad 100644 --- a/Constants.m +++ b/Constants.m @@ -3,7 +3,7 @@ // Twittia 2 // // Created by Jeena on 01.05.10. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Licence: BSD (see attached LICENCE.txt file). // #import "Constants.h" diff --git a/Controller.h b/Controller.h index b4d7b32..577505c 100644 --- a/Controller.h +++ b/Controller.h @@ -11,6 +11,7 @@ #import "ViewDelegate.h" #import #import "Constants.h" +#import "OAuth.h" @interface Controller : NSObject { @@ -19,7 +20,9 @@ IBOutlet WebView *mentionsView; IBOutlet NSWindow *mentionsViewWindow; IBOutlet NSMenuItem *globalHotkeyMenuItem; + IBOutlet NSImageView *logoLayer; ViewDelegate *viewDelegate; + OAuth *oauth; } @property (retain, nonatomic) IBOutlet WebView *timelineView; @@ -27,8 +30,11 @@ @property (retain, nonatomic) IBOutlet WebView *mentionsView; @property (retain, nonatomic) IBOutlet NSWindow *mentionsViewWindow; @property (retain, nonatomic) IBOutlet NSMenuItem *globalHotkeyMenuItem; +@property (retain, nonatomic) IBOutlet NSImageView *logoLayer; @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 a9602e2..4f7ede1 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, logoLayer; - (void)awakeFromNib { - [self initWebViews]; + [self initHotKeys]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; @@ -27,12 +27,24 @@ selector:@selector(sendTweet:) name:@"sendTweet" object:nil]; - + [nc addObserver:self + selector:@selector(authentificationSucceded:) + name:@"authentificationSucceded" + object:nil]; + [nc addObserver:self + selector:@selector(getTweetUpdates:) + name:@"getTweetUpdates" + object:nil]; + NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; [appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; + + if ([oauth accessToken]) { + [self initWebViews]; + } } - (void)initHotKeys { @@ -42,6 +54,7 @@ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSInteger defaultsNewTweetKey = (NSInteger)[defaults integerForKey:@"newTweetKey"]; + if ([defaults objectForKey:@"newTweetKey"] != nil) { newTweetKey = defaultsNewTweetKey; } else { @@ -55,6 +68,8 @@ [defaults setInteger:newTweetModifierKey forKey:@"newTweetModifierKey"]; } + [defaults synchronize]; + NSUInteger cocoaModifiers = 0; if (newTweetModifierKey & shiftKey) cocoaModifiers = cocoaModifiers | NSShiftKeyMask; if (newTweetModifierKey & optionKey) cocoaModifiers = cocoaModifiers | NSAlternateKeyMask; @@ -64,7 +79,6 @@ [globalHotkeyMenuItem setKeyEquivalent:[Constants stringFromVirtualKeyCode:newTweetKey]]; [globalHotkeyMenuItem setKeyEquivalentModifierMask:cocoaModifiers]; - /* CARBON from http://github.com/Xjs/drama-button/blob/carbon/Drama_ButtonAppDelegate.m */ EventTypeSpec eventType; @@ -83,6 +97,10 @@ /* end CARBON */ } +- (void)authentificationSucceded:(id)sender { + [self initWebViews]; +} + - (void)initWebViews { NSString *path = [[NSBundle mainBundle] resourcePath]; @@ -104,12 +122,19 @@ [mentionsView setPolicyDelegate:viewDelegate]; [mentionsView setUIDelegate:viewDelegate]; [[mentionsView windowScriptObject] setValue:self forKey:@"controller"]; + + [logoLayer removeFromSuperview]; } + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { return NO; } ++ (BOOL)isKeyExcludedFromWebScript:(const char *)name { + return NO; +} + + #pragma mark Notifications - (IBAction)openNewTweetWindow:(id)sender { @@ -124,9 +149,19 @@ } - (void)openNewTweetWindowWithString:(NSString *)aString { - [NSApp activateIgnoringOtherApps:YES]; - MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil]; - [newTweet withString:aString]; + [NSApp activateIgnoringOtherApps:YES]; + + NSRange range = [aString rangeOfString:@"oauth_token"]; + + if (range.length > 0) { + NSLog(@"test 3 %@", oauth); + + [oauth requestAccessToken]; + } else { + MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil]; + [newTweet withString:aString]; + } + } - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { @@ -135,11 +170,14 @@ } - (IBAction)sendTweet:(id)sender { - NSString *encodedString = [[[sender object] objectAtIndex:0] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; - [timelineView stringByEvaluatingJavaScriptFromString: - [NSString stringWithFormat:@"twittia_instance.sendNewTweet(\"%@\", \"%@\")", - [encodedString stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], - [[sender object] objectAtIndex:1]]]; + + NSString *replyToId; + if (![[[sender object] objectAtIndex:1] isEqualTo:@""]) { + replyToId = [[[sender object] objectAtIndex:1] stringValue]; + } + + [oauth updateTweet:[[sender object] objectAtIndex:0] inReplaToStatus:replyToId]; + } - (NSString *)pluginURL { @@ -154,8 +192,10 @@ - (void)unreadMentions:(NSInteger)count { if (![mentionsViewWindow isVisible] && count > 0) { [timelineViewWindow setTitle:[NSString stringWithFormat:@"Twittia (@%i)", count]]; + [[[NSApplication sharedApplication] dockTile] setBadgeLabel:[NSString stringWithFormat:@"%i", count]]; } else { [timelineViewWindow setTitle:[NSString stringWithFormat:@"Twittia"]]; + [[[NSApplication sharedApplication] dockTile] setBadgeLabel:nil]; [mentionsView stringByEvaluatingJavaScriptFromString:@"twittia_instance.unread_mentions = 0;"]; } } @@ -167,6 +207,11 @@ } } +- (void)getTweetUpdates:(id)sender { + [timelineView stringByEvaluatingJavaScriptFromString:@"twittia_instance.getNewData(true)"]; + [mentionsView stringByEvaluatingJavaScriptFromString:@"twittia_instance.getNewData(true)"]; +} + /* CARBON */ diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index c118f30..4fc797f 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -22,8 +22,8 @@ YES + - YES @@ -775,7 +775,7 @@ 15 2 - {{235, -22}, {397, 581}} + {{712, 280}, {397, 581}} 1685586944 Twittia NSWindow @@ -828,6 +828,43 @@ NO YES + + + 274 + + YES + + YES + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + NSFilenamesPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT TIFF v4.0 pasteboard type + + + {{17, 17}, {363, 547}} + + YES + + 67239424 + 33554432 + + NSImage + Icon + + + LucidaGrande + 13 + 1044 + + 0 + 3 + 0 + NO + + YES + {397, 581} @@ -842,7 +879,7 @@ 15 2 - {{235, -22}, {376, 581}} + {{1077, 328}, {376, 581}} 1685586944 Mentions NSWindow @@ -903,6 +940,9 @@ {1.79769e+308, 1.79769e+308} mentions + + OAuth + @@ -1331,6 +1371,22 @@ 570 + + + logoLayer + + + + 589 + + + + oauth + + + + 591 + @@ -1920,6 +1976,7 @@ YES + @@ -1973,6 +2030,25 @@ + + 587 + + + YES + + + + + + 588 + + + + + 590 + + + @@ -2138,6 +2214,10 @@ 57.editorWindowContentRectSynchronizationRect 58.IBPluginDependency 58.ImportedFromIB2 + 587.IBEditorWindowLastContentRect + 587.IBPluginDependency + 588.IBPluginDependency + 590.IBPluginDependency 72.IBPluginDependency 72.ImportedFromIB2 73.IBPluginDependency @@ -2249,7 +2329,7 @@ com.apple.InterfaceBuilder.CocoaPlugin {{525, 802}, {197, 73}} - {{690, 954}, {349, 20}} + {{371, 736}, {349, 20}} com.apple.InterfaceBuilder.CocoaPlugin {74, 862} @@ -2293,18 +2373,18 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{152, 238}, {397, 581}} + {{202, 175}, {397, 581}} com.apple.InterfaceBuilder.CocoaPlugin - {{152, 238}, {397, 581}} + {{202, 175}, {397, 581}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.WebKitIBPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{460, 356}, {376, 581}} + {{344, 175}, {376, 581}} com.apple.InterfaceBuilder.CocoaPlugin - {{460, 356}, {376, 581}} + {{344, 175}, {376, 581}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2316,13 +2396,17 @@ {{23, 794}, {245, 183}} com.apple.InterfaceBuilder.CocoaPlugin + {{21, 1074}, {48, 48}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{771, 841}, {182, 113}} + {{452, 623}, {182, 113}} com.apple.InterfaceBuilder.CocoaPlugin {{155, 774}, {199, 203}} @@ -2350,7 +2434,7 @@ - 570 + 591 @@ -2358,13 +2442,19 @@ Controller NSObject + + authentificationSucceded: + id + YES YES globalHotkeyMenuItem + logoLayer mentionsView mentionsViewWindow + oauth timelineView timelineViewWindow viewDelegate @@ -2372,8 +2462,10 @@ YES NSMenuItem + NSImageView WebView NSWindow + OAuth WebView NSWindow ViewDelegate @@ -2384,6 +2476,14 @@ Controller.h + + OAuth + NSObject + + IBProjectSource + OAuth.h + + ViewDelegate NSObject @@ -2476,6 +2576,14 @@ AppKit.framework/Headers/NSBrowser.h + + NSCell + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSCell.h + + NSControl NSView @@ -2525,6 +2633,22 @@ Foundation.framework/Headers/NSFormatter.h + + NSImageCell + NSCell + + IBFrameworkSource + AppKit.framework/Headers/NSImageCell.h + + + + NSImageView + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSImageView.h + + NSMatrix NSControl diff --git a/OAToken+WebView.h b/OAToken+WebView.h new file mode 100644 index 0000000..317ea8b --- /dev/null +++ b/OAToken+WebView.h @@ -0,0 +1,15 @@ +// +// OAToken+WebView.h +// Twittia 2 +// +// Created by Jeena on 02.05.10. +// Licence: BSD (see attached LICENCE.txt file). +// + +#import +#import + + +@interface OAToken(WebView) + +@end diff --git a/OAToken+WebView.m b/OAToken+WebView.m new file mode 100644 index 0000000..3fa9d81 --- /dev/null +++ b/OAToken+WebView.m @@ -0,0 +1,23 @@ +// +// OAToken+WebView.m +// Twittia 2 +// +// Created by Jeena on 02.05.10. +// Licence: BSD (see attached LICENCE.txt file). +// + +#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..44c4548 --- /dev/null +++ b/OAuth.h @@ -0,0 +1,31 @@ +// +// OAuth.h +// Twittia 2 +// +// Created by Jeena on 01.05.10. +// Licence: BSD (see attached LICENCE.txt file). +// + +#import +#import +#import +#import "OAToken+WebView.h" + + +@interface OAuth : NSObject { + OAToken *requestToken; + OAToken *accessToken; + OAToken *consumerToken; + OAConsumer *consumer; +} + +@property (nonatomic, retain) OAToken *accessToken; +@property (nonatomic, retain) OAToken *consumerToken; + +- (id)init; +- (void)requestAToken; +- (void)requestAccessToken; +- (void)updateTweet:(NSString *)tweet inReplaToStatus:(NSString *)statusId; + + +@end diff --git a/OAuth.m b/OAuth.m new file mode 100644 index 0000000..ecfd5ff --- /dev/null +++ b/OAuth.m @@ -0,0 +1,175 @@ +// +// OAuth.m +// Twittia 2 +// +// Created by Jeena on 01.05.10. +// Licence: BSD (see attached LICENCE.txt file). +// + +#import "OAuth.h" +#import "Constants.h" +#import +#import +#import +#import + + +@implementation OAuth + +@synthesize accessToken, consumerToken; + ++ (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]; + consumer = [[OAConsumer alloc] initWithKey:OAUTH_CONSUMER_KEY secret:OAUTH_CONSUMER_SECRET]; + } + return self; +} + +- (void)dealloc { + [consumerToken release]; + [accessToken release]; + [consumer release]; + [super dealloc]; +} + +- (void)awakeFromNib { + if (!self.accessToken) { + [self requestAToken]; + } +} + +-(void)requestAToken { + + 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]; + + 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)requestAccessToken { + NSLog(@"test 2"); + + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", OAUTH_ACCESS_TOKEN_URL]]; + + 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(accessTokenTicket:didFailWithError:)]; + + +} + +- (void)accessTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data { + NSLog(@"%@", ticket); + if (ticket.didSucceed) { + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; + + self.accessToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody]; + [accessToken storeInUserDefaultsWithServiceProviderName:OAUTH_SERVICE_NAME prefix:APP_NAME]; + + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc postNotificationName:@"authentificationSucceded" object:self]; + } +} + + + +- (void)accessTokenTicket:(OAServiceTicket *)ticket didFailWithError:(NSError *)error { + NSLog(@"ERROR a: %@", error); + // [self requestAccessToken]; + + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?oauth_token=%@", OAUTH_USER_AUTHORIZATION_URL, requestToken.key]]; + [[NSWorkspace sharedWorkspace] openURL:url]; +} + +- (void)updateTweet:(NSString *)tweet inReplaToStatus:(NSString *)statusId { + + NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"]; + OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url + consumer:consumer + token:accessToken + realm:nil + signatureProvider:nil]; + + OARequestParameter *source = [[OARequestParameter alloc] initWithName:@"source" value:@"twittia"]; + OARequestParameter *status = [[OARequestParameter alloc] initWithName:@"status" value:tweet]; + + NSMutableArray *params = [NSMutableArray arrayWithObjects:source, status, nil]; + + if (statusId) { + OARequestParameter *reply = [[OARequestParameter alloc] initWithName:@"in_reply_to_status_id" value:statusId]; + [params addObject:reply]; + } + + [request setHTTPMethod:@"POST"]; + [request setParameters:params]; + + OADataFetcher *fetcher = [[OADataFetcher alloc] init]; + [fetcher fetchDataWithRequest:request + delegate:self + didFinishSelector:@selector(updateTweetTicket:didFinishWithData:) + didFailSelector:@selector(updateTweetTokenTicket:didFailWithError:)]; +} + +- (void)updateTweetTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data { + if (ticket.didSucceed) { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc postNotificationName:@"getTweetUpdates" object:self]; + + } +} + +- (void)updateTweetTokenTicket:(OAServiceTicket *)ticket didFailWithError:(NSError *)error { + NSLog(@"ERROR update tweet: %@", error); +} + +@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/ReleaseNotes.html b/ReleaseNotes.html index c674d3a..e6658b0 100644 --- a/ReleaseNotes.html +++ b/ReleaseNotes.html @@ -12,15 +12,25 @@ -

Twittia 2.1.2

-

Added icon

-

Fixed problem where you press "a" and a new tweet window opens

+

Twittia 2.2.0

+

Now with OAuth.

+

Added badge to dock icon on new mentions.

+ +
+ +

Twittia 2.1.2

+

Added icon

+

Fixed problem where you press "a" and a new tweet window opens

+ +

Twittia 2.1.1

-

Added possibility to change hot key in defaults. +

Added possibility to change the hotkey in defaults.

Added a notice to the timeline window how many unread mentions there are.

Changed the plugin API to support more functionality.

+
+

Twittia 2.1.0

Fixed some wrong links.

Fixed problem with closed timeline window.

diff --git a/Twittia 2.xcodeproj/project.pbxproj b/Twittia 2.xcodeproj/project.pbxproj index c5a8e31..736e97e 100644 --- a/Twittia 2.xcodeproj/project.pbxproj +++ b/Twittia 2.xcodeproj/project.pbxproj @@ -9,14 +9,20 @@ /* Begin PBXBuildFile section */ 1DDD582C0DA1D0D100B32029 /* MyDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58280DA1D0D100B32029 /* MyDocument.xib */; }; 1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD582A0DA1D0D100B32029 /* MainMenu.xib */; }; + 1F122D49118E1DE100E83B77 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1F122D48118E1DE100E83B77 /* Icon.icns */; }; 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 CopyFiles */ = {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 */; }; 1F705EA6117889FA00C85707 /* sprite-icons.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F705EA5117889FA00C85707 /* sprite-icons.png */; }; 1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F70619E1178FBB300C85707 /* Carbon.framework */; }; 1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F77DB46118C5F1C007C7F1E /* Constants.m */; }; - 1FD7D54D11900A980017A19C /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1FD7D54C11900A980017A19C /* Icon.icns */; }; + 1FB074DD118DDAB60013A93C /* OAuthConsumer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F36440E118CC173008198EF /* OAuthConsumer.framework */; }; 1FE2FC93117A818D000504B0 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FE2FC92117A818D000504B0 /* Sparkle.framework */; }; 1FE2FCA4117A83B1000504B0 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1FE2FC92117A818D000504B0 /* Sparkle.framework */; }; 1FFA36CD1177D861006C8562 /* even-bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FFA36C81177D861006C8562 /* even-bg.png */; }; @@ -40,6 +46,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 1F36440F118CC173008198EF /* OAuthConsumer.framework in CopyFiles */, 1FE2FCA4117A83B1000504B0 /* Sparkle.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; @@ -52,10 +59,18 @@ 13E42FBA07B3F13500E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; 1DDD58290DA1D0D100B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MyDocument.xib; sourceTree = ""; }; 1DDD582B0DA1D0D100B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = ""; }; + 1F122D48118E1DE100E83B77 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1F198FC7117BC4AB0049BEA7 /* README.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.markdown; sourceTree = ""; }; 1F1990C5117BCA960049BEA7 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; }; 1F1990DF117BD2250049BEA7 /* Appcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Appcast.xml; sourceTree = ""; }; 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 = ""; }; @@ -63,7 +78,6 @@ 1F70619E1178FBB300C85707 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; 1F77DB45118C5F1C007C7F1E /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; 1F77DB46118C5F1C007C7F1E /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = ""; }; - 1FD7D54C11900A980017A19C /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1FE2FC92117A818D000504B0 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = ""; }; 1FE2FCA6117A8952000504B0 /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = ""; }; 1FFA36C81177D861006C8562 /* even-bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "even-bg.png"; sourceTree = ""; }; @@ -91,6 +105,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 1FB074DD118DDAB60013A93C /* OAuthConsumer.framework in Frameworks */, 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */, 1FFA37071177DAF4006C8562 /* WebKit.framework in Frameworks */, 1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */, @@ -105,6 +120,7 @@ 1058C7A6FEA54F5311CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( + 1F36440E118CC173008198EF /* OAuthConsumer.framework */, 1FE2FC92117A818D000504B0 /* Sparkle.framework */, 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */, 1FFA37061177DAF4006C8562 /* WebKit.framework */, @@ -135,6 +151,8 @@ 1FFA36C71177D861006C8562 /* WebKit */ = { isa = PBXGroup; children = ( + 1F3642ED118C8C35008198EF /* oauth.js */, + 1F3642EE118C8C35008198EF /* sha1.js */, 1F4673E61180F654006CC37C /* TwittiaCore.js */, 1FFA36C81177D861006C8562 /* even-bg.png */, 1F705EA5117889FA00C85707 /* sprite-icons.png */, @@ -168,8 +186,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 = ""; @@ -186,7 +208,7 @@ 2A37F4B8FDCFA73011CA2CEA /* Resources */ = { isa = PBXGroup; children = ( - 1FD7D54C11900A980017A19C /* Icon.icns */, + 1F122D48118E1DE100E83B77 /* Icon.icns */, 1F1990DF117BD2250049BEA7 /* Appcast.xml */, 1F198FC7117BC4AB0049BEA7 /* README.markdown */, 1FE2FCA6117A8952000504B0 /* dsa_pub.pem */, @@ -254,6 +276,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 1F3642EF118C8C35008198EF /* oauth.js in Resources */, + 1F3642F0118C8C35008198EF /* sha1.js in Resources */, 1F4673FE1180F7EA006CC37C /* TwittiaCore.js in Resources */, 8D15AC2C0486D014006FF6A4 /* Credits.rtf in Resources */, 8D15AC2F0486D014006FF6A4 /* InfoPlist.strings in Resources */, @@ -266,7 +290,7 @@ 1F4674081180F7EE006CC37C /* jQuery.js in Resources */, 1FFA36D01177D861006C8562 /* default.css in Resources */, 1F705EA6117889FA00C85707 /* sprite-icons.png in Resources */, - 1FD7D54D11900A980017A19C /* Icon.icns in Resources */, + 1F122D49118E1DE100E83B77 /* Icon.icns in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -282,6 +306,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; }; @@ -332,6 +358,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; @@ -354,6 +381,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..d873db3 100644 --- a/TwittiaCore.js +++ b/TwittiaCore.js @@ -1,10 +1,16 @@ -function Twittia(action, oauth_key, oauth_secret) { +// +// TwittiaCore.js +// Twittia 2 +// +// Created by Jeena on 15.04.10. +// Licence: BSD (see attached LICENCE.txt file). +// + +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 +176,67 @@ 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; + var data = "source=twittia&status=" + OAuth.percentEncode(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, @@ -212,12 +250,25 @@ Twittia.prototype.sendNewTweet = function(tweet, in_reply_to_status_id) { } }); } +*/ Twittia.prototype.retweet = function(status_id, item) { var url = "http://api.twitter.com/1/statuses/retweet/" + status_id + ".json"; var _this = this; + + var message = { method:"POST" , action:url }; + + 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', dataType: 'json', @@ -231,6 +282,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 +328,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 b69c4e7..ba1ed85 100644 --- a/Twittia_2-Info.plist +++ b/Twittia_2-Info.plist @@ -40,9 +40,9 @@ CFBundleSignature ???? CFBundleVersion - 2.1.2 + 2.2.0 CFBundleShortVersionString - 2.1.2 + 2.2.0 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSMainNibFile diff --git a/index.html b/index.html index 759d87e..3ae01b4 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,8 @@ + + diff --git a/oauth.js b/oauth.js new file mode 100644 index 0000000..b319612 --- /dev/null +++ b/oauth.js @@ -0,0 +1,548 @@ +/* + * Copyright 2008 Netflix, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Here's some JavaScript software for implementing OAuth. + + This isn't as useful as you might hope. OAuth is based around + allowing tools and websites to talk to each other. However, + JavaScript running in web browsers is hampered by security + restrictions that prevent code running on one website from + accessing data stored or served on another. + + Before you start hacking, make sure you understand the limitations + posed by cross-domain XMLHttpRequest. + + On the bright side, some platforms use JavaScript as their + language, but enable the programmer to access other web sites. + Examples include Google Gadgets, and Microsoft Vista Sidebar. + For those platforms, this library should come in handy. +*/ + +// The HMAC-SHA1 signature method calls b64_hmac_sha1, defined by +// http://pajhome.org.uk/crypt/md5/sha1.js + +/* An OAuth message is represented as an object like this: + {method: "GET", action: "http://server.com/path", parameters: ...} + + The parameters may be either a map {name: value, name2: value2} + or an Array of name-value pairs [[name, value], [name2, value2]]. + The latter representation is more powerful: it supports parameters + in a specific sequence, or several parameters with the same name; + for example [["a", 1], ["b", 2], ["a", 3]]. + + Parameter names and values are NOT percent-encoded in an object. + They must be encoded before transmission and decoded after reception. + For example, this message object: + {method: "GET", action: "http://server/path", parameters: {p: "x y"}} + ... can be transmitted as an HTTP request that begins: + GET /path?p=x%20y HTTP/1.0 + (This isn't a valid OAuth request, since it lacks a signature etc.) + Note that the object "x y" is transmitted as x%20y. To encode + parameters, you can call OAuth.addToURL, OAuth.formEncode or + OAuth.getAuthorization. + + This message object model harmonizes with the browser object model for + input elements of an form, whose value property isn't percent encoded. + The browser encodes each value before transmitting it. For example, + see consumer.setInputs in example/consumer.js. + */ + +/* This script needs to know what time it is. By default, it uses the local + clock (new Date), which is apt to be inaccurate in browsers. To do + better, you can load this script from a URL whose query string contains + an oauth_timestamp parameter, whose value is a current Unix timestamp. + For example, when generating the enclosing document using PHP: + +