├── .gitignore ├── Cargo.toml ├── LICENSE ├── LICENSES ├── Apache-2.0.txt ├── CC0-1.0.txt └── MIT.txt ├── README.md ├── flaura.toml ├── kawaii ├── kwdev ├── smithay ├── waylovely-build ├── waylovely-comp ├── Cargo.toml ├── build.kawaii └── src │ ├── grabs │ ├── mod.rs │ ├── move_grab.rs │ └── resize_grab.rs │ ├── handlers │ ├── compositor.rs │ ├── mod.rs │ └── xdg_shell.rs │ ├── input.rs │ ├── main.rs │ ├── state.rs │ └── winit.rs └── xdg-desktop-portal-android ├── .gitignore ├── .reuse └── dep5 ├── COPYING ├── Cargo.lock ├── Cargo.toml ├── LICENSES ├── CC0-1.0.txt └── LGPL-2.1-or-later.txt ├── README.md └── src ├── bindings ├── activity.rs ├── intent.rs ├── mod.rs └── uri.rs ├── fd.rs ├── file_chooser.rs ├── glob_to_mime.rs ├── handle_token.rs ├── helpers.rs ├── lib.rs ├── open_uri.rs ├── screen_cast.rs └── screen_shot.rs /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk 11 | 12 | # This will be generated by Kawaii 13 | .vscode/settings.json 14 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["xdg-desktop-portal-android", "waylovely-comp" ] 3 | 4 | [patch."https://github.com/waylovely-project/smithay"] 5 | smithay = { path = "../smithay"} 6 | 7 | [patch.crates-io] 8 | wayland-sys = { git = "https://github.com/Smithay/wayland-rs/", rev = "v0.30.0-beta.9"} 9 | wayland-backend = { git = "https://github.com/Smithay/wayland-rs/", rev = "v0.30.0-beta.9"} 10 | wayland-egl = { git = "https://github.com/Smithay/wayland-rs/", rev = "v0.30.0-beta.9"} 11 | wayland-protocols = { git = "https://github.com/Smithay/wayland-rs/", rev = "v0.30.0-beta.9"} 12 | wayland-protocols-wlr = { git = "https://github.com/Smithay/wayland-rs/", rev = "v0.30.0-beta.9"} 13 | wayland-protocols-misc = { git = "https://github.com/Smithay/wayland-rs/", rev = "v0.30.0-beta.9"} 14 | wayland-server = { git = "https://github.com/Smithay/wayland-rs/", rev = "v0.30.0-beta.9"} 15 | wayland-scanner = { git = "https://github.com/Smithay/wayland-rs/", rev = "v0.30.0-beta.9"} 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Waylovely Project 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 10 | 11 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 12 | 13 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 14 | 15 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 16 | 17 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 18 | 19 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 20 | 21 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 22 | 23 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 24 | 25 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 26 | 27 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 28 | 29 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 30 | 31 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 32 | 33 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 34 | 35 | (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and 36 | 37 | (b) You must cause any modified files to carry prominent notices stating that You changed the files; and 38 | 39 | (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 40 | 41 | (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 42 | 43 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 44 | 45 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 46 | 47 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 48 | 49 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 50 | 51 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 52 | 53 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 54 | 55 | END OF TERMS AND CONDITIONS 56 | 57 | APPENDIX: How to apply the Apache License to your work. 58 | 59 | To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. 60 | 61 | Copyright [yyyy] [name of copyright owner] 62 | 63 | Licensed under the Apache License, Version 2.0 (the "License"); 64 | you may not use this file except in compliance with the License. 65 | You may obtain a copy of the License at 66 | 67 | http://www.apache.org/licenses/LICENSE-2.0 68 | 69 | Unless required by applicable law or agreed to in writing, software 70 | distributed under the License is distributed on an "AS IS" BASIS, 71 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 72 | See the License for the specific language governing permissions and 73 | limitations under the License. 74 | -------------------------------------------------------------------------------- /LICENSES/CC0-1.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This project is on halt! 2 | This attempt at bringing Linux applications to Android devices, called the "Waylovely Compositor" has been on halt for... around more than a year and some months. 3 | (different from ["Waylovely Stories"](instagram.com/waylovely.stories) which is an indie multimedia doujinshi circle that has me, Astriya, as one of its members derived from the same name. You might see a big banner advertising it soon. Also please follow and share!) 4 | 5 | At first, the code lives in [a fork of the Smithay compositor](https://github.com/waylovely-project/smithay). This codebase at first was intended to be submitted to upstream, but then it became intended only for prototyping. Perhaps the core reason is that upstream added the Smallvil compositor that is much simpler because it only has support for Winit, which is how the "Waylovely Compositor" prototype was started the first time, because the initial driving force for me was, "Hey, Winit works on Android you know? So theoritically Smithay too." 6 | 7 | If you are looking to try the experiment that has at least been run by someone, you can try this codebase. I created the APK using the [`cargo-apk`](https://github.com/rust-mobile/cargo-apk) tooling which is now deprecated. You also have to build the dependencies, which are built using an earlier version of Waylovely Compositor's [`kawaii`](https://github.com/waylovely-project/kawaii) build system using [this repository](https://github.com/waylovely-project/waylovely-build) as the package repository details (it... works a bit like Meson's repository or perhaps Gentoo?). Do something and something (I have forgotten the details, but just try compiling with cargo apk and you should face the issues to solve?). Do remember to insert the dependencies that you have built into the APK, as if I remember correctly this had to be done manually by me. 8 | 9 | Overall, that experiment works, but the experimental compositor version has not been tested with an actual app. More questions related on how to get the apps loaded was raised. Newer Android versions disable the execute permissions for files that can be modified by the application and the binaries that come with the APK cannot be modified at all. This means that running any programs downloaded from the Internet or any other sources is impossible, except perhaps for interpreted and JIT compilers (hey how do browsers work then). 10 | 11 | The plan was to use QEMU (though performance will suffer), compile the apps into WASI format, or depend on KVM. But then... this project is dropped altogether. 12 | 13 | You also should look into this repository, which has a barebone XDG Portals implementation for Android and also the overall foundation to properly build Waylovely Compositor. I believe the Kawaii buildsystem files have been setup. If you like to fork this project, please fork this repository rather than the previous experiment. 14 | 15 | ___ 16 | 17 | ![Waylovely](https://user-images.githubusercontent.com/66000635/193557047-993b33ed-58cd-4d6a-a8e2-890cde6bcf4a.png) 18 | 19 |

Run all your Linux graphical apps on Android 💖✨✨✨

20 | 21 | The Android windowing system is different than those in desktop operating systems. In the desktop, windowing systems allow applications to open as much windows as the hardware able to run. However this is not the case in Android!! Android is intended to be oriented towards mobile devices, which has less powerful hardware than desktops, so it will do things like only allowing an app to get one EGLSurface!! 22 | 23 | This makes porting windowing toolkits (and UI toolkits too!) to Android a bit difficult, most windowing toolkits like GLFW or GDK are built around the idea of having multiple. Not only that, but for GDK in particular, the developers are quite too short-handed to work on things that aren't prioritized, so obviously maintaining yet another GDK backend would be troublesome!! 24 | 25 | Waylovely attempts to bridge the gap between Android and Linux applications by bringing interfaces found in desktop Linux systems, packaged as an Android app!! 26 | 27 | ## Development 28 | The development is splitted up in different repositories!! 29 | 30 | - [Smithay](https://github.com/Smithay/smithay) - The Waylovely Project contributes a backend in Smithay for use in Android applications!! Here is our [PR](https://github.com/Smithay/smithay/pull/711)! 31 | - [xdg-desktop-portal-android](https://github.com/waylovely-project/xdg-desktop-portal-android) - Xdg Desktop Portal implementation for Android. This is also useful for SDL-based applications!! SDL actually can render without the need of a Wayland compositor but the app might depend on Portals. 32 | - [simple-and-kawaii](https://github.com/waylovely-project/simple-and-kawaii) - A custom build system for boostrapping a large chunk of dependencies!! Not a package manager. 33 | - [waylovely-build](https://github.com/waylovely-project/waylovely-buid) - A repository of libraries needed by Waylovely and friends!! 34 | 35 | 36 | 37 | ### Related Things 38 | 39 | #### AOSP backend for Weston - Pekka Paalanen 40 | 41 | Back in 2012-2013, Collabora's Pekka Paalanen was working to have a fork of AOSP that uses Wayland as its display server!! However since there aren't any work anymore on that, it was removed a few months later. 42 | 43 | I wonder if I should explore the mythical lands of getting Wayland inside of today's AOSP, but I think that's not the MVP requirement! 44 | 45 | - [First Signs Of Wayland Running On Android - Phoronix](https://www.phoronix.com/news/MTA5MzA) 46 | - [Wayland's Weston Running On Android - Phoronix](https://www.phoronix.com/news/MTEwNjQ) 47 | - [The Android Back-End For Wayland's Weston - Phoronix](https://www.phoronix.com/news/MTExMDU) 48 | - [Android Support Removed From Wayland's Weston - Phoronix](https://www.phoronix.com/news/MTI4Mjk) 49 | 50 | ### Why Wayland on Android is a hard problem - Jason Ekstrand 51 | 52 | Jason Ekstrand is a developer for libhydris, a library used by "Linux on mobile phones" projects to have a great support for Android OEMs!! 53 | In this article, he lays out the technical differences between the windowing systems and EGL support in Android and Wayland, and why it's quite hard to make them talk to each other nicely, I feel in particular, actually making Wayland clients talk to Android with some compatibility layers (akin to DXVK or MetalVK)!! 54 | 55 | [Why Wayland on Android is a hard problem - Jason Ekstrand](https://www.jlekstrand.net/jason/projects/wayland/wayland-android/) 56 | -------------------------------------------------------------------------------- /flaura.toml: -------------------------------------------------------------------------------- 1 | [waylovely-comp] 2 | origin = "file://./smithay/smallvil/" 3 | -------------------------------------------------------------------------------- /kawaii: -------------------------------------------------------------------------------- 1 | ../kawaii -------------------------------------------------------------------------------- /kwdev: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | pathy=$(readlink -f "$1") 4 | cd kawaii && poetry run sh -c "cd $pathy && exec $SHELL" -------------------------------------------------------------------------------- /smithay: -------------------------------------------------------------------------------- 1 | ../smithay -------------------------------------------------------------------------------- /waylovely-build: -------------------------------------------------------------------------------- 1 | ../waylovely-build -------------------------------------------------------------------------------- /waylovely-comp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "waylovely" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | slog = { version = "2.1.1" } 8 | slog-stdlog = "4.1.0" 9 | bitflags = "1" 10 | [dependencies.smithay] 11 | git = "https://github.com/waylovely-project/smithay" 12 | branch = "for-upstream" 13 | default-features = false 14 | features = [ 15 | "backend_winit", 16 | "wayland_frontend", 17 | "desktop", 18 | ] 19 | 20 | 21 | [package.metadata.android] 22 | # Specifies the package property of the manifest. 23 | package = "com.github.lovelyyfiaaa.Waylovely" 24 | assets = "../assets" 25 | # Specifies the array of targets to build for. 26 | build_targets = [ "aarch64-linux-android" ] # For now we'll just build for Aarch64 <3 27 | 28 | # Name for final APK file. 29 | # Defaults to package name. 30 | apk_name = "waylovely" 31 | runtime_libs = "../prebuilt-libs" 32 | 33 | 34 | # Anvil needs this to create socket files for Wayland 35 | [[package.metadata.android.uses_permission]] 36 | name = "android.permission.INTERNET" 37 | 38 | # See https://developer.android.com/guide/topics/manifest/uses-sdk-element 39 | 40 | [package.metadata.android.sdk] 41 | min_sdk_version = 29 42 | target_sdk_version = 32 43 | 44 | [package.metadata.android.application] 45 | label = "Waylovely" -------------------------------------------------------------------------------- /waylovely-comp/build.kawaii: -------------------------------------------------------------------------------- 1 | deps = ["waylovely/*"] 2 | 3 | [module] 4 | run = "cargo-apk" 5 | 6 | [android] 7 | sdk = "29" 8 | ndk = "23" 9 | 10 | 11 | [collections] 12 | wraps = "file://../waylovely-build/" -------------------------------------------------------------------------------- /waylovely-comp/src/grabs/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod move_grab; 2 | pub use move_grab::MoveSurfaceGrab; 3 | 4 | pub mod resize_grab; 5 | pub use resize_grab::ResizeSurfaceGrab; 6 | -------------------------------------------------------------------------------- /waylovely-comp/src/grabs/move_grab.rs: -------------------------------------------------------------------------------- 1 | use crate::Smallvil; 2 | use smithay::{ 3 | desktop::Window, 4 | input::pointer::{ 5 | AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, 6 | PointerInnerHandle, 7 | }, 8 | reexports::wayland_server::protocol::wl_surface::WlSurface, 9 | utils::{Logical, Point}, 10 | }; 11 | 12 | pub struct MoveSurfaceGrab { 13 | pub start_data: PointerGrabStartData, 14 | pub window: Window, 15 | pub initial_window_location: Point, 16 | } 17 | 18 | impl PointerGrab for MoveSurfaceGrab { 19 | fn motion( 20 | &mut self, 21 | data: &mut Smallvil, 22 | handle: &mut PointerInnerHandle<'_, Smallvil>, 23 | _focus: Option<(WlSurface, Point)>, 24 | event: &MotionEvent, 25 | ) { 26 | // While the grab is active, no client has pointer focus 27 | handle.motion(data, None, event); 28 | 29 | let delta = event.location - self.start_data.location; 30 | let new_location = self.initial_window_location.to_f64() + delta; 31 | data.space 32 | .map_element(self.window.clone(), new_location.to_i32_round(), true); 33 | } 34 | 35 | fn button( 36 | &mut self, 37 | data: &mut Smallvil, 38 | handle: &mut PointerInnerHandle<'_, Smallvil>, 39 | event: &ButtonEvent, 40 | ) { 41 | handle.button(data, event); 42 | 43 | // The button is a button code as defined in the 44 | // Linux kernel's linux/input-event-codes.h header file, e.g. BTN_LEFT. 45 | const BTN_LEFT: u32 = 0x110; 46 | 47 | if !handle.current_pressed().contains(&BTN_LEFT) { 48 | // No more buttons are pressed, release the grab. 49 | handle.unset_grab(data, event.serial, event.time); 50 | } 51 | } 52 | 53 | fn axis( 54 | &mut self, 55 | data: &mut Smallvil, 56 | handle: &mut PointerInnerHandle<'_, Smallvil>, 57 | details: AxisFrame, 58 | ) { 59 | handle.axis(data, details) 60 | } 61 | 62 | fn start_data(&self) -> &PointerGrabStartData { 63 | &self.start_data 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /waylovely-comp/src/grabs/resize_grab.rs: -------------------------------------------------------------------------------- 1 | use crate::Smallvil; 2 | use smithay::{ 3 | desktop::{Kind, Space, Window}, 4 | input::pointer::{ 5 | AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, 6 | PointerInnerHandle, 7 | }, 8 | reexports::{ 9 | wayland_protocols::xdg::shell::server::xdg_toplevel, wayland_server::protocol::wl_surface::WlSurface, 10 | }, 11 | utils::{Logical, Point, Rectangle, Size}, 12 | wayland::{compositor, shell::xdg::SurfaceCachedState}, 13 | }; 14 | use std::cell::RefCell; 15 | 16 | bitflags::bitflags! { 17 | pub struct ResizeEdge: u32 { 18 | const TOP = 0b0001; 19 | const BOTTOM = 0b0010; 20 | const LEFT = 0b0100; 21 | const RIGHT = 0b1000; 22 | 23 | const TOP_LEFT = Self::TOP.bits | Self::LEFT.bits; 24 | const BOTTOM_LEFT = Self::BOTTOM.bits | Self::LEFT.bits; 25 | 26 | const TOP_RIGHT = Self::TOP.bits | Self::RIGHT.bits; 27 | const BOTTOM_RIGHT = Self::BOTTOM.bits | Self::RIGHT.bits; 28 | } 29 | } 30 | 31 | impl From for ResizeEdge { 32 | #[inline] 33 | fn from(x: xdg_toplevel::ResizeEdge) -> Self { 34 | Self::from_bits(x as u32).unwrap() 35 | } 36 | } 37 | 38 | pub struct ResizeSurfaceGrab { 39 | start_data: PointerGrabStartData, 40 | window: Window, 41 | 42 | edges: ResizeEdge, 43 | 44 | initial_rect: Rectangle, 45 | last_window_size: Size, 46 | } 47 | 48 | impl ResizeSurfaceGrab { 49 | pub fn start( 50 | start_data: PointerGrabStartData, 51 | window: Window, 52 | edges: ResizeEdge, 53 | initial_window_rect: Rectangle, 54 | ) -> Self { 55 | let initial_rect = initial_window_rect; 56 | 57 | ResizeSurfaceState::with(window.toplevel().wl_surface(), |state| { 58 | *state = ResizeSurfaceState::Resizing { edges, initial_rect }; 59 | }); 60 | 61 | Self { 62 | start_data, 63 | window, 64 | edges, 65 | initial_rect, 66 | last_window_size: initial_rect.size, 67 | } 68 | } 69 | } 70 | 71 | impl PointerGrab for ResizeSurfaceGrab { 72 | fn motion( 73 | &mut self, 74 | data: &mut Smallvil, 75 | handle: &mut PointerInnerHandle<'_, Smallvil>, 76 | _focus: Option<(WlSurface, Point)>, 77 | event: &MotionEvent, 78 | ) { 79 | // While the grab is active, no client has pointer focus 80 | handle.motion(data, None, event); 81 | 82 | let mut delta = event.location - self.start_data.location; 83 | 84 | let mut new_window_width = self.initial_rect.size.w; 85 | let mut new_window_height = self.initial_rect.size.h; 86 | 87 | if self.edges.intersects(ResizeEdge::LEFT | ResizeEdge::RIGHT) { 88 | if self.edges.intersects(ResizeEdge::LEFT) { 89 | delta.x = -delta.x; 90 | } 91 | 92 | new_window_width = (self.initial_rect.size.w as f64 + delta.x) as i32; 93 | } 94 | 95 | if self.edges.intersects(ResizeEdge::TOP | ResizeEdge::BOTTOM) { 96 | if self.edges.intersects(ResizeEdge::TOP) { 97 | delta.y = -delta.y; 98 | } 99 | 100 | new_window_height = (self.initial_rect.size.h as f64 + delta.y) as i32; 101 | } 102 | 103 | let (min_size, max_size) = compositor::with_states(self.window.toplevel().wl_surface(), |states| { 104 | let data = states.cached_state.current::(); 105 | (data.min_size, data.max_size) 106 | }); 107 | 108 | let min_width = min_size.w.max(1); 109 | let min_height = min_size.h.max(1); 110 | 111 | let max_width = (max_size.w == 0).then(i32::max_value).unwrap_or(max_size.w); 112 | let max_height = (max_size.h == 0).then(i32::max_value).unwrap_or(max_size.h); 113 | 114 | self.last_window_size = Size::from(( 115 | new_window_width.max(min_width).min(max_width), 116 | new_window_height.max(min_height).min(max_height), 117 | )); 118 | 119 | if let Kind::Xdg(xdg) = self.window.toplevel() { 120 | xdg.with_pending_state(|state| { 121 | state.states.set(xdg_toplevel::State::Resizing); 122 | state.size = Some(self.last_window_size); 123 | }); 124 | 125 | xdg.send_configure(); 126 | } 127 | } 128 | 129 | fn button( 130 | &mut self, 131 | data: &mut Smallvil, 132 | handle: &mut PointerInnerHandle<'_, Smallvil>, 133 | event: &ButtonEvent, 134 | ) { 135 | handle.button(data, event); 136 | 137 | // The button is a button code as defined in the 138 | // Linux kernel's linux/input-event-codes.h header file, e.g. BTN_LEFT. 139 | const BTN_LEFT: u32 = 0x110; 140 | 141 | if !handle.current_pressed().contains(&BTN_LEFT) { 142 | // No more buttons are pressed, release the grab. 143 | handle.unset_grab(data, event.serial, event.time); 144 | 145 | if let Kind::Xdg(xdg) = self.window.toplevel() { 146 | xdg.with_pending_state(|state| { 147 | state.states.unset(xdg_toplevel::State::Resizing); 148 | state.size = Some(self.last_window_size); 149 | }); 150 | 151 | xdg.send_configure(); 152 | 153 | ResizeSurfaceState::with(xdg.wl_surface(), |state| { 154 | *state = ResizeSurfaceState::WaitingForLastCommit { 155 | edges: self.edges, 156 | initial_rect: self.initial_rect, 157 | }; 158 | }); 159 | } 160 | } 161 | } 162 | 163 | fn axis( 164 | &mut self, 165 | data: &mut Smallvil, 166 | handle: &mut PointerInnerHandle<'_, Smallvil>, 167 | details: AxisFrame, 168 | ) { 169 | handle.axis(data, details) 170 | } 171 | 172 | fn start_data(&self) -> &PointerGrabStartData { 173 | &self.start_data 174 | } 175 | } 176 | 177 | /// State of the resize operation. 178 | /// 179 | /// It is stored inside of WlSurface, 180 | /// and can be accessed using [`ResizeSurfaceState::with`] 181 | #[derive(Debug, Clone, Copy, Eq, PartialEq)] 182 | enum ResizeSurfaceState { 183 | Idle, 184 | Resizing { 185 | edges: ResizeEdge, 186 | /// The initial window size and location. 187 | initial_rect: Rectangle, 188 | }, 189 | /// Resize is done, we are now waiting for last commit, to do the final move 190 | WaitingForLastCommit { 191 | edges: ResizeEdge, 192 | /// The initial window size and location. 193 | initial_rect: Rectangle, 194 | }, 195 | } 196 | 197 | impl Default for ResizeSurfaceState { 198 | fn default() -> Self { 199 | ResizeSurfaceState::Idle 200 | } 201 | } 202 | 203 | impl ResizeSurfaceState { 204 | fn with(surface: &WlSurface, cb: F) -> T 205 | where 206 | F: FnOnce(&mut Self) -> T, 207 | { 208 | compositor::with_states(surface, |states| { 209 | states.data_map.insert_if_missing(RefCell::::default); 210 | let state = states.data_map.get::>().unwrap(); 211 | 212 | cb(&mut *state.borrow_mut()) 213 | }) 214 | } 215 | 216 | fn commit(&mut self) -> Option<(ResizeEdge, Rectangle)> { 217 | match *self { 218 | Self::Resizing { edges, initial_rect } => Some((edges, initial_rect)), 219 | Self::WaitingForLastCommit { edges, initial_rect } => { 220 | // The resize is done, let's go back to idle 221 | *self = Self::Idle; 222 | 223 | Some((edges, initial_rect)) 224 | } 225 | Self::Idle => None, 226 | } 227 | } 228 | } 229 | 230 | /// Should be called on `WlSurface::commit` 231 | pub fn handle_commit(space: &mut Space, surface: &WlSurface) -> Option<()> { 232 | let window = space 233 | .elements() 234 | .find(|w| w.toplevel().wl_surface() == surface) 235 | .cloned()?; 236 | 237 | let mut window_loc = space.element_location(&window)?; 238 | let geometry = window.geometry(); 239 | 240 | let new_loc: Point, Logical> = ResizeSurfaceState::with(surface, |state| { 241 | state 242 | .commit() 243 | .and_then(|(edges, initial_rect)| { 244 | // If the window is being resized by top or left, its location must be adjusted 245 | // accordingly. 246 | edges.intersects(ResizeEdge::TOP_LEFT).then(|| { 247 | let new_x = edges 248 | .intersects(ResizeEdge::LEFT) 249 | .then(|| initial_rect.loc.x + (initial_rect.size.w - geometry.size.w)); 250 | 251 | let new_y = edges 252 | .intersects(ResizeEdge::TOP) 253 | .then(|| initial_rect.loc.y + (initial_rect.size.h - geometry.size.h)); 254 | 255 | (new_x, new_y).into() 256 | }) 257 | }) 258 | .unwrap_or_default() 259 | }); 260 | 261 | if let Some(new_x) = new_loc.x { 262 | window_loc.x = new_x; 263 | } 264 | if let Some(new_y) = new_loc.y { 265 | window_loc.y = new_y; 266 | } 267 | 268 | if new_loc.x.is_some() || new_loc.y.is_some() { 269 | // If TOP or LEFT side of the window got resized, we have to move it 270 | space.map_element(window, window_loc, false); 271 | } 272 | 273 | Some(()) 274 | } 275 | -------------------------------------------------------------------------------- /waylovely-comp/src/handlers/compositor.rs: -------------------------------------------------------------------------------- 1 | use crate::{grabs::resize_grab, Smallvil}; 2 | use smithay::{ 3 | backend::renderer::utils::on_commit_buffer_handler, 4 | delegate_compositor, delegate_shm, 5 | reexports::wayland_server::protocol::{wl_buffer, wl_surface::WlSurface}, 6 | wayland::{ 7 | buffer::BufferHandler, 8 | compositor::{get_parent, is_sync_subsurface, CompositorHandler, CompositorState}, 9 | shm::{ShmHandler, ShmState}, 10 | }, 11 | }; 12 | 13 | use super::xdg_shell; 14 | 15 | impl CompositorHandler for Smallvil { 16 | fn compositor_state(&mut self) -> &mut CompositorState { 17 | &mut self.compositor_state 18 | } 19 | 20 | fn commit(&mut self, surface: &WlSurface) { 21 | on_commit_buffer_handler(surface); 22 | if !is_sync_subsurface(surface) { 23 | let mut root = surface.clone(); 24 | while let Some(parent) = get_parent(&root) { 25 | root = parent; 26 | } 27 | if let Some(window) = self.space.elements().find(|w| w.toplevel().wl_surface() == &root) { 28 | window.on_commit(); 29 | } 30 | }; 31 | 32 | xdg_shell::handle_commit(&self.space, surface); 33 | resize_grab::handle_commit(&mut self.space, surface); 34 | } 35 | } 36 | 37 | impl BufferHandler for Smallvil { 38 | fn buffer_destroyed(&mut self, _buffer: &wl_buffer::WlBuffer) {} 39 | } 40 | 41 | impl ShmHandler for Smallvil { 42 | fn shm_state(&self) -> &ShmState { 43 | &self.shm_state 44 | } 45 | } 46 | 47 | delegate_compositor!(Smallvil); 48 | delegate_shm!(Smallvil); 49 | -------------------------------------------------------------------------------- /waylovely-comp/src/handlers/mod.rs: -------------------------------------------------------------------------------- 1 | mod compositor; 2 | mod xdg_shell; 3 | 4 | use crate::Smallvil; 5 | 6 | // 7 | // Wl Seat 8 | // 9 | 10 | use smithay::input::{SeatHandler, SeatState}; 11 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; 12 | use smithay::wayland::data_device::{ClientDndGrabHandler, DataDeviceHandler, ServerDndGrabHandler}; 13 | use smithay::{delegate_data_device, delegate_output, delegate_seat}; 14 | 15 | impl SeatHandler for Smallvil { 16 | type KeyboardFocus = WlSurface; 17 | type PointerFocus = WlSurface; 18 | 19 | fn seat_state(&mut self) -> &mut SeatState { 20 | &mut self.seat_state 21 | } 22 | 23 | fn cursor_image( 24 | &mut self, 25 | _seat: &smithay::input::Seat, 26 | _image: smithay::input::pointer::CursorImageStatus, 27 | ) { 28 | } 29 | fn focus_changed(&mut self, _seat: &smithay::input::Seat, _focused: Option<&WlSurface>) {} 30 | } 31 | 32 | delegate_seat!(Smallvil); 33 | 34 | // 35 | // Wl Data Device 36 | // 37 | 38 | impl DataDeviceHandler for Smallvil { 39 | fn data_device_state(&self) -> &smithay::wayland::data_device::DataDeviceState { 40 | &self.data_device_state 41 | } 42 | } 43 | 44 | impl ClientDndGrabHandler for Smallvil {} 45 | impl ServerDndGrabHandler for Smallvil {} 46 | 47 | delegate_data_device!(Smallvil); 48 | 49 | // 50 | // Wl Output & Xdg Output 51 | // 52 | 53 | delegate_output!(Smallvil); 54 | -------------------------------------------------------------------------------- /waylovely-comp/src/handlers/xdg_shell.rs: -------------------------------------------------------------------------------- 1 | use smithay::{ 2 | delegate_xdg_shell, 3 | desktop::{Kind, Space, Window}, 4 | input::{ 5 | pointer::{Focus, GrabStartData as PointerGrabStartData}, 6 | Seat, 7 | }, 8 | reexports::{ 9 | wayland_protocols::xdg::shell::server::xdg_toplevel, 10 | wayland_server::{ 11 | protocol::{wl_seat, wl_surface::WlSurface}, 12 | Resource, 13 | }, 14 | }, 15 | utils::{Rectangle, Serial}, 16 | wayland::{ 17 | compositor::with_states, 18 | shell::xdg::{ 19 | PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler, XdgShellState, 20 | XdgToplevelSurfaceData, 21 | }, 22 | }, 23 | }; 24 | 25 | use crate::{ 26 | grabs::{MoveSurfaceGrab, ResizeSurfaceGrab}, 27 | Smallvil, 28 | }; 29 | 30 | impl XdgShellHandler for Smallvil { 31 | fn xdg_shell_state(&mut self) -> &mut XdgShellState { 32 | &mut self.xdg_shell_state 33 | } 34 | 35 | fn new_toplevel(&mut self, surface: ToplevelSurface) { 36 | let window = Window::new(Kind::Xdg(surface)); 37 | self.space.map_element(window, (0, 0), false); 38 | } 39 | 40 | fn new_popup(&mut self, _surface: PopupSurface, _positioner: PositionerState) { 41 | // TODO: Popup handling using PopupManager 42 | } 43 | 44 | fn move_request(&mut self, surface: ToplevelSurface, seat: wl_seat::WlSeat, serial: Serial) { 45 | let seat = Seat::from_resource(&seat).unwrap(); 46 | 47 | let wl_surface = surface.wl_surface(); 48 | 49 | if let Some(start_data) = check_grab(&seat, wl_surface, serial) { 50 | let pointer = seat.get_pointer().unwrap(); 51 | 52 | let window = self 53 | .space 54 | .elements() 55 | .find(|w| w.toplevel().wl_surface() == wl_surface) 56 | .unwrap() 57 | .clone(); 58 | let initial_window_location = self.space.element_location(&window).unwrap(); 59 | 60 | let grab = MoveSurfaceGrab { 61 | start_data, 62 | window, 63 | initial_window_location, 64 | }; 65 | 66 | pointer.set_grab(self, grab, serial, Focus::Clear); 67 | } 68 | } 69 | 70 | fn resize_request( 71 | &mut self, 72 | surface: ToplevelSurface, 73 | seat: wl_seat::WlSeat, 74 | serial: Serial, 75 | edges: xdg_toplevel::ResizeEdge, 76 | ) { 77 | let seat = Seat::from_resource(&seat).unwrap(); 78 | 79 | let wl_surface = surface.wl_surface(); 80 | 81 | if let Some(start_data) = check_grab(&seat, wl_surface, serial) { 82 | let pointer = seat.get_pointer().unwrap(); 83 | 84 | let window = self 85 | .space 86 | .elements() 87 | .find(|w| w.toplevel().wl_surface() == wl_surface) 88 | .unwrap() 89 | .clone(); 90 | let initial_window_location = self.space.element_location(&window).unwrap(); 91 | let initial_window_size = window.geometry().size; 92 | 93 | surface.with_pending_state(|state| { 94 | state.states.set(xdg_toplevel::State::Resizing); 95 | }); 96 | 97 | surface.send_configure(); 98 | 99 | let grab = ResizeSurfaceGrab::start( 100 | start_data, 101 | window, 102 | edges.into(), 103 | Rectangle::from_loc_and_size(initial_window_location, initial_window_size), 104 | ); 105 | 106 | pointer.set_grab(self, grab, serial, Focus::Clear); 107 | } 108 | } 109 | 110 | fn grab(&mut self, _surface: PopupSurface, _seat: wl_seat::WlSeat, _serial: Serial) { 111 | // TODO popup grabs 112 | } 113 | } 114 | 115 | // Xdg Shell 116 | delegate_xdg_shell!(Smallvil); 117 | 118 | fn check_grab( 119 | seat: &Seat, 120 | surface: &WlSurface, 121 | serial: Serial, 122 | ) -> Option> { 123 | let pointer = seat.get_pointer()?; 124 | 125 | // Check that this surface has a click grab. 126 | if !pointer.has_grab(serial) { 127 | return None; 128 | } 129 | 130 | let start_data = pointer.grab_start_data()?; 131 | 132 | let (focus, _) = start_data.focus.as_ref()?; 133 | // If the focus was for a different surface, ignore the request. 134 | if !focus.id().same_client_as(&surface.id()) { 135 | return None; 136 | } 137 | 138 | Some(start_data) 139 | } 140 | 141 | /// Should be called on `WlSurface::commit` 142 | pub fn handle_commit(space: &Space, surface: &WlSurface) -> Option<()> { 143 | let window = space 144 | .elements() 145 | .find(|w| w.toplevel().wl_surface() == surface) 146 | .cloned()?; 147 | 148 | if let Kind::Xdg(_) = window.toplevel() { 149 | let initial_configure_sent = with_states(surface, |states| { 150 | states 151 | .data_map 152 | .get::() 153 | .unwrap() 154 | .lock() 155 | .unwrap() 156 | .initial_configure_sent 157 | }); 158 | 159 | if !initial_configure_sent { 160 | window.configure(); 161 | } 162 | } 163 | 164 | Some(()) 165 | } 166 | -------------------------------------------------------------------------------- /waylovely-comp/src/input.rs: -------------------------------------------------------------------------------- 1 | use smithay::{ 2 | backend::input::{ 3 | AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent, 4 | KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, 5 | }, 6 | input::{ 7 | keyboard::FilterResult, 8 | pointer::{AxisFrame, ButtonEvent, MotionEvent}, 9 | }, 10 | reexports::wayland_server::protocol::wl_surface::WlSurface, 11 | utils::SERIAL_COUNTER, 12 | }; 13 | 14 | use crate::state::Smallvil; 15 | 16 | impl Smallvil { 17 | pub fn process_input_event(&mut self, event: InputEvent) { 18 | match event { 19 | InputEvent::Keyboard { event, .. } => { 20 | let serial = SERIAL_COUNTER.next_serial(); 21 | let time = Event::time(&event); 22 | 23 | self.seat.get_keyboard().unwrap().input::<(), _>( 24 | self, 25 | event.key_code(), 26 | event.state(), 27 | serial, 28 | time, 29 | |_, _, _| FilterResult::Forward, 30 | ); 31 | } 32 | InputEvent::PointerMotion { .. } => {} 33 | InputEvent::PointerMotionAbsolute { event, .. } => { 34 | let output = self.space.outputs().next().unwrap(); 35 | 36 | let output_geo = self.space.output_geometry(output).unwrap(); 37 | 38 | let pos = event.position_transformed(output_geo.size) + output_geo.loc.to_f64(); 39 | 40 | let serial = SERIAL_COUNTER.next_serial(); 41 | 42 | let pointer = self.seat.get_pointer().unwrap(); 43 | 44 | let under = self.surface_under_pointer(&pointer); 45 | 46 | pointer.motion( 47 | self, 48 | under, 49 | &MotionEvent { 50 | location: pos, 51 | serial, 52 | time: event.time(), 53 | }, 54 | ); 55 | } 56 | InputEvent::PointerButton { event, .. } => { 57 | let pointer = self.seat.get_pointer().unwrap(); 58 | let keyboard = self.seat.get_keyboard().unwrap(); 59 | 60 | let serial = SERIAL_COUNTER.next_serial(); 61 | 62 | let button = event.button_code(); 63 | 64 | let button_state = event.state(); 65 | 66 | if ButtonState::Pressed == button_state && !pointer.is_grabbed() { 67 | if let Some((window, _loc)) = self 68 | .space 69 | .element_under(pointer.current_location()) 70 | .map(|(w, l)| (w.clone(), l)) 71 | { 72 | self.space.raise_element(&window, true); 73 | keyboard.set_focus(self, Some(window.toplevel().wl_surface().clone()), serial); 74 | window.set_activated(true); 75 | window.configure(); 76 | } else { 77 | self.space.elements().for_each(|window| { 78 | window.set_activated(false); 79 | window.configure(); 80 | }); 81 | keyboard.set_focus(self, Option::::None, serial); 82 | } 83 | }; 84 | 85 | pointer.button( 86 | self, 87 | &ButtonEvent { 88 | button, 89 | state: button_state, 90 | serial, 91 | time: event.time(), 92 | }, 93 | ); 94 | } 95 | InputEvent::PointerAxis { event, .. } => { 96 | let source = event.source(); 97 | 98 | let horizontal_amount = event 99 | .amount(Axis::Horizontal) 100 | .unwrap_or_else(|| event.amount_discrete(Axis::Horizontal).unwrap() * 3.0); 101 | let vertical_amount = event 102 | .amount(Axis::Vertical) 103 | .unwrap_or_else(|| event.amount_discrete(Axis::Vertical).unwrap() * 3.0); 104 | let horizontal_amount_discrete = event.amount_discrete(Axis::Horizontal); 105 | let vertical_amount_discrete = event.amount_discrete(Axis::Vertical); 106 | 107 | let mut frame = AxisFrame::new(event.time()).source(source); 108 | if horizontal_amount != 0.0 { 109 | frame = frame.value(Axis::Horizontal, horizontal_amount); 110 | if let Some(discrete) = horizontal_amount_discrete { 111 | frame = frame.discrete(Axis::Horizontal, discrete as i32); 112 | } 113 | } else if source == AxisSource::Finger { 114 | frame = frame.stop(Axis::Horizontal); 115 | } 116 | if vertical_amount != 0.0 { 117 | frame = frame.value(Axis::Vertical, vertical_amount); 118 | if let Some(discrete) = vertical_amount_discrete { 119 | frame = frame.discrete(Axis::Vertical, discrete as i32); 120 | } 121 | } else if source == AxisSource::Finger { 122 | frame = frame.stop(Axis::Vertical); 123 | } 124 | 125 | self.seat.get_pointer().unwrap().axis(self, frame); 126 | } 127 | _ => {} 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /waylovely-comp/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(irrefutable_let_patterns)] 2 | 3 | use slog::Drain; 4 | 5 | mod handlers; 6 | 7 | mod grabs; 8 | mod input; 9 | mod state; 10 | mod winit; 11 | 12 | use smithay::reexports::{calloop::EventLoop, wayland_server::Display}; 13 | pub use state::Smallvil; 14 | 15 | pub struct CalloopData { 16 | state: Smallvil, 17 | display: Display, 18 | } 19 | 20 | fn main() -> Result<(), Box> { 21 | let log = ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), slog::o!()); 22 | slog_stdlog::init()?; 23 | 24 | let mut event_loop: EventLoop = EventLoop::try_new()?; 25 | 26 | let mut display: Display = Display::new()?; 27 | let state = Smallvil::new(&mut event_loop, &mut display, log.clone()); 28 | 29 | let mut data = CalloopData { state, display }; 30 | 31 | crate::winit::init_winit(&mut event_loop, &mut data, log)?; 32 | 33 | let mut args = std::env::args().skip(1); 34 | let flag = args.next(); 35 | let arg = args.next(); 36 | 37 | match (flag.as_deref(), arg) { 38 | (Some("-c") | Some("--command"), Some(command)) => { 39 | std::process::Command::new(command).spawn().ok(); 40 | } 41 | _ => { 42 | std::process::Command::new("weston-terminal").spawn().ok(); 43 | } 44 | } 45 | 46 | event_loop.run(None, &mut data, move |_| { 47 | // Smallvil is running 48 | })?; 49 | 50 | Ok(()) 51 | } 52 | -------------------------------------------------------------------------------- /waylovely-comp/src/state.rs: -------------------------------------------------------------------------------- 1 | use std::{ffi::OsString, os::unix::prelude::AsRawFd, sync::Arc}; 2 | 3 | use slog::Logger; 4 | use smithay::{ 5 | desktop::{Space, Window, WindowSurfaceType}, 6 | input::{pointer::PointerHandle, Seat, SeatState}, 7 | reexports::{ 8 | calloop::{generic::Generic, EventLoop, Interest, LoopSignal, Mode, PostAction}, 9 | wayland_server::{ 10 | backend::{ClientData, ClientId, DisconnectReason}, 11 | protocol::wl_surface::WlSurface, 12 | Display, 13 | }, 14 | }, 15 | utils::{Logical, Point}, 16 | wayland::{ 17 | compositor::CompositorState, data_device::DataDeviceState, output::OutputManagerState, 18 | shell::xdg::XdgShellState, shm::ShmState, socket::ListeningSocketSource, 19 | }, 20 | }; 21 | 22 | use crate::CalloopData; 23 | 24 | pub struct Smallvil { 25 | pub start_time: std::time::Instant, 26 | pub socket_name: OsString, 27 | 28 | pub space: Space, 29 | pub loop_signal: LoopSignal, 30 | pub log: slog::Logger, 31 | 32 | // Smithay State 33 | pub compositor_state: CompositorState, 34 | pub xdg_shell_state: XdgShellState, 35 | pub shm_state: ShmState, 36 | pub output_manager_state: OutputManagerState, 37 | pub seat_state: SeatState, 38 | pub data_device_state: DataDeviceState, 39 | 40 | pub seat: Seat, 41 | } 42 | 43 | impl Smallvil { 44 | pub fn new(event_loop: &mut EventLoop, display: &mut Display, log: Logger) -> Self { 45 | let start_time = std::time::Instant::now(); 46 | 47 | let dh = display.handle(); 48 | 49 | let compositor_state = CompositorState::new::(&dh, log.clone()); 50 | let xdg_shell_state = XdgShellState::new::(&dh, log.clone()); 51 | let shm_state = ShmState::new::(&dh, vec![], log.clone()); 52 | let output_manager_state = OutputManagerState::new_with_xdg_output::(&dh); 53 | let mut seat_state = SeatState::new(); 54 | let data_device_state = DataDeviceState::new::(&dh, log.clone()); 55 | 56 | // A seat is a group of keyboards, pointer and touch devices. 57 | // A seat typically has a pointer and maintains a keyboard focus and a pointer focus. 58 | let mut seat: Seat = seat_state.new_wl_seat(&dh, "winit", log.clone()); 59 | 60 | // Notify clients that we have a keyboard, for the sake of the example we assume that keyboard is always present. 61 | // You may want to track keyboard hot-plug in real compositor. 62 | seat.add_keyboard(Default::default(), 200, 200).unwrap(); 63 | 64 | // Notify clients that we have a pointer (mouse) 65 | // Here we assume that there is always pointer plugged in 66 | seat.add_pointer(); 67 | 68 | // A space represents a two-dimensional plane. Windows and Outputs can be mapped onto it. 69 | // 70 | // Windows get a position and stacking order through mapping. 71 | // Outputs become views of a part of the Space and can be rendered via Space::render_output. 72 | let space = Space::new(log.clone()); 73 | 74 | let socket_name = Self::init_wayland_listener(display, event_loop, log.clone()); 75 | 76 | // Get the loop signal, used to stop the event loop 77 | let loop_signal = event_loop.get_signal(); 78 | 79 | Self { 80 | start_time, 81 | 82 | space, 83 | loop_signal, 84 | socket_name, 85 | 86 | log, 87 | compositor_state, 88 | xdg_shell_state, 89 | shm_state, 90 | output_manager_state, 91 | seat_state, 92 | data_device_state, 93 | seat, 94 | } 95 | } 96 | 97 | fn init_wayland_listener( 98 | display: &mut Display, 99 | event_loop: &mut EventLoop, 100 | log: slog::Logger, 101 | ) -> OsString { 102 | // Creates a new listening socket, automatically choosing the next available `wayland` socket name. 103 | let listening_socket = ListeningSocketSource::new_auto(log).unwrap(); 104 | 105 | // Get the name of the listening socket. 106 | // Clients will connect to this socket. 107 | let socket_name = listening_socket.socket_name().to_os_string(); 108 | 109 | let handle = event_loop.handle(); 110 | 111 | event_loop 112 | .handle() 113 | .insert_source(listening_socket, move |client_stream, _, state| { 114 | // Inside the callback, you should insert the client into the display. 115 | // 116 | // You may also associate some data with the client when inserting the client. 117 | state 118 | .display 119 | .handle() 120 | .insert_client(client_stream, Arc::new(ClientState)) 121 | .unwrap(); 122 | }) 123 | .expect("Failed to init the wayland event source."); 124 | 125 | // You also need to add the display itself to the event loop, so that client events will be processed by wayland-server. 126 | handle 127 | .insert_source( 128 | Generic::new( 129 | display.backend().poll_fd().as_raw_fd(), 130 | Interest::READ, 131 | Mode::Level, 132 | ), 133 | |_, _, state| { 134 | state.display.dispatch_clients(&mut state.state).unwrap(); 135 | Ok(PostAction::Continue) 136 | }, 137 | ) 138 | .unwrap(); 139 | 140 | socket_name 141 | } 142 | 143 | pub fn surface_under_pointer( 144 | &self, 145 | pointer: &PointerHandle, 146 | ) -> Option<(WlSurface, Point)> { 147 | let pos = pointer.current_location(); 148 | self.space.element_under(pos).and_then(|(window, location)| { 149 | window 150 | .surface_under(pos - location.to_f64(), WindowSurfaceType::ALL) 151 | .map(|(s, p)| (s, p + location)) 152 | }) 153 | } 154 | } 155 | 156 | pub struct ClientState; 157 | impl ClientData for ClientState { 158 | fn initialized(&self, _client_id: ClientId) {} 159 | fn disconnected(&self, _client_id: ClientId, _reason: DisconnectReason) {} 160 | } 161 | -------------------------------------------------------------------------------- /waylovely-comp/src/winit.rs: -------------------------------------------------------------------------------- 1 | use std::time::Duration; 2 | 3 | use smithay::{ 4 | backend::{ 5 | renderer::{damage::DamageTrackedRenderer, element::surface::WaylandSurfaceRenderElement}, 6 | winit::{self, WinitError, WinitEvent, WinitEventLoop, WinitGraphicsBackend}, 7 | }, 8 | output::{Mode, Output, PhysicalProperties, Subpixel}, 9 | reexports::calloop::{ 10 | timer::{TimeoutAction, Timer}, 11 | EventLoop, 12 | }, 13 | utils::{Rectangle, Transform}, 14 | }; 15 | 16 | use slog::Logger; 17 | 18 | use crate::{CalloopData, Smallvil}; 19 | 20 | pub fn init_winit( 21 | event_loop: &mut EventLoop, 22 | data: &mut CalloopData, 23 | log: Logger, 24 | ) -> Result<(), Box> { 25 | let display = &mut data.display; 26 | let state = &mut data.state; 27 | 28 | let (backend, mut winit) = winit::init(log.clone())?; 29 | 30 | let mode = { 31 | let backend = backend.borrow_mut(); 32 | Mode { 33 | size: backend.window_size().physical_size, 34 | refresh: 60_000, 35 | } 36 | }; 37 | 38 | let output = Output::new::<_>( 39 | "winit".to_string(), 40 | PhysicalProperties { 41 | size: (0, 0).into(), 42 | subpixel: Subpixel::Unknown, 43 | make: "Smithay".into(), 44 | model: "Winit".into(), 45 | }, 46 | log.clone(), 47 | ); 48 | let _global = output.create_global::(&display.handle()); 49 | output.change_current_state(Some(mode), Some(Transform::Flipped180), None, Some((0, 0).into())); 50 | output.set_preferred(mode); 51 | 52 | state.space.map_output(&output, (0, 0)); 53 | 54 | let mut damage_tracked_renderer = DamageTrackedRenderer::from_output(&output); 55 | 56 | std::env::set_var("WAYLAND_DISPLAY", &state.socket_name); 57 | 58 | let mut full_redraw = 0u8; 59 | 60 | let timer = Timer::immediate(); 61 | event_loop.handle().insert_source(timer, move |_, _, data| { 62 | winit_dispatch( 63 | &mut backend.borrow_mut(), 64 | &mut winit, 65 | data, 66 | &output, 67 | &mut damage_tracked_renderer, 68 | &mut full_redraw, 69 | &log, 70 | ) 71 | .unwrap(); 72 | TimeoutAction::ToDuration(Duration::from_millis(16)) 73 | })?; 74 | 75 | Ok(()) 76 | } 77 | 78 | pub fn winit_dispatch( 79 | backend: &mut WinitGraphicsBackend, 80 | winit: &mut WinitEventLoop, 81 | data: &mut CalloopData, 82 | output: &Output, 83 | damage_tracked_renderer: &mut DamageTrackedRenderer, 84 | full_redraw: &mut u8, 85 | log: &Logger, 86 | ) -> Result<(), Box> { 87 | let display = &mut data.display; 88 | let state = &mut data.state; 89 | 90 | let res = winit.dispatch_new_events(|event| match event { 91 | WinitEvent::Resized { size, .. } => { 92 | output.change_current_state( 93 | Some(Mode { 94 | size, 95 | refresh: 60_000, 96 | }), 97 | None, 98 | None, 99 | None, 100 | ); 101 | } 102 | WinitEvent::Input(event) => state.process_input_event(event), 103 | _ => (), 104 | }); 105 | 106 | if let Err(WinitError::WindowClosed) = res { 107 | // Stop the loop 108 | state.loop_signal.stop(); 109 | 110 | return Ok(()); 111 | } else { 112 | res?; 113 | } 114 | 115 | *full_redraw = full_redraw.saturating_sub(1); 116 | 117 | let size = backend.window_size().physical_size; 118 | let damage = Rectangle::from_loc_and_size((0, 0), size); 119 | 120 | backend.bind().ok().and_then(|_| { 121 | smithay::desktop::space::render_output::<_, WaylandSurfaceRenderElement, _, _, _>( 122 | output, 123 | backend.renderer(), 124 | 0, 125 | [&state.space], 126 | &[], 127 | damage_tracked_renderer, 128 | [0.1, 0.1, 0.1, 1.0], 129 | log.clone(), 130 | ) 131 | .unwrap() 132 | }); 133 | 134 | backend.submit(Some(&[damage])).unwrap(); 135 | 136 | state 137 | .space 138 | .elements() 139 | .for_each(|window| window.send_frame(state.start_time.elapsed().as_millis() as u32)); 140 | 141 | state.space.refresh(); 142 | display.flush_clients()?; 143 | 144 | Ok(()) 145 | } 146 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | /target 6 | /Cargo.lock 7 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: Portals for Android 3 | Upstream-Contact: Nefo Fortressia 4 | Source: https://github.com/EchidnaHQ/xdg-desktop-portal-android 5 | 6 | # Sample paragraph, commented out: 7 | # 8 | # Files: src/* 9 | # Copyright: $YEAR $NAME <$CONTACT> 10 | # License: ... 11 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/COPYING: -------------------------------------------------------------------------------- 1 | ./LICENSES/LGPL-2.1-or-later.txt -------------------------------------------------------------------------------- /xdg-desktop-portal-android/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "0.7.18" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "async-broadcast" 16 | version = "0.4.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "1bbd92a9bd0e9c1298118ecf8a2f825e86b12c3ec9e411573e34aaf3a0c03cdd" 19 | dependencies = [ 20 | "easy-parallel", 21 | "event-listener", 22 | "futures-core", 23 | "parking_lot", 24 | ] 25 | 26 | [[package]] 27 | name = "async-channel" 28 | version = "1.6.1" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" 31 | dependencies = [ 32 | "concurrent-queue", 33 | "event-listener", 34 | "futures-core", 35 | ] 36 | 37 | [[package]] 38 | name = "async-executor" 39 | version = "1.4.1" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" 42 | dependencies = [ 43 | "async-task", 44 | "concurrent-queue", 45 | "fastrand", 46 | "futures-lite", 47 | "once_cell", 48 | "slab", 49 | ] 50 | 51 | [[package]] 52 | name = "async-io" 53 | version = "1.7.0" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "e5e18f61464ae81cde0a23e713ae8fd299580c54d697a35820cfd0625b8b0e07" 56 | dependencies = [ 57 | "concurrent-queue", 58 | "futures-lite", 59 | "libc", 60 | "log", 61 | "once_cell", 62 | "parking", 63 | "polling", 64 | "slab", 65 | "socket2", 66 | "waker-fn", 67 | "winapi", 68 | ] 69 | 70 | [[package]] 71 | name = "async-lock" 72 | version = "2.5.0" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" 75 | dependencies = [ 76 | "event-listener", 77 | ] 78 | 79 | [[package]] 80 | name = "async-recursion" 81 | version = "0.3.2" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" 84 | dependencies = [ 85 | "proc-macro2", 86 | "quote", 87 | "syn", 88 | ] 89 | 90 | [[package]] 91 | name = "async-task" 92 | version = "4.2.0" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" 95 | 96 | [[package]] 97 | name = "async-trait" 98 | version = "0.1.56" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" 101 | dependencies = [ 102 | "proc-macro2", 103 | "quote", 104 | "syn", 105 | ] 106 | 107 | [[package]] 108 | name = "autocfg" 109 | version = "1.1.0" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 112 | 113 | [[package]] 114 | name = "bitflags" 115 | version = "1.3.2" 116 | source = "registry+https://github.com/rust-lang/crates.io-index" 117 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 118 | 119 | [[package]] 120 | name = "byteorder" 121 | version = "1.4.3" 122 | source = "registry+https://github.com/rust-lang/crates.io-index" 123 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 124 | 125 | [[package]] 126 | name = "bytes" 127 | version = "1.1.0" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" 130 | 131 | [[package]] 132 | name = "cache-padded" 133 | version = "1.2.0" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" 136 | 137 | [[package]] 138 | name = "cc" 139 | version = "1.0.73" 140 | source = "registry+https://github.com/rust-lang/crates.io-index" 141 | checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" 142 | 143 | [[package]] 144 | name = "cesu8" 145 | version = "1.1.0" 146 | source = "registry+https://github.com/rust-lang/crates.io-index" 147 | checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" 148 | 149 | [[package]] 150 | name = "cfg-if" 151 | version = "1.0.0" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 154 | 155 | [[package]] 156 | name = "combine" 157 | version = "4.6.4" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | checksum = "2a604e93b79d1808327a6fca85a6f2d69de66461e7620f5a4cbf5fb4d1d7c948" 160 | dependencies = [ 161 | "bytes", 162 | "memchr", 163 | ] 164 | 165 | [[package]] 166 | name = "concurrent-queue" 167 | version = "1.2.2" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" 170 | dependencies = [ 171 | "cache-padded", 172 | ] 173 | 174 | [[package]] 175 | name = "derivative" 176 | version = "2.2.0" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" 179 | dependencies = [ 180 | "proc-macro2", 181 | "quote", 182 | "syn", 183 | ] 184 | 185 | [[package]] 186 | name = "dirs" 187 | version = "4.0.0" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" 190 | dependencies = [ 191 | "dirs-sys", 192 | ] 193 | 194 | [[package]] 195 | name = "dirs-sys" 196 | version = "0.3.7" 197 | source = "registry+https://github.com/rust-lang/crates.io-index" 198 | checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" 199 | dependencies = [ 200 | "libc", 201 | "redox_users", 202 | "winapi", 203 | ] 204 | 205 | [[package]] 206 | name = "easy-parallel" 207 | version = "3.2.0" 208 | source = "registry+https://github.com/rust-lang/crates.io-index" 209 | checksum = "6907e25393cdcc1f4f3f513d9aac1e840eb1cc341a0fccb01171f7d14d10b946" 210 | 211 | [[package]] 212 | name = "either" 213 | version = "1.7.0" 214 | source = "registry+https://github.com/rust-lang/crates.io-index" 215 | checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" 216 | 217 | [[package]] 218 | name = "enumflags2" 219 | version = "0.7.5" 220 | source = "registry+https://github.com/rust-lang/crates.io-index" 221 | checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" 222 | dependencies = [ 223 | "enumflags2_derive", 224 | "serde", 225 | ] 226 | 227 | [[package]] 228 | name = "enumflags2_derive" 229 | version = "0.7.4" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" 232 | dependencies = [ 233 | "proc-macro2", 234 | "quote", 235 | "syn", 236 | ] 237 | 238 | [[package]] 239 | name = "event-listener" 240 | version = "2.5.2" 241 | source = "registry+https://github.com/rust-lang/crates.io-index" 242 | checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" 243 | 244 | [[package]] 245 | name = "fastrand" 246 | version = "1.7.0" 247 | source = "registry+https://github.com/rust-lang/crates.io-index" 248 | checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" 249 | dependencies = [ 250 | "instant", 251 | ] 252 | 253 | [[package]] 254 | name = "futures-core" 255 | version = "0.3.21" 256 | source = "registry+https://github.com/rust-lang/crates.io-index" 257 | checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" 258 | 259 | [[package]] 260 | name = "futures-io" 261 | version = "0.3.21" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" 264 | 265 | [[package]] 266 | name = "futures-lite" 267 | version = "1.12.0" 268 | source = "registry+https://github.com/rust-lang/crates.io-index" 269 | checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" 270 | dependencies = [ 271 | "fastrand", 272 | "futures-core", 273 | "futures-io", 274 | "memchr", 275 | "parking", 276 | "pin-project-lite", 277 | "waker-fn", 278 | ] 279 | 280 | [[package]] 281 | name = "futures-sink" 282 | version = "0.3.21" 283 | source = "registry+https://github.com/rust-lang/crates.io-index" 284 | checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" 285 | 286 | [[package]] 287 | name = "futures-task" 288 | version = "0.3.21" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" 291 | 292 | [[package]] 293 | name = "futures-util" 294 | version = "0.3.21" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" 297 | dependencies = [ 298 | "futures-core", 299 | "futures-sink", 300 | "futures-task", 301 | "pin-project-lite", 302 | "pin-utils", 303 | "slab", 304 | ] 305 | 306 | [[package]] 307 | name = "getrandom" 308 | version = "0.2.7" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" 311 | dependencies = [ 312 | "cfg-if", 313 | "libc", 314 | "wasi", 315 | ] 316 | 317 | [[package]] 318 | name = "hex" 319 | version = "0.4.3" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 322 | 323 | [[package]] 324 | name = "instant" 325 | version = "0.1.12" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 328 | dependencies = [ 329 | "cfg-if", 330 | ] 331 | 332 | [[package]] 333 | name = "itertools" 334 | version = "0.10.3" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" 337 | dependencies = [ 338 | "either", 339 | ] 340 | 341 | [[package]] 342 | name = "jni" 343 | version = "0.19.0" 344 | source = "registry+https://github.com/rust-lang/crates.io-index" 345 | checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" 346 | dependencies = [ 347 | "cesu8", 348 | "combine", 349 | "jni-sys", 350 | "log", 351 | "thiserror", 352 | "walkdir", 353 | ] 354 | 355 | [[package]] 356 | name = "jni-sys" 357 | version = "0.3.0" 358 | source = "registry+https://github.com/rust-lang/crates.io-index" 359 | checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" 360 | 361 | [[package]] 362 | name = "lazy_static" 363 | version = "1.4.0" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 366 | 367 | [[package]] 368 | name = "libc" 369 | version = "0.2.126" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" 372 | 373 | [[package]] 374 | name = "lock_api" 375 | version = "0.4.7" 376 | source = "registry+https://github.com/rust-lang/crates.io-index" 377 | checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" 378 | dependencies = [ 379 | "autocfg", 380 | "scopeguard", 381 | ] 382 | 383 | [[package]] 384 | name = "log" 385 | version = "0.4.17" 386 | source = "registry+https://github.com/rust-lang/crates.io-index" 387 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 388 | dependencies = [ 389 | "cfg-if", 390 | ] 391 | 392 | [[package]] 393 | name = "memchr" 394 | version = "2.5.0" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 397 | 398 | [[package]] 399 | name = "memoffset" 400 | version = "0.6.5" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" 403 | dependencies = [ 404 | "autocfg", 405 | ] 406 | 407 | [[package]] 408 | name = "nix" 409 | version = "0.23.1" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" 412 | dependencies = [ 413 | "bitflags", 414 | "cc", 415 | "cfg-if", 416 | "libc", 417 | "memoffset", 418 | ] 419 | 420 | [[package]] 421 | name = "once_cell" 422 | version = "1.12.0" 423 | source = "registry+https://github.com/rust-lang/crates.io-index" 424 | checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" 425 | 426 | [[package]] 427 | name = "ordered-stream" 428 | version = "0.0.1" 429 | source = "registry+https://github.com/rust-lang/crates.io-index" 430 | checksum = "44630c059eacfd6e08bdaa51b1db2ce33119caa4ddc1235e923109aa5f25ccb1" 431 | dependencies = [ 432 | "futures-core", 433 | "pin-project-lite", 434 | ] 435 | 436 | [[package]] 437 | name = "parking" 438 | version = "2.0.0" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" 441 | 442 | [[package]] 443 | name = "parking_lot" 444 | version = "0.11.2" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 447 | dependencies = [ 448 | "instant", 449 | "lock_api", 450 | "parking_lot_core", 451 | ] 452 | 453 | [[package]] 454 | name = "parking_lot_core" 455 | version = "0.8.5" 456 | source = "registry+https://github.com/rust-lang/crates.io-index" 457 | checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" 458 | dependencies = [ 459 | "cfg-if", 460 | "instant", 461 | "libc", 462 | "redox_syscall", 463 | "smallvec", 464 | "winapi", 465 | ] 466 | 467 | [[package]] 468 | name = "pin-project-lite" 469 | version = "0.2.9" 470 | source = "registry+https://github.com/rust-lang/crates.io-index" 471 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 472 | 473 | [[package]] 474 | name = "pin-utils" 475 | version = "0.1.0" 476 | source = "registry+https://github.com/rust-lang/crates.io-index" 477 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 478 | 479 | [[package]] 480 | name = "polling" 481 | version = "2.2.0" 482 | source = "registry+https://github.com/rust-lang/crates.io-index" 483 | checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" 484 | dependencies = [ 485 | "cfg-if", 486 | "libc", 487 | "log", 488 | "wepoll-ffi", 489 | "winapi", 490 | ] 491 | 492 | [[package]] 493 | name = "ppv-lite86" 494 | version = "0.2.16" 495 | source = "registry+https://github.com/rust-lang/crates.io-index" 496 | checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" 497 | 498 | [[package]] 499 | name = "proc-macro-crate" 500 | version = "1.1.3" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" 503 | dependencies = [ 504 | "thiserror", 505 | "toml", 506 | ] 507 | 508 | [[package]] 509 | name = "proc-macro2" 510 | version = "1.0.40" 511 | source = "registry+https://github.com/rust-lang/crates.io-index" 512 | checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" 513 | dependencies = [ 514 | "unicode-ident", 515 | ] 516 | 517 | [[package]] 518 | name = "quote" 519 | version = "1.0.20" 520 | source = "registry+https://github.com/rust-lang/crates.io-index" 521 | checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" 522 | dependencies = [ 523 | "proc-macro2", 524 | ] 525 | 526 | [[package]] 527 | name = "rand" 528 | version = "0.8.5" 529 | source = "registry+https://github.com/rust-lang/crates.io-index" 530 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 531 | dependencies = [ 532 | "libc", 533 | "rand_chacha", 534 | "rand_core", 535 | ] 536 | 537 | [[package]] 538 | name = "rand_chacha" 539 | version = "0.3.1" 540 | source = "registry+https://github.com/rust-lang/crates.io-index" 541 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 542 | dependencies = [ 543 | "ppv-lite86", 544 | "rand_core", 545 | ] 546 | 547 | [[package]] 548 | name = "rand_core" 549 | version = "0.6.3" 550 | source = "registry+https://github.com/rust-lang/crates.io-index" 551 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 552 | dependencies = [ 553 | "getrandom", 554 | ] 555 | 556 | [[package]] 557 | name = "redox_syscall" 558 | version = "0.2.13" 559 | source = "registry+https://github.com/rust-lang/crates.io-index" 560 | checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" 561 | dependencies = [ 562 | "bitflags", 563 | ] 564 | 565 | [[package]] 566 | name = "redox_users" 567 | version = "0.4.3" 568 | source = "registry+https://github.com/rust-lang/crates.io-index" 569 | checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" 570 | dependencies = [ 571 | "getrandom", 572 | "redox_syscall", 573 | "thiserror", 574 | ] 575 | 576 | [[package]] 577 | name = "regex" 578 | version = "1.5.6" 579 | source = "registry+https://github.com/rust-lang/crates.io-index" 580 | checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" 581 | dependencies = [ 582 | "aho-corasick", 583 | "memchr", 584 | "regex-syntax", 585 | ] 586 | 587 | [[package]] 588 | name = "regex-syntax" 589 | version = "0.6.26" 590 | source = "registry+https://github.com/rust-lang/crates.io-index" 591 | checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" 592 | 593 | [[package]] 594 | name = "remove_dir_all" 595 | version = "0.5.3" 596 | source = "registry+https://github.com/rust-lang/crates.io-index" 597 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 598 | dependencies = [ 599 | "winapi", 600 | ] 601 | 602 | [[package]] 603 | name = "same-file" 604 | version = "1.0.6" 605 | source = "registry+https://github.com/rust-lang/crates.io-index" 606 | checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 607 | dependencies = [ 608 | "winapi-util", 609 | ] 610 | 611 | [[package]] 612 | name = "scopeguard" 613 | version = "1.1.0" 614 | source = "registry+https://github.com/rust-lang/crates.io-index" 615 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 616 | 617 | [[package]] 618 | name = "serde" 619 | version = "1.0.137" 620 | source = "registry+https://github.com/rust-lang/crates.io-index" 621 | checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" 622 | dependencies = [ 623 | "serde_derive", 624 | ] 625 | 626 | [[package]] 627 | name = "serde_derive" 628 | version = "1.0.137" 629 | source = "registry+https://github.com/rust-lang/crates.io-index" 630 | checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" 631 | dependencies = [ 632 | "proc-macro2", 633 | "quote", 634 | "syn", 635 | ] 636 | 637 | [[package]] 638 | name = "serde_repr" 639 | version = "0.1.8" 640 | source = "registry+https://github.com/rust-lang/crates.io-index" 641 | checksum = "a2ad84e47328a31223de7fed7a4f5087f2d6ddfe586cf3ca25b7a165bc0a5aed" 642 | dependencies = [ 643 | "proc-macro2", 644 | "quote", 645 | "syn", 646 | ] 647 | 648 | [[package]] 649 | name = "sha1" 650 | version = "0.6.1" 651 | source = "registry+https://github.com/rust-lang/crates.io-index" 652 | checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" 653 | dependencies = [ 654 | "sha1_smol", 655 | ] 656 | 657 | [[package]] 658 | name = "sha1_smol" 659 | version = "1.0.0" 660 | source = "registry+https://github.com/rust-lang/crates.io-index" 661 | checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" 662 | 663 | [[package]] 664 | name = "slab" 665 | version = "0.4.6" 666 | source = "registry+https://github.com/rust-lang/crates.io-index" 667 | checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" 668 | 669 | [[package]] 670 | name = "smallvec" 671 | version = "1.9.0" 672 | source = "registry+https://github.com/rust-lang/crates.io-index" 673 | checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" 674 | 675 | [[package]] 676 | name = "socket2" 677 | version = "0.4.4" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" 680 | dependencies = [ 681 | "libc", 682 | "winapi", 683 | ] 684 | 685 | [[package]] 686 | name = "static_assertions" 687 | version = "1.1.0" 688 | source = "registry+https://github.com/rust-lang/crates.io-index" 689 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 690 | 691 | [[package]] 692 | name = "syn" 693 | version = "1.0.98" 694 | source = "registry+https://github.com/rust-lang/crates.io-index" 695 | checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" 696 | dependencies = [ 697 | "proc-macro2", 698 | "quote", 699 | "unicode-ident", 700 | ] 701 | 702 | [[package]] 703 | name = "tempfile" 704 | version = "3.3.0" 705 | source = "registry+https://github.com/rust-lang/crates.io-index" 706 | checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" 707 | dependencies = [ 708 | "cfg-if", 709 | "fastrand", 710 | "libc", 711 | "redox_syscall", 712 | "remove_dir_all", 713 | "winapi", 714 | ] 715 | 716 | [[package]] 717 | name = "thiserror" 718 | version = "1.0.31" 719 | source = "registry+https://github.com/rust-lang/crates.io-index" 720 | checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" 721 | dependencies = [ 722 | "thiserror-impl", 723 | ] 724 | 725 | [[package]] 726 | name = "thiserror-impl" 727 | version = "1.0.31" 728 | source = "registry+https://github.com/rust-lang/crates.io-index" 729 | checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" 730 | dependencies = [ 731 | "proc-macro2", 732 | "quote", 733 | "syn", 734 | ] 735 | 736 | [[package]] 737 | name = "toml" 738 | version = "0.5.9" 739 | source = "registry+https://github.com/rust-lang/crates.io-index" 740 | checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" 741 | dependencies = [ 742 | "serde", 743 | ] 744 | 745 | [[package]] 746 | name = "tracing" 747 | version = "0.1.35" 748 | source = "registry+https://github.com/rust-lang/crates.io-index" 749 | checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" 750 | dependencies = [ 751 | "cfg-if", 752 | "pin-project-lite", 753 | "tracing-attributes", 754 | "tracing-core", 755 | ] 756 | 757 | [[package]] 758 | name = "tracing-attributes" 759 | version = "0.1.22" 760 | source = "registry+https://github.com/rust-lang/crates.io-index" 761 | checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" 762 | dependencies = [ 763 | "proc-macro2", 764 | "quote", 765 | "syn", 766 | ] 767 | 768 | [[package]] 769 | name = "tracing-core" 770 | version = "0.1.28" 771 | source = "registry+https://github.com/rust-lang/crates.io-index" 772 | checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" 773 | dependencies = [ 774 | "once_cell", 775 | ] 776 | 777 | [[package]] 778 | name = "uds_windows" 779 | version = "1.0.2" 780 | source = "registry+https://github.com/rust-lang/crates.io-index" 781 | checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" 782 | dependencies = [ 783 | "tempfile", 784 | "winapi", 785 | ] 786 | 787 | [[package]] 788 | name = "unicode-ident" 789 | version = "1.0.1" 790 | source = "registry+https://github.com/rust-lang/crates.io-index" 791 | checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" 792 | 793 | [[package]] 794 | name = "waker-fn" 795 | version = "1.1.0" 796 | source = "registry+https://github.com/rust-lang/crates.io-index" 797 | checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" 798 | 799 | [[package]] 800 | name = "walkdir" 801 | version = "2.3.2" 802 | source = "registry+https://github.com/rust-lang/crates.io-index" 803 | checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" 804 | dependencies = [ 805 | "same-file", 806 | "winapi", 807 | "winapi-util", 808 | ] 809 | 810 | [[package]] 811 | name = "wasi" 812 | version = "0.11.0+wasi-snapshot-preview1" 813 | source = "registry+https://github.com/rust-lang/crates.io-index" 814 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 815 | 816 | [[package]] 817 | name = "wepoll-ffi" 818 | version = "0.1.2" 819 | source = "registry+https://github.com/rust-lang/crates.io-index" 820 | checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" 821 | dependencies = [ 822 | "cc", 823 | ] 824 | 825 | [[package]] 826 | name = "winapi" 827 | version = "0.3.9" 828 | source = "registry+https://github.com/rust-lang/crates.io-index" 829 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 830 | dependencies = [ 831 | "winapi-i686-pc-windows-gnu", 832 | "winapi-x86_64-pc-windows-gnu", 833 | ] 834 | 835 | [[package]] 836 | name = "winapi-i686-pc-windows-gnu" 837 | version = "0.4.0" 838 | source = "registry+https://github.com/rust-lang/crates.io-index" 839 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 840 | 841 | [[package]] 842 | name = "winapi-util" 843 | version = "0.1.5" 844 | source = "registry+https://github.com/rust-lang/crates.io-index" 845 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 846 | dependencies = [ 847 | "winapi", 848 | ] 849 | 850 | [[package]] 851 | name = "winapi-x86_64-pc-windows-gnu" 852 | version = "0.4.0" 853 | source = "registry+https://github.com/rust-lang/crates.io-index" 854 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 855 | 856 | [[package]] 857 | name = "xdg-desktop-portal-android" 858 | version = "0.1.0" 859 | dependencies = [ 860 | "itertools", 861 | "jni", 862 | "lazy_static", 863 | "once_cell", 864 | "rand", 865 | "regex", 866 | "serde", 867 | "serde_repr", 868 | "zbus", 869 | ] 870 | 871 | [[package]] 872 | name = "zbus" 873 | version = "2.3.2" 874 | source = "registry+https://github.com/rust-lang/crates.io-index" 875 | checksum = "2d8f1a037b2c4a67d9654dc7bdfa8ff2e80555bbefdd3c1833c1d1b27c963a6b" 876 | dependencies = [ 877 | "async-broadcast", 878 | "async-channel", 879 | "async-executor", 880 | "async-io", 881 | "async-lock", 882 | "async-recursion", 883 | "async-task", 884 | "async-trait", 885 | "byteorder", 886 | "derivative", 887 | "dirs", 888 | "enumflags2", 889 | "event-listener", 890 | "futures-core", 891 | "futures-sink", 892 | "futures-util", 893 | "hex", 894 | "lazy_static", 895 | "nix", 896 | "once_cell", 897 | "ordered-stream", 898 | "rand", 899 | "serde", 900 | "serde_repr", 901 | "sha1", 902 | "static_assertions", 903 | "tracing", 904 | "uds_windows", 905 | "winapi", 906 | "zbus_macros", 907 | "zbus_names", 908 | "zvariant", 909 | ] 910 | 911 | [[package]] 912 | name = "zbus_macros" 913 | version = "2.3.2" 914 | source = "registry+https://github.com/rust-lang/crates.io-index" 915 | checksum = "1f8fb5186d1c87ae88cf234974c240671238b4a679158ad3b94ec465237349a6" 916 | dependencies = [ 917 | "proc-macro-crate", 918 | "proc-macro2", 919 | "quote", 920 | "regex", 921 | "syn", 922 | ] 923 | 924 | [[package]] 925 | name = "zbus_names" 926 | version = "2.1.0" 927 | source = "registry+https://github.com/rust-lang/crates.io-index" 928 | checksum = "45dfcdcf87b71dad505d30cc27b1b7b88a64b6d1c435648f48f9dbc1fdc4b7e1" 929 | dependencies = [ 930 | "serde", 931 | "static_assertions", 932 | "zvariant", 933 | ] 934 | 935 | [[package]] 936 | name = "zvariant" 937 | version = "3.4.1" 938 | source = "registry+https://github.com/rust-lang/crates.io-index" 939 | checksum = "cf2c71467724d4a77f0a1f0339dab10ca5d63f6a82411289cdcdfbfd47d2e407" 940 | dependencies = [ 941 | "byteorder", 942 | "enumflags2", 943 | "libc", 944 | "serde", 945 | "static_assertions", 946 | "zvariant_derive", 947 | ] 948 | 949 | [[package]] 950 | name = "zvariant_derive" 951 | version = "3.4.1" 952 | source = "registry+https://github.com/rust-lang/crates.io-index" 953 | checksum = "2c47f3630ce926a03abf21f5a8db90c60c81ed71599b5c86ad1a54fd3c7564c5" 954 | dependencies = [ 955 | "proc-macro-crate", 956 | "proc-macro2", 957 | "quote", 958 | "syn", 959 | ] 960 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/Cargo.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | [package] 6 | name = "xdg-desktop-portal-android" 7 | version = "0.1.0" 8 | edition = "2021" 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | 12 | [dependencies] 13 | zbus = "2.3.2" 14 | jni = { version = "0.19.0", features = ["invocation"] } 15 | serde = "1.0.137" 16 | rand = "0.8.5" 17 | once_cell = "1.12.0" 18 | serde_repr = "0.1.8" 19 | regex = "1.5.6" 20 | lazy_static = "1.4.0" 21 | itertools = "0.10.3" -------------------------------------------------------------------------------- /xdg-desktop-portal-android/LICENSES/CC0-1.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/LICENSES/LGPL-2.1-or-later.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | 3 | Version 2.1, February 1999 4 | 5 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 6 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 9 | 10 | [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] 11 | 12 | Preamble 13 | 14 | The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. 15 | 16 | This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. 17 | 18 | When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. 19 | 20 | To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. 21 | 22 | For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. 23 | 24 | We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. 25 | 26 | To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. 27 | 28 | Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. 29 | 30 | Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. 31 | 32 | When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. 33 | 34 | We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. 35 | 36 | For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. 37 | 38 | In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. 39 | 40 | Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. 41 | 42 | The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. 43 | 44 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 45 | 46 | 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". 47 | 48 | A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. 49 | 50 | The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) 51 | 52 | "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. 53 | 54 | Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 55 | 56 | 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. 57 | 58 | You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 59 | 60 | 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 61 | 62 | a) The modified work must itself be a software library. 63 | 64 | b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. 65 | 66 | c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. 67 | 68 | d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. 69 | 70 | (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) 71 | 72 | These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. 73 | 74 | Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. 75 | 76 | In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 77 | 78 | 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. 79 | 80 | Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. 81 | 82 | This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 83 | 84 | 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. 85 | 86 | If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 87 | 88 | 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. 89 | 90 | However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. 91 | 92 | When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. 93 | 94 | If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) 95 | 96 | Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 97 | 98 | 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. 99 | 100 | You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: 101 | 102 | a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) 103 | 104 | b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. 105 | 106 | c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. 107 | 108 | d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. 109 | 110 | e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. 111 | 112 | For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. 113 | 114 | It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 115 | 116 | 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: 117 | 118 | a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. 119 | 120 | b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 121 | 122 | 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 123 | 124 | 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 125 | 126 | 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 127 | 128 | 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. 129 | 130 | If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. 131 | 132 | It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. 133 | 134 | This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 135 | 136 | 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 137 | 138 | 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 139 | 140 | Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 141 | 142 | 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 143 | 144 | NO WARRANTY 145 | 146 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 147 | 148 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 149 | 150 | END OF TERMS AND CONDITIONS 151 | 152 | How to Apply These Terms to Your New Libraries 153 | 154 | If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). 155 | 156 | To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. 157 | 158 | one line to give the library's name and an idea of what it does. 159 | Copyright (C) year name of author 160 | 161 | This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 162 | 163 | This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 164 | 165 | You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. 166 | 167 | You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: 168 | 169 | Yoyodyne, Inc., hereby disclaims all copyright interest in 170 | the library `Frob' (a library for tweaking knobs) written 171 | by James Random Hacker. 172 | 173 | signature of Ty Coon, 1 April 1990 174 | Ty Coon, President of Vice 175 | That's all there is to it! 176 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/README.md: -------------------------------------------------------------------------------- 1 | # xdg-desktop-portal-android 2 | 3 | This is an implementation of the Xdg Desktop Portal specification for the Android platform!!! 4 | 5 | ## Checklist 6 | - [ ] org.freedesktop.portal.Account — Portal for obtaining information about the user 7 | - [ ] org.freedesktop.portal.Background — Portal for requesting autostart and background activity 8 | - [ ] org.freedesktop.portal.Camera — Camera portal 9 | - [ ] org.freedesktop.portal.Device — Portal for device access 10 | - [ ] org.freedesktop.portal.Documents — Document portal 11 | - [ ] org.freedesktop.portal.DynamicLauncher — Portal for installing application launchers 12 | - [ ] org.freedesktop.portal.Email — Portal for sending email 13 | - [ ] org.freedesktop.portal.FileChooser — File chooser portal 14 | - [ ] org.freedesktop.portal.FileTransfer — Portal for transferring files between apps 15 | - [ ] org.freedesktop.portal.Flatpak.UpdateMonitor 16 | - [ ] org.freedesktop.portal.Flatpak — Flatpak portal 17 | - [ ] org.freedesktop.portal.GameMode — Portal for accessing GameMode 18 | - [ ] org.freedesktop.portal.Inhibit — Portal for inhibiting session transitions 19 | - [ ] org.freedesktop.portal.Location — Portal for obtaining information about the location 20 | - [ ] org.freedesktop.portal.MemoryMonitor — Memory monitoring portal 21 | - [ ] org.freedesktop.portal.NetworkMonitor — Network monitoring portal 22 | - [ ] org.freedesktop.portal.Notification — Portal for sending notifications 23 | - [ ] org.freedesktop.portal.OpenURI — Portal for opening URIs 24 | - [ ] org.freedesktop.portal.PowerProfileMonitor — Power Profile monitoring portal 25 | - [ ] org.freedesktop.portal.Print — Portal for printing 26 | - [ ] org.freedesktop.portal.ProxyResolver — Proxy information 27 | - [ ] org.freedesktop.portal.Realtime — Portal for setting threads to realtime 28 | - [ ] org.freedesktop.portal.RemoteDesktop — Remote desktop portal 29 | - [ ] org.freedesktop.portal.Request — Shared request interface 30 | - [ ] org.freedesktop.portal.ScreenCast — Screen cast portal 31 | - [ ] org.freedesktop.portal.Screenshot — Portal for taking screenshots 32 | - [ ] org.freedesktop.portal.Secret — Portal for retrieving application secret 33 | - [ ] org.freedesktop.portal.Session — Shared session interface 34 | - [ ] org.freedesktop.portal.Settings — Settings interface 35 | - [ ] org.freedesktop.portal.Trash — Portal for trashing files 36 | - [ ] org.freedesktop.portal.Wallpaper — Portal for setting the desktop's Wallpaper -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/bindings/activity.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use jni::objects::{JString, JValue}; 6 | 7 | use crate::helpers::get_env; 8 | 9 | use super::intent::Intent; 10 | 11 | pub struct Activity {} 12 | 13 | impl Activity { 14 | pub fn start_activity(intent: &Intent) { 15 | get_env() 16 | .call_static_method( 17 | "android/app/Activity", 18 | "startActivity", 19 | "(Landroid/content/Intent;)V", 20 | &[JValue::from(**intent)], 21 | ) 22 | .unwrap(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/bindings/intent.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use std::ops::Deref; 6 | 7 | use jni::{ 8 | errors::Result, 9 | objects::{JObject, JString, JValue}, 10 | JNIEnv, 11 | }; 12 | 13 | use crate::helpers::get_env; 14 | 15 | use super::uri::Uri; 16 | 17 | pub struct Intent<'a>(JObject<'a>); 18 | 19 | impl Intent<'_> { 20 | pub const ID: &'static str = "android/content/Intent"; 21 | 22 | pub fn with_action(action: Action) -> Self { 23 | let env: JNIEnv = get_env(); 24 | let intent = env 25 | .new_object( 26 | Self::ID, 27 | "(Ljava/lang/String;)Landroid/content/Intent;", 28 | &[action.into()], 29 | ) 30 | .unwrap(); 31 | Self(intent) 32 | } 33 | pub fn with_uri(action: Action, juri: &Uri) -> Self { 34 | let env: JNIEnv = get_env(); 35 | let intent = env 36 | .new_object( 37 | Self::ID, 38 | "(Ljava/lang/String;Landroid/net/Uri;)Landroid/content/Intent;", 39 | &[action.into(), **juri], 40 | ) 41 | .unwrap(); 42 | Self(intent) 43 | } 44 | 45 | pub fn set_type(&self, mime: &str) -> Result { 46 | let env: JNIEnv = get_env(); 47 | 48 | env.call_static_method(Self::ID, "setType", "()", &[]) 49 | } 50 | 51 | pub fn normalize_mime_type(mime: &str) -> Result { 52 | let env: JNIEnv = get_env(); 53 | 54 | env.call_static_method( 55 | Self::ID, 56 | "normalizeMimeType", 57 | "(Ljava/lang/String;)Ljava/lang/String;", 58 | &[env.new_string(mime).unwrap().into()], 59 | ) 60 | } 61 | 62 | pub fn set_type_and_normalize(&self, mime: &str) -> Result { 63 | let env: JNIEnv = get_env(); 64 | 65 | env.call_static_method( 66 | Self::ID, 67 | "setTypeAndNormalize", 68 | "(Ljava/lang/String;)Ljava/lang/String;", 69 | &[env.new_string(mime).unwrap().into()], 70 | ) 71 | } 72 | } 73 | 74 | impl<'a> From> for JValue<'a> { 75 | fn from(intent: Intent<'a>) -> Self { 76 | Self::from(intent.0) 77 | } 78 | } 79 | 80 | impl<'a> Deref for Intent<'a> { 81 | type Target = JObject<'a>; 82 | 83 | fn deref(&self) -> &Self::Target { 84 | &self.0 85 | } 86 | } 87 | 88 | pub struct Action(&'static str); 89 | 90 | impl Action { 91 | pub const VIEW: Action = Action("android.intent.action.VIEW"); 92 | pub const GET_CONTENT: Action = Action("android.intent.action.GET_CONTENT"); 93 | pub const SEND: Action = Action("android.intent.action.SEND"); 94 | } 95 | 96 | impl<'a> Into> for Action { 97 | fn into(self) -> JString<'a> { 98 | get_env().new_string(self.0).unwrap() 99 | } 100 | } 101 | 102 | impl<'a> Into> for Action { 103 | fn into(self) -> JValue<'a> { 104 | JValue::from(Into::::into(self)) 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/bindings/mod.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | pub mod activity; 6 | pub mod intent; 7 | pub mod uri; 8 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/bindings/uri.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use std::ops::Deref; 6 | 7 | use jni::objects::JValue; 8 | use zbus::zvariant::Fd; 9 | 10 | use crate::{fd::zbusfd_to_pathbuf, JVM}; 11 | 12 | pub struct Uri<'a>(JValue<'a>); 13 | 14 | impl Uri<'_> { 15 | pub fn from_str(uri: &str) -> Self { 16 | let jvm = JVM.get().unwrap(); 17 | 18 | let env = jvm.get_env().unwrap(); 19 | let juri = env 20 | .call_static_method( 21 | "android/net/Uri", 22 | "path", 23 | "(Ljava/lang/String;)Landroid/net/Uri;", 24 | &[JValue::from(env.new_string(uri).unwrap())], 25 | ) 26 | .unwrap(); 27 | 28 | Self(juri) 29 | } 30 | } 31 | 32 | impl<'a> From> for Uri<'a> { 33 | fn from(string: dyn AsRef) -> Self { 34 | Self::from_str(&string) 35 | } 36 | } 37 | 38 | impl<'a> From for Uri<'a> { 39 | fn from(fd: Fd) -> Self { 40 | Self::from_str(&format!("file://{}", zbusfd_to_pathbuf(&fd).to_string())) 41 | } 42 | } 43 | 44 | impl<'a> Deref for Uri<'a> { 45 | type Target = JValue<'a>; 46 | 47 | fn deref(&self) -> &JValue<'a> { 48 | &self.0 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/fd.rs: -------------------------------------------------------------------------------- 1 | use zbus::zvariant::Fd; 2 | /** 3 | * 4 | */ 5 | pub fn zbusfd_to_pathbuf(file: &Fd) { 6 | let uri = format!("/proc/self/fd/{:?}", file.as_raw_fd()); 7 | 8 | std::fs::canonicalize(uri) 9 | } 10 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/file_chooser.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use std::collections::HashMap; 6 | use std::iter::Product; 7 | 8 | use crate::bindings::intent::Action; 9 | use crate::glob_to_mime::glob_to_mime; 10 | use crate::{bindings::intent::Intent, helpers::get_object_path}; 11 | use itertools::{iproduct, Itertools}; 12 | use jni::objects::{JString, JValue}; 13 | use regex::Regex; 14 | use serde::{Deserialize, Serialize}; 15 | use serde_repr::{Deserialize_repr, Serialize_repr}; 16 | use std::slice::Iter; 17 | use zbus::dbus_interface; 18 | use zbus::fdo::{Error, Result}; 19 | use zbus::zvariant::{DeserializeDict, OwnedObjectPath, SerializeDict, Type}; 20 | 21 | use super::handle_token::HandleToken; 22 | 23 | // This lovelyyy codee is copieed from https://github.com/bilelmoussaoui/ashpd/blob/master/src/desktop/open_uri.rs 24 | // Licensed under the lovellyy MIT License (https://github.com/bilelmoussaoui/ashpd/blob/master/LICENSE) 25 | 26 | #[derive(Serialize, Deserialize, Type, Clone, Debug)] 27 | /// A file filter, to limit the available file choices to a mimetype or a glob 28 | /// pattern. 29 | pub struct FileFilter(String, Vec<(FilterType, String)>); 30 | 31 | #[derive(Serialize_repr, Clone, Deserialize_repr, PartialEq, Eq, Debug, Type)] 32 | #[repr(u32)] 33 | enum FilterType { 34 | GlobPattern = 0, 35 | MimeType = 1, 36 | } 37 | 38 | #[derive(Serialize, Deserialize, Type, Clone, Debug)] 39 | /// Presents the user with a choice to select from or as a checkbox. 40 | pub struct Choice(String, String, Vec<(String, String)>, String); 41 | 42 | #[derive(SerializeDict, DeserializeDict, Type, Clone, Debug, Default)] 43 | /// Specified options for a [`FileChooserProxy::open_file`] request. 44 | #[zvariant(signature = "dict")] 45 | pub struct OpenFileOptions { 46 | /// A string that will be used as the last element of the handle. 47 | handle_token: HandleToken, 48 | /// Label for the accept button. Mnemonic underlines are allowed. 49 | accept_label: Option, 50 | /// Whether the dialog should be modal. 51 | modal: Option, 52 | /// Whether multiple files can be selected or not. 53 | multiple: Option, 54 | /// Whether to select for folders instead of files. 55 | directory: Option, 56 | /// List of serialized file filters. 57 | filters: Vec, 58 | /// Request that this filter be set by default at dialog creation. 59 | current_filter: Option, 60 | /// List of serialized combo boxes to add to the file chooser 61 | choices: Vec, 62 | } 63 | 64 | // Code copied from ASHPD ends here! <3 65 | 66 | pub struct FileChooser {} 67 | 68 | #[dbus_interface(name = "org.freedesktop.portal.FileChooser")] 69 | impl FileChooser { 70 | async fn open_file( 71 | &self, 72 | _parent_window: &str, 73 | _title: &str, 74 | options: OpenFileOptions, 75 | ) -> Result { 76 | let intent = Intent::with_action(Action::GET_CONTENT); 77 | let mut mimes = Vec::new(); 78 | for filter in options.filters { 79 | for mime in filter.1 { 80 | if mime.0 == FilterType::MimeType { 81 | mimes.push(mime.1); 82 | } else if mime.0 == FilterType::GlobPattern { 83 | mimes.extend(glob_to_mime(&mime.1)) 84 | } 85 | } 86 | } 87 | 88 | intent.set_type_and_normalize(&mimes.join(",")); 89 | Ok(get_object_path(options.handle_token.clone())) 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/glob_to_mime.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use itertools::{iproduct, Itertools}; 6 | use regex::Regex; 7 | 8 | lazy_static::lazy_static! { 9 | /// See this regex in the playground: regexr.com/6ohnu 10 | static ref PARSE_GLOB_PATTERN: Regex = Regex::new(r"\[(.*?)\]").unwrap(); 11 | } 12 | 13 | pub fn glob_to_mime(glob: &str) -> Vec { 14 | let extension = glob.split("*.").last().unwrap(); 15 | 16 | // let mut current_possibilities: Option> = None; 17 | let mut allthings = Vec::new(); 18 | 19 | let patterns: Vec<&str> = PARSE_GLOB_PATTERN 20 | .find_iter(extension) 21 | .map(|raw_pattern| { 22 | let mut pattern = raw_pattern.as_str().to_string(); 23 | pattern.pop(); 24 | pattern.remove(0); 25 | 26 | let allchars = pattern.chars().collect::>(); 27 | let mut chars = Vec::new(); 28 | for char in allchars { 29 | let chara = char.to_lowercase().collect::>()[0]; 30 | if !chars.contains(&chara) { 31 | chars.push(chara) 32 | } 33 | } 34 | 35 | allthings.push(chars); 36 | 37 | raw_pattern.as_str() 38 | }) 39 | .collect(); 40 | iproduct!(&*&mut allthings[..]) 41 | .map(|combination| { 42 | let mut extension = String::from(extension); 43 | for (i, combination_part) in combination.iter().enumerate() { 44 | extension = extension 45 | .split(patterns[i]) 46 | .join(&combination_part.to_string()); 47 | } 48 | 49 | extension 50 | }) 51 | .collect() 52 | } 53 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/handle_token.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | /** 6 | * Copied from https://github.com/bilelmoussaoui/ashpd 7 | * Originally licensed under the MIT License https://github.com/bilelmoussaoui/ashpd/blob/master/LICENSE 8 | * But upgraded to Apache-2.0 OR MIT! 9 | */ 10 | use std::{ 11 | convert::TryFrom, 12 | fmt::{self, Debug, Display}, 13 | }; 14 | 15 | use rand::{distributions::Alphanumeric, thread_rng, Rng}; 16 | use serde::{Deserialize, Serialize}; 17 | use zbus::{names::OwnedMemberName, zvariant::Type}; 18 | 19 | /// A handle token is a DBus Object Path element, specified in the 20 | /// `RequestProxy` or [`SessionProxy`](crate::desktop::SessionProxy) object path 21 | /// following this format `/org/freedesktop/portal/desktop/request/SENDER/TOKEN` 22 | /// where sender is the caller's unique name and token is the [`HandleToken`]. 23 | /// 24 | /// A valid object path element must only contain the ASCII characters 25 | /// `[A-Z][a-z][0-9]_` 26 | #[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Type)] 27 | pub struct HandleToken(OwnedMemberName); 28 | 29 | impl Display for HandleToken { 30 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 31 | f.write_str(&self.0) 32 | } 33 | } 34 | 35 | impl Debug for HandleToken { 36 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 37 | f.debug_tuple("HandleToken") 38 | .field(&self.0.as_str()) 39 | .finish() 40 | } 41 | } 42 | 43 | impl Default for HandleToken { 44 | fn default() -> Self { 45 | let mut rng = thread_rng(); 46 | let token: String = (&mut rng) 47 | .sample_iter(Alphanumeric) 48 | .take(10) 49 | .map(char::from) 50 | .collect(); 51 | HandleToken::try_from(format!("ashpd_{}", token)).unwrap() 52 | } 53 | } 54 | 55 | #[derive(Debug)] 56 | pub struct HandleInvalidCharacter(char); 57 | 58 | impl std::fmt::Display for HandleInvalidCharacter { 59 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 60 | f.write_fmt(format_args!("Invalid Character {}", self.0)) 61 | } 62 | } 63 | 64 | impl std::error::Error for HandleInvalidCharacter {} 65 | 66 | impl TryFrom<&str> for HandleToken { 67 | type Error = HandleInvalidCharacter; 68 | fn try_from(value: &str) -> Result { 69 | for char in value.chars() { 70 | if !char.is_ascii_alphanumeric() && char != '_' { 71 | return Err(HandleInvalidCharacter(char)); 72 | } 73 | } 74 | Ok(Self( 75 | OwnedMemberName::try_from(value).expect("Invalid handle token"), 76 | )) 77 | } 78 | } 79 | 80 | impl TryFrom for HandleToken { 81 | type Error = HandleInvalidCharacter; 82 | fn try_from(value: String) -> Result { 83 | HandleToken::try_from(value.as_str()) 84 | } 85 | } 86 | 87 | #[cfg(test)] 88 | mod test { 89 | use std::convert::TryFrom; 90 | 91 | use super::HandleToken; 92 | 93 | #[test] 94 | fn handle_token() { 95 | assert_eq!(HandleToken::try_from("token").is_ok(), true); 96 | 97 | let token = HandleToken::try_from("token2").unwrap(); 98 | assert_eq!(token.to_string(), "token2".to_string()); 99 | 100 | assert_eq!(HandleToken::try_from("/test").is_ok(), false); 101 | 102 | assert_eq!(HandleToken::try_from("تجربة").is_ok(), false); 103 | 104 | assert_eq!(HandleToken::try_from("test_token").is_ok(), true); 105 | 106 | HandleToken::default(); // ensure we don't panic 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/helpers.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use crate::JVM; 6 | use crate::{handle_token::HandleToken, CONNECTION}; 7 | use jni::{JNIEnv, JavaVM}; 8 | use zbus::zvariant::OwnedObjectPath; 9 | 10 | pub fn get_env<'a>() -> JNIEnv<'a> { 11 | let vm: &JavaVM = JVM.get().unwrap(); 12 | vm.get_env().unwrap() 13 | } 14 | /** 15 | * 16 | * Copied from https://github.com/bilelmoussaoui/ashpd/blob/master/src/desktop/request.rs#L191-L197 17 | * 18 | * Upgraded to LGPLv2.1-or-later! 19 | */ 20 | pub fn get_object_path(handle_token: HandleToken) -> OwnedObjectPath { 21 | let connection = CONNECTION.get().unwrap(); 22 | let unique_name = connection.unique_name().unwrap(); 23 | let unique_identifier = unique_name.trim_start_matches(':').replace('.', "_"); 24 | 25 | OwnedObjectPath::try_from(format!( 26 | "/org/freedesktop/portal/desktop/request/{}/{}", 27 | unique_identifier, handle_token 28 | )) 29 | .unwrap() 30 | } 31 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/lib.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | pub mod bindings; 6 | mod file_chooser; 7 | pub mod glob_to_mime; 8 | use file_chooser::FileChooser; 9 | use jni::{InitArgsBuilder, JNIVersion, JavaVM}; 10 | use once_cell::sync::OnceCell; 11 | use zbus::{Connection, ConnectionBuilder}; 12 | mod handle_token; 13 | mod open_uri; 14 | use open_uri::OpenURI; 15 | mod helpers; 16 | pub static JVM: OnceCell = OnceCell::new(); 17 | pub static CONNECTION: OnceCell = OnceCell::new(); 18 | 19 | fn init_jvm() -> jni::errors::Result<()> { 20 | // Build the VM properties 21 | let jvm_args = InitArgsBuilder::new() 22 | // Pass the JNI API version (default is 8) 23 | .version(JNIVersion::V8) 24 | // You can additionally pass any JVM options (standard, like a system property, 25 | // or VM-specific). 26 | // Here we enable some extra JNI checks useful during development 27 | .option("-Xcheck:jni") 28 | .build() 29 | .unwrap(); 30 | 31 | // Create a new VM 32 | let jvm = JavaVM::new(jvm_args)?; 33 | jvm.attach_current_thread()?; 34 | 35 | if JVM.set(jvm).is_err() { 36 | panic!("Can't assign to JVM once cell variable"); 37 | }; 38 | // Attach the current thread to call into Java — see extra options in 39 | // "Attaching Native Threads" section. 40 | // 41 | // This method returns the guard that will detach the current thread when dropped, 42 | // also freeing any local references created in it 43 | 44 | Ok(()) 45 | } 46 | 47 | async fn init_zbus() -> zbus::Result<()> { 48 | let connection = ConnectionBuilder::session()? 49 | .name("org.freedesktop.impl.portal.desktop.android")? 50 | .serve_at("/org/freedesktop/portal/desktop", OpenURI {})? 51 | .serve_at("/org/freedesktop/portal/desktop", FileChooser {})? 52 | .build() 53 | .await?; 54 | if CONNECTION.set(connection).is_err() { 55 | panic!("Can't set the CONNECTION once cell variable") 56 | }; 57 | 58 | loop { 59 | std::future::pending::<()>().await; 60 | } 61 | } 62 | pub enum Errors { 63 | JNIError(jni::errors::Error), 64 | ZbusError(zbus::Error), 65 | } 66 | pub async fn init() -> Result<(), Errors> { 67 | if let Err(error) = init_jvm() { 68 | return Err(Errors::JNIError(error)); 69 | }; 70 | 71 | if let Err(error) = init_zbus().await { 72 | return Err(Errors::ZbusError(error)); 73 | } else { 74 | return Ok(()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/open_uri.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use super::handle_token::HandleToken; 6 | use crate::bindings::activity::Activity; 7 | use crate::bindings::intent::{self, Action, Intent}; 8 | use crate::bindings::uri::Uri; 9 | use crate::helpers::{get_env, get_object_path}; 10 | use crate::JVM; 11 | use jni::objects::{JString, JValue}; 12 | use std::fs; 13 | use std::os::unix::prelude::*; 14 | use zbus::dbus_interface; 15 | use zbus::fdo::{Error, Result}; 16 | use zbus::zvariant::{DeserializeDict, Fd, ObjectPath, OwnedObjectPath, SerializeDict, Type}; 17 | 18 | // This lovelyyy codee is copieed from https://github.com/bilelmoussaoui/ashpd/blob/master/src/desktop/open_uri.rs#L125 19 | // Licensed under the lovellyy MIT License (https://github.com/bilelmoussaoui/ashpd/blob/master/LICENSE) 20 | #[derive(SerializeDict, DeserializeDict, Type, Debug, Default)] 21 | /// Specified options for a [`OpenURIProxy::open_file`] or 22 | /// [`OpenURIProxy::open_uri`] request. 23 | #[zvariant(signature = "dict")] 24 | struct OpenUriOptions { 25 | /// A string that will be used as the last element of the handle. 26 | handle_token: HandleToken, 27 | /// Whether to allow the chosen application to write to the file. 28 | /// This key only takes effect the uri points to a local file that is 29 | /// exported in the document portal, and the chosen application is sandboxed 30 | /// itself. 31 | writeable: Option, 32 | /// Whether to ask the user to choose an app. If this is not passed, or 33 | /// false, the portal may use a default or pick the last choice. 34 | ask: Option, 35 | // Token to activate the chosen application. 36 | activation_token: Option, 37 | } 38 | 39 | // Code copied from ASHPD ends here! <3 40 | 41 | pub struct OpenURI {} 42 | 43 | #[dbus_interface(name = "org.freedesktop.portal.OpenURI")] 44 | impl OpenURI { 45 | async fn open_uri( 46 | &self, 47 | _parent_window: &str, 48 | uri: &str, 49 | options: OpenUriOptions, 50 | ) -> Result { 51 | let env = get_env(); 52 | 53 | let juri = Uri::from_string(uri); 54 | let intent = Intent::with_uri(Action::VIEW, &juri); 55 | 56 | Activity::start_activity(&intent); 57 | 58 | Ok(get_object_path(options.handle_token.clone())) 59 | } 60 | 61 | async fn open_directory( 62 | &self, 63 | parent_window: &str, 64 | directory: Fd, 65 | options: OpenUriOptions, 66 | ) -> Result { 67 | let uri = format!("/proc/self/fd/{:?}", directory.as_raw_fd()); 68 | 69 | if uri.starts_with("/data/data") { 70 | return Err(Error::AccessDenied("Files under /data/data might not be available to other apps! And we don't want to open their secret files!".to_string())); 71 | } 72 | 73 | match fs::canonicalize(uri) { 74 | Ok(path) => { 75 | self.open_uri(parent_window, &path.to_string_lossy(), options) 76 | .await 77 | } 78 | Err(error) => Err(Error::IOError(error.to_string())), 79 | } 80 | } 81 | async fn open_file( 82 | &self, 83 | parent_window: &str, 84 | file: Fd, 85 | options: OpenUriOptions, 86 | ) -> Result { 87 | let uri = format!("/proc/self/fd/{:?}", file.as_raw_fd()); 88 | 89 | if uri.starts_with("/data/data") { 90 | return Err(Error::AccessDenied("Files under /data/data might not be available to other apps! And we don't want to open their secret files!".to_string())); 91 | } 92 | match fs::canonicalize(uri) { 93 | Ok(path) => { 94 | self.open_uri(parent_window, &path.to_string_lossy(), options) 95 | .await 96 | } 97 | Err(error) => Err(Error::IOError(error.to_string())), 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/screen_cast.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use crate::helpers::get_object_path; 6 | use crate::JVM; 7 | use jni::objects::{JString, JValue}; 8 | use zbus::dbus_interface; 9 | use zbus::fdo::Result; 10 | use zbus::zvariant::{DeserializeDict, ObjectPath, OwnedObjectPath, SerializeDict, Type}; 11 | 12 | use super::handle_token::HandleToken; 13 | 14 | // This lovelyyy codee is copieed from https://github.com/bilelmoussaoui/ashpd/blob/master/src/desktop/open_uri.rs#L125 15 | // Originally licensed under the lovellyy MIT License (https://github.com/bilelmoussaoui/ashpd/blob/master/LICENSE) 16 | // But upgraded to LGPLv2.1-or-later! 17 | #[derive(SerializeDict, DeserializeDict, Type, Debug, Default)] 18 | /// Specified options for a [`ScreenCastProxy::open_file`] or 19 | /// [`ScreenCastProxy::open_uri`] request. 20 | #[zvariant(signature = "dict")] 21 | struct Options { 22 | /// A string that will be used as the last element of the handle. 23 | handle_token: HandleToken, 24 | /// Whether to allow the chosen application to write to the file. 25 | /// This key only takes effect the uri points to a local file that is 26 | /// exported in the document portal, and the chosen application is sandboxed 27 | /// itself. 28 | writeable: Option, 29 | /// Whether to ask the user to choose an app. If this is not passed, or 30 | /// false, the portal may use a default or pick the last choice. 31 | ask: Option, 32 | // Token to activate the chosen application. 33 | activation_token: Option, 34 | } 35 | // Code copied from ASHPD ends here! <3 36 | 37 | pub struct ScreenCast {} 38 | 39 | #[dbus_interface(name = "org.freedesktop.portal.ScreenCast")] 40 | impl ScreenCast { 41 | 42 | async fn create_session( 43 | &self, 44 | options: Option, 45 | 46 | ) { 47 | 48 | } 49 | async fn open_uri( 50 | &self, 51 | _parent_window: &str, 52 | uri: &str, 53 | options: OpenFileOptions, 54 | ) -> Result { 55 | 56 | Ok(get_object_path(options.handle_token.clone())) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /xdg-desktop-portal-android/src/screen_shot.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2022 Nefo Fortressia 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 OR MIT 4 | 5 | use crate::helpers::get_object_path; 6 | use crate::JVM; 7 | use jni::objects::{JString, JValue}; 8 | use zbus::dbus_interface; 9 | use zbus::fdo::Result; 10 | use zbus::zvariant::{DeserializeDict, ObjectPath, OwnedObjectPath, SerializeDict, Type}; 11 | 12 | use super::handle_token::HandleToken; 13 | 14 | // This lovelyyy codee is copieed from https://github.com/bilelmoussaoui/ashpd/blob/master/src/desktop/open_uri.rs#L125 15 | // Licensed under the lovellyy MIT License (https://github.com/bilelmoussaoui/ashpd/blob/master/LICENSE) 16 | #[derive(SerializeDict, DeserializeDict, Type, Debug, Default)] 17 | /// Specified options for a [`ScreenCastProxy::open_file`] or 18 | /// [`ScreenCastProxy::open_uri`] request. 19 | #[zvariant(signature = "dict")] 20 | struct Options { 21 | /// A string that will be used as the last element of the handle. 22 | handle_token: HandleToken, 23 | /// Whether to allow the chosen application to write to the file. 24 | /// This key only takes effect the uri points to a local file that is 25 | /// exported in the document portal, and the chosen application is sandboxed 26 | /// itself. 27 | writeable: Option, 28 | /// Whether to ask the user to choose an app. If this is not passed, or 29 | /// false, the portal may use a default or pick the last choice. 30 | ask: Option, 31 | // Token to activate the chosen application. 32 | activation_token: Option, 33 | } 34 | // Code copied from ASHPD ends here! <3 35 | 36 | pub struct ScreenCast {} 37 | 38 | #[dbus_interface(name = "org.freedesktop.portal.ScreenCast")] 39 | impl ScreenCast { 40 | 41 | async fn create_session( 42 | &self, 43 | options: Option, 44 | 45 | ) { 46 | 47 | } 48 | async fn open_uri( 49 | &self, 50 | _parent_window: &str, 51 | uri: &str, 52 | options: OpenFileOptions, 53 | ) -> Result { 54 | 55 | Ok(get_object_path(options.handle_token.clone())) 56 | } 57 | } 58 | --------------------------------------------------------------------------------