Browse Source

[xdga_directories] Implement xdga_directories plugin. OMP#OS-16308

merge-requests/19/merge
Vitaliy Zarubin 2 years ago
parent
commit
9725526d11
  1. 30
      packages/xdga_directories/.gitignore
  2. 40
      packages/xdga_directories/README.md
  3. 4
      packages/xdga_directories/analysis_options.yaml
  4. 15
      packages/xdga_directories/aurora/CMakeLists.txt
  5. BIN
      packages/xdga_directories/data/preview.png
  6. 47
      packages/xdga_directories/example/.gitignore
  7. 21
      packages/xdga_directories/example/README.md
  8. 4
      packages/xdga_directories/example/analysis_options.yaml
  9. 1
      packages/xdga_directories/example/aurora/.gitignore
  10. 51
      packages/xdga_directories/example/aurora/CMakeLists.txt
  11. 12
      packages/xdga_directories/example/aurora/desktop/com.example.xdga_directories_example.desktop
  12. BIN
      packages/xdga_directories/example/aurora/icons/108x108.png
  13. BIN
      packages/xdga_directories/example/aurora/icons/128x128.png
  14. BIN
      packages/xdga_directories/example/aurora/icons/172x172.png
  15. BIN
      packages/xdga_directories/example/aurora/icons/86x86.png
  16. 13
      packages/xdga_directories/example/aurora/main.cpp
  17. 31
      packages/xdga_directories/example/aurora/rpm/com.example.xdga_directories_example.spec
  18. 180
      packages/xdga_directories/example/lib/main.dart
  19. 182
      packages/xdga_directories/example/pubspec.lock
  20. 27
      packages/xdga_directories/example/pubspec.yaml
  21. 20
      packages/xdga_directories/ffigen.yaml
  22. 47
      packages/xdga_directories/lib/xdga_directories.dart
  23. 104
      packages/xdga_directories/lib/xdga_directories_bindings_generated.dart
  24. 28
      packages/xdga_directories/pubspec.yaml
  25. 24
      packages/xdga_directories/src/CMakeLists.txt
  26. 47
      packages/xdga_directories/src/xdga_directories.cpp
  27. 27
      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/

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

4
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

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

BIN
packages/xdga_directories/data/preview.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

47
packages/xdga_directories/example/.gitignore vendored

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

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)

4
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

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

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

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

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

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

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

@ -0,0 +1,13 @@
/*
* Copyright (c) 2023. Open Mobile Platform LLC.
* License: Proprietary.
*/
#include <flutter/application.h>
#include "generated_plugin_registrant.h"
int main(int argc, char *argv[]) {
Application::Initialize(argc, argv);
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

180
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<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,
),
],
),
),
),
),
),
);
}
}

182
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"

27
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

20
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

47
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<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()>();
}

28
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

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

47
packages/xdga_directories/src/xdga_directories.cpp

@ -0,0 +1,47 @@
/*
* Copyright (c) 2023. Open Mobile Platform LLC.
* License: Proprietary.
*/
#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();
}

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