Browse Source

[xdga_directories] Add plugin xdga_directories

merge-requests/18/head
Vitaliy Zarubin 2 years ago
parent
commit
52aa2998c8
  1. 30
      packages/xdga_directories/.gitignore
  2. 30
      packages/xdga_directories/.metadata
  3. 40
      packages/xdga_directories/README.md
  4. 1
      packages/xdga_directories/analysis_options.yaml
  5. 12
      packages/xdga_directories/aurora/CMakeLists.txt
  6. BIN
      packages/xdga_directories/data/preview.png
  7. 44
      packages/xdga_directories/example/.gitignore
  8. 21
      packages/xdga_directories/example/README.md
  9. 1
      packages/xdga_directories/example/analysis_options.yaml
  10. 1
      packages/xdga_directories/example/aurora/.gitignore
  11. 48
      packages/xdga_directories/example/aurora/CMakeLists.txt
  12. 12
      packages/xdga_directories/example/aurora/desktop/com.example.xdga_directories_example.desktop
  13. 14
      packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.cpp
  14. 12
      packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.h
  15. 31
      packages/xdga_directories/example/aurora/flutter/generated_plugins.cmake
  16. BIN
      packages/xdga_directories/example/aurora/icons/108x108.png
  17. BIN
      packages/xdga_directories/example/aurora/icons/128x128.png
  18. BIN
      packages/xdga_directories/example/aurora/icons/172x172.png
  19. BIN
      packages/xdga_directories/example/aurora/icons/86x86.png
  20. 10
      packages/xdga_directories/example/aurora/main.cpp
  21. 31
      packages/xdga_directories/example/aurora/rpm/com.example.xdga_directories_example.spec
  22. 176
      packages/xdga_directories/example/lib/main.dart
  23. 24
      packages/xdga_directories/example/pubspec.yaml
  24. 17
      packages/xdga_directories/ffigen.yaml
  25. 43
      packages/xdga_directories/lib/xdga_directories.dart
  26. 104
      packages/xdga_directories/lib/xdga_directories_bindings_generated.dart
  27. 25
      packages/xdga_directories/pubspec.yaml
  28. 21
      packages/xdga_directories/src/CMakeLists.txt
  29. 43
      packages/xdga_directories/src/xdga_directories.cpp
  30. 23
      packages/xdga_directories/src/xdga_directories.h

30
packages/xdga_directories/.gitignore vendored

@ -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/

30
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'

40
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();
```

1
packages/xdga_directories/analysis_options.yaml

@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml

12
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)

BIN
packages/xdga_directories/data/preview.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

44
packages/xdga_directories/example/.gitignore vendored

@ -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

21
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)

1
packages/xdga_directories/example/analysis_options.yaml

@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml

1
packages/xdga_directories/example/aurora/.gitignore vendored

@ -0,0 +1 @@
flutter/ephemeral

48
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)

12
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

14
packages/xdga_directories/example/aurora/flutter/generated_plugin_registrant.cpp

@ -0,0 +1,14 @@
//
// Generated file. Do not edit.
//
// clang-format off
#include <flutter/application.h>
#include "generated_plugin_registrant.h"
void RegisterPlugins() {
Application::RegisterPlugins({
});
}

12
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 */

31
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
"$<TARGET_FILE:${TARGET}>"
"${ROOT_PROJECT_BINARY_DIR}/bundle/lib/$<TARGET_FILE_NAME:${TARGET}>")
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)

BIN
packages/xdga_directories/example/aurora/icons/108x108.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
packages/xdga_directories/example/aurora/icons/128x128.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
packages/xdga_directories/example/aurora/icons/172x172.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
packages/xdga_directories/example/aurora/icons/86x86.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

10
packages/xdga_directories/example/aurora/main.cpp

@ -0,0 +1,10 @@
#include <flutter/application.h>
#include "generated_plugin_registrant.h"
int main(int argc, char *argv[]) {
Application::Initialize(argc, argv);
Application::SetPixelRatio(1.8);
RegisterPlugins();
Application::Launch();
return 0;
}

31
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

176
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<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
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,
),
],
),
),
),
),
),
);
}
}

24
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

17
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

43
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<Utf8>().toDartString();
/// QStandardPaths::AppDataLocation
String getAppDataLocation() =>
_bindings.getAppDataLocation().cast<Utf8>().toDartString();
/// QStandardPaths::DocumentsLocation
String getDocumentsLocation() =>
_bindings.getDocumentsLocation().cast<Utf8>().toDartString();
/// QStandardPaths::DownloadLocation
String getDownloadLocation() =>
_bindings.getDownloadLocation().cast<Utf8>().toDartString();
/// QStandardPaths::MusicLocation
String getMusicLocation() =>
_bindings.getMusicLocation().cast<Utf8>().toDartString();
/// QStandardPaths::PicturesLocation
String getPicturesLocation() =>
_bindings.getPicturesLocation().cast<Utf8>().toDartString();
/// QStandardPaths::GenericDataLocation
String getGenericDataLocation() =>
_bindings.getGenericDataLocation().cast<Utf8>().toDartString();
/// QStandardPaths::MoviesLocation
String getMoviesLocation() =>
_bindings.getMoviesLocation().cast<Utf8>().toDartString();

104
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<T> Function<T extends ffi.NativeType>(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<T> Function<T extends ffi.NativeType>(String symbolName)
lookup)
: _lookup = lookup;
ffi.Pointer<ffi.Char> getCacheLocation() {
return _getCacheLocation();
}
late final _getCacheLocationPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'getCacheLocation');
late final _getCacheLocation =
_getCacheLocationPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
ffi.Pointer<ffi.Char> getAppDataLocation() {
return _getAppDataLocation();
}
late final _getAppDataLocationPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'getAppDataLocation');
late final _getAppDataLocation =
_getAppDataLocationPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
ffi.Pointer<ffi.Char> getDocumentsLocation() {
return _getDocumentsLocation();
}
late final _getDocumentsLocationPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'getDocumentsLocation');
late final _getDocumentsLocation =
_getDocumentsLocationPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
ffi.Pointer<ffi.Char> getDownloadLocation() {
return _getDownloadLocation();
}
late final _getDownloadLocationPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'getDownloadLocation');
late final _getDownloadLocation =
_getDownloadLocationPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
ffi.Pointer<ffi.Char> getMusicLocation() {
return _getMusicLocation();
}
late final _getMusicLocationPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'getMusicLocation');
late final _getMusicLocation =
_getMusicLocationPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
ffi.Pointer<ffi.Char> getPicturesLocation() {
return _getPicturesLocation();
}
late final _getPicturesLocationPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'getPicturesLocation');
late final _getPicturesLocation =
_getPicturesLocationPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
ffi.Pointer<ffi.Char> getGenericDataLocation() {
return _getGenericDataLocation();
}
late final _getGenericDataLocationPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'getGenericDataLocation');
late final _getGenericDataLocation =
_getGenericDataLocationPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
ffi.Pointer<ffi.Char> getMoviesLocation() {
return _getMoviesLocation();
}
late final _getMoviesLocationPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'getMoviesLocation');
late final _getMoviesLocation =
_getMoviesLocationPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
}

25
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

21
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)

43
packages/xdga_directories/src/xdga_directories.cpp

@ -0,0 +1,43 @@
#include <QStandardPaths>
#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();
}

23
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
Loading…
Cancel
Save