Allow storing SQLite through SQLCipher
ClosedPublic

Authored by wojnilowicz on Jun 30 2018, 6:55 PM.

Diff Detail

Repository
R261 KMyMoney
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
wojnilowicz requested review of this revision.Jun 30 2018, 6:55 PM
wojnilowicz created this revision.
tbaumgart added inline comments.
kmymoney/plugins/sql/sqlstorage.cpp
169

Why are you using a fixed name for the DB here?

wojnilowicz updated this revision to Diff 36993.Jul 1 2018, 8:41 AM
wojnilowicz marked an inline comment as done.
wojnilowicz added inline comments.
kmymoney/plugins/sql/sqlstorage.cpp
169

That shouldn't be here. It was for testing purpose only.

tbaumgart requested changes to this revision.Jul 10 2018, 6:25 PM

Cannot build w/o sqlcipher being installed. Sqlcipher must be optional not mandatory.

-- Checking for module 'sqlcipher'
--   No package 'sqlcipher' found
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:363 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPkgConfig.cmake:528 (_pkg_check_modules_internal)
  CMakeLists.txt:56 (pkg_check_modules)


-- Configuring incomplete, errors occurred!
See also "/home/thb/devel/kmymoney/build/CMakeFiles/CMakeOutput.log".
See also "/home/thb/devel/kmymoney/build/CMakeFiles/CMakeError.log".
Makefile:3426: recipe for target 'cmake_check_build_system' failed
This revision now requires changes to proceed.Jul 10 2018, 6:25 PM

The patch compiles now, but the option is disabled here. I don't have all the necessary packages and don't use SQL backends. Can you find someone else who can verify that this change works as expected and does not break anything?

wojnilowicz added a comment.EditedJul 12 2018, 1:47 PM

The patch compiles now, but the option is disabled here. I don't have all the necessary packages and don't use SQL backends. Can you find someone else who can verify that this change works as expected and does not break anything?

There is no SQL cipher support now in KMM, so we could only gain something. Could you compile SQL cipher yourself? It shouldn't be so difficult to do. If not then I think there's no point in halting it.

tbaumgart requested changes to this revision.Jul 12 2018, 2:40 PM

After installing the necessary sqlcipher packages, I get the option to be found and turned on, but cmake produces the following output

-- Checking for module 'sqlcipher'
--   Found sqlcipher, version 3.11.0
-- Found PythonInterp: /usr/bin/python (found version "2.7.13") 
-- Boost version: 1.61.0
-- Found LibAlkimia: /usr/lib64/cmake/LibAlkimia5-7.0/LibAlkimia5Config.cmake (found version "7.0.80")
-- Found PythonInterp: /usr/bin/python (found suitable version "2.7.13", minimum required is "2.6") 
-- Could NOT find PythonLibs (missing:  PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is at least version "2.7.13")
-- Found Libical version 1.0

Build type: DebugFull
-- The following REQUIRED packages have not been found:

-- The following OPTIONAL packages have not been found:
 * Gpgmepp
 * PythonLibs (required version >= 2.7.13)

-- The following features have been enabled:
 * Encryption , It allows encrypting your financial data.
 * Doxygen , Generate API documentation with Doxygen (for devs only).
 * Address book , It allows fetching payee information from KDE PIM system.
 * Holidays , It allows fetching holidays from KDE PIM system.
 * Forecast view , It adds possibility to calculate forecasts.
 * Reports view , It adds possibility to display chart and table reports.
 * Budget view , It adds possibility to plan a budget.
 * Online job outbox view , It adds outbox for sending online jobs.
 * SQL Storage , It allows storing your financial data in SQL database.
 * SQLCipher , It allows encrypting your SQLite3 database.
 * OFX Importer , It allows importing OFX files (have client uid version: yes)
 * KBanking , Interface for the following online banking protocols: HBCI, EBICS, OFX Direct Connect, Paypal
 * iCalendar , iCalendar integration.
 * QIF Importer , It allows importing QIF files.
 * QIF Exporter , It allows exporting QIF files.
 * GNC Importer , It allows importing GNUCash files.
 * CSV Importer , It allows importing CSV files.
 * CSV Exporter , It allows exporting CSV files.

-- The following features have been disabled:
 * IBAN/BIC data , Adds predefined IBAN/BIC numbers to KMyMoney (note: doesn't work yet).
 * Weboob , Online banking interface using Weboob.
 * Model test , Generate modeltest code (for devs only).
 * QtDesigner , Qt-Designer library support (for devs only).

-- Configuring done
CMake Error at /usr/lib64/cmake/KF5CoreAddons/KF5CoreAddonsMacros.cmake:139 (add_library):
  Target "qsqlcipher" links to target "Qt5::SqlPrivate" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  kmymoney/plugins/sqlcipher/CMakeLists.txt:29 (kcoreaddons_add_plugin)


CMake Error at /usr/lib64/cmake/KF5CoreAddons/KF5CoreAddonsMacros.cmake:139 (add_library):
  Target "qsqlcipher" links to target "Qt5::SqlPrivate" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  kmymoney/plugins/sqlcipher/CMakeLists.txt:29 (kcoreaddons_add_plugin)


-- Generating done
-- Build files have been written to: /home/thb/devel/kmymoney/build

and make complains

[ 98%] Building CXX object kmymoney/plugins/kbanking/CMakeFiles/kbanking.dir/kbanking_automoc.cpp.o
[ 98%] Linking CXX shared module kbanking.so
[ 98%] Built target kbanking
make[2]: *** No rule to make target 'kmymoney/plugins/sqlcipher/sqlcipher.json', needed by 'kmymoney/plugins/sqlcipher/CMakeFiles/qsqlcipher_automoc'.  Stop.
CMakeFiles/Makefile2:8028: recipe for target 'kmymoney/plugins/sqlcipher/CMakeFiles/qsqlcipher_automoc.dir/all' failed
make[1]: *** [kmymoney/plugins/sqlcipher/CMakeFiles/qsqlcipher_automoc.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
This revision now requires changes to proceed.Jul 12 2018, 2:40 PM

Tried to fix sqlcipher.json issue.

wojnilowicz added a comment.EditedJul 13 2018, 4:44 PM

On my system Qt5::SqlPrivate is defined in Qt5SqlConfig.cmake which is installed by qt5-qtbase-devel. If you won't manage to get Qt5::SqlPrivate on your system, then we'll use less elegant way.

Now it fails with

[ 98%] Building CXX object kmymoney/plugins/sqlcipher/CMakeFiles/qsqlcipher.dir/qsql_sqlite.cpp.o
/home/thb/devel/kmymoney/build/kmymoney/plugins/sqlcipher/qsql_sqlite.cpp:44:10: fatal error: 
      'QtSql/private/qsqlcachedresult_p.h' file not found
#include <QtSql/private/qsqlcachedresult_p.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

I am not sure if using any of these private headers is a good idea. Where does this file come from? I cannot find it for my distro anywhere (maybe, I have not looked everywhere yet).

tbaumgart requested changes to this revision.Jul 14 2018, 10:01 AM
This revision now requires changes to proceed.Jul 14 2018, 10:01 AM

Now it fails with

[ 98%] Building CXX object kmymoney/plugins/sqlcipher/CMakeFiles/qsqlcipher.dir/qsql_sqlite.cpp.o
/home/thb/devel/kmymoney/build/kmymoney/plugins/sqlcipher/qsql_sqlite.cpp:44:10: fatal error: 
      'QtSql/private/qsqlcachedresult_p.h' file not found
#include <QtSql/private/qsqlcachedresult_p.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

I am not sure if using any of these private headers is a good idea. Where does this file come from? I cannot find it for my distro anywhere (maybe, I have not looked everywhere yet).

I know no other way to add new SQL driver to Qt and it's used by others as well.
I believe that in your distro you have to have additional package

wojnilowicz requested review of this revision.Jul 15 2018, 2:33 PM
tbaumgart accepted this revision as: tbaumgart.Jul 15 2018, 5:00 PM

This package does not match my distro and I honestly don't want to install it. But since I can compile w/o this feature enabled, go ahead and add it.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 16 2018, 4:33 PM
This revision was automatically updated to reflect the committed changes.