merged oauth with master

This commit is contained in:
Jeena Paradies 2010-05-16 12:55:45 +02:00
commit eb10cd5859
40 changed files with 1981 additions and 79 deletions

View file

@ -6,15 +6,15 @@
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version 2.1.2</title>
<title>Version 2.2.0</title>
<sparkle:minimumSystemVersion>10.5.0</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>http://jeenaparadies.net/twittia/ReleaseNotes.html</sparkle:releaseNotesLink>
<pubDate>Tue, 04 May 2010 10:05:22 +0200</pubDate>
<enclosure url="http://jeenaparadies.net/twittia/Twittia.app.zip"
sparkle:version="2.1.2"
length="741000"
type="application/octet-stream"
sparkle:dsaSignature="MCwCFHhJ3+WiTHveO/rVQWBBiRKs/pNCAhRjQo5mVURRV/DO/t8sfYfHWRKTew==" />
<pubDate>Sun, 16 May 2010 12:39:02 +0200</pubDate>
<enclosure url="http://jeenaparadies.net/twittia/Twittia.app.zip"
sparkle:version="2.2.0"
length="829960"
type="application/octet-stream"
sparkle:dsaSignature="MCwCFA9pHTR6Yhm4hnGbx+yrdUFOmy+hAhRy6xcQfr5MM3S0YQe9Z5K4TRBH7A==" />
</item>
</channel>
</rss>

View file

@ -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 <Foundation/Foundation.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;

View file

@ -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"

View file

@ -11,6 +11,7 @@
#import "ViewDelegate.h"
#import <Carbon/Carbon.h>
#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;

View file

@ -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 {
@ -125,8 +150,18 @@
- (void)openNewTweetWindowWithString:(NSString *)aString {
[NSApp activateIgnoringOtherApps:YES];
MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
[newTweet withString:aString];
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 */

View file

@ -22,8 +22,8 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="559"/>
<integer value="588"/>
<integer value="81"/>
<integer value="535"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -775,7 +775,7 @@
<object class="NSWindowTemplate" id="1010634651">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{235, -22}, {397, 581}}</string>
<string key="NSWindowRect">{{712, 280}, {397, 581}}</string>
<int key="NSWTFlags">1685586944</int>
<string key="NSWindowTitle">Twittia</string>
<string key="NSWindowClass">NSWindow</string>
@ -828,6 +828,43 @@
<bool key="UseBackForwardList">NO</bool>
<bool key="AllowsUndo">YES</bool>
</object>
<object class="NSImageView" id="398890244">
<reference key="NSNextResponder" ref="332867700"/>
<int key="NSvFlags">274</int>
<object class="NSMutableSet" key="NSDragTypes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="set.sortedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Apple PDF pasteboard type</string>
<string>Apple PICT pasteboard type</string>
<string>Apple PNG pasteboard type</string>
<string>NSFilenamesPboardType</string>
<string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
</object>
</object>
<string key="NSFrame">{{17, 17}, {363, 547}}</string>
<reference key="NSSuperview" ref="332867700"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="747210486">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">33554432</int>
<object class="NSCustomResource" key="NSContents">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">Icon</string>
</object>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<int key="NSAlign">0</int>
<int key="NSScale">3</int>
<int key="NSStyle">0</int>
<bool key="NSAnimates">NO</bool>
</object>
<bool key="NSEditable">YES</bool>
</object>
</object>
<string key="NSFrameSize">{397, 581}</string>
<reference key="NSSuperview"/>
@ -842,7 +879,7 @@
<object class="NSWindowTemplate" id="134415325">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{235, -22}, {376, 581}}</string>
<string key="NSWindowRect">{{1077, 328}, {376, 581}}</string>
<int key="NSWTFlags">1685586944</int>
<string key="NSWindowTitle">Mentions</string>
<string key="NSWindowClass">NSWindow</string>
@ -903,6 +940,9 @@
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
<string key="NSFrameAutosaveName">mentions</string>
</object>
<object class="NSCustomObject" id="456221404">
<string key="NSClassName">OAuth</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@ -1331,6 +1371,22 @@
</object>
<int key="connectionID">570</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">logoLayer</string>
<reference key="source" ref="408500656"/>
<reference key="destination" ref="398890244"/>
</object>
<int key="connectionID">589</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">oauth</string>
<reference key="source" ref="408500656"/>
<reference key="destination" ref="456221404"/>
</object>
<int key="connectionID">591</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -1920,6 +1976,7 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="690752143"/>
<reference ref="398890244"/>
</object>
<reference key="parent" ref="1010634651"/>
</object>
@ -1973,6 +2030,25 @@
<reference key="object" ref="126069112"/>
<reference key="parent" ref="438898709"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">587</int>
<reference key="object" ref="398890244"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="747210486"/>
</object>
<reference key="parent" ref="332867700"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">588</int>
<reference key="object" ref="747210486"/>
<reference key="parent" ref="398890244"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">590</int>
<reference key="object" ref="456221404"/>
<reference key="parent" ref="0"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -2138,6 +2214,10 @@
<string>57.editorWindowContentRectSynchronizationRect</string>
<string>58.IBPluginDependency</string>
<string>58.ImportedFromIB2</string>
<string>587.IBEditorWindowLastContentRect</string>
<string>587.IBPluginDependency</string>
<string>588.IBPluginDependency</string>
<string>590.IBPluginDependency</string>
<string>72.IBPluginDependency</string>
<string>72.ImportedFromIB2</string>
<string>73.IBPluginDependency</string>
@ -2249,7 +2329,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{525, 802}, {197, 73}}</string>
<string>{{690, 954}, {349, 20}}</string>
<string>{{371, 736}, {349, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{74, 862}</string>
@ -2293,18 +2373,18 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{152, 238}, {397, 581}}</string>
<string>{{202, 175}, {397, 581}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{152, 238}, {397, 581}}</string>
<string>{{202, 175}, {397, 581}}</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.WebKitIBPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{460, 356}, {376, 581}}</string>
<string>{{344, 175}, {376, 581}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{460, 356}, {376, 581}}</string>
<string>{{344, 175}, {376, 581}}</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
@ -2316,13 +2396,17 @@
<string>{{23, 794}, {245, 183}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{21, 1074}, {48, 48}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{771, 841}, {182, 113}}</string>
<string>{{452, 623}, {182, 113}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{155, 774}, {199, 203}}</string>
@ -2350,7 +2434,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">570</int>
<int key="maxID">591</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -2358,13 +2442,19 @@
<object class="IBPartialClassDescription">
<string key="className">Controller</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">authentificationSucceded:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>globalHotkeyMenuItem</string>
<string>logoLayer</string>
<string>mentionsView</string>
<string>mentionsViewWindow</string>
<string>oauth</string>
<string>timelineView</string>
<string>timelineViewWindow</string>
<string>viewDelegate</string>
@ -2372,8 +2462,10 @@
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSMenuItem</string>
<string>NSImageView</string>
<string>WebView</string>
<string>NSWindow</string>
<string>OAuth</string>
<string>WebView</string>
<string>NSWindow</string>
<string>ViewDelegate</string>
@ -2384,6 +2476,14 @@
<string key="minorKey">Controller.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">OAuth</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">OAuth.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">ViewDelegate</string>
<string key="superclassName">NSObject</string>
@ -2476,6 +2576,14 @@
<string key="minorKey">AppKit.framework/Headers/NSBrowser.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSCell</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSControl</string>
<string key="superclassName">NSView</string>
@ -2525,6 +2633,22 @@
<string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSImageCell</string>
<string key="superclassName">NSCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSImageCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSImageView</string>
<string key="superclassName">NSControl</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSImageView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSMatrix</string>
<string key="superclassName">NSControl</string>

15
OAToken+WebView.h Normal file
View file

@ -0,0 +1,15 @@
//
// OAToken+WebView.h
// Twittia 2
//
// Created by Jeena on 02.05.10.
// Licence: BSD (see attached LICENCE.txt file).
//
#import <Foundation/Foundation.h>
#import <OAuthConsumer/OAToken.h>
@interface OAToken(WebView)
@end

23
OAToken+WebView.m Normal file
View file

@ -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

31
OAuth.h Normal file
View file

@ -0,0 +1,31 @@
//
// OAuth.h
// Twittia 2
//
// Created by Jeena on 01.05.10.
// Licence: BSD (see attached LICENCE.txt file).
//
#import <Foundation/Foundation.h>
#import <OAuthConsumer/OAToken.h>
#import <OAuthConsumer/OAConsumer.h>
#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

175
OAuth.m Normal file
View file

@ -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 <OAuthConsumer/OAConsumer.h>
#import <OAuthConsumer/OAMutableURLRequest.h>
#import <OAuthConsumer/OADataFetcher.h>
#import <OAuthConsumer/OAToken.h>
@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

View file

@ -0,0 +1 @@
Versions/Current/Headers

View file

@ -0,0 +1 @@
Versions/Current/OAuthConsumer

View file

@ -0,0 +1 @@
Versions/Current/Resources

View file

@ -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 <Foundation/Foundation.h>
#import "OARequestParameter.h"
#import "NSURL+Base.h"
@interface NSMutableURLRequest (OAParameterAdditions)
- (NSArray *)parameters;
- (void)setParameters:(NSArray *)parameters;
@end

View file

@ -0,0 +1,34 @@
//
// NSString+URLEncoding.h
//
// Created by Jon Crosby on 10/19/07.
// Copyright 2007 Kaboomerang LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
@interface NSString (OAURLEncodingAdditions)
- (NSString *)URLEncodedString;
- (NSString *)URLDecodedString;
@end

View file

@ -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 <Foundation/Foundation.h>
@interface NSURL (OABaseAdditions)
- (NSString *)URLStringWithoutQuery;
@end

View file

@ -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 <Foundation/Foundation.h>
#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

View file

@ -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 <Foundation/Foundation.h>
@interface OAConsumer : NSObject {
@protected
NSString *key;
NSString *secret;
}
@property(retain) NSString *key;
@property(retain) NSString *secret;
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
@end

View file

@ -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 <Foundation/Foundation.h>
#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

View file

@ -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 <Foundation/Foundation.h>
#import "OASignatureProviding.h"
@interface OAHMAC_SHA1SignatureProvider : NSObject <OASignatureProviding>
@end

View file

@ -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 <Foundation/Foundation.h>
#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<OASignatureProviding> 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<OASignatureProviding, NSObject>)aProvider;
- (id)initWithURL:(NSURL *)aUrl
consumer:(OAConsumer *)aConsumer
token:(OAToken *)aToken
realm:(NSString *)aRealm
signatureProvider:(id<OASignatureProviding, NSObject>)aProvider
nonce:(NSString *)aNonce
timestamp:(NSString *)aTimestamp;
- (void)prepare;
- (void)setOAuthParameterName:(NSString*)parameterName withValue:(NSString*)parameterValue;
@end

View file

@ -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 <Foundation/Foundation.h>
#import "OASignatureProviding.h"
@interface OAPlaintextSignatureProvider : NSObject <OASignatureProviding>
@end

View file

@ -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 <Foundation/Foundation.h>
#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

View file

@ -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 <Foundation/Foundation.h>
#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

View file

@ -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 <Foundation/Foundation.h>
@protocol OASignatureProviding <NSObject>
- (NSString *)name;
- (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret;
@end

View file

@ -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 <Foundation/Foundation.h>
@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

View file

@ -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 <Security/Security.h>
@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

View file

@ -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 <Foundation/Foundation.h>
#import <OAuthConsumer/OAToken.h>
#import <OAuthConsumer/OAConsumer.h>
#import <OAuthConsumer/OAMutableURLRequest.h>
#import <OAuthConsumer/NSString+URLEncoding.h>
#import <OAuthConsumer/NSMutableURLRequest+Parameters.h>
#import <OAuthConsumer/NSURL+Base.h>
#import <OAuthConsumer/OASignatureProviding.h>
#import <OAuthConsumer/OAHMAC_SHA1SignatureProvider.h>
#import <OAuthConsumer/OAPlaintextSignatureProvider.h>
#import <OAuthConsumer/OARequestParameter.h>
#import <OAuthConsumer/OAServiceTicket.h>
#import <OAuthConsumer/OADataFetcher.h>
#import <OAuthConsumer/OAAsynchronousDataFetcher.h>

Binary file not shown.

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>OAuthConsumer</string>
<key>CFBundleIdentifier</key>
<string>net.oauth.OAuthConsumer</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>OAuthConsumer</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.1.1</string>
</dict>
</plist>

View file

@ -0,0 +1 @@
A

View file

@ -12,15 +12,25 @@
</head>
<body>
<h1>Twittia 2.2.0</h1>
<p>Now with OAuth.</p>
<p>Added badge to dock icon on new mentions.</p>
<hr />
<h1>Twittia 2.1.2</h1>
<p>Added icon</p>
<p>Fixed problem where you press "a" and a new tweet window opens</p>
<hr />
<h1>Twittia 2.1.1</h1>
<p>Added possibility to change hot key in defaults.</>
<p>Added possibility to change the hotkey in defaults.</p>
<p>Added a notice to the timeline window how many unread mentions there are.</p>
<p>Changed the plugin API to support more functionality.</p>
<hr />
<h1>Twittia 2.1.0</h1>
<p>Fixed some wrong links.</p>
<p>Fixed problem with closed timeline window.</p>

View file

@ -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 = "<absolute>"; };
1DDD58290DA1D0D100B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MyDocument.xib; sourceTree = "<group>"; };
1DDD582B0DA1D0D100B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
1F122D48118E1DE100E83B77 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
1F198FC7117BC4AB0049BEA7 /* README.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.markdown; sourceTree = "<group>"; };
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 = "<group>"; };
1F1990E1117BD2650049BEA7 /* ReleaseNotes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ReleaseNotes.html; sourceTree = "<group>"; };
1F3642ED118C8C35008198EF /* oauth.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = oauth.js; sourceTree = "<group>"; };
1F3642EE118C8C35008198EF /* sha1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = sha1.js; sourceTree = "<group>"; };
1F364396118CBC77008198EF /* OAuth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAuth.h; sourceTree = "<group>"; };
1F364397118CBC77008198EF /* OAuth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OAuth.m; sourceTree = "<group>"; };
1F36440E118CC173008198EF /* OAuthConsumer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = OAuthConsumer.framework; sourceTree = "<group>"; };
1F36465C118DA5A7008198EF /* OAToken+WebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OAToken+WebView.h"; sourceTree = "<group>"; };
1F36465D118DA5A7008198EF /* OAToken+WebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "OAToken+WebView.m"; sourceTree = "<group>"; };
1F4673E21180F519006CC37C /* jQuery.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jQuery.js; sourceTree = "<group>"; };
1F4673E41180F590006CC37C /* jQuery-Plugins.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "jQuery-Plugins.js"; sourceTree = "<group>"; };
1F4673E61180F654006CC37C /* TwittiaCore.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = TwittiaCore.js; sourceTree = "<group>"; };
@ -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 = "<group>"; };
1F77DB46118C5F1C007C7F1E /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = "<group>"; };
1FD7D54C11900A980017A19C /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
1FE2FC92117A818D000504B0 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
1FE2FCA6117A8952000504B0 /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
1FFA36C81177D861006C8562 /* even-bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "even-bg.png"; sourceTree = "<group>"; };
@ -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 = "<group>";
@ -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;

View file

@ -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;
$.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);
}
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(
{ 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,"<a href='$1'>$1</a>");
@ -254,4 +328,5 @@ function loadPlugin(url) {
document.getElementsByTagName("head")[0].appendChild(plugin);
}
var twittia_instance;

View file

@ -40,9 +40,9 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.1.2</string>
<string>2.2.0</string>
<key>CFBundleShortVersionString</key>
<string>2.1.2</string>
<string>2.2.0</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>

View file

@ -6,6 +6,8 @@
<link rel="stylesheet" href="default.css" type="text/css" />
<script type="text/javascript" src="jQuery.js"></script>
<script type="text/javascript" src="jQuery-Plugins.js"></script>
<script type="text/javascript" src="sha1.js"></script>
<script type="text/javascript" src="oauth.js"></script>
<script type="text/javascript" src="TwittiaCore.js"></script>
</head>
<body>

548
oauth.js Normal file
View file

@ -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:
<script src="oauth.js?oauth_timestamp=<?=time()?>" ...
Another option is to call OAuth.correctTimestamp with a Unix timestamp.
*/
var OAuth; if (OAuth == null) OAuth = {};
OAuth.setProperties = function setProperties(into, from) {
if (into != null && from != null) {
for (var key in from) {
into[key] = from[key];
}
}
return into;
}
OAuth.setProperties(OAuth, // utility functions
{
percentEncode: function percentEncode(s) {
if (s == null) {
return "";
}
if (s instanceof Array) {
var e = "";
for (var i = 0; i < s.length; ++s) {
if (e != "") e += '&';
e += OAuth.percentEncode(s[i]);
}
return e;
}
s = encodeURIComponent(s);
// Now replace the values which encodeURIComponent doesn't do
// encodeURIComponent ignores: - _ . ! ~ * ' ( )
// OAuth dictates the only ones you can ignore are: - _ . ~
// Source: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponent
s = s.replace(/\!/g, "%21");
s = s.replace(/\*/g, "%2A");
s = s.replace(/\'/g, "%27");
s = s.replace(/\(/g, "%28");
s = s.replace(/\)/g, "%29");
return s;
}
,
decodePercent: function decodePercent(s) {
if (s != null) {
// Handle application/x-www-form-urlencoded, which is defined by
// http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
s = s.replace(/\+/g, " ");
}
return decodeURIComponent(s);
}
,
/** Convert the given parameters to an Array of name-value pairs. */
getParameterList: function getParameterList(parameters) {
if (parameters == null) {
return [];
}
if (typeof parameters != "object") {
return OAuth.decodeForm(parameters + "");
}
if (parameters instanceof Array) {
return parameters;
}
var list = [];
for (var p in parameters) {
list.push([p, parameters[p]]);
}
return list;
}
,
/** Convert the given parameters to a map from name to value. */
getParameterMap: function getParameterMap(parameters) {
if (parameters == null) {
return {};
}
if (typeof parameters != "object") {
return OAuth.getParameterMap(OAuth.decodeForm(parameters + ""));
}
if (parameters instanceof Array) {
var map = {};
for (var p = 0; p < parameters.length; ++p) {
var key = parameters[p][0];
if (map[key] === undefined) { // first value wins
map[key] = parameters[p][1];
}
}
return map;
}
return parameters;
}
,
getParameter: function getParameter(parameters, name) {
if (parameters instanceof Array) {
for (var p = 0; p < parameters.length; ++p) {
if (parameters[p][0] == name) {
return parameters[p][1]; // first value wins
}
}
} else {
return OAuth.getParameterMap(parameters)[name];
}
return null;
}
,
formEncode: function formEncode(parameters) {
var form = "";
var list = OAuth.getParameterList(parameters);
for (var p = 0; p < list.length; ++p) {
var value = list[p][1];
if (value == null) value = "";
if (form != "") form += '&';
form += OAuth.percentEncode(list[p][0])
+'='+ OAuth.percentEncode(value);
}
return form;
}
,
decodeForm: function decodeForm(form) {
var list = [];
var nvps = form.split('&');
for (var n = 0; n < nvps.length; ++n) {
var nvp = nvps[n];
if (nvp == "") {
continue;
}
var equals = nvp.indexOf('=');
var name;
var value;
if (equals < 0) {
name = OAuth.decodePercent(nvp);
value = null;
} else {
name = OAuth.decodePercent(nvp.substring(0, equals));
value = OAuth.decodePercent(nvp.substring(equals + 1));
}
list.push([name, value]);
}
return list;
}
,
setParameter: function setParameter(message, name, value) {
var parameters = message.parameters;
if (parameters instanceof Array) {
for (var p = 0; p < parameters.length; ++p) {
if (parameters[p][0] == name) {
if (value === undefined) {
parameters.splice(p, 1);
} else {
parameters[p][1] = value;
value = undefined;
}
}
}
if (value !== undefined) {
parameters.push([name, value]);
}
} else {
parameters = OAuth.getParameterMap(parameters);
parameters[name] = value;
message.parameters = parameters;
}
}
,
setParameters: function setParameters(message, parameters) {
var list = OAuth.getParameterList(parameters);
for (var i = 0; i < list.length; ++i) {
OAuth.setParameter(message, list[i][0], list[i][1]);
}
}
,
/** Fill in parameters to help construct a request message.
This function doesn't fill in every parameter.
The accessor object should be like:
{consumerKey:'foo', consumerSecret:'bar', accessorSecret:'nurn', token:'krelm', tokenSecret:'blah'}
The accessorSecret property is optional.
*/
completeRequest: function completeRequest(message, accessor) {
if (message.method == null) {
message.method = "GET";
}
var map = OAuth.getParameterMap(message.parameters);
if (map.oauth_consumer_key == null) {
OAuth.setParameter(message, "oauth_consumer_key", accessor.consumerKey || "");
}
if (map.oauth_token == null && accessor.token != null) {
OAuth.setParameter(message, "oauth_token", accessor.token);
}
if (map.oauth_version == null) {
OAuth.setParameter(message, "oauth_version", "1.0");
}
if (map.oauth_timestamp == null) {
OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
}
if (map.oauth_nonce == null) {
OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
}
OAuth.SignatureMethod.sign(message, accessor);
}
,
setTimestampAndNonce: function setTimestampAndNonce(message) {
OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
}
,
addToURL: function addToURL(url, parameters) {
newURL = url;
if (parameters != null) {
var toAdd = OAuth.formEncode(parameters);
if (toAdd.length > 0) {
var q = url.indexOf('?');
if (q < 0) newURL += '?';
else newURL += '&';
newURL += toAdd;
}
}
return newURL;
}
,
/** Construct the value of the Authorization header for an HTTP request. */
getAuthorizationHeader: function getAuthorizationHeader(realm, parameters) {
var header = 'OAuth realm="' + OAuth.percentEncode(realm) + '"';
var list = OAuth.getParameterList(parameters);
for (var p = 0; p < list.length; ++p) {
var parameter = list[p];
var name = parameter[0];
if (name.indexOf("oauth_") == 0) {
header += ',' + OAuth.percentEncode(name) + '="' + OAuth.percentEncode(parameter[1]) + '"';
}
}
return header;
}
,
/** Correct the time using a parameter from the URL from which the last script was loaded. */
correctTimestampFromSrc: function correctTimestampFromSrc(parameterName) {
parameterName = parameterName || "oauth_timestamp";
var scripts = document.getElementsByTagName('script');
if (scripts == null || !scripts.length) return;
var src = scripts[scripts.length-1].src;
if (!src) return;
var q = src.indexOf("?");
if (q < 0) return;
parameters = OAuth.getParameterMap(OAuth.decodeForm(src.substring(q+1)));
var t = parameters[parameterName];
if (t == null) return;
OAuth.correctTimestamp(t);
}
,
/** Generate timestamps starting with the given value. */
correctTimestamp: function correctTimestamp(timestamp) {
OAuth.timeCorrectionMsec = (timestamp * 1000) - (new Date()).getTime();
}
,
/** The difference between the correct time and my clock. */
timeCorrectionMsec: 0
,
timestamp: function timestamp() {
var t = (new Date()).getTime() + OAuth.timeCorrectionMsec;
return Math.floor(t / 1000);
}
,
nonce: function nonce(length) {
var chars = OAuth.nonce.CHARS;
var result = "";
for (var i = 0; i < length; ++i) {
var rnum = Math.floor(Math.random() * chars.length);
result += chars.substring(rnum, rnum+1);
}
return result;
}
});
OAuth.nonce.CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
/** Define a constructor function,
without causing trouble to anyone who was using it as a namespace.
That is, if parent[name] already existed and had properties,
copy those properties into the new constructor.
*/
OAuth.declareClass = function declareClass(parent, name, newConstructor) {
var previous = parent[name];
parent[name] = newConstructor;
if (newConstructor != null && previous != null) {
for (var key in previous) {
if (key != "prototype") {
newConstructor[key] = previous[key];
}
}
}
return newConstructor;
}
/** An abstract algorithm for signing messages. */
OAuth.declareClass(OAuth, "SignatureMethod", function OAuthSignatureMethod(){});
OAuth.setProperties(OAuth.SignatureMethod.prototype, // instance members
{
/** Add a signature to the message. */
sign: function sign(message) {
var baseString = OAuth.SignatureMethod.getBaseString(message);
var signature = this.getSignature(baseString);
OAuth.setParameter(message, "oauth_signature", signature);
return signature; // just in case someone's interested
}
,
/** Set the key string for signing. */
initialize: function initialize(name, accessor) {
var consumerSecret;
if (accessor.accessorSecret != null
&& name.length > 9
&& name.substring(name.length-9) == "-Accessor")
{
consumerSecret = accessor.accessorSecret;
} else {
consumerSecret = accessor.consumerSecret;
}
this.key = OAuth.percentEncode(consumerSecret)
+"&"+ OAuth.percentEncode(accessor.tokenSecret);
}
});
/* SignatureMethod expects an accessor object to be like this:
{tokenSecret: "lakjsdflkj...", consumerSecret: "QOUEWRI..", accessorSecret: "xcmvzc..."}
The accessorSecret property is optional.
*/
// Class members:
OAuth.setProperties(OAuth.SignatureMethod, // class members
{
sign: function sign(message, accessor) {
var name = OAuth.getParameterMap(message.parameters).oauth_signature_method;
if (name == null || name == "") {
name = "HMAC-SHA1";
OAuth.setParameter(message, "oauth_signature_method", name);
}
OAuth.SignatureMethod.newMethod(name, accessor).sign(message);
}
,
/** Instantiate a SignatureMethod for the given method name. */
newMethod: function newMethod(name, accessor) {
var impl = OAuth.SignatureMethod.REGISTERED[name];
if (impl != null) {
var method = new impl();
method.initialize(name, accessor);
return method;
}
var err = new Error("signature_method_rejected");
var acceptable = "";
for (var r in OAuth.SignatureMethod.REGISTERED) {
if (acceptable != "") acceptable += '&';
acceptable += OAuth.percentEncode(r);
}
err.oauth_acceptable_signature_methods = acceptable;
throw err;
}
,
/** A map from signature method name to constructor. */
REGISTERED : {}
,
/** Subsequently, the given constructor will be used for the named methods.
The constructor will be called with no parameters.
The resulting object should usually implement getSignature(baseString).
You can easily define such a constructor by calling makeSubclass, below.
*/
registerMethodClass: function registerMethodClass(names, classConstructor) {
for (var n = 0; n < names.length; ++n) {
OAuth.SignatureMethod.REGISTERED[names[n]] = classConstructor;
}
}
,
/** Create a subclass of OAuth.SignatureMethod, with the given getSignature function. */
makeSubclass: function makeSubclass(getSignatureFunction) {
var superClass = OAuth.SignatureMethod;
var subClass = function() {
superClass.call(this);
};
subClass.prototype = new superClass();
// Delete instance variables from prototype:
// delete subclass.prototype... There aren't any.
subClass.prototype.getSignature = getSignatureFunction;
subClass.prototype.constructor = subClass;
return subClass;
}
,
getBaseString: function getBaseString(message) {
var URL = message.action;
var q = URL.indexOf('?');
var parameters;
if (q < 0) {
parameters = message.parameters;
} else {
// Combine the URL query string with the other parameters:
parameters = OAuth.decodeForm(URL.substring(q + 1));
var toAdd = OAuth.getParameterList(message.parameters);
for (var a = 0; a < toAdd.length; ++a) {
parameters.push(toAdd[a]);
}
}
return OAuth.percentEncode(message.method.toUpperCase())
+'&'+ OAuth.percentEncode(OAuth.SignatureMethod.normalizeUrl(URL))
+'&'+ OAuth.percentEncode(OAuth.SignatureMethod.normalizeParameters(parameters));
}
,
normalizeUrl: function normalizeUrl(url) {
var uri = OAuth.SignatureMethod.parseUri(url);
var scheme = uri.protocol.toLowerCase();
var authority = uri.authority.toLowerCase();
var dropPort = (scheme == "http" && uri.port == 80)
|| (scheme == "https" && uri.port == 443);
if (dropPort) {
// find the last : in the authority
var index = authority.lastIndexOf(":");
if (index >= 0) {
authority = authority.substring(0, index);
}
}
var path = uri.path;
if (!path) {
path = "/"; // conforms to RFC 2616 section 3.2.2
}
// we know that there is no query and no fragment here.
return scheme + "://" + authority + path;
}
,
parseUri: function parseUri (str) {
/* This function was adapted from parseUri 1.2.1
http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
*/
var o = {key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
parser: {strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/ }};
var m = o.parser.strict.exec(str);
var uri = {};
var i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
return uri;
}
,
normalizeParameters: function normalizeParameters(parameters) {
if (parameters == null) {
return "";
}
var list = OAuth.getParameterList(parameters);
var sortable = [];
for (var p = 0; p < list.length; ++p) {
var nvp = list[p];
if (nvp[0] != "oauth_signature") {
sortable.push([ OAuth.percentEncode(nvp[0])
+ " " // because it comes before any character that can appear in a percentEncoded string.
+ OAuth.percentEncode(nvp[1])
, nvp]);
}
}
sortable.sort(function(a,b) {
if (a[0] < b[0]) return -1;
if (a[0] > b[0]) return 1;
return 0;
});
var sorted = [];
for (var s = 0; s < sortable.length; ++s) {
sorted.push(sortable[s][1]);
}
return OAuth.formEncode(sorted);
}
});
OAuth.SignatureMethod.registerMethodClass(["PLAINTEXT", "PLAINTEXT-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
return this.key;
}
));
OAuth.SignatureMethod.registerMethodClass(["HMAC-SHA1", "HMAC-SHA1-Accessor"],
OAuth.SignatureMethod.makeSubclass(
function getSignature(baseString) {
b64pad = '=';
var signature = b64_hmac_sha1(this.key, baseString);
return signature;
}
));
OAuth.correctTimestampFromSrc();

38
publish.rb Normal file → Executable file
View file

@ -1,42 +1,40 @@
#!/usr/bin/env ruby -wKU
require 'time'
require "time"
path = File.dirname File.expand_path(__FILE__)
PATH = File.dirname(__FILE__)
# system "cd \"#{path}/build/Release/\"; zip -r Twittia.app.zip Twittia.app; cd \"#{path}\""
version = `defaults read \"#{path}/build/Release/Twittia.app/Contents/Info\" CFBundleVersion`.gsub(/\n/,'')
length = `stat -f %z \"#{path}/build/Release/Twittia.app.zip\"`.gsub(/\n/,'')
signature = `ruby \"#{path}/../Sparkle\ 1.5b6/Extras/Signing Tools/sign_update.rb\" \"#{path}/build/Release/Twittia.app.zip\" \"#{path}/dsa_priv.pem\"`.gsub(/\n/,'')
`cd "#{PATH}"`
version = `defaults read "#{PATH}/build/Release/Twittia.app/Contents/Info" CFBundleVersion`.delete "\n"
length = `stat -f %z build/Release/Twittia.app.zip`.delete "\n"
signature = `"../Sparkle 1.5b6/Extras/Signing Tools/sign_update.rb" build/Release/Twittia.app.zip dsa_priv.pem`.delete "\n"
date = Time.now.rfc2822
xml =<<XML
xml = <<XML
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Twittia's Changelog</title>
<link>http://wiki.github.com/jeena/twittia/</link>
<link>http://github.com/downloads/jeena/Twittia/Appcast.xml</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version #{version}</title>
<sparkle:minimumSystemVersion>10.5.0</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>http://jeenaparadies.net/twittia/ReleaseNotes.html</sparkle:releaseNotesLink>
<pubDate>#{date}</pubDate>
<enclosure url="http://jeenaparadies.net/twittia/Twittia.app.zip"
sparkle:version="#{version}"
length="#{length}"
type="application/octet-stream"
sparkle:dsaSignature="#{signature}" />
<pubDate>#{Time.now.rfc2822}</pubDate>
<enclosure url="http://jeenaparadies.net/twittia/Twittia.app.zip"
sparkle:version="#{version}"
length="#{length}"
type="application/octet-stream"
sparkle:dsaSignature="#{signature}" />
</item>
</channel>
</rss>
XML
File.open("#{PATH}/Appcast.xml", 'w') {|f| f.write(xml) }
`scp ReleaseNotes.html jeena@jeenaparadies.net:~/jeenaparadies.net/htdocs/twittia/`
`scp build/Release/Twittia.app.zip jeena@jeenaparadies.net:~/jeenaparadies.net/htdocs/twittia/`
`scp Appcast.xml jeena@jeenaparadies.net:~/jeenaparadies.net/htdocs/twittia/`
File.open("#{path}/Appcast.xml", 'w') {|f| f.write(xml) }
system "scp \"#{path}/build/Release/Twittia.app.zip\" jeena@jeenaparadies.net:~/jeenaparadies.net/htdocs/twittia/"
system "scp \"#{path}/ReleaseNotes.html\" jeena@jeenaparadies.net:~/jeenaparadies.net/htdocs/twittia/"
system "scp \"#{path}/Appcast.xml\" jeena@jeenaparadies.net:~/jeenaparadies.net/htdocs/twittia/"
puts "Done."

202
sha1.js Normal file
View file

@ -0,0 +1,202 @@
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
/*
* Perform a simple self-test to see if the VM is working
*/
function sha1_vm_test()
{
return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
}
/*
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function core_sha1(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << (24 - len % 32);
x[((len + 64 >> 9) << 4) + 15] = len;
var w = Array(80);
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var e = -1009589776;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
var olde = e;
for(var j = 0; j < 80; j++)
{
if(j < 16) w[j] = x[i + j];
else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
}
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
}
return Array(a, b, c, d, e);
}
/*
* Perform the appropriate triplet combination function for the current
* iteration
*/
function sha1_ft(t, b, c, d)
{
if(t < 20) return (b & c) | ((~b) & d);
if(t < 40) return b ^ c ^ d;
if(t < 60) return (b & c) | (b & d) | (c & d);
return b ^ c ^ d;
}
/*
* Determine the appropriate additive constant for the current iteration
*/
function sha1_kt(t)
{
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
(t < 60) ? -1894007588 : -899497514;
}
/*
* Calculate the HMAC-SHA1 of a key and some data
*/
function core_hmac_sha1(key, data)
{
var bkey = str2binb(key);
if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
return core_sha1(opad.concat(hash), 512 + 160);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert an 8-bit or 16-bit string to an array of big-endian words
* In 8-bit function, characters >255 have their hi-byte silently ignored.
*/
function str2binb(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
return bin;
}
/*
* Convert an array of big-endian words to a string
*/
function binb2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
return str;
}
/*
* Convert an array of big-endian words to a hex string.
*/
function binb2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of big-endian words to a base-64 string
*/
function binb2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}