version 0.3.29
[fms.git] / include / ithreaddatabase.h
1 #ifndef _ithreaddatabase_\r
2 #define _ithreaddatabase_\r
3 \r
4 #include "db/sqlite3db.h"\r
5 \r
6 // each thread using the database must inherit from this class\r
7 class IThreadDatabase\r
8 {\r
9 public:\r
10         IThreadDatabase():m_db(0)       {}\r
11         virtual ~IThreadDatabase()\r
12         {\r
13                 delete m_db;\r
14         }\r
15         \r
16         void LoadDatabase()\r
17         {\r
18                 if(m_db)\r
19                 {\r
20                         delete m_db;    \r
21                 }\r
22                 m_db=new SQLite3DB::DB("fms.db3");\r
23                 m_db->SetBusyTimeout(40000);            // set timeout to 40 seconds\r
24                 m_db->Execute("PRAGMA synchronous = FULL;");\r
25 \r
26                 // MessageInserter will insert a record into this temp table which the MessageListInserter will query for and insert a MessageList when needed\r
27                 m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpMessageListInsert(\\r
28                                         MessageListInsertID     INTEGER PRIMARY KEY,\\r
29                                         LocalIdentityID         INTEGER,\\r
30                                         Date                            DATETIME\\r
31                                         );");\r
32 \r
33                 // A temporary table that will hold a local identity id of the last identity who was loaded in the trust list page\r
34                 m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpLocalIdentityPeerTrustPage(\\r
35                                         LocalIdentityID         INTEGER\\r
36                                         );");\r
37 \r
38                 // Temporary table for form passwords\r
39                 m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpFormPassword(\\r
40                                         Date                    DATETIME,\\r
41                                         Password                TEXT\\r
42                                         );");\r
43 \r
44         }\r
45         \r
46 protected:\r
47         SQLite3DB::DB *m_db;\r
48 };\r
49 \r
50 #endif  // _ithreaddatabase_\r