def mail_to_send(js):
     mail = Server.get_mail(js)
     m = hashlib.md5()
     m.update(mail)
     print m.hexdigest()
     j_obj = {'HASH': str(m.hexdigest()), 'MESSAGE': mail}
     return LocalJSON.addCommand(j_obj, 'MESSAGE')
    def get_mails_inbox_id(js):
        try:
            mail_fold = """Users\{0}\mails_inbox.json""".format(
                str(js['login']))

            result = Server.get_header_mail(mail_fold)

            result = LocalJSON.addCommand(result, "INBOX")
            return result
        except:
            raise Exception("GETINBOX with: " + json.dumps(js))
 def delMessage(event):
     mail_object = listbox.getCurrent()
     js = {"login": currentUser.login, "idMail": mail_object['id']}
     toSent = LocalJSON.addCommand(js, 'DELMESSAGE')
     self.sendData(toSent)
 def getMessage(event):
     mail_object = listbox.getCurrent()
     js = {"idMail": mail_object['id']}
     toSent = LocalJSON.addCommand(js, 'GETMESSAGE')
     self.sendData(toSent)
 def getInboxJSON(event):
     js = {"login": currentUser.login}
     toSent = LocalJSON.addCommand(js, 'GETINBOX')
     self.sendData(toSent)
 def getSentJSON(event):
     js = {"login": currentUser.login}
     toSent = LocalJSON.addCommand(js, 'GETSENT')
     self.sendData(toSent)
 def connectionLost(self, reason):
     print "Lost connection from " + self.getName()
     self.factory.clientProtocols.remove(self)
     self.factory.sendMessageToAllClients(
         LocalJSON.message(self.getName() + " has disconnected."))