diff --git a/Linux/Tentia.py b/Linux/Tentia.py
index 3723597..192260f 100755
--- a/Linux/Tentia.py
+++ b/Linux/Tentia.py
@@ -14,6 +14,8 @@ class Tentia:
self.preferences = Windows.Preferences(self)
self.preferences.show()
+ self.oauth_implementation = Windows.Oauth(self)
+
if self.controller.stringForKey("user_access_token") != "":
self.authentification_succeded()
@@ -27,7 +29,7 @@ class Tentia:
def login_with_entity(self, entity):
self.controller.setStringForKey(entity, "entity")
- self.oauth_implementation = Windows.Oauth(self)
+ self.oauth_implementation.login()
def authentification_succeded(self):
self.preferences.hide()
diff --git a/Linux/Windows.py b/Linux/Windows.py
index b5d2333..681592a 100644
--- a/Linux/Windows.py
+++ b/Linux/Windows.py
@@ -35,7 +35,6 @@ class Preferences:
# text field
self.text_field = QtGui.QLineEdit(self.window)
- # self.text_field.setText("http://jeena.net")
self.text_field.setPlaceholderText("https://example.tent.is")
self.text_field.setGeometry(194, 84, 262, 22)
self.window.connect(self.text_field, QtCore.SIGNAL('returnPressed()'), self.on_login_button_clicked)
@@ -177,6 +176,10 @@ class Oauth:
script = "function HostAppGo() { start('oauth'); }"
self.core.page().mainFrame().evaluateJavaScript(script)
+ def login(self):
+ script = "tentia_instance.authenticate();"
+ self.core.page().mainFrame().evaluateJavaScript(script)
+
def handle_authentication(self, url):
self.auth_view = Helper.WebViewCreator(self.app)
self.auth_view.setWindowTitle("Authentication")
@@ -207,7 +210,8 @@ class Oauth:
self.core.page().mainFrame().evaluateJavaScript(script)
def hide(self):
- self.auth_view.hide()
+ if hasattr(self, "auth_view"):
+ self.auth_view.hide()
class Login(QtGui.QDialog):
diff --git a/Mac/Controller.m b/Mac/Controller.m
index f552dd6..33a6477 100644
--- a/Mac/Controller.m
+++ b/Mac/Controller.m
@@ -52,12 +52,12 @@
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
-
+
+
viewDelegate = [[ViewDelegate alloc] init];
-
-
accessToken = [[AccessToken alloc] init];
+
//[accessToken setString:nil forKey:@"user_access_token"];
if (![accessToken stringForKey:@"version-0.2.0-new-login"]) {
[self logout:self];
@@ -74,6 +74,7 @@
[timelineViewWindow performClose:self];
[mentionsViewWindow performClose:self];
[self.loginViewWindow makeKeyAndOrderFront:self];
+ [self initOauth];
} else {
[timelineViewWindow makeKeyAndOrderFront:self];
[self initWebViews];
@@ -104,15 +105,17 @@
//[oauthView stringByEvaluatingJavaScriptFromString:@"function HostAppGo() { start('oauth'); };"];
} else {
- [oauthView stringByEvaluatingJavaScriptFromString:@"start('oauth');"];
+ //[oauthView stringByEvaluatingJavaScriptFromString:@"start('oauth');"];
}
}
- (void)initWebViews
{
- if (YES) //viewDelegate.timelineView != timelineView)
+ if (viewDelegate.timelineView != timelineView)
{
+ [self initOauth];
+
NSString *localStoragePath = @"~/Library/Application Support/Tentia";
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Webkit/"];
@@ -409,7 +412,7 @@
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
}
-
+/*
- (void)storeAccessToken:(NSString *)_accessToken secret:(NSString *)secret userId:(NSString *)userId andScreenName:(NSString *)screenName
{
self.accessToken.accessToken = _accessToken;
@@ -419,12 +422,14 @@
[timelineViewWindow makeKeyAndOrderFront:self];
[[NSNotificationCenter defaultCenter] postNotificationName:@"authentificationSucceded" object:nil];
-}
+}*/
- (void)loggedIn
{
+ [loginActivityIndicator stopAnimation:self];
+ [self initWebViews];
+ [loginViewWindow performClose:self];
[timelineViewWindow makeKeyAndOrderFront:self];
- [[NSNotificationCenter defaultCenter] postNotificationName:@"authentificationSucceded" object:nil];
}
- (IBAction)login:(id)sender
@@ -432,32 +437,22 @@
if ([[loginEntityTextField stringValue] length] > 0) {
[[loginEntityTextField window] makeFirstResponder:nil];
[loginActivityIndicator startAnimation:self];
- [self initOauth];
+ [oauthView stringByEvaluatingJavaScriptFromString:@"tentia_instance.authenticate();"];
}
}
- (IBAction)logout:(id)sender
{
+ [oauthView stringByEvaluatingJavaScriptFromString:@"tentia_instance.logout();"];
+
[timelineViewWindow performClose:self];
[mentionsViewWindow performClose:self];
+ [conversationViewWindow performClose:self];
+ [profileViewWindow performClose:self];
[self.loginViewWindow makeKeyAndOrderFront:self];
[timelineView stringByEvaluatingJavaScriptFromString:@"tentia_instance.logout();"];
[mentionsView stringByEvaluatingJavaScriptFromString:@"tentia_instance.logout();"];
- if (oauthView) {
- [oauthView stringByEvaluatingJavaScriptFromString:@"tentia_instance.logout();"];
- }
-
- [accessToken setString:nil forKey:@"app_mac_key"];
- [accessToken setString:nil forKey:@"app_mac_key_id"];
- [accessToken setString:nil forKey:@"app_id"];
- [accessToken setString:nil forKey:@"app_mac_algorithm"];
- [accessToken setString:nil forKey:@"user_access_token"];
- [accessToken setString:nil forKey:@"user_mac_key"];
- [accessToken setString:nil forKey:@"user_mac_algorithm"];
- [accessToken setString:nil forKey:@"user_token_type"];
- [accessToken setString:nil forKey:@"api_root"];
- [accessToken setString:nil forKey:@"entity"];
}
// Mentions window has been visible
diff --git a/Mac/English.lproj/MainMenu.xib b/Mac/English.lproj/MainMenu.xib
index 7acd75b..5e3541c 100644
--- a/Mac/English.lproj/MainMenu.xib
+++ b/Mac/English.lproj/MainMenu.xib
@@ -859,7 +859,6 @@
{397, 581}
-
@@ -879,7 +878,6 @@
{397, 581}
-
{{0, 0}, {2560, 1418}}
@@ -930,7 +928,6 @@
{376, 581}
-
@@ -948,7 +945,6 @@
{376, 581}
-
{{0, 0}, {2560, 1418}}
@@ -996,7 +992,6 @@
{376, 581}
-
@@ -1007,7 +1002,6 @@
{376, 581}
-
{{0, 0}, {2560, 1418}}
@@ -1055,7 +1049,6 @@
{376, 581}
-
@@ -1066,7 +1059,6 @@
{376, 581}
-
{{0, 0}, {2560, 1418}}
@@ -1084,7 +1076,7 @@
@@ -1651,14 +1650,6 @@
606
-
-
- login:
-
-
-
- 609
-
logout:
@@ -1731,6 +1722,14 @@
665
+
+
+ login:
+
+
+
+ 666
+
makeKeyAndOrderFront:
@@ -2883,7 +2882,7 @@
- 665
+ 666
@@ -2898,12 +2897,18 @@
clearCache:
login:
logout:
+ openNewMessageWindow:
+ sendTweet:
+ showConversationForPostId:andEntity:
YES
id
id
id
+ id
+ id
+ NSString
@@ -2913,6 +2918,9 @@
clearCache:
login:
logout:
+ openNewMessageWindow:
+ sendTweet:
+ showConversationForPostId:andEntity:
YES
@@ -2928,6 +2936,18 @@
logout:
id
+
+ openNewMessageWindow:
+ id
+
+
+ sendTweet:
+ id
+
+
+ showConversationForPostId:andEntity:
+ NSString
+
diff --git a/Mac/English.lproj/NewMessageWindow.xib b/Mac/English.lproj/NewMessageWindow.xib
index df93ca0..c1aacae 100644
--- a/Mac/English.lproj/NewMessageWindow.xib
+++ b/Mac/English.lproj/NewMessageWindow.xib
@@ -164,6 +164,7 @@
{{258, 2}, {38, 16}}
+
_NS:9
YES
@@ -241,15 +242,23 @@
Add current location
2147483647
-
+
NSImage
NSMenuCheckmark
-
+
NSImage
NSMenuMixedState
+
@@ -422,6 +431,14 @@ A
100080
+
+
+ addImage:
+
+
+
+ 100083
+
delegate
@@ -539,6 +556,7 @@ A
YES
+
@@ -589,6 +607,11 @@ A
+
+ 100081
+
+
+
@@ -612,6 +635,7 @@ A
100066.IBPluginDependency
100074.IBPluginDependency
100075.IBPluginDependency
+ 100081.IBPluginDependency
5.IBPluginDependency
5.IBWindowTemplateEditedContentRect
6.IBPluginDependency
@@ -636,6 +660,7 @@ A
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
{{127, 736}, {299, 113}}
com.apple.InterfaceBuilder.CocoaPlugin
@@ -652,7 +677,7 @@ A
- 100080
+ 100083
diff --git a/WebKit/scripts/controller/Conversation.js b/WebKit/scripts/controller/Conversation.js
index 3fa4db2..145e547 100644
--- a/WebKit/scripts/controller/Conversation.js
+++ b/WebKit/scripts/controller/Conversation.js
@@ -14,6 +14,8 @@ function(HostApp, Core, Paths, URI) {
this.action = "conversation";
+ document.body.innerHTML = "";
+
this.body = document.createElement("ol");
this.body.className = this.action;
document.body.appendChild(this.body);
diff --git a/WebKit/scripts/controller/Oauth.js b/WebKit/scripts/controller/Oauth.js
index 51091ea..675737e 100644
--- a/WebKit/scripts/controller/Oauth.js
+++ b/WebKit/scripts/controller/Oauth.js
@@ -9,7 +9,7 @@ function(HostApp, Paths, Hmac) {
function Oauth() {
this.app_info = {
"id": null,
- "name": "Tentia",
+ "name": "Tentia on " + HostApp.osType(),
"description": "A small TentStatus client.",
"url": "http://jabs.nu/Tentia/",
"icon": "http://jabs.nu/Tentia/icon.png",
@@ -32,6 +32,10 @@ function(HostApp, Paths, Hmac) {
this.state = null;
}
+ Oauth.prototype.isAuthenticated = function() {
+ return HostApp.stringForKey("user_access_token") != null;
+ }
+
Oauth.prototype.authenticate = function() {
var entity = HostApp.stringForKey("entity");
@@ -153,7 +157,28 @@ function(HostApp, Paths, Hmac) {
}
Oauth.prototype.logout = function() {
- return false;
+
+ var url = Paths.mkApiRootPath("/apps/" + HostApp.stringForKey("app_id"));
+ var http_method = "DELETE";
+ var auth_header = Hmac.makeAuthHeader(
+ url,
+ http_method,
+ HostApp.stringForKey("app_mac_key"),
+ HostApp.stringForKey("app_mac_key_id")
+ );
+
+ Paths.getURL(url, http_method, function(resp) {
+ HostApp.setStringForKey(null, "app_mac_key");
+ HostApp.setStringForKey(null, "app_mac_key_id");
+ HostApp.setStringForKey(null, "app_id");
+ HostApp.setStringForKey(null, "app_mac_algorithm");
+ HostApp.setStringForKey(null, "user_access_token");
+ HostApp.setStringForKey(null, "user_mac_key");
+ HostApp.setStringForKey(null, "user_mac_algorithm");
+ HostApp.setStringForKey(null, "user_token_type");
+ HostApp.setStringForKey(null, "api_root");
+ HostApp.setStringForKey(null, "entity");
+ }, null, auth_header);
}
diff --git a/WebKit/scripts/controller/Profile.js b/WebKit/scripts/controller/Profile.js
index 8e37778..09332f9 100644
--- a/WebKit/scripts/controller/Profile.js
+++ b/WebKit/scripts/controller/Profile.js
@@ -14,6 +14,8 @@ function(HostApp, Core, Paths, URI) {
this.action = "profile";
+ document.body.innerHTML = "";
+
this.initProfileTemplate();
}
diff --git a/WebKit/scripts/controller/Timeline.js b/WebKit/scripts/controller/Timeline.js
index bc3fb7c..12fcd93 100644
--- a/WebKit/scripts/controller/Timeline.js
+++ b/WebKit/scripts/controller/Timeline.js
@@ -148,6 +148,11 @@ function(Core, Paths, HostApp, URI) {
Core.prototype.repost.call(this, id, entity, callback);
}
+ Timeline.prototype.logout = function() {
+ clearInterval(this.reloadIntervall);
+ Core.prototype.logout.call(this);
+ }
+
return Timeline;
});
\ No newline at end of file
diff --git a/WebKit/scripts/helper/HostApp.js b/WebKit/scripts/helper/HostApp.js
index 132ddcb..0d2ddcf 100644
--- a/WebKit/scripts/helper/HostApp.js
+++ b/WebKit/scripts/helper/HostApp.js
@@ -117,6 +117,10 @@ define(function() {
}
}
+ HostApp.osType = function() {
+ return OS_TYPE == "mac" ? "OS X" : "Linux";
+ }
+
return HostApp;
});
\ No newline at end of file
diff --git a/WebKit/scripts/main.js b/WebKit/scripts/main.js
index 4afd40f..e90c291 100644
--- a/WebKit/scripts/main.js
+++ b/WebKit/scripts/main.js
@@ -11,7 +11,6 @@ function start(view) {
require(["controller/Oauth"], function(Oauth) {
tentia_instance = new Oauth();
- tentia_instance.authenticate();
});