(self)
| 27 | threading.Thread.__init__(self, name="SQL") |
| 28 | |
| 29 | def run(self): |
| 30 | self.conn = sqlite3.connect(state.appdata + 'messages.dat') |
| 31 | self.conn.text_factory = str |
| 32 | self.cur = self.conn.cursor() |
| 33 | |
| 34 | self.cur.execute('PRAGMA secure_delete = true') |
| 35 | |
| 36 | try: |
| 37 | self.cur.execute( |
| 38 | '''CREATE TABLE inbox (msgid blob, toaddress text, fromaddress text, subject text, received text, message text, folder text, encodingtype int, read bool, sighash blob, UNIQUE(msgid) ON CONFLICT REPLACE)''' ) |
| 39 | self.cur.execute( |
| 40 | '''CREATE TABLE sent (msgid blob, toaddress text, toripe blob, fromaddress text, subject text, message text, ackdata blob, senttime integer, lastactiontime integer, sleeptill integer, status text, retrynumber integer, folder text, encodingtype int, ttl int)''' ) |
| 41 | self.cur.execute( |
| 42 | '''CREATE TABLE subscriptions (label text, address text, enabled bool)''' ) |
| 43 | self.cur.execute( |
| 44 | '''CREATE TABLE addressbook (label text, address text)''' ) |
| 45 | self.cur.execute( |
| 46 | '''CREATE TABLE blacklist (label text, address text, enabled bool)''' ) |
| 47 | self.cur.execute( |
| 48 | '''CREATE TABLE whitelist (label text, address text, enabled bool)''' ) |
| 49 | self.cur.execute( |
| 50 | '''CREATE TABLE pubkeys (address text, addressversion int, transmitdata blob, time int, usedpersonally text, UNIQUE(address) ON CONFLICT REPLACE)''' ) |
| 51 | self.cur.execute( |
| 52 | '''CREATE TABLE inventory (hash blob, objecttype int, streamnumber int, payload blob, expirestime integer, tag blob, UNIQUE(hash) ON CONFLICT REPLACE)''' ) |
| 53 | self.cur.execute( |
| 54 | '''INSERT INTO subscriptions VALUES('Bitmessage new releases/announcements','BM-GtovgYdgs7qXPkoYaRgrLFuFKz1SFpsw',1)''') |
| 55 | self.cur.execute( |
| 56 | '''CREATE TABLE settings (key blob, value blob, UNIQUE(key) ON CONFLICT REPLACE)''' ) |
| 57 | self.cur.execute( '''INSERT INTO settings VALUES('version','10')''') |
| 58 | self.cur.execute( '''INSERT INTO settings VALUES('lastvacuumtime',?)''', ( |
| 59 | int(time.time()),)) |
| 60 | self.cur.execute( |
| 61 | '''CREATE TABLE objectprocessorqueue (objecttype int, data blob, UNIQUE(objecttype, data) ON CONFLICT REPLACE)''' ) |
| 62 | self.conn.commit() |
| 63 | logger.info('Created messages database file') |
| 64 | except Exception as err: |
| 65 | if str(err) == 'table inbox already exists': |
| 66 | logger.debug('Database file already exists.') |
| 67 | |
| 68 | else: |
| 69 | sys.stderr.write( |
| 70 | 'ERROR trying to create database file (message.dat). Error message: %s\n' % str(err)) |
| 71 | os._exit(0) |
| 72 | |
| 73 | if BMConfigParser().getint('bitmessagesettings', 'settingsversion') == 1: |
| 74 | BMConfigParser().set('bitmessagesettings', 'settingsversion', '2') |
| 75 | # If the settings version is equal to 2 or 3 then the |
| 76 | # sqlThread will modify the pubkeys table and change |
| 77 | # the settings version to 4. |
| 78 | BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'none') |
| 79 | BMConfigParser().set('bitmessagesettings', 'sockshostname', 'localhost') |
| 80 | BMConfigParser().set('bitmessagesettings', 'socksport', '9050') |
| 81 | BMConfigParser().set('bitmessagesettings', 'socksauthentication', 'false') |
| 82 | BMConfigParser().set('bitmessagesettings', 'socksusername', '') |
| 83 | BMConfigParser().set('bitmessagesettings', 'sockspassword', '') |
| 84 | BMConfigParser().set('bitmessagesettings', 'sockslisten', 'false') |
| 85 | BMConfigParser().set('bitmessagesettings', 'keysencrypted', 'false') |
| 86 | BMConfigParser().set('bitmessagesettings', 'messagesencrypted', 'false') |
nothing calls this directly
no test coverage detected