fixed problem with basic auth, added new message window
This commit is contained in:
parent
efecb823cd
commit
a861de4eb4
6 changed files with 79 additions and 23 deletions
|
@ -27,6 +27,7 @@ class WebViewCreator(QtWebKit.QWebView):
|
|||
|
||||
def load_local(self, callback=None):
|
||||
self.page().settings().setAttribute(QtWebKit.QWebSettings.LocalContentCanAccessRemoteUrls, True)
|
||||
self.page().settings().setAttribute(QtWebKit.QWebSettings.LocalStorageEnabled, True)
|
||||
self.loadFinished.connect(lambda ok: self.load_finished(ok, callback))
|
||||
|
||||
frame = self.page().mainFrame()
|
||||
|
|
|
@ -7,15 +7,13 @@ class Tentia:
|
|||
|
||||
def __init__(self):
|
||||
self.app = QtGui.QApplication(sys.argv)
|
||||
self.new_message_windows = []
|
||||
self.controller = Controller(self)
|
||||
self.console = Console()
|
||||
|
||||
self.preferences = Windows.Preferences(self)
|
||||
self.preferences.show()
|
||||
|
||||
#self.timeline = Windows.Timeline(self)
|
||||
self.mentions = Windows.Timeline(self, "mentions", "Mentions")
|
||||
|
||||
if self.controller.stringForKey("user_access_token") != "":
|
||||
self.authentification_succeded()
|
||||
|
||||
|
@ -32,13 +30,18 @@ class Tentia:
|
|||
self.oauth_implementation = Windows.Oauth(self)
|
||||
|
||||
def authentification_succeded(self):
|
||||
self.preferences.active(False)
|
||||
self.preferences.hide()
|
||||
if hasattr(self, "oauth_implementation"):
|
||||
self.oauth_implementation.hide()
|
||||
self.preferences.active(False)
|
||||
self.init_web_views()
|
||||
|
||||
def init_web_views(self):
|
||||
#self.timeline.show()
|
||||
self.mentions.show()
|
||||
self.timeline = Windows.Timeline(self)
|
||||
self.mentions = Windows.Timeline(self, "mentions", "Mentions")
|
||||
|
||||
self.timeline.show()
|
||||
#self.mentions.show()
|
||||
|
||||
|
||||
class Controller(QtCore.QObject):
|
||||
|
@ -78,30 +81,51 @@ class Controller(QtCore.QObject):
|
|||
def openURL(self, url):
|
||||
self.app.oauth_implementation.handle_authentication(str(url))
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def loggedIn(self):
|
||||
self.app.authentification_succeded()
|
||||
|
||||
@QtCore.pyqtSlot(int)
|
||||
def unreadMentions(self, count):
|
||||
i = int(count)
|
||||
if i == 0:
|
||||
self.app.timeline.setWindowTitle("Tentia (^" + count + ")")
|
||||
if i > 0:
|
||||
self.app.timeline.set_window_title("Tentia (^" + count + ")")
|
||||
else:
|
||||
self.app.timeline.setWindowTitle("Tentia")
|
||||
self.app.timeline.set_window_title("Tentia")
|
||||
|
||||
@QtCore.pyqtSlot(str, str, str, str)
|
||||
def notificateUserAboutMention(self, text, name, post_id, entity):
|
||||
print "notificateUserAboutMention is not implemented yet"
|
||||
|
||||
def openNewMessageWidow(self, entity, status_id, string):
|
||||
@QtCore.pyqtSlot(str, str, str)
|
||||
def openNewMessageWidow(self, string):
|
||||
print "openNewMessageWidow is not implemented yet"
|
||||
|
||||
@QtCore.pyqtSlot(str, str, str, bool)
|
||||
def openNewMessageWindowInReplyTostatusIdwithStringIsPrivate(self, entity, status_id, string, is_private):
|
||||
new_message_window = Windows.NewPost()
|
||||
new_message_window.inReplyToStatusIdWithString(entity, status_id, string)
|
||||
new_message_window.setIsPrivate(is_private)
|
||||
new_message_window.show()
|
||||
new_message_window.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||
self.app.new_message_windows.append(new_message_window)
|
||||
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def showConversation(self, id, entity):
|
||||
print "showConversation is not implemented yet"
|
||||
|
||||
@QtCore.pyqtSlot(str)
|
||||
def authentificationDidNotSucceed(self, errorMessage):
|
||||
print "authentificationDidNotSucceed is not implemented yet"
|
||||
msgBox = QtGui.QMessageBox()
|
||||
msgBox.setText(errorMessage)
|
||||
msgBox.exec_()
|
||||
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
def alertTitleWithMessage(self, title, message):
|
||||
print "alertTitleWithMessage is not implemented yet"
|
||||
msgBox = QtGui.QMessageBox()
|
||||
msgBox.setText(title)
|
||||
msgBox.setInformativeText(message)
|
||||
msgBox.exec_()
|
||||
|
||||
def logout(self, sender):
|
||||
print "logout is not implemented yet"
|
||||
|
|
|
@ -97,6 +97,9 @@ class Timeline:
|
|||
script = "function HostAppGo() { start('" + self.action + "'); }"
|
||||
self.window.page().mainFrame().evaluateJavaScript(script)
|
||||
|
||||
def set_window_title(self, title):
|
||||
self.window.setWindowTitle(title)
|
||||
|
||||
|
||||
class Oauth:
|
||||
|
||||
|
@ -126,12 +129,12 @@ class Oauth:
|
|||
|
||||
dialog = Login()
|
||||
|
||||
def callback(ok):
|
||||
def callback():
|
||||
authenticator.setUser(dialog.textName.text())
|
||||
authenticator.setPassword(dialog.textPass.text())
|
||||
|
||||
dialog.setInfo(reply.url(), authenticator.realm())
|
||||
#dialog.accepted.connect(callback)
|
||||
dialog.accepted.connect(callback)
|
||||
|
||||
dialog.exec_()
|
||||
|
||||
|
@ -139,11 +142,14 @@ class Oauth:
|
|||
script = "tentia_instance.requestAccessToken('" + url.toString() + "');"
|
||||
self.core.page().mainFrame().evaluateJavaScript(script)
|
||||
|
||||
def hide(self):
|
||||
self.auth_view.hide()
|
||||
|
||||
|
||||
class Login(QtGui.QDialog):
|
||||
def __init__(self):
|
||||
QtGui.QDialog.__init__(self)
|
||||
#self.setWindowTitle("Login")
|
||||
self.setWindowTitle("Login")
|
||||
|
||||
self.label = QtGui.QLabel(self)
|
||||
self.label.setText("The Server requires a username and password.")
|
||||
|
@ -154,17 +160,43 @@ class Login(QtGui.QDialog):
|
|||
self.textPass.setEchoMode(QtGui.QLineEdit.Password);
|
||||
#self.textPass.setInputMethodHints(Qt.ImhHiddenText | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase)
|
||||
|
||||
self.buttonLogin = QtGui.QPushButton('Login', self)
|
||||
self.buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
|
||||
self.buttons.accepted.connect(self.accept)
|
||||
|
||||
layout = QtGui.QVBoxLayout(self)
|
||||
layout.addWidget(self.label)
|
||||
layout.addWidget(self.textName)
|
||||
layout.addWidget(self.textPass)
|
||||
layout.addWidget(self.buttonLogin)
|
||||
layout.addWidget(self.buttons)
|
||||
|
||||
def setInfo(self, url, realm):
|
||||
pass
|
||||
#self.buttonLogin.clicked.connect(callback)
|
||||
#self.label.setText("The server " + url.host() + " requires a username and password.")
|
||||
|
||||
class NewPost(QtGui.QPlainTextEdit):
|
||||
def __init__(self):
|
||||
QtGui.QPlainTextEdit.__init__(self)
|
||||
self.setWindowTitle("New Post")
|
||||
self.resize(300, 150)
|
||||
self.setMinimumSize(100, 100)
|
||||
|
||||
self.statusBar = QtGui.QStatusBar(self)
|
||||
self.statusBar.showMessage("256")
|
||||
|
||||
self.isPrivate = False
|
||||
|
||||
def setIsPrivate(self, is_private):
|
||||
self.isPrivate = is_private
|
||||
|
||||
def toggle_is_private(self):
|
||||
self.isPrivate = not self.isPrivate
|
||||
|
||||
def inReplyToStatusIdWithString(self, reply_to, status_id, string):
|
||||
self.reply_to_entity = reply_to
|
||||
self.status_id = status_id
|
||||
self.setPlainText(string)
|
||||
|
||||
cursor = self.textCursor()
|
||||
cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.MoveAnchor)
|
||||
self.setTextCursor(cursor)
|
|
@ -78,8 +78,8 @@ function(HostApp, Paths, Hmac) {
|
|||
var data = JSON.parse(resp.responseText);
|
||||
those.authRequest(data);
|
||||
}
|
||||
Paths.getURL(Paths.mkApiRootPath("/apps"), "POST", callback, JSON.stringify(those.app_info));
|
||||
});
|
||||
Paths.getURL(Paths.mkApiRootPath("/apps"), "POST", callback, JSON.stringify(those.app_info), false);
|
||||
}, null, false);
|
||||
}
|
||||
|
||||
Oauth.prototype.authRequest = function(register_data) {
|
||||
|
|
|
@ -47,7 +47,6 @@ define(function() {
|
|||
}
|
||||
|
||||
HostApp.loggedIn = function() {
|
||||
|
||||
controller.loggedIn();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue