diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85e7c1d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea/ diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 0000000..5647788 --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,5 @@ +# Authors + +* Vitaliy Zarubin, + * Product owner, 2023 + * Maintainer, 2023 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..f98331d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,83 @@ +# Code of Conduct + +## What is this code of conduct for? + +Code of conduct is a current set of rules of the Open Mobile Platform +which informs you how we expect +the members of the Open Mobile Platform community +will interact while contributing and communicating. +We are committed to providing a friendly, safe and welcoming +environment for all, regardless of gender, gender identity and expression, +sexual orientation, ability, physical appearance, body size, race, age, +socioeconomic status, religion (or lack thereof), +or other marginalized aspect of community members. +We expect all members of the Open Mobile Platform community +to abide by this Code of Conduct whenever interacting +in Open Mobile Platform venues +(merge requests, pull requests, issues, 1-1 or group chat, meetups, conferences, etc.) + +## Examples of appropriate behavior + +* Using welcoming and inclusive language. +* Being respectful of differing viewpoints and experiences. +* Gracefully accepting constructive criticism. +* Focusing on what is best for the community. +* Showing empathy towards other community members. + +## Examples of inappropriate behavior + +Because we come from a variety of backgrounds, +we do not want to assume that everyone has the same assumptions +about what is and is not appropriate. +Here are some examples of inappropriate behavior +that are incompatible with our community's ethos: + +* spamming, trolling, intentionally disrupting conversations, + or irrelevant solicitation or advertisement; +* making demeaning or discriminatory comments; +* making negative assumptions about someone's background, + abilities, or intentions; +* harassing or stalking individuals (online or in person). + +In general: treat others how you would like to be treated, +were you in their place. +Do ask questions. +Do keep conflicts productively focused on technical issues. +Do remember that we are all people, not robots, +and all equally deserving of sensitivity and respect. + +## What will organizers do about inappropriate behavior? + +If we notice you doing or saying something inappropriate, +an organizer will ask you to stop. +We will not demonize you. +But please do stop the inappropriate behavior +so we can get back to writing and discussing code in a safe environment. +If you have philosophical disagreements about what is actually inappropriate, +please take them to a separate public or private conversation +with an Open Mobile Platform maintainer +so we don't turn pull requests into an ethics debate. +If you keep doing unacceptable things, +we will likely ban you, report you to the administration, +or take other appropriate action. + +## What if I see or am subject to what feels like inappropriate behavior? + +Let us know. +Please notify a community organizer as soon as possible. +Full contact information is listed in the Contact Info section of this document. +All communications will be kept strictly confidential, +unless otherwise required by law. +No issue will be considered too inconsequential or unimportant for us +to have a conversation about. + +## Contact Info + +If you need to report an incident, +please contact . + +This work is licensed under a Creative Commons Attribution 3.0 Unported License +For attribution requirements: +«Open Mobile Platform Code of Conduct» +Copyright (c) 2021 Open Mobile Platform LLC, +used under a [Creative Commons Attribution Unported license](http://creativecommons.org/licenses/by/3.0/). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5fc75b6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,169 @@ +# Contributor License Agreements + +Thank you for your interest in contributing +to software projects managed by Open Mobile Platform («We» or «Us»). +This contributor agreement («Agreement») +documents the rights granted by contributors to Us. +To make this document effective, +please sign it and send it to Us by email or electronic submission. +This is a legally binding document, +so please read it carefully before agreeing to it. +The Agreement may cover more than one software project managed by Us. + +## 1. Definitions + +**«We» or «Us»** means Open Mobile Platform Limited Liability Company +(Open Mobile Platform LLC), +420500, Republic of Tatarstan, Verkhneuslonsky District, +Innopolis, Universitetskaya Street, h. 7, office 59, +OGRN (Primary State Registration Number) 1161690087020. + +**«You»** means the individual who Submits a Contribution to Us. + +**«Contribution»** means any work of authorship +that is Submitted by You to Us +in which You own or assert ownership of the Copyright. + +**«Copyright»** means all rights protecting works of authorship +owned or controlled by You, +including copyright, moral and neighboring rights, as appropriate, +for the full term of their existence including any extensions by You. + +**«Material»** means the work of authorship +which is made available by Us to third parties. +When this Agreement covers more than one software project, +the Material means the work of authorship +to which the Contribution was Submitted. +After You Submit the Contribution, +it may be included in the Material. + +**«Submit»** means any form of electronic, verbal, or written communication +sent to Us or our representatives, +including but not limited to electronic mailing lists, +source code control systems, and issue tracking systems +that are managed by, or on behalf of, Us +for the purpose of discussing and improving the Material, +but excluding communication that is conspicuously marked +or otherwise designated in writing by You as «Not a Contribution». + +**«Submission Date»** means the date +on which You Submit a Contribution to Us. + +**«Effective Date»** means the date You execute this Agreement +or the date You first Submit a Contribution to Us, +whichever is earlier. + +**«Media»** means any portion of a Contribution which is not software. + +## 2. Grant of Rights + +### 2.1. Copyright License + +(a) You retain ownership of the Copyright in Your Contribution +and have the same rights to use or license the Contribution +which You would have had without entering into the Agreement. + +(b) To the maximum extent permitted by the relevant law, +You grant to Us a perpetual, worldwide, non-exclusive, +transferable, royalty-free, irrevocable license +under the Copyright covering the Contribution, +with the right to sublicense +such rights through multiple tiers of sublicensees, +to reproduce, modify, display, perform and distribute +the Contribution as part of the Material; +provided that this license is conditioned upon compliance with Section 2.3. + +### 2.2. Patent License + +For patent claims including, without limitation, +method, process, and apparatus claims +which You own, control or have the right to grant, now or in the future, +You grant to Us a perpetual, worldwide, non-exclusive, +transferable, royalty-free, irrevocable patent license, +with the right to sublicense these rights to multiple tiers of sublicensees, +to make, have made, use, sell, offer for sale, import +and otherwise transfer the Contribution +and the Contribution in combination with the Material +(and portions of such combination). +This license is granted only to the extent +that the exercise of the licensed rights infringes such patent claims; +and provided that this license is conditioned upon compliance with Section 2.3. + +### 2.3. Outbound License + +Based on the grant of rights in Sections 2.1 and 2.2, +if We include Your Contribution in a Material, +We may license the Contribution under any license, +including copyleft, permissive, commercial, or proprietary licenses. +As a condition on the exercise of this right, +We agree to also license the Contribution +under the terms of the license or licenses +which We are using for the Material on the Submission Date. + +### 2.4. Our Rights + +You acknowledge that We are not obligated +to use Your Contribution as part of the Material +and may decide to include any Contribution We consider appropriate. + +## 3. Agreement + +You confirm that: + +(a) You have the legal authority to enter into this Agreement. + +(b) You own the Copyright and patent claims +covering the Contribution which are required +to grant the rights under Section 2. + +(c) The grant of rights under Section 2 +does not violate any grant of rights +which You have made to third parties, including Your employer. +If You are an employee, +You have had Your employer approve this Agreement +or sign the Entity version of this document. +If You are less than eighteen years old, +please have Your parents or guardian sign the Agreement. + +## 4. Disclaimer + +EXCEPT FOR THE EXPRESS WARRANTIES IN SECTION 3, +THE CONTRIBUTION IS PROVIDED «AS IS». +MORE PARTICULARLY, ALL EXPRESS OR IMPLIED WARRANTIES +INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTY OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE +AND NON-INFRINGEMENT ARE EXPRESSLY DISCLAIMED BY YOU TO US. +TO THE EXTENT THAT ANY SUCH WARRANTIES CANNOT BE DISCLAIMED, +SUCH WARRANTY IS LIMITED IN DURATION TO THE MINIMUM PERIOD PERMITTED BY LAW. + +## 5. Miscellaneous + +5.1. This Agreement will be governed by and construed +in accordance with the laws of Russian Federation. + +5.2. This Agreement sets out the entire agreement between You +and Us for Your Contributions to Us +and overrides all other agreements or understandings. + +5.3. If You or We assign the rights or obligations +received through this Agreement to a third party, +as a condition of the assignment, +that third party must agree in writing +to abide by all the rights and obligations in the Agreement. + +5.4. The failure of either party to require performance +by the other party of any provision of this Agreement in one situation +shall not affect the right of a party +to require such performance at any time in the future. +A waiver of performance under a provision in one situation +shall not be considered a waiver of the performance +of the provision in the future or a waiver of the provision in its entirety. + +5.5. If any provision of this Agreement is found void and unenforceable, +such provision will be replaced to the extent possible with a provision +that comes closest to the meaning of the original provision +and which is enforceable. +The terms and conditions set forth in this Agreement +shall apply notwithstanding any failure of essential purpose +of this Agreement or any limited remedy +to the maximum extent possible under law. diff --git a/LICENSE.BSD-3-CLAUSE.md b/LICENSE.BSD-3-CLAUSE.md new file mode 100644 index 0000000..f040be6 --- /dev/null +++ b/LICENSE.BSD-3-CLAUSE.md @@ -0,0 +1,30 @@ +# The 3-Clause BSD License + +_Copyright (C) 2022 ru.auroraos_ + +Redistribution and use in source and binary forms, +with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain + the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce + the above copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the distribution. +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..25c9900 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Flutter Packages Aurora OS + +This repo is a companion repo to the main flutter repo. +It contains the source code for Aurora Flutter's packages (i.e., packages developed by the Aurora team). +Check the packages directory to see all packages. diff --git a/packages/path_provider/path_provider_aurora/.gitignore b/packages/path_provider/path_provider_aurora/.gitignore new file mode 100644 index 0000000..3e96523 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/.gitignore @@ -0,0 +1,32 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +*.lock +.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/ +/.metadata diff --git a/packages/path_provider/path_provider_aurora/README.md b/packages/path_provider/path_provider_aurora/README.md new file mode 100644 index 0000000..fd4611b --- /dev/null +++ b/packages/path_provider/path_provider_aurora/README.md @@ -0,0 +1,42 @@ +# path_provider_aurora + +The Aurora OS implementation of [`path_provider`](https://pub.dev/packages/path_provider). + +## Usage + +This package is not an _endorsed_ implementation of `path_provider`. +Therefore, you have to include `path_provider_aurora` alongside `path_provider` as dependencies in your `pubspec.yaml` file. + +```yaml +dependencies: + path_provider: ^2.0.14 + path_provider_aurora: + path: + +``` + +Then you can import `path_provider` in your Dart code: + +```dart +import 'package:path_provider/path_provider.dart'; +``` + +## Supported APIs + +- [x] `getTemporaryDirectory` +- [ ] `getApplicationSupportDirectory` +- [ ] `getLibraryDirectory` +- [x] `getApplicationDocumentsDirectory` +- [ ] `getExternalStorageDirectory` +- [ ] `getExternalCacheDirectories` +- [x] `getExternalStorageDirectories` (There is no concept of External in Aurora OS, but this interface allows you to get the pictures/music/movies directory) +- [x] `getDownloadsDirectory` + +## Extra methods + +PathProviderAurora.getApplicationOrg(); +PathProviderAurora.getApplicationName(); + +### Preview example + +![preview.png](data%2Fpreview.png) diff --git a/packages/path_provider/path_provider_aurora/analysis_options.yaml b/packages/path_provider/path_provider_aurora/analysis_options.yaml new file mode 100644 index 0000000..f9b3034 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/packages/path_provider/path_provider_aurora/aurora/CMakeLists.txt b/packages/path_provider/path_provider_aurora/aurora/CMakeLists.txt new file mode 100644 index 0000000..68335fe --- /dev/null +++ b/packages/path_provider/path_provider_aurora/aurora/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.10) + +set(PROJECT_NAME path_provider_aurora) +set(PLUGIN_NAME path_provider_aurora_platform_plugin) + +project(${PROJECT_NAME} LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-psabi") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + +find_package(PkgConfig REQUIRED) +pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) + +add_library(${PLUGIN_NAME} SHARED path_provider_aurora_plugin.cpp) + +set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) +target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::FlutterEmbedder) + +target_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_compile_definitions(${PLUGIN_NAME} PRIVATE PLUGIN_IMPL) diff --git a/packages/path_provider/path_provider_aurora/aurora/include/path_provider_aurora/path_provider_aurora_plugin.h b/packages/path_provider/path_provider_aurora/aurora/include/path_provider_aurora/path_provider_aurora_plugin.h new file mode 100644 index 0000000..d6c9faf --- /dev/null +++ b/packages/path_provider/path_provider_aurora/aurora/include/path_provider_aurora/path_provider_aurora_plugin.h @@ -0,0 +1,24 @@ +#ifndef FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H +#define FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H + +#include + +#ifdef PLUGIN_IMPL +#define PLUGIN_EXPORT __attribute__((visibility("default"))) +#else +#define PLUGIN_EXPORT +#endif + +class PLUGIN_EXPORT PathProviderAuroraPlugin final : public PluginInterface +{ +public: + void RegisterWithRegistrar(PluginRegistrar ®istrar) override; + +private: + void onMethodCall(const MethodCall &call); + void onGetApplicationOrg(const MethodCall &call); + void onGetApplicationName(const MethodCall &call); + void unimplemented(const MethodCall &call); +}; + +#endif /* FLUTTER_PLUGIN_PATH_PROVIDER_AURORA_PLUGIN_H */ diff --git a/packages/path_provider/path_provider_aurora/aurora/path_provider_aurora_plugin.cpp b/packages/path_provider/path_provider_aurora/aurora/path_provider_aurora_plugin.cpp new file mode 100644 index 0000000..7f83406 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/aurora/path_provider_aurora_plugin.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +void PathProviderAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) +{ + registrar.RegisterMethodChannel("path_provider_aurora", + MethodCodecType::Standard, + [this](const MethodCall &call) { this->onMethodCall(call); }); +} + +void PathProviderAuroraPlugin::onMethodCall(const MethodCall &call) +{ + const auto &method = call.GetMethod(); + + if (method == "getApplicationOrg") { + onGetApplicationOrg(call); + return; + } + + if (method == "getApplicationName") { + onGetApplicationName(call); + return; + } + + unimplemented(call); +} + +void PathProviderAuroraPlugin::onGetApplicationOrg(const MethodCall &call) +{ + call.SendSuccessResponse(Application::GetID().orgname); +} + +void PathProviderAuroraPlugin::onGetApplicationName(const MethodCall &call) +{ + call.SendSuccessResponse(Application::GetID().appname); +} + +void PathProviderAuroraPlugin::unimplemented(const MethodCall &call) +{ + call.SendSuccessResponse(nullptr); +} diff --git a/packages/path_provider/path_provider_aurora/data/preview.png b/packages/path_provider/path_provider_aurora/data/preview.png new file mode 100644 index 0000000..311649c Binary files /dev/null and b/packages/path_provider/path_provider_aurora/data/preview.png differ diff --git a/packages/path_provider/path_provider_aurora/example/.gitignore b/packages/path_provider/path_provider_aurora/example/.gitignore new file mode 100644 index 0000000..511e219 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +*.lock +.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/path_provider/path_provider_aurora/example/README.md b/packages/path_provider/path_provider_aurora/example/README.md new file mode 100644 index 0000000..4dd2726 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/README.md @@ -0,0 +1,17 @@ +# path_provider_aurora_example + +Demonstrates how to use the path_provider_aurora 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 +``` + +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`. \ No newline at end of file diff --git a/packages/path_provider/path_provider_aurora/example/analysis_options.yaml b/packages/path_provider/path_provider_aurora/example/analysis_options.yaml new file mode 100644 index 0000000..f9b3034 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/packages/path_provider/path_provider_aurora/example/aurora/.gitignore b/packages/path_provider/path_provider_aurora/example/aurora/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/aurora/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/packages/path_provider/path_provider_aurora/example/aurora/CMakeLists.txt b/packages/path_provider/path_provider_aurora/example/aurora/CMakeLists.txt new file mode 100644 index 0000000..9652e3f --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/aurora/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 3.10) +project(com.example.path_provider_aurora_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) +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) +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/path_provider/path_provider_aurora/example/aurora/desktop/com.example.path_provider_aurora_example.desktop b/packages/path_provider/path_provider_aurora/example/aurora/desktop/com.example.path_provider_aurora_example.desktop new file mode 100644 index 0000000..39b28d4 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/aurora/desktop/com.example.path_provider_aurora_example.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=Application +Name=path_provider_aurora_example +Comment=Demonstrates how to use the path_provider_aurora plugin. +Icon=com.example.path_provider_aurora_example +Exec=/usr/bin/com.example.path_provider_aurora_example +X-Nemo-Application-Type=silica-qt5 + +[X-Application] +Permissions= +OrganizationName=com.example +ApplicationName=path_provider_aurora_example diff --git a/packages/path_provider/path_provider_aurora/example/aurora/flutter/generated_plugin_registrant.cpp b/packages/path_provider/path_provider_aurora/example/aurora/flutter/generated_plugin_registrant.cpp new file mode 100644 index 0000000..bd5a44d --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/aurora/flutter/generated_plugin_registrant.cpp @@ -0,0 +1,16 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include +#include + +#include "generated_plugin_registrant.h" + +void RegisterPlugins() { + Application::RegisterPlugins({ + std::make_shared(), + }); +} diff --git a/packages/path_provider/path_provider_aurora/example/aurora/flutter/generated_plugin_registrant.h b/packages/path_provider/path_provider_aurora/example/aurora/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..648dcb3 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/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/path_provider/path_provider_aurora/example/aurora/flutter/generated_plugins.cmake b/packages/path_provider/path_provider_aurora/example/aurora/flutter/generated_plugins.cmake new file mode 100644 index 0000000..fa1ac5f --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/aurora/flutter/generated_plugins.cmake @@ -0,0 +1,32 @@ +# +# 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 + path_provider_aurora +) + +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/path_provider/path_provider_aurora/example/aurora/icons/108x108.png b/packages/path_provider/path_provider_aurora/example/aurora/icons/108x108.png new file mode 100644 index 0000000..984893d Binary files /dev/null and b/packages/path_provider/path_provider_aurora/example/aurora/icons/108x108.png differ diff --git a/packages/path_provider/path_provider_aurora/example/aurora/icons/128x128.png b/packages/path_provider/path_provider_aurora/example/aurora/icons/128x128.png new file mode 100644 index 0000000..2d552ef Binary files /dev/null and b/packages/path_provider/path_provider_aurora/example/aurora/icons/128x128.png differ diff --git a/packages/path_provider/path_provider_aurora/example/aurora/icons/172x172.png b/packages/path_provider/path_provider_aurora/example/aurora/icons/172x172.png new file mode 100644 index 0000000..9dc271b Binary files /dev/null and b/packages/path_provider/path_provider_aurora/example/aurora/icons/172x172.png differ diff --git a/packages/path_provider/path_provider_aurora/example/aurora/icons/86x86.png b/packages/path_provider/path_provider_aurora/example/aurora/icons/86x86.png new file mode 100644 index 0000000..5923bb1 Binary files /dev/null and b/packages/path_provider/path_provider_aurora/example/aurora/icons/86x86.png differ diff --git a/packages/path_provider/path_provider_aurora/example/aurora/main.cpp b/packages/path_provider/path_provider_aurora/example/aurora/main.cpp new file mode 100644 index 0000000..2dd2f52 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/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/path_provider/path_provider_aurora/example/aurora/rpm/com.example.path_provider_aurora_example.spec b/packages/path_provider/path_provider_aurora/example/aurora/rpm/com.example.path_provider_aurora_example.spec new file mode 100644 index 0000000..fb1eaa6 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/aurora/rpm/com.example.path_provider_aurora_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.path_provider_aurora_example +Summary: Demonstrates how to use the path_provider_aurora 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/path_provider/path_provider_aurora/example/lib/main.dart b/packages/path_provider/path_provider_aurora/example/lib/main.dart new file mode 100644 index 0000000..156bb67 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/lib/main.dart @@ -0,0 +1,249 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:path_provider_aurora/path_provider_aurora.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + String? _error; + String? _applicationOrg; + String? _applicationName; + String? _pathApplicationSupportDirectory; + String? _pathTempDirectory; + String? _pathApplicationDocumentsPath; + String? _pathDownloadsPath; + String? _pathPictures; + String? _pathMusic; + String? _pathMovies; + + @override + void initState() { + super.initState(); + loadPathDirectory(); + } + + /// Asynchronous function receiving directory paths + Future loadPathDirectory() async { + try { + // Get names + String? applicationOrg = await PathProviderAurora.getApplicationOrg(); + String? applicationName = await PathProviderAurora.getApplicationName(); + + // Get directories + Directory? applicationSupportDirectory = await getApplicationSupportDirectory(); + Directory? tempDirectory = await getTemporaryDirectory(); + Directory? pathApplicationDocumentsPath = await getApplicationDocumentsDirectory(); + Directory? pathDownloadsPath = await getDownloadsDirectory(); + List? pathPictures = await getExternalStorageDirectories(type: StorageDirectory.pictures); + List? pathMusic = await getExternalStorageDirectories(type: StorageDirectory.music); + List? pathMovies = await getExternalStorageDirectories(type: StorageDirectory.movies); + + // Update state variable + setState(() { + _applicationOrg = applicationOrg; + _applicationName = applicationName; + + _pathApplicationSupportDirectory = applicationSupportDirectory.path; + _pathTempDirectory = tempDirectory.path; + _pathApplicationDocumentsPath = pathApplicationDocumentsPath.path; + _pathDownloadsPath = pathDownloadsPath?.path; + _pathPictures = pathPictures?.first.path; + _pathMusic = pathMusic?.first.path; + _pathMovies = pathMovies?.first.path; + }); + } on Exception catch (e) { + setState(() { + _error = e.toString(); + }); + } + } + + @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: 20); + const spaceSmall = SizedBox(height: 10); + + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Example path_provider'), + ), + body: Stack( + children: [ + // Error message + Visibility( + visible: _error != null, + child: Center( + child: Padding( + padding: const EdgeInsets.all(16), + child: Container( + padding: const EdgeInsets.all(20), + decoration: const BoxDecoration( + color: Colors.redAccent, + borderRadius: BorderRadius.all(Radius.circular(10.0)), + ), + child: Text( + _error ?? '', + style: textStyleWhite, + ), + ), + ), + ), + ), + // List directories path + Visibility( + visible: _error == null, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Column( + children: [ + // Info + Container( + padding: const EdgeInsets.all(20), + decoration: const BoxDecoration( + color: Colors.green, + borderRadius: BorderRadius.all(Radius.circular(10.0)), + ), + child: const Text( + 'Demo application demonstration implementation of path_provider', + style: textStyleWhite, + textAlign: TextAlign.center, + ), + ), + const SizedBox(height: 30), + + // ApplicationOrg + const Text( + 'Application Org', + style: textStyleTitle, + ), + spaceSmall, + Text( + _applicationOrg ?? 'Not found.', + style: textStylePath, + ), + + spaceMedium, + // ApplicationName + const Text( + 'Application Name', + style: textStyleTitle, + ), + spaceSmall, + Text( + _applicationName ?? 'Not found.', + style: textStylePath, + ), + + spaceMedium, + // TempDirectory + const Text( + 'ApplicationSupportDirectory', + style: textStyleTitle, + ), + spaceSmall, + Text( + _pathApplicationSupportDirectory ?? 'Not found.', + style: textStylePath, + ), + + spaceMedium, + // TempDirectory + const Text( + 'TempDirectory', + style: textStyleTitle, + ), + spaceSmall, + Text( + _pathTempDirectory ?? 'Not found.', + style: textStylePath, + ), + spaceMedium, + + // ApplicationDocumentsPath + const Text( + 'ApplicationDocumentsPath', + style: textStyleTitle, + ), + spaceSmall, + Text( + _pathApplicationDocumentsPath ?? 'Not found.', + style: textStylePath, + ), + spaceMedium, + + // DownloadsPath + const Text( + 'DownloadsPath', + style: textStyleTitle, + ), + spaceSmall, + Text( + _pathDownloadsPath ?? 'Not found.', + style: textStylePath, + ), + spaceMedium, + + // Pictures + const Text( + 'Pictures', + style: textStyleTitle, + ), + spaceSmall, + Text( + _pathPictures ?? 'Not found.', + style: textStylePath, + ), + spaceMedium, + + // Music + const Text( + 'Music', + style: textStyleTitle, + ), + spaceSmall, + Text( + _pathMusic ?? 'Not found.', + style: textStylePath, + ), + spaceMedium, + + // Movies + const Text( + 'Movies', + style: textStyleTitle, + ), + spaceSmall, + Text( + _pathMovies ?? 'Not found.', + style: textStylePath, + ), + ], + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/packages/path_provider/path_provider_aurora/example/pubspec.yaml b/packages/path_provider/path_provider_aurora/example/pubspec.yaml new file mode 100644 index 0000000..a69bf60 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/example/pubspec.yaml @@ -0,0 +1,23 @@ +name: path_provider_aurora_example +description: Demonstrates how to use the path_provider_aurora plugin. + +publish_to: 'none' + +environment: + sdk: '>=2.18.6 <3.0.0' + +dependencies: + flutter: + sdk: flutter + path_provider: ^2.0.7 + path_provider_aurora: + 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/path_provider/path_provider_aurora/lib/path_provider_aurora.dart b/packages/path_provider/path_provider_aurora/lib/path_provider_aurora.dart new file mode 100644 index 0000000..285bf65 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/lib/path_provider_aurora.dart @@ -0,0 +1,81 @@ +import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; +import 'package:xdga_directories/xdga_directories.dart' as xdga_directories; +import 'package:path/path.dart' as p; + +import 'path_provider_aurora_platform_interface.dart'; + +/// The aurora implementation of [PathProviderPlatform] +/// +/// This class implements the `package:path_provider` functionality for Aurora. +class PathProviderAurora extends PathProviderPlatform { + /// Registers this class as the default instance of [PathProviderPlatform] + static void registerWith() { + PathProviderPlatform.instance = PathProviderAurora(); + } + + /// Get application name + static Future getApplicationName() { + return PathProviderAuroraPlatform.instance.getApplicationName(); + } + + /// Get application org + static Future getApplicationOrg() { + return PathProviderAuroraPlatform.instance.getApplicationOrg(); + } + + /// Path to a directory where the application may place application support files. + @override + Future getApplicationSupportPath() async { + String? org = await getApplicationOrg(); + String? name = await getApplicationName(); + // QStandardPaths::AppDataLocation + return p.join(xdga_directories.getAppDataLocation(), org, name); + } + + /// Path to the temporary directory on the device that is not backed up and is + /// suitable for storing caches of downloaded files. + @override + Future getTemporaryPath() async { + String? org = await getApplicationOrg(); + String? name = await getApplicationName(); + // QStandardPaths::CacheLocation + return p.join(xdga_directories.getCacheLocation(), org, name); + } + + /// Path to a directory where the application may place data that is + /// user-generated, or that cannot otherwise be recreated by your application. + @override + Future getApplicationDocumentsPath() async { + // QStandardPaths::DocumentsLocation + return xdga_directories.getDocumentsLocation(); + } + + /// Path to the directory where downloaded files can be stored. + /// This is typically only relevant on desktop operating systems. + @override + Future getDownloadsPath() async { + // QStandardPaths::DownloadLocation + return xdga_directories.getDownloadLocation(); + } + + /// Paths to directories where application specific data can be stored. + /// These paths typically reside on external storage like separate partitions + /// or SD cards. Phones may have multiple storage directories available. + @override + Future?> getExternalStoragePaths({ + /// Optional parameter. See [StorageDirectory] for more informations on + /// how this type translates to Android storage directories. + StorageDirectory? type, + }) async { + switch (type) { + case StorageDirectory.pictures: + return [xdga_directories.getPicturesLocation()]; // QStandardPaths::PicturesLocation + case StorageDirectory.music: + return [xdga_directories.getMusicLocation()]; // QStandardPaths::MusicLocation + case StorageDirectory.movies: + return [xdga_directories.getMoviesLocation()]; // QStandardPaths::MoviesLocation + default: + throw UnimplementedError('Type "$type" not supported.'); + } + } +} diff --git a/packages/path_provider/path_provider_aurora/lib/path_provider_aurora_method_channel.dart b/packages/path_provider/path_provider_aurora/lib/path_provider_aurora_method_channel.dart new file mode 100644 index 0000000..2d275df --- /dev/null +++ b/packages/path_provider/path_provider_aurora/lib/path_provider_aurora_method_channel.dart @@ -0,0 +1,21 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; + +import 'path_provider_aurora_platform_interface.dart'; + +/// An implementation of [PathProviderAuroraPlatform] that uses method channels. +class MethodChannelPathProviderAurora extends PathProviderAuroraPlatform { + /// The method channel used to interact with the native platform. + @visibleForTesting + final methodChannel = const MethodChannel('path_provider_aurora'); + + @override + Future getApplicationOrg() async { + return await methodChannel.invokeMethod('getApplicationOrg'); + } + + @override + Future getApplicationName() async { + return await methodChannel.invokeMethod('getApplicationName'); + } +} diff --git a/packages/path_provider/path_provider_aurora/lib/path_provider_aurora_platform_interface.dart b/packages/path_provider/path_provider_aurora/lib/path_provider_aurora_platform_interface.dart new file mode 100644 index 0000000..d465660 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/lib/path_provider_aurora_platform_interface.dart @@ -0,0 +1,33 @@ +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'path_provider_aurora_method_channel.dart'; + +abstract class PathProviderAuroraPlatform extends PlatformInterface { + /// Constructs a PathProviderAuroraPlatform. + PathProviderAuroraPlatform() : super(token: _token); + + static final Object _token = Object(); + + static PathProviderAuroraPlatform _instance = MethodChannelPathProviderAurora(); + + /// The default instance of [PathProviderAuroraPlatform] to use. + /// + /// Defaults to [MethodChannelPathProviderAurora]. + static PathProviderAuroraPlatform get instance => _instance; + + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [PathProviderAuroraPlatform] when + /// they register themselves. + static set instance(PathProviderAuroraPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + Future getApplicationOrg() { + throw UnimplementedError('getApplicationOrg() has not been implemented.'); + } + + Future getApplicationName() { + throw UnimplementedError('getApplicationName() has not been implemented.'); + } +} diff --git a/packages/path_provider/path_provider_aurora/pubspec.yaml b/packages/path_provider/path_provider_aurora/pubspec.yaml new file mode 100644 index 0000000..a37a56d --- /dev/null +++ b/packages/path_provider/path_provider_aurora/pubspec.yaml @@ -0,0 +1,32 @@ +name: path_provider_aurora +description: The Aurora OS implementation of path_provider. +version: 0.0.1 +homepage: https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/packages/xdga_directories + +environment: + sdk: '>=2.18.6 <3.0.0' + flutter: ">=2.5.0" + +flutter: + plugin: + implements: path_provider + platforms: + aurora: + dartPluginClass: PathProviderAurora + pluginClass: PathProviderAuroraPlugin + +dependencies: + flutter: + sdk: flutter + path: ^1.8.2 + plugin_platform_interface: ^2.0.2 + path_provider_platform_interface: ^2.0.6 + xdga_directories: + path: ../../xdga_directories + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + + diff --git a/packages/path_provider/path_provider_aurora/test/path_provider_aurora_method_channel_test.dart b/packages/path_provider/path_provider_aurora/test/path_provider_aurora_method_channel_test.dart new file mode 100644 index 0000000..137a103 --- /dev/null +++ b/packages/path_provider/path_provider_aurora/test/path_provider_aurora_method_channel_test.dart @@ -0,0 +1,34 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:path_provider_aurora/path_provider_aurora_method_channel.dart'; + +void main() { + MethodChannelPathProviderAurora platform = MethodChannelPathProviderAurora(); + const MethodChannel channel = MethodChannel('path_provider_aurora'); + + TestWidgetsFlutterBinding.ensureInitialized(); + + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) async { + switch (methodCall.method) { + case 'getApplicationOrg': + return 'com.example'; + case 'getApplicationName': + return 'path_provider_aurora'; + } + return ''; + }); + }); + + tearDown(() { + channel.setMockMethodCallHandler(null); + }); + + test('onGetApplicationOrg', () async { + expect(await platform.getApplicationOrg(), 'com.example'); + }); + + test('onGetApplicationName', () async { + expect(await platform.getApplicationName(), 'path_provider_aurora'); + }); +} diff --git a/packages/xdga_directories/.gitignore b/packages/xdga_directories/.gitignore new file mode 100644 index 0000000..3e96523 --- /dev/null +++ b/packages/xdga_directories/.gitignore @@ -0,0 +1,32 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +*.lock +.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/ +/.metadata diff --git a/packages/xdga_directories/README.md b/packages/xdga_directories/README.md new file mode 100644 index 0000000..cbee34d --- /dev/null +++ b/packages/xdga_directories/README.md @@ -0,0 +1,43 @@ +# xdga_directories + +A Dart package for reading directory path on Aurora OS. + +## Usage + +This package can be used alone, but the best solution would be to use `path_provider`. + +```yaml +dependencies: + xdga_directories: + path: +``` + +Then you can import `xdga_directories` in your Dart code: + +```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(); +``` + +## Supported APIs + +- `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. + +### Preview example + +![preview.png](data%2Fpreview.png) 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..511e219 --- /dev/null +++ b/packages/xdga_directories/example/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +*.lock +.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..14f1764 --- /dev/null +++ b/packages/xdga_directories/example/README.md @@ -0,0 +1,17 @@ +# 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 +``` + +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`. \ No newline at end of file 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..1cb3a11 --- /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_directories; + +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_directories.getAppDataLocation(); + cacheLocation = xdga_directories.getCacheLocation(); + documentsLocation = xdga_directories.getDocumentsLocation(); + downloadLocation = xdga_directories.getDownloadLocation(); + musicLocation = xdga_directories.getMusicLocation(); + picturesLocation = xdga_directories.getPicturesLocation(); + genericDataLocation = xdga_directories.getGenericDataLocation(); + moviesLocation = xdga_directories.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'), + ), + 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( + 'A Dart package for reading directory path on Aurora OS.', + 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..fcd032d --- /dev/null +++ b/packages/xdga_directories/ffigen.yaml @@ -0,0 +1,17 @@ +# Run with `flutter pub run ffigen --config ffigen.yaml`. +name: XdgaDirectoriesBindings +llvm-path: + - '/usr/lib/llvm-14/lib/libclang.so' # Ubuntu 22.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..0b77018 --- /dev/null +++ b/packages/xdga_directories/lib/xdga_directories.dart @@ -0,0 +1,39 @@ +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; + +import 'xdga_directories_bindings_generated.dart'; + +const String _libName = 'xdga_directories'; + +/// The dynamic library in which the symbols for [XdgaDirectoriesBindings] can be found. +final DynamicLibrary _dylib = () { + return DynamicLibrary.open('lib$_libName.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..c1be5ee --- /dev/null +++ b/packages/xdga_directories/pubspec.yaml @@ -0,0 +1,26 @@ +name: xdga_directories +description: A Dart package for reading XDG directory configuration information on Aurora OS. +version: 0.0.1 +homepage: https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/packages/xdga_directories + +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 diff --git a/script/build_example.sh b/script/build_example.sh new file mode 100755 index 0000000..2df16ba --- /dev/null +++ b/script/build_example.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +## Build example, sign rpm, upload rpm to device + +## Usage +## chmod +x ./build_example.sh +## ./build_example.sh -p xdga_directories -u 192.168.1.59:/home/defaultuser/Downloads -k /home/user/sign/system_keys + +## Flatter path +FLATTER="$HOME/.local/opt/flutter-sdk/bin/flutter" +## Install Platform SDK path +PLATFORM_SDK_ROOT="/srv/mer" + +## https://community.omprussia.ru/documentation/software_development/psdk/setup.html +## You may not have set the PSDK_DIR environment variable. +export PSDK_DIR="$PLATFORM_SDK_ROOT/sdks/sfossdk" + +while getopts p:u:k: flag; do + case "${flag}" in + p) package=${OPTARG} ;; + u) upload=${OPTARG} ;; + k) keys_folder=${OPTARG} ;; + *) + echo "usage: $0 [-v] [-r]" >&2 + exit 1 + ;; + esac +done + +if [ -z "$package" ]; then + echo "Specify a build package" + exit +else + cd "../packages/$package" 2>/dev/null || eval 'echo "Package \"$package\" not found." && exit' + ## Update dependency + $FLATTER pub get + ## Run ffigen if has + $FLATTER pub run ffigen --config ffigen.yaml 2>/dev/null + ## Open example dir + cd "example" || exit + ## Build aurora example app + $FLATTER build aurora --release +fi + +if [ -n "$keys_folder" ]; then + + key=$(ls "$keys_folder"/*key.pem) + + if [ -z "$key" ]; then + echo "Key *key.pem not found." + exit + fi + + cert=$(ls "$keys_folder"/*cert.pem) + + if [ -z "$cert" ]; then + echo "Key *cert.pem not found." + exit + fi + + ## Sign rpm system key + "$PSDK_DIR"/sdk-chroot rpmsign-external sign \ + --key "$key" \ + --cert "$cert" \ + build/aurora/arm/release/RPMS/*.rpm +fi + +if [ -n "$upload" ]; then + + # shellcheck disable=SC2012 + rpm=$(ls "$PWD"/build/aurora/arm/release/RPMS/*.rpm | sort -r | head -n 1) + + scp "$rpm" defaultuser@"$upload" +fi