diff --git a/packages/xdga_directories/.gitignore b/packages/xdga_directories/.gitignore new file mode 100644 index 0000000..96486fd --- /dev/null +++ b/packages/xdga_directories/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/packages/xdga_directories/.metadata b/packages/xdga_directories/.metadata new file mode 100644 index 0000000..641645c --- /dev/null +++ b/packages/xdga_directories/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 135454af32477f815a7525073027a3ff9eff1bfd + channel: aurora + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 135454af32477f815a7525073027a3ff9eff1bfd + base_revision: 135454af32477f815a7525073027a3ff9eff1bfd + - platform: aurora + create_revision: 135454af32477f815a7525073027a3ff9eff1bfd + base_revision: 135454af32477f815a7525073027a3ff9eff1bfd + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/packages/xdga_directories/README.md b/packages/xdga_directories/README.md new file mode 100644 index 0000000..bf161ac --- /dev/null +++ b/packages/xdga_directories/README.md @@ -0,0 +1,40 @@ +# xdga_directories + +A Dart package for reading directory path on Aurora OS. +Documentation for setting permissions can be found [here](https://developer.auroraos.ru/doc/software_development/reference/user_data). + +To use this package, the basic XDG values for the following are available via a Dart API: + +- `getAppDataLocation` - Returns a directory location where persistent application data can be stored. +- `getCacheLocation` - Returns a directory location where user-specific non-essential (cached) data should be written. +- `getDocumentsLocation` - Returns the directory containing user document files. +- `getDownloadLocation` - Returns a directory for user's downloaded files. +- `getMusicLocation` - Returns the directory containing the user's music or other audio files. +- `getPicturesLocation` - Returns the directory containing the user's pictures or photos. +- `getGenericDataLocation` - Returns a directory location where persistent data shared across applications can be stored. +- `getMoviesLocation` - Returns the directory containing the user's movies and videos. + +## Usage + +**pubspec.yaml** + +```yaml +dependencies: + flutter_secure_storage_aurora: + path: # path to folder with plugin +``` + +***.dart** + +```dart +import 'package:xdga_directories/xdga_directories.dart' as xdga; + +final appDataLocation = xdga.getAppDataLocation(); +final cacheLocation = xdga.getCacheLocation(); +final documentsLocation = xdga.getDocumentsLocation(); +final downloadLocation = xdga.getDownloadLocation(); +final musicLocation = xdga.getMusicLocation(); +final picturesLocation = xdga.getPicturesLocation(); +final genericDataLocation = xdga.getGenericDataLocation(); +final moviesLocation = xdga.getMoviesLocation(); +``` diff --git a/packages/xdga_directories/analysis_options.yaml b/packages/xdga_directories/analysis_options.yaml new file mode 100644 index 0000000..f9b3034 --- /dev/null +++ b/packages/xdga_directories/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/packages/xdga_directories/aurora/CMakeLists.txt b/packages/xdga_directories/aurora/CMakeLists.txt new file mode 100644 index 0000000..2fb2126 --- /dev/null +++ b/packages/xdga_directories/aurora/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.10) + +set(PLUGIN_NAME xdga_directories) +project(${PLUGIN_NAME} LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_CURRENT_BINARY_DIR}/shared) diff --git a/packages/xdga_directories/data/preview.png b/packages/xdga_directories/data/preview.png new file mode 100644 index 0000000..1fc2f51 Binary files /dev/null and b/packages/xdga_directories/data/preview.png differ diff --git a/packages/xdga_directories/example/.gitignore b/packages/xdga_directories/example/.gitignore new file mode 100644 index 0000000..24476c5 --- /dev/null +++ b/packages/xdga_directories/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/packages/xdga_directories/example/README.md b/packages/xdga_directories/example/README.md new file mode 100644 index 0000000..f407146 --- /dev/null +++ b/packages/xdga_directories/example/README.md @@ -0,0 +1,21 @@ +# xdga_directories_example + +Demonstrates how to use the xdga_directories plugin. + +## Build + +```shell +# Add an alias if it doesn't already exist +alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter +# Get dependencies +flutter-aurora pub get +# Run build +flutter-aurora build aurora --release # [--release|--debug|--profile] +``` + +You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` +More information in `build_example.sh`. + +### Preview example + +![preview.png](../data/preview.png) diff --git a/packages/xdga_directories/example/analysis_options.yaml b/packages/xdga_directories/example/analysis_options.yaml new file mode 100644 index 0000000..f9b3034 --- /dev/null +++ b/packages/xdga_directories/example/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/packages/xdga_directories/example/aurora/.gitignore b/packages/xdga_directories/example/aurora/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/packages/xdga_directories/example/aurora/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/packages/xdga_directories/example/aurora/CMakeLists.txt b/packages/xdga_directories/example/aurora/CMakeLists.txt new file mode 100644 index 0000000..48ee0cc --- /dev/null +++ b/packages/xdga_directories/example/aurora/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.10) +project(com.example.xdga_directories_example LANGUAGES CXX) + +include(GNUInstallDirs) + +set(BINARY_NAME ${CMAKE_PROJECT_NAME}) +set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_CXX_FLAGS "-Wall -Wextra") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + +set(CMAKE_SKIP_RPATH OFF) +set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") + +find_package(PkgConfig REQUIRED) +find_package(Qt5 COMPONENTS Core REQUIRED) +pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) + +add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder Qt5::Core) +target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) + +include(flutter/generated_plugins.cmake) + +set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) +set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) +set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) + +add_custom_command(TARGET ${BINARY_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so + ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) + +install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) +install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) +install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) + +foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) + install(FILES icons/${ICONS_SIZE}.png + RENAME ${BINARY_NAME}.png + DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) +endforeach(ICONS_SIZE) diff --git a/packages/xdga_directories/example/aurora/desktop/com.example.xdga_directories_example.desktop b/packages/xdga_directories/example/aurora/desktop/com.example.xdga_directories_example.desktop new file mode 100644 index 0000000..b025d3c --- /dev/null +++ b/packages/xdga_directories/example/aurora/desktop/com.example.xdga_directories_example.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=Application +Name=xdga_directories_example +Comment=Demonstrates how to use the xdga_directories plugin. +Icon=com.example.xdga_directories_example +Exec=/usr/bin/com.example.xdga_directories_example +X-Nemo-Application-Type=silica-qt5 + +[X-Application] +Permissions= +OrganizationName=com.example +ApplicationName=xdga_directories_example diff --git a/packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.cpp b/packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.cpp new file mode 100644 index 0000000..b315972 --- /dev/null +++ b/packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.cpp @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include + +#include "generated_plugin_registrant.h" + +void RegisterPlugins() { + Application::RegisterPlugins({ + }); +} diff --git a/packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.h b/packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..648dcb3 --- /dev/null +++ b/packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.h @@ -0,0 +1,12 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT +#define GENERATED_PLUGIN_REGISTRANT + +void RegisterPlugins(); + +#endif /* GENERATED_PLUGIN_REGISTRANT */ diff --git a/packages/xdga_directories/example/aurora/flutter/generated_plugins.cmake b/packages/xdga_directories/example/aurora/flutter/generated_plugins.cmake new file mode 100644 index 0000000..2d7ab7b --- /dev/null +++ b/packages/xdga_directories/example/aurora/flutter/generated_plugins.cmake @@ -0,0 +1,31 @@ +# +# Generated file, do not edit. +# +set(ROOT_PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}") + +function(add_library TARGET) + _add_library(${TARGET} ${ARGN}) + + if(NOT "${TARGET}" MATCHES "^PkgConfig::.*") + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + "$" + "${ROOT_PROJECT_BINARY_DIR}/bundle/lib/$") + endif(NOT "${TARGET}" MATCHES "^PkgConfig::.*") +endfunction() + +list(APPEND FLUTTER_PLATFORM_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + xdga_directories +) + +foreach(PLUGIN ${FLUTTER_PLATFORM_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${PLUGIN}/aurora plugins/${PLUGIN}) + target_link_libraries(${BINARY_NAME} PRIVATE ${PLUGIN}_platform_plugin) +endforeach(PLUGIN) + +foreach(FFI_PLUGIN ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${FFI_PLUGIN}/aurora plugins/${FFI_PLUGIN}) +endforeach(FFI_PLUGIN) diff --git a/packages/xdga_directories/example/aurora/icons/108x108.png b/packages/xdga_directories/example/aurora/icons/108x108.png new file mode 100644 index 0000000..984893d Binary files /dev/null and b/packages/xdga_directories/example/aurora/icons/108x108.png differ diff --git a/packages/xdga_directories/example/aurora/icons/128x128.png b/packages/xdga_directories/example/aurora/icons/128x128.png new file mode 100644 index 0000000..2d552ef Binary files /dev/null and b/packages/xdga_directories/example/aurora/icons/128x128.png differ diff --git a/packages/xdga_directories/example/aurora/icons/172x172.png b/packages/xdga_directories/example/aurora/icons/172x172.png new file mode 100644 index 0000000..9dc271b Binary files /dev/null and b/packages/xdga_directories/example/aurora/icons/172x172.png differ diff --git a/packages/xdga_directories/example/aurora/icons/86x86.png b/packages/xdga_directories/example/aurora/icons/86x86.png new file mode 100644 index 0000000..5923bb1 Binary files /dev/null and b/packages/xdga_directories/example/aurora/icons/86x86.png differ diff --git a/packages/xdga_directories/example/aurora/main.cpp b/packages/xdga_directories/example/aurora/main.cpp new file mode 100644 index 0000000..2dd2f52 --- /dev/null +++ b/packages/xdga_directories/example/aurora/main.cpp @@ -0,0 +1,10 @@ +#include +#include "generated_plugin_registrant.h" + +int main(int argc, char *argv[]) { + Application::Initialize(argc, argv); + Application::SetPixelRatio(1.8); + RegisterPlugins(); + Application::Launch(); + return 0; +} diff --git a/packages/xdga_directories/example/aurora/rpm/com.example.xdga_directories_example.spec b/packages/xdga_directories/example/aurora/rpm/com.example.xdga_directories_example.spec new file mode 100644 index 0000000..36130d1 --- /dev/null +++ b/packages/xdga_directories/example/aurora/rpm/com.example.xdga_directories_example.spec @@ -0,0 +1,31 @@ +%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ +%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ + +Name: com.example.xdga_directories_example +Summary: Demonstrates how to use the xdga_directories plugin. +Version: 0.1.0 +Release: 1 +License: Proprietary +Source0: %{name}-%{version}.tar.zst + +BuildRequires: cmake +BuildRequires: pkgconfig(flutter-embedder) + +%description +%{summary}. + +%prep +%autosetup + +%build +%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} +%make_build + +%install +%make_install + +%files +%{_bindir}/%{name} +%{_datadir}/%{name}/* +%{_datadir}/applications/%{name}.desktop +%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/xdga_directories/example/lib/main.dart b/packages/xdga_directories/example/lib/main.dart new file mode 100644 index 0000000..ffb767e --- /dev/null +++ b/packages/xdga_directories/example/lib/main.dart @@ -0,0 +1,176 @@ +import 'package:flutter/material.dart'; +import 'package:xdga_directories/xdga_directories.dart' as xdga; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + late String appDataLocation; + late String cacheLocation; + late String documentsLocation; + late String downloadLocation; + late String musicLocation; + late String picturesLocation; + late String genericDataLocation; + late String moviesLocation; + + @override + void initState() { + super.initState(); + // Get paths + appDataLocation = xdga.getAppDataLocation(); + cacheLocation = xdga.getCacheLocation(); + documentsLocation = xdga.getDocumentsLocation(); + downloadLocation = xdga.getDownloadLocation(); + musicLocation = xdga.getMusicLocation(); + picturesLocation = xdga.getPicturesLocation(); + genericDataLocation = xdga.getGenericDataLocation(); + moviesLocation = xdga.getMoviesLocation(); + } + + @override + Widget build(BuildContext context) { + const textStyleWhite = TextStyle(fontSize: 18, color: Colors.white); + const textStyleTitle = TextStyle(fontSize: 20, color: Colors.black); + const textStylePath = TextStyle(fontSize: 18, color: Colors.black54); + + const spaceMedium = SizedBox(height: 16); + const spacerSmall = SizedBox(height: 8); + + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Example xdga_directories'), + ), + body: SingleChildScrollView( + child: Center( + child: Container( + padding: const EdgeInsets.all(10), + child: Column( + children: [ + Container( + decoration: const BoxDecoration( + color: Colors.green, + borderRadius: BorderRadius.all(Radius.circular(10.0)), + ), + child: const Padding( + padding: EdgeInsets.all(20), + child: Text( + 'Demo application demonstration use xdga_directories', + style: textStyleWhite, + ), + ), + ), + const SizedBox(height: 30), + + // getAppDataLocation + const Text( + 'getAppDataLocation()', + style: textStyleTitle, + ), + spacerSmall, + Text( + appDataLocation, + style: textStylePath, + ), + spaceMedium, + + // getCacheLocation + const Text( + 'getCacheLocation()', + style: textStyleTitle, + ), + spacerSmall, + Text( + cacheLocation, + style: textStylePath, + ), + spaceMedium, + + // getDocumentsLocation + const Text( + 'getDocumentsLocation()', + style: textStyleTitle, + ), + spacerSmall, + Text( + documentsLocation, + style: textStylePath, + ), + spaceMedium, + + // getDocumentsLocation + const Text( + 'getDownloadLocation()', + style: textStyleTitle, + ), + spacerSmall, + Text( + downloadLocation, + style: textStylePath, + ), + spaceMedium, + + // getDocumentsLocation + const Text( + 'getMusicLocation()', + style: textStyleTitle, + ), + spacerSmall, + Text( + musicLocation, + style: textStylePath, + ), + spaceMedium, + + // getDocumentsLocation + const Text( + 'getPicturesLocation()', + style: textStyleTitle, + ), + spacerSmall, + Text( + picturesLocation, + style: textStylePath, + ), + spaceMedium, + + // getDocumentsLocation + const Text( + 'getGenericDataLocation()', + style: textStyleTitle, + ), + spacerSmall, + Text( + genericDataLocation, + style: textStylePath, + ), + spaceMedium, + + // getDocumentsLocation + const Text( + 'getMoviesLocation()', + style: textStyleTitle, + ), + spacerSmall, + Text( + moviesLocation, + style: textStylePath, + ), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/packages/xdga_directories/example/pubspec.yaml b/packages/xdga_directories/example/pubspec.yaml new file mode 100644 index 0000000..15f0699 --- /dev/null +++ b/packages/xdga_directories/example/pubspec.yaml @@ -0,0 +1,24 @@ +name: xdga_directories_example +description: Demonstrates how to use the xdga_directories plugin. + +publish_to: 'none' + +version: 1.0.0+1 + +environment: + sdk: '>=2.18.6 <3.0.0' + +dependencies: + flutter: + sdk: flutter + xdga_directories: + path: ../ + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +flutter: + uses-material-design: true diff --git a/packages/xdga_directories/ffigen.yaml b/packages/xdga_directories/ffigen.yaml new file mode 100644 index 0000000..14d5a49 --- /dev/null +++ b/packages/xdga_directories/ffigen.yaml @@ -0,0 +1,17 @@ +name: XdgaDirectoriesBindings +llvm-path: + - '/usr/lib/llvm-14/lib/libclang.so' # Ubuntu 22.04 + - '/usr/lib/llvm-15/lib/libclang.so' # Ubuntu 23.04 +description: | + Bindings for `src/xdga_directories.h`. + + Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. +output: 'lib/xdga_directories_bindings_generated.dart' +headers: + entry-points: + - 'src/xdga_directories.h' + include-directives: + - 'src/xdga_directories.h' +comments: + style: any + length: full diff --git a/packages/xdga_directories/lib/xdga_directories.dart b/packages/xdga_directories/lib/xdga_directories.dart new file mode 100644 index 0000000..014e220 --- /dev/null +++ b/packages/xdga_directories/lib/xdga_directories.dart @@ -0,0 +1,43 @@ +import 'dart:ffi'; +import 'package:ffi/ffi.dart'; +import 'xdga_directories_bindings_generated.dart'; + +/// The dynamic library in which the symbols for [XdgaDirectoriesBindings] can be found. +final DynamicLibrary _dylib = () { + return DynamicLibrary.open('libxdga_directories.so'); +}(); + +/// The bindings to the native functions in [_dylib]. +final XdgaDirectoriesBindings _bindings = XdgaDirectoriesBindings(_dylib); + +/// QStandardPaths::CacheLocation +String getCacheLocation() => + _bindings.getCacheLocation().cast().toDartString(); + +/// QStandardPaths::AppDataLocation +String getAppDataLocation() => + _bindings.getAppDataLocation().cast().toDartString(); + +/// QStandardPaths::DocumentsLocation +String getDocumentsLocation() => + _bindings.getDocumentsLocation().cast().toDartString(); + +/// QStandardPaths::DownloadLocation +String getDownloadLocation() => + _bindings.getDownloadLocation().cast().toDartString(); + +/// QStandardPaths::MusicLocation +String getMusicLocation() => + _bindings.getMusicLocation().cast().toDartString(); + +/// QStandardPaths::PicturesLocation +String getPicturesLocation() => + _bindings.getPicturesLocation().cast().toDartString(); + +/// QStandardPaths::GenericDataLocation +String getGenericDataLocation() => + _bindings.getGenericDataLocation().cast().toDartString(); + +/// QStandardPaths::MoviesLocation +String getMoviesLocation() => + _bindings.getMoviesLocation().cast().toDartString(); diff --git a/packages/xdga_directories/lib/xdga_directories_bindings_generated.dart b/packages/xdga_directories/lib/xdga_directories_bindings_generated.dart new file mode 100644 index 0000000..c48bdb0 --- /dev/null +++ b/packages/xdga_directories/lib/xdga_directories_bindings_generated.dart @@ -0,0 +1,104 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; + +/// Bindings for `src/xdga_directories.h`. +/// +/// Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. +/// +class XdgaDirectoriesBindings { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + XdgaDirectoriesBindings(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + XdgaDirectoriesBindings.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + ffi.Pointer getCacheLocation() { + return _getCacheLocation(); + } + + late final _getCacheLocationPtr = + _lookup Function()>>( + 'getCacheLocation'); + late final _getCacheLocation = + _getCacheLocationPtr.asFunction Function()>(); + + ffi.Pointer getAppDataLocation() { + return _getAppDataLocation(); + } + + late final _getAppDataLocationPtr = + _lookup Function()>>( + 'getAppDataLocation'); + late final _getAppDataLocation = + _getAppDataLocationPtr.asFunction Function()>(); + + ffi.Pointer getDocumentsLocation() { + return _getDocumentsLocation(); + } + + late final _getDocumentsLocationPtr = + _lookup Function()>>( + 'getDocumentsLocation'); + late final _getDocumentsLocation = + _getDocumentsLocationPtr.asFunction Function()>(); + + ffi.Pointer getDownloadLocation() { + return _getDownloadLocation(); + } + + late final _getDownloadLocationPtr = + _lookup Function()>>( + 'getDownloadLocation'); + late final _getDownloadLocation = + _getDownloadLocationPtr.asFunction Function()>(); + + ffi.Pointer getMusicLocation() { + return _getMusicLocation(); + } + + late final _getMusicLocationPtr = + _lookup Function()>>( + 'getMusicLocation'); + late final _getMusicLocation = + _getMusicLocationPtr.asFunction Function()>(); + + ffi.Pointer getPicturesLocation() { + return _getPicturesLocation(); + } + + late final _getPicturesLocationPtr = + _lookup Function()>>( + 'getPicturesLocation'); + late final _getPicturesLocation = + _getPicturesLocationPtr.asFunction Function()>(); + + ffi.Pointer getGenericDataLocation() { + return _getGenericDataLocation(); + } + + late final _getGenericDataLocationPtr = + _lookup Function()>>( + 'getGenericDataLocation'); + late final _getGenericDataLocation = + _getGenericDataLocationPtr.asFunction Function()>(); + + ffi.Pointer getMoviesLocation() { + return _getMoviesLocation(); + } + + late final _getMoviesLocationPtr = + _lookup Function()>>( + 'getMoviesLocation'); + late final _getMoviesLocation = + _getMoviesLocationPtr.asFunction Function()>(); +} diff --git a/packages/xdga_directories/pubspec.yaml b/packages/xdga_directories/pubspec.yaml new file mode 100644 index 0000000..712aa48 --- /dev/null +++ b/packages/xdga_directories/pubspec.yaml @@ -0,0 +1,25 @@ +name: xdga_directories +description: Plugin for Aurora OS like xdg_directories +version: 0.0.1 + +environment: + sdk: '>=2.18.6 <3.0.0' + flutter: ">=2.11.0" + +dependencies: + flutter: + sdk: flutter + ffi: ^1.2.1 + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + ffigen: ^5.0.1 + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +flutter: + plugin: + platforms: + aurora: + ffiPlugin: true diff --git a/packages/xdga_directories/src/CMakeLists.txt b/packages/xdga_directories/src/CMakeLists.txt new file mode 100644 index 0000000..6486fab --- /dev/null +++ b/packages/xdga_directories/src/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.10) + +project(xdga_directories VERSION 0.0.1) + +find_package(PkgConfig REQUIRED) + +pkg_check_modules(Qt5Core REQUIRED IMPORTED_TARGET Qt5Core) + +add_library(xdga_directories SHARED + "xdga_directories.cpp" +) + +target_link_libraries(xdga_directories PRIVATE PkgConfig::Qt5Core) + +set_target_properties(xdga_directories PROPERTIES + PUBLIC_HEADER "xdga_directories.h" + OUTPUT_NAME "xdga_directories" +) + +target_compile_definitions(xdga_directories PUBLIC DART_SHARED_LIB) + diff --git a/packages/xdga_directories/src/xdga_directories.cpp b/packages/xdga_directories/src/xdga_directories.cpp new file mode 100644 index 0000000..3707be9 --- /dev/null +++ b/packages/xdga_directories/src/xdga_directories.cpp @@ -0,0 +1,43 @@ +#include + +#include "xdga_directories.h" + +char *getCacheLocation() +{ + return QStandardPaths::writableLocation(QStandardPaths::CacheLocation).toUtf8().data(); +} + +char *getAppDataLocation() +{ + return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation).toUtf8().data(); +} + +char *getDocumentsLocation() +{ + return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation).toUtf8().data(); +} + +char *getDownloadLocation() +{ + return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation).toUtf8().data(); +} + +char *getMusicLocation() +{ + return QStandardPaths::writableLocation(QStandardPaths::MusicLocation).toUtf8().data(); +} + +char *getPicturesLocation() +{ + return QStandardPaths::writableLocation(QStandardPaths::PicturesLocation).toUtf8().data(); +} + +char *getGenericDataLocation() +{ + return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).toUtf8().data(); +} + +char *getMoviesLocation() +{ + return QStandardPaths::writableLocation(QStandardPaths::MoviesLocation).toUtf8().data(); +} \ No newline at end of file diff --git a/packages/xdga_directories/src/xdga_directories.h b/packages/xdga_directories/src/xdga_directories.h new file mode 100644 index 0000000..e2f3187 --- /dev/null +++ b/packages/xdga_directories/src/xdga_directories.h @@ -0,0 +1,23 @@ +#ifdef __cplusplus +extern "C" { +#endif + +char *getCacheLocation(); + +char *getAppDataLocation(); + +char *getDocumentsLocation(); + +char *getDownloadLocation(); + +char *getMusicLocation(); + +char *getPicturesLocation(); + +char *getGenericDataLocation(); + +char *getMoviesLocation(); + +#ifdef __cplusplus +} +#endif \ No newline at end of file