Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Sep 25, 2024
1 parent 1a86b10 commit 698be80
Show file tree
Hide file tree
Showing 15 changed files with 430 additions and 132 deletions.
19 changes: 16 additions & 3 deletions src/3rdParty/lxqt_wallet/backend/lxqtwallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,15 +1390,28 @@ int lxqt_wallet_exists(const char *wallet_name, const char *application_name)
}
}

static int _lxqt_wallet_has_custom_path = 0;
static char _lxqt_wallet_custom_wallet_path[PATH_MAX] = {0};

void lxqt_wallet_set_internal_wallet_custom_path(const char *path)
{
_lxqt_wallet_has_custom_path = 1;
snprintf(_lxqt_wallet_custom_wallet_path, PATH_MAX, "%s", path);
}

void lxqt_wallet_application_wallet_path(char *path, u_int32_t path_buffer_size, const char *application_name)
{
struct passwd *pass = getpwuid(getuid());
snprintf(path, path_buffer_size, "%s/.config/lxqt/wallets/%s/", pass->pw_dir, application_name);
if(_lxqt_wallet_has_custom_path){
snprintf(path, path_buffer_size, "%s",_lxqt_wallet_custom_wallet_path);
}else{
struct passwd *pass = getpwuid(getuid());
snprintf(path, path_buffer_size, "%s/.config/lxqt/wallets/%s/", pass->pw_dir, application_name);
}
}

static char *_wallet_full_path(char *path_buffer, u_int32_t path_buffer_size, const char *wallet_name, const char *application_name)
{
char path_1[ PATH_MAX ];
char path_1[PATH_MAX];
lxqt_wallet_application_wallet_path(path_1, sizeof (path_1), application_name);
snprintf(path_buffer, path_buffer_size, "%s/%s%s", path_1, wallet_name, WALLET_EXTENSION);
return path_buffer;
Expand Down
17 changes: 16 additions & 1 deletion src/checkforupdates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,22 @@ void checkUpdates::checkIfInstalled()

QStringList apps ;

if( settings::instance().autodownloadMissingEngines() ){
if( utility::platformIsFlatPak() ){

auto src = "/app/bin/securefs" ;

if( QFile::exists( src ) ){

auto dst = basePath + "securefs" ;

if( !QFile::exists( dst ) ){

utility::copyFile( src,dst ) ;
}
}
}

if( settings::instance().autodownloadMissingEngines() && utility::canDownload() ){

if( !QFile::exists( basePath + "securefs" ) ){

Expand Down
13 changes: 9 additions & 4 deletions src/checkforupdateswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@

bool checkforupdateswindow::updatable( const QString& m )
{
if( m == "Securefs" ){
if( utility::canDownload() ){

return utility::platformIsLinux() || utility::platformIsWindows() ;
if( m == "Securefs" ){

}else if( m == "Gocryptfs" ){
return utility::platformIsLinux() || utility::platformIsWindows() ;

return utility::platformIsLinux() ;
}else if( m == "Gocryptfs" ){

return utility::platformIsLinux() ;
}else{
return false ;
}
}else{
return false ;
}
Expand Down
32 changes: 16 additions & 16 deletions src/engines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,28 +1314,28 @@ engines::engine::exe_args engines::engine::unMountCommand( const engines::engine
return _replace_opts( w ) ;
}
}else{
if( m_Options.unMountCommand.isEmpty() ){
if( !m_Options.unMountCommand.isEmpty() ){

if( utility::platformIsOSX() ){
return _replace_opts( m_Options.unMountCommand ) ;
}

return { "umount",{ e.mountPath() } } ;
}else{
if( utility::platformIsFlatPak() ){
if( utility::platformIsOSX() ){

return { "flatpak-spawn",{ "--host","fusermount","-u",e.mountPath() } } ;
}else{
auto fuserMount = engines::engine::fuserMountPath() ;
return { "umount",{ e.mountPath() } } ;
}

if( fuserMount.isEmpty() ){
if( utility::platformIsFlatPak() ){

return { engines::engine::status::fuserMountNotFound } ;
}else{
return { fuserMount,{ "-u",e.mountPath() } } ;
}
}
}
return { "flatpak-spawn",{ "--host","fusermount","-u",e.mountPath() } } ;
}

const auto& fm = engines::engine::fuserMountPath() ;

if( fm.isEmpty() ){

return { engines::engine::status::fuserMountNotFound } ;
}else{
return _replace_opts( m_Options.unMountCommand ) ;
return { fm,{ "-u",e.mountPath() } } ;
}
}
}
Expand Down
235 changes: 195 additions & 40 deletions src/flatpak/io.github.mhogomchungu.sirikali.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,199 @@
{
"app-id": "io.github.mhogomchungu.sirikali",
"runtime": "org.kde.Platform",
"runtime-version": "6.7",
"sdk": "org.kde.Sdk",
"command": "io.github.mhogomchungu.sirikali",
"finish-args": [
"--share=ipc",
"--socket=wayland",
"--socket=fallback-x11",
"--filesystem=xdg-documents",
"--share=network",
"--device=dri",
"--talk-name=org.kde.StatusNotifierWatcher",
"--talk-name=org.freedesktop.Flatpak"
],
"modules": [
{
"name": "libfuse",
"buildsystem": "autotools",
"config-opts": [
"--disable-util"
],
"sources": [
{
"type": "archive",
"url": "https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz",
"sha256": "d0e69d5d608cc22ff4843791ad097f554dd32540ddc9bed7638cc6fea7c1b4b5"
}
]
"app-id" : "io.github.mhogomchungu.sirikali",
"runtime" : "org.kde.Platform",
"runtime-version" : "6.7",
"sdk" : "org.kde.Sdk",
"command" : "io.github.mhogomchungu.sirikali",
"finish-args" : [
"--share=ipc",
"--socket=wayland",
"--socket=fallback-x11",
"--filesystem=xdg-documents",
"--share=network",
"--device=dri",
"--talk-name=org.kde.StatusNotifierWatcher",
"--talk-name=org.freedesktop.Flatpak"
],
"modules" : [
{
"name" : "libfuse",
"buildsystem" : "autotools",
"cleanup" : [
"/include",
"/lib/pkgconfig",
"*.a",
"*.la",
"/lib/libulockmgr*"
],
"config-opts" : [
"--disable-util"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz",
"sha256" : "d0e69d5d608cc22ff4843791ad097f554dd32540ddc9bed7638cc6fea7c1b4b5"
}
]
},
{
"name" : "absl",
"buildsystem" : "cmake-ninja",
"cleanup" : [
"*"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/abseil/abseil-cpp/releases/download/20240722.0/abseil-cpp-20240722.0.tar.gz",
"sha256" : "f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3"
}
]
},
{
"name" : "cryptopp-cmake",
"buildsystem" : "cmake-ninja",
"cleanup" : [
"*"
],
"config-opts" : [
"-DCRYPTOPP_SOURCES=src/deps/cryptopp1",
"-DCRYPTOPP_BUILD_TESTING=OFF",
"-DCRYPTOPP_BUILD_DOCUMENTATION=OFF"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/abdes/cryptopp-cmake/archive/refs/tags/CRYPTOPP_8_9_0.tar.gz",
"sha256" : "191d69061c56602de1610ebf03b44dcf75636006e7e60ef8105bee6472ec0caf"
},
{
"type" : "archive",
"url" : "https://github.com/weidai11/cryptopp/archive/refs/tags/CRYPTOPP_8_9_0.tar.gz",
"sha256" : "ab5174b9b5c6236588e15a1aa1aaecb6658cdbe09501c7981ac8db276a24d9ab",
"dest" : "src/deps/cryptopp1"
}
]
},
{
"name" : "uni-algo",
"buildsystem" : "cmake-ninja",
"cleanup" : [
"*"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/uni-algo/uni-algo/archive/refs/tags/v1.2.0.tar.gz",
"sha256" : "f2a1539cd8635bc6088d05144a73ecfe7b4d74ee0361fabed6f87f9f19e74ca9"
}
]
},
{
"name" : "protobuf",
"buildsystem" : "cmake-ninja",
"cleanup" : [
"*"
],
"config-opts" : [
"-Dprotobuf_BUILD_TESTS=OFF",
"-Dprotobuf_BUILD_CONFORMANCE=OFF",
"-Dprotobuf_ABSL_PROVIDER=package"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/protocolbuffers/protobuf/releases/download/v28.2/protobuf-28.2.tar.gz",
"sha256" : "b2340aa47faf7ef10a0328190319d3f3bee1b24f426d4ce8f4253b6f27ce16db"
}
]
},
{
"name" : "argon2",
"buildsystem" : "cmake-ninja",
"cleanup" : [
"*"
],
"sources" : [
{
"type" : "file",
"url" : "https://raw.githubusercontent.com/microsoft/vcpkg/98aa6396292d57e737a6ef999d4225ca488859d5/ports/argon2/CMakeLists.txt",
"sha256" : "55492f7b05cdcb2c3fd78abc1bedad79e9c8186623a7ff91bdd4582fd3f07992"
},
{
"name": "io.github.mhogomchungu.sirikali",
"buildsystem": "cmake-ninja",
"config-opts": ["-DCMAKE_BUILD_TYPE=release","-DBUILD_FLATPAK=TRUE"],
"sources": [
{
"type": "dir",
"path": "../.."
}
]
}
]
"type" : "file",
"url" : "https://raw.githubusercontent.com/microsoft/vcpkg/98aa6396292d57e737a6ef999d4225ca488859d5/ports/argon2/unofficial-argon2-config.cmake",
"sha256" : "0ba4414821d7f76edef65af4d2c15fd4dfbafe8a6ef5da43155267c8e41817f3"
},
{
"type" : "archive",
"url" : "https://github.com/P-H-C/phc-winner-argon2/archive/refs/tags/20190702.tar.gz",
"sha256" : "daf972a89577f8772602bf2eb38b6a3dd3d922bf5724d45e7f9589b5e830442c"
}
]
},
{
"name" : "fruit",
"buildsystem" : "cmake-ninja",
"cleanup" : [
"/include",
"/lib/pkgconfig",
"*.a"
],
"config-opts" : [
"-DCMAKE_BUILD_TYPE=Release",
"-DFRUIT_USES_BOOST=False",
"-DBUILD_SHARED_LIBS=FALSE"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/google/fruit/archive/refs/tags/v3.7.1.tar.gz",
"sha256" : "ed4c6b7ebfbf75e14a74e21eb74ce2703b8485bfc9e660b1c36fb7fe363172d0"
}
]
},
{
"name" : "securefs",
"buildsystem" : "cmake-ninja",
"config-opts" : [
"-DSECUREFS_USE_VCPKG=FALSE",
"-DSECUREFS_ENABLE_UNIT_TEST=FALSE",
"-DTCLAP_INCLUDE_DIRS=tclap/include"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/mirror/tclap/archive/refs/tags/v1.2.5.tar.gz",
"sha256" : "7e87d13734076fa4f626f6144ce9a02717198b3f054341a6886e2107b048b235",
"dest" : "tclap"
},
{
"type" : "archive",
"url" : "https://github.com/netheril96/securefs/archive/refs/tags/v1.0.0.tar.gz",
"sha256" : "de888359734a05ca0db56d006b4c9774f18fd9e6f9253466a86739b5f6ac3753"
},
{
"type" : "patch",
"paths" : [
"patches/securefs.patch"
]
}
]
},
{
"name" : "io.github.mhogomchungu.sirikali",
"buildsystem" : "cmake-ninja",
"config-opts" : [
"-DCMAKE_BUILD_TYPE=release",
"-DBUILD_FLATPAK=TRUE"
],
"sources" : [
{
"type" : "dir",
"path" : "../.."
}
]
}
]
}
9 changes: 3 additions & 6 deletions src/flatpak/io.github.mhogomchungu.sirikali.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<name>Francis Banyikwa</name>
</developer>

<description><p>This application make it easy to use CLI based tools to manage folder based encrypted volumes.</p></description>
<description><p>This application makes it easy to store your documents in a secured folder. Securefs is bundled with the application and users who prefer to use gocryptfs or Cryfs should add them to "/home/ink/.var/app/io.github.mhogomchungu.sirikali/data/SiriKali/bin" folder</p></description>

<launchable type="desktop-id">io.github.mhogomchungu.sirikali.desktop</launchable>

Expand All @@ -36,15 +36,12 @@
</categories>

<releases>
<release version="1.6.1" type="stable" date="2024-09-21" >
<release version="1.6.0.2" type="stable" date="2024-09-24" >
<url type="details">https://github.com/mhogomchungu/sirikali/releases/download/$version/sirikali-$version.tar.xz/</url>
<description>
<p>Changelog</p>
<ul>
<li>[WINDOWS]</li>
<li> Internally manage securefs and make it possible to update it from within the app.</li>
<li>[LINUX]</li>
<li> Internally manage gocryptfs and securefs and make it possible to update them from within the app.</li>
<li>Initial Flatpak release</li>
</ul>
</description>
</release>
Expand Down
Loading

0 comments on commit 698be80

Please sign in to comment.