def saveAccounts (self): settings = QSettings('DA-IICT', 'SAM') settings.beginGroup("Accounts") settings.setValue("Length", self.table.topLevelItemCount()) for i in range(self.table.topLevelItemCount()): ac = self.table.topLevelItem(i) temp = str(ac.text(0))+'!@#$%'+ b64encode(str(ac.passwd)) temp1 = "Account"+str(i) settings.setValue(temp1, temp) settings.endGroup()
def connect(self): settings = QSettings("Trunat", "PyTalk") settings.beginGroup("Connection") self.userID = settings.value("userID").toString().__str__() self.password = settings.value("password").toString().__str__() self.server = settings.value("server").toString().__str__() self.useSSL = settings.value("useSSL", QVariant(True)).toBool() if self.useSSL: self.port = settings.value("port", QVariant("5223")).toInt() else: self.port = settings.value("port", QVariant("5222")).toInt() self.port = int(self.port[0]) self.ressource = settings.value( "ressource", QVariant("PyTalk")).toString().__str__() settings.endGroup() self.jid = xmpp.protocol.JID(self.userID.__str__()) self.jabber = xmpp.Client(self.jid.getDomain(), debug=[]) if self.server: server = (self.server, self.port) else: server = None connection = self.jabber.connect(server) if not connection: self.emit(SIGNAL("error"), self.tr("Connection Error"), self.tr("Could not connect")) return False sys.stderr.write('Connected with %s\n' % connection) auth = self.jabber.auth(self.jid.getNode(), self.password, self.ressource) if not auth: self.emit(SIGNAL("error"), self.tr("Authentication Error"), self.tr("Could not authenticate")) return False sys.stderr.write('Authenticate using %s\n' % auth) self.register_handlers() self.jabber.sendInitPresence(requestRoster=1) return connection
def connect(self): settings = QSettings("Trunat", "PyTalk") settings.beginGroup("Connection") self.userID = settings.value("userID").toString().__str__() self.password = settings.value("password").toString().__str__() self.server = settings.value("server").toString().__str__() self.useSSL = settings.value("useSSL", QVariant(True)).toBool() if self.useSSL: self.port = settings.value("port", QVariant("5223")).toInt() else: self.port = settings.value("port", QVariant("5222")).toInt() self.port = int(self.port[0]) self.ressource = settings.value("ressource", QVariant("PyTalk")).toString().__str__() settings.endGroup() self.jid = xmpp.protocol.JID(self.userID.__str__()) self.jabber = xmpp.Client(self.jid.getDomain(), debug=[]) if self.server: server = (self.server, self.port) else: server = None connection = self.jabber.connect(server) if not connection: self.emit(SIGNAL("error"), self.tr("Connection Error"), self.tr("Could not connect")) return False sys.stderr.write('Connected with %s\n' % connection) auth = self.jabber.auth(self.jid.getNode(), self.password, self.ressource) if not auth: self.emit(SIGNAL("error"), self.tr("Authentication Error"), self.tr("Could not authenticate")) return False sys.stderr.write('Authenticate using %s\n' % auth) self.register_handlers() self.jabber.sendInitPresence(requestRoster=1) return connection