version 0.3.29
[fms.git] / include / ithreaddatabase.h
diff --git a/include/ithreaddatabase.h b/include/ithreaddatabase.h
new file mode 100644 (file)
index 0000000..b5d303a
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef _ithreaddatabase_\r
+#define _ithreaddatabase_\r
+\r
+#include "db/sqlite3db.h"\r
+\r
+// each thread using the database must inherit from this class\r
+class IThreadDatabase\r
+{\r
+public:\r
+       IThreadDatabase():m_db(0)       {}\r
+       virtual ~IThreadDatabase()\r
+       {\r
+               delete m_db;\r
+       }\r
+       \r
+       void LoadDatabase()\r
+       {\r
+               if(m_db)\r
+               {\r
+                       delete m_db;    \r
+               }\r
+               m_db=new SQLite3DB::DB("fms.db3");\r
+               m_db->SetBusyTimeout(40000);            // set timeout to 40 seconds\r
+               m_db->Execute("PRAGMA synchronous = FULL;");\r
+\r
+               // MessageInserter will insert a record into this temp table which the MessageListInserter will query for and insert a MessageList when needed\r
+               m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpMessageListInsert(\\r
+                                       MessageListInsertID     INTEGER PRIMARY KEY,\\r
+                                       LocalIdentityID         INTEGER,\\r
+                                       Date                            DATETIME\\r
+                                       );");\r
+\r
+               // A temporary table that will hold a local identity id of the last identity who was loaded in the trust list page\r
+               m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpLocalIdentityPeerTrustPage(\\r
+                                       LocalIdentityID         INTEGER\\r
+                                       );");\r
+\r
+               // Temporary table for form passwords\r
+               m_db->Execute("CREATE TEMPORARY TABLE IF NOT EXISTS tmpFormPassword(\\r
+                                       Date                    DATETIME,\\r
+                                       Password                TEXT\\r
+                                       );");\r
+\r
+       }\r
+       \r
+protected:\r
+       SQLite3DB::DB *m_db;\r
+};\r
+\r
+#endif // _ithreaddatabase_\r