From 46bece79dcca69f305298c9ee69dad4b9c33fc02 Mon Sep 17 00:00:00 2001 From: jeena Date: Sun, 18 Nov 2012 10:20:31 +0100 Subject: [PATCH 1/2] added HostApp methods --- Linux/Tentia.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Linux/Tentia.py b/Linux/Tentia.py index d9cd5a9..206632d 100755 --- a/Linux/Tentia.py +++ b/Linux/Tentia.py @@ -81,6 +81,31 @@ class Controller(QtCore.QObject): def loggedIn(self): self.app.authentification_succeded() + def unreadMentions(self, count): + i = int(count) + if i == 0: + self.app.timeline.setWindowTitle("Tentia (^" + count + ")") + else: + self.app.timeline.setWindowTitle("Tentia") + + def notificateUserAboutMention(self, text, name, post_id, entity): + print "notificateUserAboutMention is not implemented yet" + + def openNewMessageWidow(self, entity, status_id, string): + print "openNewMessageWidow is not implemented yet" + + def showConversation(self, id, entity): + print "showConversation is not implemented yet" + + def authentificationDidNotSucceed(self, errorMessage): + print "authentificationDidNotSucceed is not implemented yet" + + def alertTitleWithMessage(self, title, message): + print "alertTitleWithMessage is not implemented yet" + + def logout(self, sender): + print "logout is not implemented yet" + class Console(QtCore.QObject): From 9bc284c291bb8bdb06ae5f7ffeed9ab4f2ada215 Mon Sep 17 00:00:00 2001 From: jeena Date: Sun, 18 Nov 2012 12:03:24 +0100 Subject: [PATCH 2/2] added basic auth --- Linux/Tentia.py | 4 ++-- Linux/Windows.py | 26 ++++++++------------------ 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Linux/Tentia.py b/Linux/Tentia.py index 206632d..da5cccc 100755 --- a/Linux/Tentia.py +++ b/Linux/Tentia.py @@ -13,7 +13,7 @@ class Tentia: self.preferences = Windows.Preferences(self) self.preferences.show() - self.timeline = Windows.Timeline(self) + #self.timeline = Windows.Timeline(self) self.mentions = Windows.Timeline(self, "mentions", "Mentions") if self.controller.stringForKey("user_access_token") != "": @@ -37,7 +37,7 @@ class Tentia: self.init_web_views() def init_web_views(self): - self.timeline.show() + #self.timeline.show() self.mentions.show() diff --git a/Linux/Windows.py b/Linux/Windows.py index f3814b7..e5a3e94 100644 --- a/Linux/Windows.py +++ b/Linux/Windows.py @@ -1,5 +1,5 @@ from PyQt4 import QtCore, QtGui, QtWebKit -import Helper, urllib +import Helper, urllib, urllib2 class Preferences: @@ -116,28 +116,18 @@ class Oauth: old_manager = self.auth_view.page().networkAccessManager() new_manager = Helper.NetworkAccessManager(old_manager, self.tentia_callback) + new_manager.authenticationRequired.connect(self.authentication_required) self.auth_view.page().setNetworkAccessManager(new_manager) - self.auth_view.show() + self.auth_view.load_url(url) + return False - if self.is_basic_auth(url): - print "Basic auth" - else: - self.auth_view.load_url(url) + def authentication_required(self, reply, authenticator): - - def is_basic_auth(self, url): - url_opener = urllib.URLopener() - - try: - url_opener.open(url) - except IOError, error_code: - if error_code[0] == "http error" : - if error_code[1] == 401: - return True - - return False + authenticator.setUser("jeena") + authenticator.setPassword("") def tentia_callback(self, url): script = "tentia_instance.requestAccessToken('" + url.toString() + "');" self.core.page().mainFrame().evaluateJavaScript(script) +