Пример #1
0
    def authorize_request(self, request_data):
        return True
        header = QHttpRequestHeader(QString(request_data))
        if self.debug:
            self.log.write(header.toString())

        auth = header.value('Proxy-Authorization')
        if not auth:
            return False

        challenge = base64.b64encode(self.username + ':' + self.password)
        return challenge == str(auth).split()[1]
Пример #2
0
    def authorize_request(self, request_data):
        return True
        header = QHttpRequestHeader(QString(request_data))
        if self.debug:
            self.log.write(header.toString())

        auth = header.value('Proxy-Authorization')
        if not auth:
            return False

        challenge = base64.b64encode(self.username+':'+self.password)
        return challenge == str(auth).split()[1]
Пример #3
0
class QWingsChatLineEdit(QtGui.QLineEdit):

    def __init__(self, login, uid=2303, parent=None):
        super(QWingsChatLineEdit, self).__init__(parent)
        self.parent = parent
        self.history = ['']
        self.history_index = 0
        self.login = login
        self.uid = uid
        self.http = QHttp('torrent.mnx.net.ru')
        self.http_header = QHttpRequestHeader("POST", "/ajaxchat/sendChatData.php")
        self.http_header.setValue('Host', 'torrent.mnx.net.ru')
        self.http_header.setContentType("application/x-www-form-urlencoded")
        self.connect(self.http, QtCore.SIGNAL("requestFinished(int,bool)"), self.postCompleted)

    def keyPressEvent(self, event):
        key = event.key()
        if key == Qt.Key_Up:
            if self.history_index < len(self.history) - 1:
                self.history_index += 1
                self.setText(self.history[self.history_index])
            event.accept()
        elif key == Qt.Key_Down:
            if self.history_index > 0:
                self.history_index -= 1
                self.setText(self.history[self.history_index])
            event.accept()
        elif key == Qt.Key_Return:
            msg = str(self.text())
            if msg:
                data = bytes(urlencode({'n': self.login,'c': msg,'u': self.uid}), 'utf-8')
                self.http.request(self.http_header, data);
                if len(self.history) == 1 or msg != self.history[1]:
                    self.history[0] = msg
                    self.history_index = 0
                    self.history.insert(0, '')
                self.clear()
            event.accept()
        else:
            super(QWingsChatLineEdit, self).keyPressEvent(event)
            if self.history_index == 0:
                self.history[0] = self.text()

    def postCompleted(self, msgid, error):
        if error:
            m = QtGui.QMessageBox()
            m.setText("Не удалось отправить сообщение!")
            m.exec()
Пример #4
0
 def __init__(self, login, uid=2303, parent=None):
     super(QWingsChatLineEdit, self).__init__(parent)
     self.parent = parent
     self.history = ['']
     self.history_index = 0
     self.login = login
     self.uid = uid
     self.http = QHttp('torrent.mnx.net.ru')
     self.http_header = QHttpRequestHeader("POST", "/ajaxchat/sendChatData.php")
     self.http_header.setValue('Host', 'torrent.mnx.net.ru')
     self.http_header.setContentType("application/x-www-form-urlencoded")
     self.connect(self.http, QtCore.SIGNAL("requestFinished(int,bool)"), self.postCompleted)