From f8867fb08e915a416bafc1874b30a92a535aa936 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 1 Nov 2018 14:32:50 -0500 Subject: [PATCH] work on sentbox --- .../default-plugins/pms/sentboxdb.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 onionr/static-data/default-plugins/pms/sentboxdb.py diff --git a/onionr/static-data/default-plugins/pms/sentboxdb.py b/onionr/static-data/default-plugins/pms/sentboxdb.py new file mode 100644 index 00000000..6a79f24d --- /dev/null +++ b/onionr/static-data/default-plugins/pms/sentboxdb.py @@ -0,0 +1,53 @@ +''' + Onionr - P2P Microblogging Platform & Social network + + This file handles the sentbox for the mail plugin +''' +''' + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +''' +import sqlite3, os +import core +class SentBox: + def __init__(self, core): + assert isinstance(core, core.Core) + self.dbLocation = core.dataDir + 'sentbox.db' + if not os.path.exists(self.dbLocation): + self.createDB() + self.conn = sqlite3.connect(self.dbLocation) + self.cursor = self.conn.cursor() + return + + def createDB(self): + self.cursor.execute('''CREATE TABLE sent( + hash id not null, + peer text not null, + message text not null, + date int not null + ); + ''') + self.conn.commit() + return + + def listSent(self): + retData = [] + for entry in self.cursor.execute('SELECT * FROM sent;'): + retData.append({'hash': entry[0], 'peer': entry[1], 'message': entry[2], 'date': entry[3]}) + return retData + + def addToSent(self, blockID): + return + + def removeSent(self, blockID): + return \ No newline at end of file