first working oAuth Twittia

This commit is contained in:
Jeena Paradies 2010-05-02 17:37:14 +02:00
parent bba00dd94a
commit 301fa12b21
33 changed files with 1260 additions and 46 deletions

View file

@ -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 #define TWEET_MAX_LENGTH 140
+ (NSString *)stringFromVirtualKeyCode:(NSInteger)code; + (NSString *)stringFromVirtualKeyCode:(NSInteger)code;

View file

@ -11,6 +11,7 @@
#import "ViewDelegate.h" #import "ViewDelegate.h"
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
#import "Constants.h" #import "Constants.h"
#import "OAuth.h"
@interface Controller : NSObject { @interface Controller : NSObject {
@ -20,6 +21,7 @@
IBOutlet NSWindow *mentionsViewWindow; IBOutlet NSWindow *mentionsViewWindow;
IBOutlet NSMenuItem *globalHotkeyMenuItem; IBOutlet NSMenuItem *globalHotkeyMenuItem;
ViewDelegate *viewDelegate; ViewDelegate *viewDelegate;
OAuth *oauth;
} }
@property (retain, nonatomic) IBOutlet WebView *timelineView; @property (retain, nonatomic) IBOutlet WebView *timelineView;
@ -28,7 +30,9 @@
@property (retain, nonatomic) IBOutlet NSWindow *mentionsViewWindow; @property (retain, nonatomic) IBOutlet NSWindow *mentionsViewWindow;
@property (retain, nonatomic) IBOutlet NSMenuItem *globalHotkeyMenuItem; @property (retain, nonatomic) IBOutlet NSMenuItem *globalHotkeyMenuItem;
@property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate; @property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate;
@property (retain, nonatomic) IBOutlet OAuth *oauth;
- (void)authentificationSucceded:(id)sender;
- (void)initWebViews; - (void)initWebViews;
- (void)initHotKeys; - (void)initHotKeys;
- (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId; - (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId;

View file

@ -12,10 +12,10 @@
@implementation Controller @implementation Controller
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, globalHotkeyMenuItem, viewDelegate; @synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, globalHotkeyMenuItem, viewDelegate, oauth;
- (void)awakeFromNib { - (void)awakeFromNib {
[self initWebViews];
[self initHotKeys]; [self initHotKeys];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
@ -27,12 +27,20 @@
selector:@selector(sendTweet:) selector:@selector(sendTweet:)
name:@"sendTweet" name:@"sendTweet"
object:nil]; object:nil];
[nc addObserver:self
selector:@selector(authentificationSucceded:)
name:@"authentificationSucceded"
object:nil];
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self [appleEventManager setEventHandler:self
andSelector:@selector(handleGetURLEvent:withReplyEvent:) andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass forEventClass:kInternetEventClass
andEventID:kAEGetURL]; andEventID:kAEGetURL];
if ([oauth accessToken]) {
[self initWebViews];
}
} }
- (void)initHotKeys { - (void)initHotKeys {
@ -60,25 +68,10 @@
if (newTweetModifierKey & optionKey) cocoaModifiers = cocoaModifiers | NSAlternateKeyMask; if (newTweetModifierKey & optionKey) cocoaModifiers = cocoaModifiers | NSAlternateKeyMask;
if (newTweetModifierKey & controlKey) cocoaModifiers = cocoaModifiers | NSControlKeyMask; if (newTweetModifierKey & controlKey) cocoaModifiers = cocoaModifiers | NSControlKeyMask;
if (newTweetModifierKey & cmdKey) cocoaModifiers = cocoaModifiers | NSCommandKeyMask; if (newTweetModifierKey & cmdKey) cocoaModifiers = cocoaModifiers | NSCommandKeyMask;
NSLog(@"%i", shiftKey);
NSInteger theNumber = cocoaModifiers;
NSMutableString *str = [NSMutableString string];
NSInteger numberCopy = theNumber; // so you won't change your original value
for(NSInteger i = 0; i < 32 ; i++) {
// Prepend "0" or "1", depending on the bit
[str insertString:((numberCopy & 1) ? @"1" : @"0") atIndex:0];
numberCopy >>= 1;
}
// NSLog(@"Binary version: %@", str);
NSLog(@"%c", kVK_ANSI_T);
[globalHotkeyMenuItem setKeyEquivalent:[Constants stringFromVirtualKeyCode:newTweetKey]]; [globalHotkeyMenuItem setKeyEquivalent:[Constants stringFromVirtualKeyCode:newTweetKey]];
[globalHotkeyMenuItem setKeyEquivalentModifierMask:cocoaModifiers]; [globalHotkeyMenuItem setKeyEquivalentModifierMask:cocoaModifiers];
/* CARBON from http://github.com/Xjs/drama-button/blob/carbon/Drama_ButtonAppDelegate.m */ /* CARBON from http://github.com/Xjs/drama-button/blob/carbon/Drama_ButtonAppDelegate.m */
EventTypeSpec eventType; EventTypeSpec eventType;
@ -97,6 +90,10 @@
/* end CARBON */ /* end CARBON */
} }
- (void)authentificationSucceded:(id)sender {
[self initWebViews];
}
- (void)initWebViews { - (void)initWebViews {
NSString *path = [[NSBundle mainBundle] resourcePath]; NSString *path = [[NSBundle mainBundle] resourcePath];
@ -124,6 +121,11 @@
return NO; return NO;
} }
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name {
return NO;
}
#pragma mark Notifications #pragma mark Notifications
- (IBAction)openNewTweetWindow:(id)sender { - (IBAction)openNewTweetWindow:(id)sender {
@ -138,9 +140,15 @@
} }
- (void)openNewTweetWindowWithString:(NSString *)aString { - (void)openNewTweetWindowWithString:(NSString *)aString {
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
[newTweet withString:aString]; if ([aString hasPrefix:@"//oauth_token/"]) {
// [oauth requestAccessToken:[aString substringFromIndex:14]];
} else {
MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
[newTweet withString:aString];
}
} }
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent {

View file

@ -22,8 +22,9 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<integer value="559"/> <integer value="559"/>
<integer value="81"/> <integer value="571"/>
<integer value="535"/> <integer value="535"/>
<integer value="81"/>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -775,7 +776,7 @@
<object class="NSWindowTemplate" id="1010634651"> <object class="NSWindowTemplate" id="1010634651">
<int key="NSWindowStyleMask">15</int> <int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</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> <int key="NSWTFlags">1685586944</int>
<string key="NSWindowTitle">Twittia</string> <string key="NSWindowTitle">Twittia</string>
<string key="NSWindowClass">NSWindow</string> <string key="NSWindowClass">NSWindow</string>
@ -842,7 +843,7 @@
<object class="NSWindowTemplate" id="134415325"> <object class="NSWindowTemplate" id="134415325">
<int key="NSWindowStyleMask">15</int> <int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</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> <int key="NSWTFlags">1685586944</int>
<string key="NSWindowTitle">Mentions</string> <string key="NSWindowTitle">Mentions</string>
<string key="NSWindowClass">NSWindow</string> <string key="NSWindowClass">NSWindow</string>
@ -903,6 +904,97 @@
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
<string key="NSFrameAutosaveName">mentions</string> <string key="NSFrameAutosaveName">mentions</string>
</object> </object>
<object class="NSWindowTemplate" id="414262167">
<int key="NSWindowStyleMask">29</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{787, 515}, {324, 89}}</string>
<int key="NSWTFlags">611845120</int>
<string key="NSWindowTitle">Twitter PIN</string>
<string key="NSWindowClass">NSPanel</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="439593917">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTextField" id="821023742">
<reference key="NSNextResponder" ref="439593917"/>
<int key="NSvFlags">270</int>
<string key="NSFrame">{{20, 20}, {182, 49}}</string>
<reference key="NSSuperview" ref="439593917"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="670215897">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">138413056</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">36</double>
<int key="NSfFlags">16</int>
</object>
<reference key="NSControlView" ref="821023742"/>
<bool key="NSDrawsBackground">YES</bool>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
<object class="NSArray" key="NSAllowedInputLocales">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</object>
</object>
</object>
<object class="NSButton" id="766838214">
<reference key="NSNextResponder" ref="439593917"/>
<int key="NSvFlags">265</int>
<string key="NSFrame">{{214, 26}, {96, 32}}</string>
<reference key="NSSuperview" ref="439593917"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="530701499">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Ok</string>
<object class="NSFont" key="NSSupport" id="19773046">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="766838214"/>
<int key="NSButtonFlags">-2038284033</int>
<int key="NSButtonFlags2">129</int>
<reference key="NSAlternateImage" ref="19773046"/>
<string key="NSAlternateContents"/>
<string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
</object>
</object>
<string key="NSFrameSize">{324, 89}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
<string key="NSFrameAutosaveName">twitter-pin</string>
</object>
<object class="NSCustomObject" id="829471819">
<string key="NSClassName">OAuth</string>
</object>
</object> </object>
<object class="IBObjectContainer" key="IBDocument.Objects"> <object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords"> <object class="NSMutableArray" key="connectionRecords">
@ -1331,6 +1423,46 @@
</object> </object>
<int key="connectionID">570</int> <int key="connectionID">570</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">oauth</string>
<reference key="source" ref="408500656"/>
<reference key="destination" ref="829471819"/>
</object>
<int key="connectionID">578</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">twitterPINField</string>
<reference key="source" ref="829471819"/>
<reference key="destination" ref="821023742"/>
</object>
<int key="connectionID">581</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">requestAccessTokenWithPIN:</string>
<reference key="source" ref="829471819"/>
<reference key="destination" ref="821023742"/>
</object>
<int key="connectionID">582</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">requestAccessTokenWithPIN:</string>
<reference key="source" ref="829471819"/>
<reference key="destination" ref="766838214"/>
</object>
<int key="connectionID">583</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">twitterPINPanel</string>
<reference key="source" ref="829471819"/>
<reference key="destination" ref="414262167"/>
</object>
<int key="connectionID">584</int>
</object>
</object> </object>
<object class="IBMutableOrderedSet" key="objectRecords"> <object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects"> <object class="NSArray" key="orderedObjects">
@ -1973,6 +2105,58 @@
<reference key="object" ref="126069112"/> <reference key="object" ref="126069112"/>
<reference key="parent" ref="438898709"/> <reference key="parent" ref="438898709"/>
</object> </object>
<object class="IBObjectRecord">
<int key="objectID">571</int>
<reference key="object" ref="414262167"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="439593917"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">572</int>
<reference key="object" ref="439593917"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="821023742"/>
<reference ref="766838214"/>
</object>
<reference key="parent" ref="414262167"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">573</int>
<reference key="object" ref="821023742"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="670215897"/>
</object>
<reference key="parent" ref="439593917"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">574</int>
<reference key="object" ref="670215897"/>
<reference key="parent" ref="821023742"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">575</int>
<reference key="object" ref="766838214"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="530701499"/>
</object>
<reference key="parent" ref="439593917"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">576</int>
<reference key="object" ref="530701499"/>
<reference key="parent" ref="766838214"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">577</int>
<reference key="object" ref="829471819"/>
<reference key="parent" ref="0"/>
</object>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="flattenedProperties"> <object class="NSMutableDictionary" key="flattenedProperties">
@ -2136,6 +2320,15 @@
<string>57.IBPluginDependency</string> <string>57.IBPluginDependency</string>
<string>57.ImportedFromIB2</string> <string>57.ImportedFromIB2</string>
<string>57.editorWindowContentRectSynchronizationRect</string> <string>57.editorWindowContentRectSynchronizationRect</string>
<string>571.IBEditorWindowLastContentRect</string>
<string>571.IBPluginDependency</string>
<string>571.IBWindowTemplateEditedContentRect</string>
<string>571.NSWindowTemplate.visibleAtLaunch</string>
<string>572.IBPluginDependency</string>
<string>573.IBPluginDependency</string>
<string>574.IBPluginDependency</string>
<string>575.IBPluginDependency</string>
<string>576.IBPluginDependency</string>
<string>58.IBPluginDependency</string> <string>58.IBPluginDependency</string>
<string>58.ImportedFromIB2</string> <string>58.ImportedFromIB2</string>
<string>72.IBPluginDependency</string> <string>72.IBPluginDependency</string>
@ -2302,9 +2495,9 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</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> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{460, 356}, {376, 581}}</string> <string>{{226, 247}, {376, 581}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{460, 356}, {376, 581}}</string> <string>{{226, 247}, {376, 581}}</string>
<boolean value="NO"/> <boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/> <integer value="1"/>
@ -2314,6 +2507,15 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/> <integer value="1"/>
<string>{{23, 794}, {245, 183}}</string> <string>{{23, 794}, {245, 183}}</string>
<string>{{866, 734}, {324, 89}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{866, 734}, {324, 89}}</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</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>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/> <integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -2350,7 +2552,7 @@
</object> </object>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">570</int> <int key="maxID">584</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -2358,6 +2560,10 @@
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">Controller</string> <string key="className">Controller</string>
<string key="superclassName">NSObject</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"> <object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys"> <object class="NSArray" key="dict.sortedKeys">
@ -2365,6 +2571,7 @@
<string>globalHotkeyMenuItem</string> <string>globalHotkeyMenuItem</string>
<string>mentionsView</string> <string>mentionsView</string>
<string>mentionsViewWindow</string> <string>mentionsViewWindow</string>
<string>oauth</string>
<string>timelineView</string> <string>timelineView</string>
<string>timelineViewWindow</string> <string>timelineViewWindow</string>
<string>viewDelegate</string> <string>viewDelegate</string>
@ -2374,6 +2581,7 @@
<string>NSMenuItem</string> <string>NSMenuItem</string>
<string>WebView</string> <string>WebView</string>
<string>NSWindow</string> <string>NSWindow</string>
<string>OAuth</string>
<string>WebView</string> <string>WebView</string>
<string>NSWindow</string> <string>NSWindow</string>
<string>ViewDelegate</string> <string>ViewDelegate</string>
@ -2384,6 +2592,31 @@
<string key="minorKey">Controller.h</string> <string key="minorKey">Controller.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">OAuth</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">requestAccessTokenWithPIN:</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>twitterPINField</string>
<string>twitterPINPanel</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSTextField</string>
<string>NSPanel</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">OAuth.h</string>
</object>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">ViewDelegate</string> <string key="className">ViewDelegate</string>
<string key="superclassName">NSObject</string> <string key="superclassName">NSObject</string>
@ -2425,6 +2658,14 @@
</object> </object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NSActionCell</string>
<string key="superclassName">NSCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">NSApplication</string> <string key="className">NSApplication</string>
<string key="superclassName">NSResponder</string> <string key="superclassName">NSResponder</string>
@ -2476,6 +2717,30 @@
<string key="minorKey">AppKit.framework/Headers/NSBrowser.h</string> <string key="minorKey">AppKit.framework/Headers/NSBrowser.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">NSButton</string>
<string key="superclassName">NSControl</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSButtonCell</string>
<string key="superclassName">NSActionCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSButtonCell.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"> <object class="IBPartialClassDescription">
<string key="className">NSControl</string> <string key="className">NSControl</string>
<string key="superclassName">NSView</string> <string key="superclassName">NSView</string>
@ -2889,6 +3154,14 @@
<string key="minorKey">WebKit.framework/Headers/WebUIDelegate.h</string> <string key="minorKey">WebKit.framework/Headers/WebUIDelegate.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">NSPanel</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSPanel.h</string>
</object>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">NSResponder</string> <string key="className">NSResponder</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier"> <object class="IBClassDescriptionSource" key="sourceIdentifier">
@ -2917,6 +3190,22 @@
<string key="minorKey">AppKit.framework/Headers/NSText.h</string> <string key="minorKey">AppKit.framework/Headers/NSText.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">NSTextField</string>
<string key="superclassName">NSControl</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSTextField.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSTextFieldCell</string>
<string key="superclassName">NSActionCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">NSTextView</string> <string key="className">NSTextView</string>
<string key="superclassName">NSText</string> <string key="superclassName">NSText</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.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#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.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "OAToken+WebView.h"
// this is just so the JavaScript can get the tokens.
@implementation OAToken(WebView)
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector {
return NO;
}
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name {
return NO;
}
@end

33
OAuth.h Normal file
View file

@ -0,0 +1,33 @@
//
// OAuth.h
// Twittia 2
//
// Created by Jeena on 01.05.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#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;
IBOutlet NSTextField *twitterPINField;
IBOutlet NSPanel *twitterPINPanel;
}
@property (nonatomic, retain) OAToken *accessToken;
@property (nonatomic, retain) OAToken *consumerToken;
@property (nonatomic, retain) IBOutlet NSTextField *twitterPINField;
@property (nonatomic, retain) IBOutlet NSPanel *twitterPINPanel;
- (id)init;
- (void)requestAToken;
- (IBAction)requestAccessTokenWithPIN:(id)sender;
@end

151
OAuth.m Normal file
View file

@ -0,0 +1,151 @@
//
// OAuth.m
// Twittia 2
//
// Created by Jeena on 01.05.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "OAuth.h"
#import "Constants.h"
#import <OAuthConsumer/OAConsumer.h>
#import <OAuthConsumer/OAMutableURLRequest.h>
#import <OAuthConsumer/OADataFetcher.h>
#import <OAuthConsumer/OAToken.h>
@implementation OAuth
@synthesize accessToken, consumerToken, twitterPINField, twitterPINPanel;
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector {
return NO;
}
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name {
return NO;
}
-(id)init {
if (self = [super init]) {
self.consumerToken = [[OAToken alloc] initWithKey:OAUTH_CONSUMER_KEY secret:OAUTH_CONSUMER_SECRET];
self.accessToken = [[OAToken alloc] initWithUserDefaultsUsingServiceProviderName:OAUTH_SERVICE_NAME prefix:APP_NAME];
}
return self;
}
- (void)dealloc {
[consumerToken release];
[accessToken release];
[consumer release];
[super dealloc];
}
- (void)awakeFromNib {
if (!self.accessToken) {
[self requestAToken];
}
}
-(void)requestAToken {
consumer = [[OAConsumer alloc] initWithKey:OAUTH_CONSUMER_KEY secret:OAUTH_CONSUMER_SECRET];
NSURL *url = [NSURL URLWithString:OAUTH_REQUEST_TOKEN_URL];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:nil // we don't have a Token yet
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[request setHTTPMethod:@"POST"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(requestTokenTicket:didFinishWithData:)
didFailSelector:@selector(requestTokenTicket:didFailWithError:)];
}
- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
if (ticket.didSucceed) {
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
requestToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
// show PIN panel
[twitterPINPanel makeKeyAndOrderFront:self];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?oauth_token=%@", OAUTH_USER_AUTHORIZATION_URL, requestToken.key]];
[[NSWorkspace sharedWorkspace] openURL:url];
}
}
- (void)requestTokenTicket:(OAServiceTicket *)ticket didFailWithError:(NSError *)error {
NSLog(@"ERROR: %@", error);
}
- (void)requestAccessTokenWithPIN:(id)sender {
[twitterPINPanel resignKeyWindow];
[twitterPINPanel close];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?oauth_verifier=%@", OAUTH_ACCESS_TOKEN_URL, [twitterPINField stringValue]]];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:requestToken // we don't have a Token yet
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[request setHTTPMethod:@"POST"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(accessTokenTicket:didFinishWithData:)
didFailSelector:@selector(requestTokenTicket:didFailWithError:)];
}
- (void)accessTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
if (ticket.didSucceed) {
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
accessToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
[accessToken storeInUserDefaultsWithServiceProviderName:OAUTH_SERVICE_NAME prefix:APP_NAME];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:@"authentificationSucceded" object:self];
/*
NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/home_timeline.json"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:accessToken
realm:nil
signatureProvider:nil];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(apiTicket:didFinishWithData:)
didFailSelector:@selector(requestTokenTicket:didFailWithError:)];
*/
}
}
- (void)apiTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
if (ticket.didSucceed) {
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(@"%@", responseBody);
}
}
@end

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,6 +12,9 @@
1F1990C6117BCA960049BEA7 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1990C5117BCA960049BEA7 /* ApplicationServices.framework */; }; 1F1990C6117BCA960049BEA7 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1990C5117BCA960049BEA7 /* ApplicationServices.framework */; };
1F3642EF118C8C35008198EF /* oauth.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F3642ED118C8C35008198EF /* oauth.js */; }; 1F3642EF118C8C35008198EF /* oauth.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F3642ED118C8C35008198EF /* oauth.js */; };
1F3642F0118C8C35008198EF /* sha1.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F3642EE118C8C35008198EF /* sha1.js */; }; 1F3642F0118C8C35008198EF /* sha1.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F3642EE118C8C35008198EF /* sha1.js */; };
1F364398118CBC77008198EF /* OAuth.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F364397118CBC77008198EF /* OAuth.m */; };
1F36440F118CC173008198EF /* OAuthConsumer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F36440E118CC173008198EF /* OAuthConsumer.framework */; };
1F36465E118DA5A7008198EF /* OAToken+WebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F36465D118DA5A7008198EF /* OAToken+WebView.m */; };
1F4673FE1180F7EA006CC37C /* TwittiaCore.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F4673E61180F654006CC37C /* TwittiaCore.js */; }; 1F4673FE1180F7EA006CC37C /* TwittiaCore.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F4673E61180F654006CC37C /* TwittiaCore.js */; };
1F4674081180F7EE006CC37C /* jQuery.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F4673E21180F519006CC37C /* jQuery.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 */; }; 1F4674091180F7F3006CC37C /* jQuery-Plugins.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F4673E41180F590006CC37C /* jQuery-Plugins.js */; };
@ -59,6 +62,11 @@
1F1990E1117BD2650049BEA7 /* ReleaseNotes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ReleaseNotes.html; sourceTree = "<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>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 1F4673E61180F654006CC37C /* TwittiaCore.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = TwittiaCore.js; sourceTree = "<group>"; };
@ -93,6 +101,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
1F36440F118CC173008198EF /* OAuthConsumer.framework in Frameworks */,
8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */, 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */,
1FFA37071177DAF4006C8562 /* WebKit.framework in Frameworks */, 1FFA37071177DAF4006C8562 /* WebKit.framework in Frameworks */,
1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */, 1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */,
@ -107,6 +116,7 @@
1058C7A6FEA54F5311CA2CBB /* Linked Frameworks */ = { 1058C7A6FEA54F5311CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
1F36440E118CC173008198EF /* OAuthConsumer.framework */,
1FE2FC92117A818D000504B0 /* Sparkle.framework */, 1FE2FC92117A818D000504B0 /* Sparkle.framework */,
1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */, 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */,
1FFA37061177DAF4006C8562 /* WebKit.framework */, 1FFA37061177DAF4006C8562 /* WebKit.framework */,
@ -172,8 +182,12 @@
1FFA36D51177D879006C8562 /* ViewDelegate.m */, 1FFA36D51177D879006C8562 /* ViewDelegate.m */,
2A37F4AEFDCFA73011CA2CEA /* MyDocument.h */, 2A37F4AEFDCFA73011CA2CEA /* MyDocument.h */,
2A37F4ACFDCFA73011CA2CEA /* MyDocument.m */, 2A37F4ACFDCFA73011CA2CEA /* MyDocument.m */,
1F364396118CBC77008198EF /* OAuth.h */,
1F364397118CBC77008198EF /* OAuth.m */,
1F77DB45118C5F1C007C7F1E /* Constants.h */, 1F77DB45118C5F1C007C7F1E /* Constants.h */,
1F77DB46118C5F1C007C7F1E /* Constants.m */, 1F77DB46118C5F1C007C7F1E /* Constants.m */,
1F36465C118DA5A7008198EF /* OAToken+WebView.h */,
1F36465D118DA5A7008198EF /* OAToken+WebView.m */,
); );
name = Classes; name = Classes;
sourceTree = "<group>"; sourceTree = "<group>";
@ -286,6 +300,8 @@
1FFA36D71177D879006C8562 /* Controller.m in Sources */, 1FFA36D71177D879006C8562 /* Controller.m in Sources */,
1FFA36D81177D879006C8562 /* ViewDelegate.m in Sources */, 1FFA36D81177D879006C8562 /* ViewDelegate.m in Sources */,
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */, 1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */,
1F364398118CBC77008198EF /* OAuth.m in Sources */,
1F36465E118DA5A7008198EF /* OAToken+WebView.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -336,6 +352,7 @@
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)\"", "\"$(SRCROOT)\"",
"\"$(SRCROOT)/../../Desktop/mpoauthconnection-read-only/build/Release\"", "\"$(SRCROOT)/../../Desktop/mpoauthconnection-read-only/build/Release\"",
"\"$(SRCROOT)/../oauth-obj-c/OAuthConsumer/build/Release\"",
); );
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_FIX_AND_CONTINUE = YES;
@ -358,6 +375,7 @@
"$(inherited)", "$(inherited)",
"\"$(SRCROOT)\"", "\"$(SRCROOT)\"",
"\"$(SRCROOT)/../../Desktop/mpoauthconnection-read-only/build/Release\"", "\"$(SRCROOT)/../../Desktop/mpoauthconnection-read-only/build/Release\"",
"\"$(SRCROOT)/../oauth-obj-c/OAuthConsumer/build/Release\"",
); );
GCC_MODEL_TUNING = G5; GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;

View file

@ -1,10 +1,8 @@
function Twittia(action, oauth_key, oauth_secret) { function Twittia(action) {
this.max_length = 100; this.max_length = 100;
this.since_id; this.since_id;
this.timeout = 2 * 60 * 1000; this.timeout = 2 * 60 * 1000;
this.action = action; this.action = action;
this.oauth_key = oauth_key;
this.oauth_secret = oauth_secret;
this.getNewData(); this.getNewData();
this.unread_mentions = 0; this.unread_mentions = 0;
@ -170,35 +168,66 @@ Twittia.prototype.getTemplate = function() {
return jQuery.extend(true, {}, this.template); return jQuery.extend(true, {}, this.template);
} }
Twittia.prototype.getNewData = function(supress_new_with_timeout) { Twittia.prototype.getNewData = function(supress_new_with_timeout) {
var url = "http://api.twitter.com/1/statuses/" + this.action + ".json" var url = "http://api.twitter.com/1/statuses/" + this.action + ".json"
url += "?count=" + this.max_length; var parameters = {count: this.max_length}
if(this.since_id) url += "&since_id=" + this.since_id; 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 _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({ $.ajax(
url: url, { beforeSend: function(xhr) {
dataType: 'json', xhr.setRequestHeader("Authorization", OAuth.getAuthorizationHeader("", message.parameters));
success: function(data) { },
_this.newStatus(data, supress_new_with_timeout); url: url + url2,
}, dataType: 'json',
error:function (xhr, ajaxOptions, thrownError){ success: function(data) {
alert(xhr.status); _this.newStatus(data, supress_new_with_timeout);
alert(thrownError); },
setTimeout(function() { _this.getNewData(supress_new_with_timeout) }, this.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) { Twittia.prototype.sendNewTweet = function(tweet, in_reply_to_status_id) {
var url = "http://api.twitter.com/1/statuses/update.json"; var url = "http://api.twitter.com/1/statuses/update.json";
var _this = this;
var data = "source=twittia&status=" + tweet; var data = "source=twittia&status=" + tweet;
if(in_reply_to_status_id != '') data += "&in_reply_to_status_id=" + in_reply_to_status_id 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({ $.ajax({
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", OAuth.getAuthorizationHeader("", message.parameters));
},
url: url, url: url,
type: 'POST', type: 'POST',
data: data, data: data,
@ -231,6 +260,29 @@ Twittia.prototype.retweet = function(status_id, item) {
}); });
} }
Twittia.prototype.authorizationHeader = function(method, url, params) {
if(params == undefined)
params = '';
if(method == undefined)
method = 'GET';
var timestamp = OAuth.timestamp();
var nonce = OAuth.nonce(11);
var accessor = { consumerSecret: controller.oauth.consumerToken.secret, tokenSecret: controller.oauth.accessToken.secret };
var message = {method: method, action: url, parameters: OAuth.decodeForm(params)};
message.parameters.push(['oauth_consumer_key',controller.oauth.consumerToken.key]);
message.parameters.push(['oauth_nonce',nonce]);
message.parameters.push(['oauth_signature_method','HMAC-SHA1']);
message.parameters.push(['oauth_timestamp',timestamp]);
message.parameters.push(['oauth_token', controller.oauth.accessToken.key]);
message.parameters.push(['oauth_version','1.0']);
message.parameters.sort()
OAuth.SignatureMethod.sign(message, accessor);
return OAuth.getAuthorizationHeader("", message.parameters);
}
function replaceURLWithHTMLLinks(text) { function replaceURLWithHTMLLinks(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1'>$1</a>"); return text.replace(exp,"<a href='$1'>$1</a>");
@ -254,4 +306,5 @@ function loadPlugin(url) {
document.getElementsByTagName("head")[0].appendChild(plugin); document.getElementsByTagName("head")[0].appendChild(plugin);
} }
var twittia_instance; var twittia_instance;

View file

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