removed obj-c oauth
This commit is contained in:
parent
61b195eebb
commit
65ca64c505
14 changed files with 437 additions and 1124 deletions
24
AccessToken.h
Normal file
24
AccessToken.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// AccessToken.h
|
||||||
|
// Twittia 2
|
||||||
|
//
|
||||||
|
// Created by Jeena Paradies on 19/09/2011.
|
||||||
|
// Copyright 2011 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@interface AccessToken : NSObject {
|
||||||
|
NSUserDefaults *d;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setAccessToken:(NSString *)_accessToken;
|
||||||
|
- (NSString *)accessToken;
|
||||||
|
- (void)setSecret:(NSString *)_secret;
|
||||||
|
- (NSString *)secret;
|
||||||
|
- (void)setUserId:(NSString *)_userId;
|
||||||
|
- (NSString *)userId;
|
||||||
|
- (void)setScreenName:(NSString *)_screenName;
|
||||||
|
- (NSString *)screenName;
|
||||||
|
|
||||||
|
@end
|
69
AccessToken.m
Normal file
69
AccessToken.m
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
//
|
||||||
|
// AccessToken.m
|
||||||
|
// Twittia 2
|
||||||
|
//
|
||||||
|
// Created by Jeena Paradies on 19/09/2011.
|
||||||
|
// Copyright 2011 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AccessToken.h"
|
||||||
|
|
||||||
|
@implementation AccessToken
|
||||||
|
|
||||||
|
- (id)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self) {
|
||||||
|
// Initialization code here.
|
||||||
|
d = [NSUserDefaults standardUserDefaults];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setAccessToken:(NSString *)_accessToken
|
||||||
|
{
|
||||||
|
[d setObject:_accessToken forKey:@"accessToken"];
|
||||||
|
[d synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)accessToken
|
||||||
|
{
|
||||||
|
return [d objectForKey:@"accessToken"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setSecret:(NSString *)_secret
|
||||||
|
{
|
||||||
|
[d setObject:_secret forKey:@"secret"];
|
||||||
|
[d synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)secret
|
||||||
|
{
|
||||||
|
return [d objectForKey:@"secret"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setUserId:(NSString *)_userId
|
||||||
|
{
|
||||||
|
[d setObject:_userId forKey:@"userId"];
|
||||||
|
[d synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)userId
|
||||||
|
{
|
||||||
|
return [d objectForKey:@"userId"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setScreenName:(NSString *)_screenName
|
||||||
|
{
|
||||||
|
[d setObject:_screenName forKey:@"screenName"];
|
||||||
|
[d synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)screenName
|
||||||
|
{
|
||||||
|
return [d objectForKey:@"screenName"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
17
Constants.js
Normal file
17
Constants.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// TwittiaOauth.js
|
||||||
|
// Twittia 2
|
||||||
|
//
|
||||||
|
// Created by Jeena on 19.09.11.
|
||||||
|
// Licence: BSD (see attached LICENCE.txt file).
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
OAUTH_CONSUMER_KEY = "JPmU8KJhiBKfpohCiWLg"
|
||||||
|
OAUTH_CONSUMER_SECRET = "jtfSrnDrRcUnL1nqTMcAW0055m63EMClmkxhiBjQ"
|
||||||
|
OAUTH_SIGNATURE_METHOD = "HMAC-SHA1"
|
||||||
|
OAUTH_REQUEST_TOKEN_URL = "http://twitter.com/oauth/request_token"
|
||||||
|
OAUTH_USER_AUTHORIZATION_URL = "http://twitter.com/oauth/authorize"
|
||||||
|
OAUTH_ACCESS_TOKEN_URL = "http://twitter.com/oauth/access_token"
|
||||||
|
OAUTH_SERVICE_NAME = "twitter.com"
|
||||||
|
APP_NAME = "Twittia";
|
10
Controller.h
10
Controller.h
|
@ -11,7 +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"
|
#import "AccessToken.h"
|
||||||
|
|
||||||
|
|
||||||
@interface Controller : NSObject {
|
@interface Controller : NSObject {
|
||||||
|
@ -22,7 +22,8 @@
|
||||||
IBOutlet NSMenuItem *globalHotkeyMenuItem;
|
IBOutlet NSMenuItem *globalHotkeyMenuItem;
|
||||||
IBOutlet NSImageView *logoLayer;
|
IBOutlet NSImageView *logoLayer;
|
||||||
ViewDelegate *viewDelegate;
|
ViewDelegate *viewDelegate;
|
||||||
OAuth *oauth;
|
WebView *twittiaOauthView;
|
||||||
|
AccessToken *accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (retain, nonatomic) IBOutlet WebView *timelineView;
|
@property (retain, nonatomic) IBOutlet WebView *timelineView;
|
||||||
|
@ -32,8 +33,10 @@
|
||||||
@property (retain, nonatomic) IBOutlet NSMenuItem *globalHotkeyMenuItem;
|
@property (retain, nonatomic) IBOutlet NSMenuItem *globalHotkeyMenuItem;
|
||||||
@property (retain, nonatomic) IBOutlet NSImageView *logoLayer;
|
@property (retain, nonatomic) IBOutlet NSImageView *logoLayer;
|
||||||
@property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate;
|
@property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate;
|
||||||
@property (retain, nonatomic) IBOutlet OAuth *oauth;
|
@property (retain, nonatomic) WebView *twittiaOauthView;
|
||||||
|
@property (retain, nonatomic) AccessToken *accessToken;
|
||||||
|
|
||||||
|
- (void)initOauth;
|
||||||
- (void)authentificationSucceded:(id)sender;
|
- (void)authentificationSucceded:(id)sender;
|
||||||
- (void)initWebViews;
|
- (void)initWebViews;
|
||||||
- (void)initHotKeys;
|
- (void)initHotKeys;
|
||||||
|
@ -42,6 +45,7 @@
|
||||||
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
||||||
- (void)unreadMentions:(NSInteger)count;
|
- (void)unreadMentions:(NSInteger)count;
|
||||||
- (void)openURL:(NSString *)url;
|
- (void)openURL:(NSString *)url;
|
||||||
|
- (void)storeAccessToken:(NSString *)accessToken secret:(NSString *)secret userId:(NSString *)userId andScreenName:(NSString *)screenName;
|
||||||
|
|
||||||
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
||||||
|
|
||||||
|
|
50
Controller.m
50
Controller.m
|
@ -13,7 +13,9 @@
|
||||||
|
|
||||||
@implementation Controller
|
@implementation Controller
|
||||||
|
|
||||||
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, globalHotkeyMenuItem, viewDelegate, oauth, logoLayer;
|
@synthesize timelineView, timelineViewWindow, mentionsView, mentionsViewWindow, globalHotkeyMenuItem, viewDelegate;
|
||||||
|
@synthesize logoLayer;
|
||||||
|
@synthesize twittiaOauthView, accessToken;
|
||||||
|
|
||||||
- (void)awakeFromNib {
|
- (void)awakeFromNib {
|
||||||
|
|
||||||
|
@ -43,9 +45,32 @@
|
||||||
forEventClass:kInternetEventClass
|
forEventClass:kInternetEventClass
|
||||||
andEventID:kAEGetURL];
|
andEventID:kAEGetURL];
|
||||||
|
|
||||||
if ([oauth accessToken]) {
|
viewDelegate = [[ViewDelegate alloc] init];
|
||||||
[self initWebViews];
|
|
||||||
}
|
|
||||||
|
accessToken = [[AccessToken alloc] init];
|
||||||
|
NSLog(@"%@", accessToken.accessToken);
|
||||||
|
accessToken.accessToken = nil;
|
||||||
|
if (!accessToken.accessToken) {
|
||||||
|
[self initOauth];
|
||||||
|
} else {
|
||||||
|
[self initWebViews];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)initOauth {
|
||||||
|
NSString *path = [[NSBundle mainBundle] resourcePath];
|
||||||
|
NSURL *url = [NSURL fileURLWithPath:path];
|
||||||
|
NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/index_oauth.html", path] encoding:NSUTF8StringEncoding error:nil];
|
||||||
|
|
||||||
|
|
||||||
|
twittiaOauthView = [[WebView alloc] init];
|
||||||
|
viewDelegate.twittiaOauthView = twittiaOauthView;
|
||||||
|
[[twittiaOauthView mainFrame] loadHTMLString:index_string baseURL:url];
|
||||||
|
[twittiaOauthView setFrameLoadDelegate:viewDelegate];
|
||||||
|
[twittiaOauthView setPolicyDelegate:viewDelegate];
|
||||||
|
[twittiaOauthView setUIDelegate:viewDelegate];
|
||||||
|
[[twittiaOauthView windowScriptObject] setValue:self forKey:@"controller"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initHotKeys {
|
- (void)initHotKeys {
|
||||||
|
@ -107,8 +132,6 @@
|
||||||
NSString *path = [[NSBundle mainBundle] resourcePath];
|
NSString *path = [[NSBundle mainBundle] resourcePath];
|
||||||
NSURL *url = [NSURL fileURLWithPath:path];
|
NSURL *url = [NSURL fileURLWithPath:path];
|
||||||
NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/index.html", path] encoding:NSUTF8StringEncoding error:nil];
|
NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/index.html", path] encoding:NSUTF8StringEncoding error:nil];
|
||||||
|
|
||||||
viewDelegate = [[ViewDelegate alloc] init];
|
|
||||||
|
|
||||||
viewDelegate.timelineView = timelineView;
|
viewDelegate.timelineView = timelineView;
|
||||||
[[timelineView mainFrame] loadHTMLString:index_string baseURL:url];
|
[[timelineView mainFrame] loadHTMLString:index_string baseURL:url];
|
||||||
|
@ -155,7 +178,7 @@
|
||||||
NSRange range = [aString rangeOfString:@"oauth_token"];
|
NSRange range = [aString rangeOfString:@"oauth_token"];
|
||||||
|
|
||||||
if (range.length > 0) {
|
if (range.length > 0) {
|
||||||
[oauth requestAccessToken];
|
[twittiaOauthView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"twittia_oauth.requestAccessToken('%@')", aString]];
|
||||||
} else {
|
} else {
|
||||||
MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
|
MyDocument *newTweet = (MyDocument *)[[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:nil];
|
||||||
[newTweet withString:aString];
|
[newTweet withString:aString];
|
||||||
|
@ -170,7 +193,6 @@
|
||||||
|
|
||||||
- (IBAction)sendTweet:(id)sender {
|
- (IBAction)sendTweet:(id)sender {
|
||||||
TweetModel *tweet = (TweetModel *)[sender object];
|
TweetModel *tweet = (TweetModel *)[sender object];
|
||||||
//[oauth updateTweet:tweet.text inReplaToStatus:tweet.inReplyTostatusId];
|
|
||||||
NSString *func = [NSString stringWithFormat:@"twittia_instance.sendNewTweet(\"%@\", \"%@\")", [tweet.text stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], tweet.inReplyTostatusId];
|
NSString *func = [NSString stringWithFormat:@"twittia_instance.sendNewTweet(\"%@\", \"%@\")", [tweet.text stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], tweet.inReplyTostatusId];
|
||||||
[timelineView stringByEvaluatingJavaScriptFromString:func];
|
[timelineView stringByEvaluatingJavaScriptFromString:func];
|
||||||
}
|
}
|
||||||
|
@ -199,6 +221,18 @@
|
||||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
|
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)storeAccessToken:(NSString *)_accessToken secret:(NSString *)secret userId:(NSString *)userId andScreenName:(NSString *)screenName
|
||||||
|
{
|
||||||
|
self.accessToken.accessToken = _accessToken;
|
||||||
|
self.accessToken.secret = secret;
|
||||||
|
self.accessToken.userId = userId;
|
||||||
|
self.accessToken.screenName = screenName;
|
||||||
|
|
||||||
|
[timelineViewWindow makeKeyAndOrderFront:self];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"authentificationSucceded" object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
// Mentions window has been visible
|
// Mentions window has been visible
|
||||||
- (void)windowDidBecomeKey:(NSNotification *)notification {
|
- (void)windowDidBecomeKey:(NSNotification *)notification {
|
||||||
if ([notification object] == mentionsViewWindow) {
|
if ([notification object] == mentionsViewWindow) {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
archiveVersion = 1;
|
archiveVersion = 1;
|
||||||
classes = {
|
classes = {
|
||||||
};
|
};
|
||||||
objectVersion = 45;
|
objectVersion = 46;
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
@ -14,9 +14,6 @@
|
||||||
1F2746FC12D9057600339B4F /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 1FE2FCA6117A8952000504B0 /* dsa_pub.pem */; };
|
1F2746FC12D9057600339B4F /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 1FE2FCA6117A8952000504B0 /* dsa_pub.pem */; };
|
||||||
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 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 */; };
|
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 */; };
|
||||||
|
@ -25,7 +22,10 @@
|
||||||
1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F70619E1178FBB300C85707 /* Carbon.framework */; };
|
1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F70619E1178FBB300C85707 /* Carbon.framework */; };
|
||||||
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F77DB46118C5F1C007C7F1E /* Constants.m */; };
|
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F77DB46118C5F1C007C7F1E /* Constants.m */; };
|
||||||
1F98DC9E124BFFD7004289ED /* pin.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F98DC9D124BFFD7004289ED /* pin.png */; };
|
1F98DC9E124BFFD7004289ED /* pin.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F98DC9D124BFFD7004289ED /* pin.png */; };
|
||||||
1FB074DD118DDAB60013A93C /* OAuthConsumer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F36440E118CC173008198EF /* OAuthConsumer.framework */; };
|
1FC254941427BC050035D84B /* index_oauth.html in Resources */ = {isa = PBXBuildFile; fileRef = 1FC254931427BC050035D84B /* index_oauth.html */; };
|
||||||
|
1FC254951427BF150035D84B /* TwittiaOauth.js in Resources */ = {isa = PBXBuildFile; fileRef = 1FC254911427ADF90035D84B /* TwittiaOauth.js */; };
|
||||||
|
1FC2549F1427DC7F0035D84B /* Constants.js in Resources */ = {isa = PBXBuildFile; fileRef = 1FC2549D1427DC2B0035D84B /* Constants.js */; };
|
||||||
|
1FC254A01427DFAD0035D84B /* AccessToken.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FC2549B1427D9930035D84B /* AccessToken.m */; };
|
||||||
1FE2FC93117A818D000504B0 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FE2FC92117A818D000504B0 /* Sparkle.framework */; };
|
1FE2FC93117A818D000504B0 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FE2FC92117A818D000504B0 /* Sparkle.framework */; };
|
||||||
1FE2FCA4117A83B1000504B0 /* Sparkle.framework in CopyFiles */ = {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 */; };
|
1FFA36CD1177D861006C8562 /* even-bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FFA36C81177D861006C8562 /* even-bg.png */; };
|
||||||
|
@ -49,7 +49,6 @@
|
||||||
dstPath = "";
|
dstPath = "";
|
||||||
dstSubfolderSpec = 10;
|
dstSubfolderSpec = 10;
|
||||||
files = (
|
files = (
|
||||||
1F36440F118CC173008198EF /* OAuthConsumer.framework in CopyFiles */,
|
|
||||||
1FE2FCA4117A83B1000504B0 /* Sparkle.framework in CopyFiles */,
|
1FE2FCA4117A83B1000504B0 /* Sparkle.framework in CopyFiles */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -84,6 +83,11 @@
|
||||||
1F77DB45118C5F1C007C7F1E /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = "<group>"; };
|
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>"; };
|
1F77DB46118C5F1C007C7F1E /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = "<group>"; };
|
||||||
1F98DC9D124BFFD7004289ED /* pin.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pin.png; sourceTree = "<group>"; };
|
1F98DC9D124BFFD7004289ED /* pin.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pin.png; sourceTree = "<group>"; };
|
||||||
|
1FC254911427ADF90035D84B /* TwittiaOauth.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = TwittiaOauth.js; sourceTree = "<group>"; };
|
||||||
|
1FC254931427BC050035D84B /* index_oauth.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index_oauth.html; sourceTree = "<group>"; };
|
||||||
|
1FC2549A1427D9930035D84B /* AccessToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessToken.h; sourceTree = "<group>"; };
|
||||||
|
1FC2549B1427D9930035D84B /* AccessToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AccessToken.m; sourceTree = "<group>"; };
|
||||||
|
1FC2549D1427DC2B0035D84B /* Constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = Constants.js; sourceTree = "<group>"; };
|
||||||
1FE2FC92117A818D000504B0 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; 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>"; };
|
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>"; };
|
1FFA36C81177D861006C8562 /* even-bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "even-bg.png"; sourceTree = "<group>"; };
|
||||||
|
@ -111,7 +115,6 @@
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
1FB074DD118DDAB60013A93C /* 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 */,
|
||||||
|
@ -160,10 +163,13 @@
|
||||||
1F3642ED118C8C35008198EF /* oauth.js */,
|
1F3642ED118C8C35008198EF /* oauth.js */,
|
||||||
1F3642EE118C8C35008198EF /* sha1.js */,
|
1F3642EE118C8C35008198EF /* sha1.js */,
|
||||||
1F4673E61180F654006CC37C /* TwittiaCore.js */,
|
1F4673E61180F654006CC37C /* TwittiaCore.js */,
|
||||||
|
1FC254911427ADF90035D84B /* TwittiaOauth.js */,
|
||||||
|
1FC2549D1427DC2B0035D84B /* Constants.js */,
|
||||||
1FFA36C81177D861006C8562 /* even-bg.png */,
|
1FFA36C81177D861006C8562 /* even-bg.png */,
|
||||||
1F98DC9D124BFFD7004289ED /* pin.png */,
|
1F98DC9D124BFFD7004289ED /* pin.png */,
|
||||||
1F705EA5117889FA00C85707 /* sprite-icons.png */,
|
1F705EA5117889FA00C85707 /* sprite-icons.png */,
|
||||||
1FFA36C91177D861006C8562 /* index.html */,
|
1FFA36C91177D861006C8562 /* index.html */,
|
||||||
|
1FC254931427BC050035D84B /* index_oauth.html */,
|
||||||
1FFA36CA1177D861006C8562 /* odd-bg.png */,
|
1FFA36CA1177D861006C8562 /* odd-bg.png */,
|
||||||
1FFA36CB1177D861006C8562 /* default.css */,
|
1FFA36CB1177D861006C8562 /* default.css */,
|
||||||
1F4673E21180F519006CC37C /* jQuery.js */,
|
1F4673E21180F519006CC37C /* jQuery.js */,
|
||||||
|
@ -201,6 +207,8 @@
|
||||||
1F36465D118DA5A7008198EF /* OAToken+WebView.m */,
|
1F36465D118DA5A7008198EF /* OAToken+WebView.m */,
|
||||||
1F618EC812DB5E6100E500D9 /* TweetModel.h */,
|
1F618EC812DB5E6100E500D9 /* TweetModel.h */,
|
||||||
1F618EC912DB5E6100E500D9 /* TweetModel.m */,
|
1F618EC912DB5E6100E500D9 /* TweetModel.m */,
|
||||||
|
1FC2549A1427D9930035D84B /* AccessToken.h */,
|
||||||
|
1FC2549B1427D9930035D84B /* AccessToken.m */,
|
||||||
);
|
);
|
||||||
name = Classes;
|
name = Classes;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -268,8 +276,11 @@
|
||||||
/* Begin PBXProject section */
|
/* Begin PBXProject section */
|
||||||
2A37F4A9FDCFA73011CA2CEA /* Project object */ = {
|
2A37F4A9FDCFA73011CA2CEA /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0410;
|
||||||
|
};
|
||||||
buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "Twittia 2" */;
|
buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "Twittia 2" */;
|
||||||
compatibilityVersion = "Xcode 3.1";
|
compatibilityVersion = "Xcode 3.2";
|
||||||
developmentRegion = English;
|
developmentRegion = English;
|
||||||
hasScannedForEncodings = 1;
|
hasScannedForEncodings = 1;
|
||||||
knownRegions = (
|
knownRegions = (
|
||||||
|
@ -292,6 +303,8 @@
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
1FC2549F1427DC7F0035D84B /* Constants.js in Resources */,
|
||||||
|
1FC254951427BF150035D84B /* TwittiaOauth.js in Resources */,
|
||||||
1F2746FC12D9057600339B4F /* dsa_pub.pem in Resources */,
|
1F2746FC12D9057600339B4F /* dsa_pub.pem in Resources */,
|
||||||
1F3642EF118C8C35008198EF /* oauth.js in Resources */,
|
1F3642EF118C8C35008198EF /* oauth.js in Resources */,
|
||||||
1F3642F0118C8C35008198EF /* sha1.js in Resources */,
|
1F3642F0118C8C35008198EF /* sha1.js in Resources */,
|
||||||
|
@ -309,6 +322,7 @@
|
||||||
1F705EA6117889FA00C85707 /* sprite-icons.png in Resources */,
|
1F705EA6117889FA00C85707 /* sprite-icons.png in Resources */,
|
||||||
1F122D49118E1DE100E83B77 /* Icon.icns in Resources */,
|
1F122D49118E1DE100E83B77 /* Icon.icns in Resources */,
|
||||||
1F98DC9E124BFFD7004289ED /* pin.png in Resources */,
|
1F98DC9E124BFFD7004289ED /* pin.png in Resources */,
|
||||||
|
1FC254941427BC050035D84B /* index_oauth.html in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -319,13 +333,12 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
1FC254A01427DFAD0035D84B /* AccessToken.m in Sources */,
|
||||||
8D15AC310486D014006FF6A4 /* MyDocument.m in Sources */,
|
8D15AC310486D014006FF6A4 /* MyDocument.m in Sources */,
|
||||||
8D15AC320486D014006FF6A4 /* main.m in Sources */,
|
8D15AC320486D014006FF6A4 /* main.m in Sources */,
|
||||||
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 */,
|
|
||||||
1F618ECA12DB5E6100E500D9 /* TweetModel.m in Sources */,
|
1F618ECA12DB5E6100E500D9 /* TweetModel.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -380,7 +393,6 @@
|
||||||
"\"$(SRCROOT)/../oauth-obj-c/OAuthConsumer/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_MODEL_TUNING = G5;
|
GCC_MODEL_TUNING = G5;
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
|
@ -424,7 +436,6 @@
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
PREBINDING = NO;
|
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
|
@ -437,7 +448,6 @@
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
MACOSX_DEPLOYMENT_TARGET = 10.5;
|
||||||
PREBINDING = NO;
|
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
|
|
|
@ -10,16 +10,6 @@ API_PATH = "http://api.twitter.com/1/";
|
||||||
WEBSITE_PATH = "http://twitter.com/";
|
WEBSITE_PATH = "http://twitter.com/";
|
||||||
//API_PATH = "http://identi.ca/api/";
|
//API_PATH = "http://identi.ca/api/";
|
||||||
|
|
||||||
OAUTH_CONSUMER_KEY = "JPmU8KJhiBKfpohCiWLg"
|
|
||||||
OAUTH_CONSUMER_SECRET = "jtfSrnDrRcUnL1nqTMcAW0055m63EMClmkxhiBjQ"
|
|
||||||
OAUTH_SIGNATURE_METHOD = "HMAC-SHA1"
|
|
||||||
OAUTH_REQUEST_TOKEN_URL = "http://twitter.com/oauth/request_token"
|
|
||||||
OAUTH_USER_AUTHORIZATION_URL = "http://twitter.com/oauth/authorize"
|
|
||||||
OAUTH_ACCESS_TOKEN_URL = "http://twitter.com/oauth/access_token"
|
|
||||||
OAUTH_SERVICE_NAME = "twitter.com"
|
|
||||||
|
|
||||||
APP_NAME = "Twittia"
|
|
||||||
|
|
||||||
function Twittia(action) {
|
function Twittia(action) {
|
||||||
this.max_length = 100;
|
this.max_length = 100;
|
||||||
this.since_id;
|
this.since_id;
|
||||||
|
@ -274,10 +264,10 @@ Twittia.prototype.getNewData = function(supress_new_with_timeout) {
|
||||||
var message = { method:"GET" , action:url, parameters: parameters };
|
var message = { method:"GET" , action:url, parameters: parameters };
|
||||||
|
|
||||||
OAuth.completeRequest(message,
|
OAuth.completeRequest(message,
|
||||||
{ consumerKey : controller.oauth.consumerToken.key
|
{ consumerKey : OAUTH_CONSUMER_KEY
|
||||||
, consumerSecret: controller.oauth.consumerToken.secret
|
, consumerSecret: OAUTH_CONSUMER_SECRET
|
||||||
, token : controller.oauth.accessToken.key
|
, token : controller.accessToken.accessToken
|
||||||
, tokenSecret : controller.oauth.accessToken.secret
|
, tokenSecret : controller.accessToken.secret
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax(
|
$.ajax(
|
||||||
|
@ -313,10 +303,10 @@ Twittia.prototype.sendNewTweet = function(tweet, in_reply_to_status_id) {
|
||||||
var message = { method:"POST" , action:url, parameters:parameters };
|
var message = { method:"POST" , action:url, parameters:parameters };
|
||||||
|
|
||||||
OAuth.completeRequest(message,
|
OAuth.completeRequest(message,
|
||||||
{ consumerKey : controller.oauth.consumerToken.key
|
{ consumerKey : OAUTH_CONSUMER_KEY
|
||||||
, consumerSecret: controller.oauth.consumerToken.secret
|
, consumerSecret: OAUTH_CONSUMER_SECRET
|
||||||
, token : controller.oauth.accessToken.key
|
, token : controller.accessToken.accessToken
|
||||||
, tokenSecret : controller.oauth.accessToken.secret
|
, tokenSecret : controller.accessToken.secret
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -345,10 +335,10 @@ Twittia.prototype.retweet = function(status_id, item) {
|
||||||
var message = { method:"POST" , action:url };
|
var message = { method:"POST" , action:url };
|
||||||
|
|
||||||
OAuth.completeRequest(message,
|
OAuth.completeRequest(message,
|
||||||
{ consumerKey : controller.oauth.consumerToken.key
|
{ consumerKey : OAUTH_CONSUMER_KEY
|
||||||
, consumerSecret: controller.oauth.consumerToken.secret
|
, consumerSecret: OAUTH_CONSUMER_SECRET
|
||||||
, token : controller.oauth.accessToken.key
|
, token : controller.accessToken.accessToken
|
||||||
, tokenSecret : controller.oauth.accessToken.secret
|
, tokenSecret : controller.accessToken.secret
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -367,66 +357,6 @@ 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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Twittia.prototype.requestAToken = function() {
|
|
||||||
var url = OAUTH_REQUEST_TOKEN_URL;
|
|
||||||
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: 'text',
|
|
||||||
success: function(data) {
|
|
||||||
_this.requestTokenTicketFinished(data);
|
|
||||||
},
|
|
||||||
error:function (xhr, ajaxOptions, thrownError) {
|
|
||||||
alert(xhr.statusText);
|
|
||||||
alert(ajaxOptions);
|
|
||||||
alert(thrownError);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Twittia.prototype.requestTokenTicketFinished = function(data) {
|
|
||||||
controller.openURL_(OAUTH_USER_AUTHORIZATION_URL + "?" + data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function replaceURLWithHTMLLinks(text, entities, message_node) {
|
function replaceURLWithHTMLLinks(text, entities, message_node) {
|
||||||
var urls = entities.urls;
|
var urls = entities.urls;
|
||||||
|
|
111
TwittiaOauth.js
Normal file
111
TwittiaOauth.js
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
//
|
||||||
|
// TwittiaOauth.js
|
||||||
|
// Twittia 2
|
||||||
|
//
|
||||||
|
// Created by Jeena on 19.09.11.
|
||||||
|
// Licence: BSD (see attached LICENCE.txt file).
|
||||||
|
//
|
||||||
|
|
||||||
|
function TwittiaOauth() {
|
||||||
|
this.requestAToken();
|
||||||
|
alert(APP_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
TwittiaOauth.prototype.requestAToken = function() {
|
||||||
|
var url = OAUTH_REQUEST_TOKEN_URL;
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
|
var message = { method:"POST" , action:url };
|
||||||
|
|
||||||
|
OAuth.completeRequest(message,
|
||||||
|
{ consumerKey : OAUTH_CONSUMER_KEY
|
||||||
|
, consumerSecret: OAUTH_CONSUMER_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: 'text',
|
||||||
|
success: function(data) {
|
||||||
|
_this.requestTokenTicketFinished(data);
|
||||||
|
},
|
||||||
|
error:function (xhr, ajaxOptions, thrownError) {
|
||||||
|
alert(xhr.statusText);
|
||||||
|
alert(ajaxOptions);
|
||||||
|
alert(thrownError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TwittiaOauth.prototype.requestTokenTicketFinished = function(data) {
|
||||||
|
controller.openURL_(OAUTH_USER_AUTHORIZATION_URL + "?" + data);
|
||||||
|
}
|
||||||
|
|
||||||
|
TwittiaOauth.prototype.requestAccessToken = function(responseBody) {
|
||||||
|
// "twittia://oauth_token?oauth_token=jCcf7ClzJMbE4coZdONi467OAQxRGOBZJsuopG8C8&oauth_verifier=BK2ZkAIz51lqI4qta8MnKc280GyDLy0OQBpdsEmjT40"
|
||||||
|
alert(responseBody);
|
||||||
|
|
||||||
|
var urlVars = getUrlVars(responseBody);
|
||||||
|
|
||||||
|
var url = OAUTH_ACCESS_TOKEN_URL;
|
||||||
|
var _this = this;
|
||||||
|
var accessTokenKey = getUrlVars(responseBody)
|
||||||
|
|
||||||
|
var message = { method:"POST" , action:url };
|
||||||
|
|
||||||
|
OAuth.completeRequest(message,
|
||||||
|
{ consumerKey : OAUTH_CONSUMER_KEY
|
||||||
|
, consumerSecret: OAUTH_CONSUMER_SECRET
|
||||||
|
, token : urlVars["oauth_token"]
|
||||||
|
, tokenSecret : urlVars["oauth_verifier"]
|
||||||
|
});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
beforeSend: function(xhr) {
|
||||||
|
xhr.setRequestHeader("Authorization", OAuth.getAuthorizationHeader("", message.parameters));
|
||||||
|
},
|
||||||
|
url: url,
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'text',
|
||||||
|
success: function(data) {
|
||||||
|
_this.requestAccessTokenTicketFinished(data);
|
||||||
|
},
|
||||||
|
error:function (xhr, ajaxOptions, thrownError) {
|
||||||
|
alert(xhr.statusText);
|
||||||
|
alert(ajaxOptions);
|
||||||
|
alert(thrownError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
TwittiaOauth.prototype.requestAccessTokenTicketFinished = function(responseBody) {
|
||||||
|
var urlVars = getUrlVars(responseBody);
|
||||||
|
controller.storeAccessToken_secret_userId_andScreenName_(
|
||||||
|
urlVars["oauth_token"],
|
||||||
|
urlVars["oauth_token_secret"],
|
||||||
|
urlVars["user_id"],
|
||||||
|
urlVars["screen_name"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUrlVars(url)
|
||||||
|
{
|
||||||
|
var vars = [], hash;
|
||||||
|
if(url.indexOf("#") > -1) url = url.slice(0, url.indexOf("#"));
|
||||||
|
var hashes = url.slice(url.indexOf('?') + 1).split('&');
|
||||||
|
for(var i = 0; i < hashes.length; i++)
|
||||||
|
{
|
||||||
|
hash = hashes[i].split('=');
|
||||||
|
vars.push(hash[0]);
|
||||||
|
vars[hash[0]] = hash[1];
|
||||||
|
}
|
||||||
|
return vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
var twittia_oauth;
|
|
@ -34,7 +34,7 @@
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>Icon.icns</string>
|
<string>Icon.icns</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>net.jeena.apps.twittia.test</string>
|
<string>net.jeena.apps.twittia</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
|
|
|
@ -13,9 +13,11 @@
|
||||||
@interface ViewDelegate : NSObject {
|
@interface ViewDelegate : NSObject {
|
||||||
WebView *timelineView;
|
WebView *timelineView;
|
||||||
WebView *mentionsView;
|
WebView *mentionsView;
|
||||||
|
WebView *twittiaOauthView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, assign) WebView *timelineView;
|
@property (nonatomic, assign) WebView *timelineView;
|
||||||
@property (nonatomic, assign) WebView *mentionsView;
|
@property (nonatomic, assign) WebView *mentionsView;
|
||||||
|
@property (nonatomic, assign) WebView *twittiaOauthView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -11,13 +11,18 @@
|
||||||
|
|
||||||
@implementation ViewDelegate
|
@implementation ViewDelegate
|
||||||
|
|
||||||
@synthesize timelineView, mentionsView;
|
@synthesize timelineView, mentionsView, twittiaOauthView;
|
||||||
|
|
||||||
- (void)webView:(WebView *)sender addMessageToConsole:(NSDictionary *)message;{
|
- (void)webView:(WebView *)sender addMessageToConsole:(NSDictionary *)message;{
|
||||||
|
|
||||||
if (![message isKindOfClass:[NSDictionary class]]) return;
|
if (![message isKindOfClass:[NSDictionary class]]) return;
|
||||||
|
|
||||||
NSLog(@"js: %@:%@: %@",
|
NSString *viewName = @"TimelineView";
|
||||||
|
if (sender == mentionsView) viewName = @"MentionsView";
|
||||||
|
if (sender == twittiaOauthView) viewName = @"TwittiaOauthView";
|
||||||
|
|
||||||
|
NSLog(@"js<%@>: %@:%@: %@",
|
||||||
|
viewName,
|
||||||
[[message objectForKey:@"sourceURL"] lastPathComponent],
|
[[message objectForKey:@"sourceURL"] lastPathComponent],
|
||||||
[message objectForKey:@"lineNumber"],
|
[message objectForKey:@"lineNumber"],
|
||||||
[message objectForKey:@"message"]
|
[message objectForKey:@"message"]
|
||||||
|
@ -25,7 +30,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
|
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
|
||||||
NSLog(@"jsa: %@", message);
|
NSString *viewName = @"TimelineView";
|
||||||
|
if (sender == mentionsView) viewName = @"MentionsView";
|
||||||
|
if (sender == twittiaOauthView) viewName = @"TwittiaOauthView";
|
||||||
|
|
||||||
|
NSLog(@"jsa<%@>: %@", viewName, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id <WebPolicyDecisionListener>)listener {
|
- (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id <WebPolicyDecisionListener>)listener {
|
||||||
|
@ -34,18 +43,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
|
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
|
||||||
NSString *action = @"home_timeline";
|
|
||||||
NSString *delay = @"1";
|
|
||||||
|
|
||||||
if (sender == mentionsView) {
|
if (sender == twittiaOauthView) {
|
||||||
action = @"mentions";
|
|
||||||
delay = @"1000";
|
[twittiaOauthView stringByEvaluatingJavaScriptFromString:@"setTimeout( function() { twittia_oauth = new TwittiaOauth(); }, 2);"];
|
||||||
}
|
|
||||||
|
} else {
|
||||||
[sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:
|
|
||||||
@"setTimeout(function(){ twittia_instance = new Twittia('%@'); \
|
NSString *action = @"home_timeline";
|
||||||
document.getElementsByTagName('body')[0].appendChild(twittia_instance.body); \
|
NSString *delay = @"1";
|
||||||
setTimeout(function() { loadPlugin(controller.pluginURL()) }, 1); }, %@);", action, delay]];
|
|
||||||
|
if (sender == mentionsView) {
|
||||||
|
action = @"mentions";
|
||||||
|
delay = @"1000";
|
||||||
|
}
|
||||||
|
|
||||||
|
[sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:
|
||||||
|
@"setTimeout(function(){ twittia_instance = new Twittia('%@'); \
|
||||||
|
document.getElementsByTagName('body')[0].appendChild(twittia_instance.body); \
|
||||||
|
setTimeout(function() { loadPlugin(controller.pluginURL()) }, 1); }, %@);", action, delay]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<script type="text/javascript" src="jQuery-Plugins.js"></script>
|
<script type="text/javascript" src="jQuery-Plugins.js"></script>
|
||||||
<script type="text/javascript" src="sha1.js"></script>
|
<script type="text/javascript" src="sha1.js"></script>
|
||||||
<script type="text/javascript" src="oauth.js"></script>
|
<script type="text/javascript" src="oauth.js"></script>
|
||||||
|
<script type="text/javascript" src="Constants.js"></script>
|
||||||
<script type="text/javascript" src="TwittiaCore.js"></script>
|
<script type="text/javascript" src="TwittiaCore.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
15
index_oauth.html
Normal file
15
index_oauth.html
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<title>Twittia</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<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="Constants.js"></script>
|
||||||
|
<script type="text/javascript" src="TwittiaOauth.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in a new issue