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/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..566c597 --- /dev/null +++ b/packages/xdga_directories/analysis_options.yaml @@ -0,0 +1,4 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +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..e72e52b --- /dev/null +++ b/packages/xdga_directories/aurora/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +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..3db3823 --- /dev/null +++ b/packages/xdga_directories/example/.gitignore @@ -0,0 +1,47 @@ +# 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 + +# Aurora generated +/aurora/flutter 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..566c597 --- /dev/null +++ b/packages/xdga_directories/example/analysis_options.yaml @@ -0,0 +1,4 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +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..0495b62 --- /dev/null +++ b/packages/xdga_directories/example/aurora/CMakeLists.txt @@ -0,0 +1,51 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +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/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..83f2ca8 --- /dev/null +++ b/packages/xdga_directories/example/aurora/main.cpp @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +#include +#include "generated_plugin_registrant.h" + +int main(int argc, char *argv[]) { + Application::Initialize(argc, argv); + 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..860ac8a --- /dev/null +++ b/packages/xdga_directories/example/lib/main.dart @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +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.lock b/packages/xdga_directories/example/pubspec.lock new file mode 100644 index 0000000..2ee3257 --- /dev/null +++ b/packages/xdga_directories/example/pubspec.lock @@ -0,0 +1,182 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.9.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.12" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + xdga_directories: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.1" +sdks: + dart: ">=2.18.6 <3.0.0" + flutter: ">=2.11.0" diff --git a/packages/xdga_directories/example/pubspec.yaml b/packages/xdga_directories/example/pubspec.yaml new file mode 100644 index 0000000..be27c0e --- /dev/null +++ b/packages/xdga_directories/example/pubspec.yaml @@ -0,0 +1,27 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +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..9973cd8 --- /dev/null +++ b/packages/xdga_directories/ffigen.yaml @@ -0,0 +1,20 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +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..a0fd12c --- /dev/null +++ b/packages/xdga_directories/lib/xdga_directories.dart @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +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..d358645 --- /dev/null +++ b/packages/xdga_directories/pubspec.yaml @@ -0,0 +1,28 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +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: ^2.0.2 + plugin_platform_interface: ^2.0.2 + +dev_dependencies: + ffigen: ^7.2.7 + 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..4e3c332 --- /dev/null +++ b/packages/xdga_directories/src/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +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..13b5429 --- /dev/null +++ b/packages/xdga_directories/src/xdga_directories.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +#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(); +} diff --git a/packages/xdga_directories/src/xdga_directories.h b/packages/xdga_directories/src/xdga_directories.h new file mode 100644 index 0000000..0fbc2ff --- /dev/null +++ b/packages/xdga_directories/src/xdga_directories.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +#ifdef __cplusplus +extern "C" { +#endif + +char *getCacheLocation(); + +char *getAppDataLocation(); + +char *getDocumentsLocation(); + +char *getDownloadLocation(); + +char *getMusicLocation(); + +char *getPicturesLocation(); + +char *getGenericDataLocation(); + +char *getMoviesLocation(); + +#ifdef __cplusplus +} +#endif