Skip to content

Commit 9f50501

Browse files
committed
Add demo code for iOS.
1 parent 09f08e0 commit 9f50501

5 files changed

Lines changed: 44 additions & 17 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ GeneratedFiles/
2222
ipch/
2323
/libs/
2424
Makefile
25-
Win32/
25+
Win32/
26+
\.DS_Store
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
## 0.6 2017-03-20
1+
## 0.7 (2017-04-08)
2+
* Update sqlitecipher plugin debug name pattern on Mac OS.
3+
* Port test code to iOS.
4+
5+
## 0.6 (2017-03-20)
26
* Fix a crash bug compiling with gcc.
37
* Update sqlite to 3.17.0
48
* Update wxSqlite3 to 3.5.2
59

6-
## 0.5 2016-05-20
10+
## 0.5 (2016-05-20)
711
* Copy private Qt sources to this project.
812

9-
## 0.4 2016-05-19
13+
## 0.4 (2016-05-19)
1014
* Update sqlite to 3.12.2
1115
* Update wxSqlite3 to 3.3.1
1216
* Update driver code to Qt 5.6. Now we could support Qt 5.0 to 5.6, but not for 5.7.
1317
* Improve Qt private path settings.
1418
* Add password create, update and remove. **Thanks to @topillar**
1519
* Return false when password is incorrect.
1620

17-
## 0.3 2014-09-20
21+
## 0.3 (2014-09-20)
1822
* Add password paramater to open() function.
1923
* Update sqlite to 3.8.5
2024
* Update wxSqlite3 to 3.1.0
2125

22-
## 0.2 2013-01-09
26+
## 0.2 (2013-01-09)
2327
* Update sqlite to 3.7.15.1
2428
* Support for Qt 5
2529

26-
## 0.1 2012-09-27
30+
## 0.1 (2012-09-27)
2731
* sqlite 3.7.13

sqlitecipher/sqlitecipher.pro

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
TARGET = sqlitecipher
12
CONFIG(debug, debug|release) {
2-
TARGET = sqlitecipherd
3-
}else{
4-
TARGET = sqlitecipher
3+
mac: TARGET = $$join(TARGET,,,_debug)
4+
else: TARGET = $$join(TARGET,,,d)
55
}
66

77
android {
@@ -31,10 +31,16 @@ OTHER_FILES += SqliteCipherDriverPlugin.json
3131

3232
!system-sqlite:!contains( LIBS, .*sqlite.* ) {
3333
CONFIG(release, debug|release):DEFINES *= NDEBUG
34-
DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE QT_PLUGIN
35-
blackberry: DEFINES += SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_RTREE
36-
wince*: DEFINES += HAVE_LOCALTIME_S=0
34+
DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_RTREE
35+
!contains(CONFIG, largefile):DEFINES += SQLITE_DISABLE_LFS
36+
winrt: DEFINES += SQLITE_OS_WINRT
37+
winphone: DEFINES += SQLITE_WIN32_FILEMAPPING_API=1
38+
qnx: DEFINES += _QNX_SOURCE
3739
} else {
38-
LIBS *= $$QT_LFLAGS_SQLITE
40+
LIBS += $$QT_LFLAGS_SQLITE
3941
QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE
4042
}
43+
44+
PLUGIN_CLASS_NAME = SqliteCipherDriverPlugin
45+
46+
PLUGIN_TYPE = sqldrivers

test/main.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#include <QtSql>
22
#include <QCoreApplication>
33

4+
#ifdef Q_OS_IOS
5+
# include <QtPlugin>
6+
7+
Q_IMPORT_PLUGIN(SqliteCipherDriverPlugin)
8+
#endif
9+
410
#define CONNECTION_FAILED -1
511

612
int main(int argc, char *argv[])
@@ -9,9 +15,12 @@ int main(int argc, char *argv[])
915
Q_UNUSED(app);
1016

1117
qDebug() << QSqlDatabase::drivers();
18+
QString dir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
19+
QString DB_FILE_PATH = dir + "/test_c.db";
20+
qDebug() << "DB File Path is:" << DB_FILE_PATH;
1221

13-
QSqlDatabase dbconn = QSqlDatabase::addDatabase("SQLITECIPHER");
14-
dbconn.setDatabaseName("test_c.db");
22+
QSqlDatabase dbconn = QSqlDatabase::addDatabase("QSQLITE");
23+
dbconn.setDatabaseName(DB_FILE_PATH);
1524
dbconn.setPassword("test");
1625
if (!dbconn.open()) {
1726
qDebug() << "Can not open connection: " << dbconn.lastError().driverText();

test/test.pro

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@ QT += core sql
22

33
QT -= gui
44

5-
TARGET = test
5+
TARGET = test
66
CONFIG += console
77
CONFIG -= app_bundle
88

99
TEMPLATE = app
1010

11+
ios {
12+
CONFIG(debug, debug|release) {
13+
LIBS += -lsqlitecipher_debug
14+
} else {
15+
LIBS += -lsqlitecipher
16+
}
17+
}
1118

1219
SOURCES += main.cpp

0 commit comments

Comments
 (0)