glycin-2.0.1/.cargo_vcs_info.json0000644000000001440000000000100123200ustar { "git": { "sha1": "eceb0da6f2e1204ee534c6a92060d1b66a8e4fa8" }, "path_in_vcs": "glycin" }glycin-2.0.1/Cargo.lock0000644000001244050000000000100103020ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "async-broadcast" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cd0e2e25ea8e5f7e9df04578dc6cf5c83577fd09b1a46aaf5c85e1c33f2a7e" dependencies = [ "event-listener", "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-channel" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" dependencies = [ "concurrent-queue", "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-executor" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7ebdfa2ebdab6b1760375fa7d6f382b9f486eac35fc994625a00e89280bdbb7" dependencies = [ "async-task", "concurrent-queue", "fastrand", "futures-lite", "slab", ] [[package]] name = "async-fs" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" dependencies = [ "async-lock", "blocking", "futures-lite", ] [[package]] name = "async-io" version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" dependencies = [ "async-lock", "cfg-if", "concurrent-queue", "futures-io", "futures-lite", "parking", "polling", "rustix", "slab", "tracing", "windows-sys", ] [[package]] name = "async-lock" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ "event-listener", "event-listener-strategy", "pin-project-lite", ] [[package]] name = "async-process" version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7eda79bbd84e29c2b308d1dc099d7de8dcc7035e48f4bf5dc4a531a44ff5e2a" dependencies = [ "async-channel", "async-io", "async-lock", "async-signal", "async-task", "blocking", "cfg-if", "event-listener", "futures-lite", "rustix", "tracing", "windows-sys", ] [[package]] name = "async-recursion" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "async-signal" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfb3634b73397aa844481f814fad23bbf07fdb0eabec10f2eb95e58944b1ec32" dependencies = [ "async-io", "async-lock", "atomic-waker", "cfg-if", "futures-core", "futures-io", "rustix", "signal-hook-registry", "slab", "windows-sys", ] [[package]] name = "async-task" version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", ] [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] [[package]] name = "blocking" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" dependencies = [ "async-channel", "async-task", "futures-io", "futures-lite", "piper", ] [[package]] name = "bytemuck" version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cairo-rs" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "797fd5a634dcb0ad0d7d583df794deb0a236d88e759cd34b7da20198c6c9d145" dependencies = [ "bitflags 2.6.0", "cairo-sys-rs", "glib", "libc", "thiserror", ] [[package]] name = "cairo-sys-rs" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "428290f914b9b86089f60f5d8a9f6e440508e1bcff23b25afd51502b0a2da88f" dependencies = [ "glib-sys", "libc", "system-deps", ] [[package]] name = "cc" version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" dependencies = [ "jobserver", "libc", ] [[package]] name = "cfg-expr" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "345c78335be0624ed29012dc10c49102196c6882c12dde65d9f35b02da2aada8" dependencies = [ "smallvec", "target-lexicon", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "concurrent-queue" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] [[package]] name = "cpufeatures" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] name = "crossbeam-utils" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crypto-common" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", ] [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", ] [[package]] name = "dlib" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ "libloading", ] [[package]] name = "dunce" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "endi" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" [[package]] name = "enumflags2" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" dependencies = [ "enumflags2_derive", "serde", ] [[package]] name = "enumflags2_derive" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "env_filter" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ "log", ] [[package]] name = "env_logger" version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ "env_filter", "humantime", "log", ] [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys", ] [[package]] name = "event-listener" version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", "pin-project-lite", ] [[package]] name = "event-listener-strategy" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ "event-listener", "pin-project-lite", ] [[package]] name = "fastrand" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "foreign-types" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", "foreign-types-shared", ] [[package]] name = "foreign-types-macros" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "foreign-types-shared" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" [[package]] name = "futures-channel" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", ] [[package]] name = "futures-core" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", "futures-util", ] [[package]] name = "futures-io" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "fastrand", "futures-core", "futures-io", "parking", "pin-project-lite", ] [[package]] name = "futures-macro" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "futures-sink" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", "futures-macro", "futures-sink", "futures-task", "memchr", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "gdk-pixbuf" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28bb53ecb56857c683c9ec859908e076dd3969c7d67598bd8b1ce095d211304a" dependencies = [ "gdk-pixbuf-sys", "gio", "glib", "libc", ] [[package]] name = "gdk-pixbuf-sys" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f6681a0c1330d1d3968bec1529f7172d62819ef0bdbb0d18022320654158b03" dependencies = [ "gio-sys", "glib-sys", "gobject-sys", "libc", "system-deps", ] [[package]] name = "gdk4" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b7d7237c1487ed4b300aac7744efcbf1319e12d60d7afcd6f505414bd5b5dea" dependencies = [ "cairo-rs", "gdk-pixbuf", "gdk4-sys", "gio", "glib", "libc", "pango", ] [[package]] name = "gdk4-sys" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a67576c8ec012156d7f680e201a807b4432a77babb3157e0555e990ab6bcd878" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", "gio-sys", "glib-sys", "gobject-sys", "libc", "pango-sys", "pkg-config", "system-deps", ] [[package]] name = "generic-array" version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", ] [[package]] name = "getrandom" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", "wasi", ] [[package]] name = "gimli" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "gio" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "398e3da68749fdc32783cbf7521ec3f65c9cf946db8c7774f8460af49e52c6e2" dependencies = [ "futures-channel", "futures-core", "futures-io", "futures-util", "gio-sys", "glib", "libc", "pin-project-lite", "smallvec", "thiserror", ] [[package]] name = "gio-sys" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4feb96b31c32730ea3e1e89aecd2e4e37ecb1c473ad8f685e3430a159419f63" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", "windows-sys", ] [[package]] name = "glib" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fee90a615ce05be7a32932cfb8adf2c4bbb4700e80d37713c981fb24c0c56238" dependencies = [ "bitflags 2.6.0", "futures-channel", "futures-core", "futures-executor", "futures-task", "futures-util", "gio-sys", "glib-macros", "glib-sys", "gobject-sys", "libc", "memchr", "smallvec", "thiserror", ] [[package]] name = "glib-macros" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4da558d8177c0c8c54368818b508a4244e1286fce2858cef4e547023f0cfa5ef" dependencies = [ "heck", "proc-macro-crate", "proc-macro2", "quote", "syn", ] [[package]] name = "glib-sys" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4958c26e5a01c9af00dea669a97369eccbec29a8e6d125c24ea2d85ee7467b60" dependencies = [ "libc", "system-deps", ] [[package]] name = "glycin" version = "2.0.1" dependencies = [ "async-fs", "async-io", "async-lock", "blocking", "futures-channel", "futures-timer", "futures-util", "gdk4", "gio", "glycin-utils", "gufo-common", "gufo-exif", "lcms2", "lcms2-sys", "libc", "libseccomp", "memfd", "memmap2", "nix", "static_assertions", "thiserror", "tokio", "tokio-stream", "tracing", "yeslogic-fontconfig-sys", "zbus", ] [[package]] name = "glycin-utils" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c6132ef2817b05110f3b1f98c53dbddaac74ea8366472354ab486d02442f08f" dependencies = [ "env_logger", "glib", "gufo-common", "libc", "libseccomp", "log", "memmap2", "nix", "paste", "rmp-serde", "serde", "thiserror", "tokio", "zbus", ] [[package]] name = "gobject-sys" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6908864f5ffff15b56df7e90346863904f49b949337ed0456b9287af61903b8" dependencies = [ "glib-sys", "libc", "system-deps", ] [[package]] name = "gufo-common" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1af2c3c6b244761a93e30989fa0868b92e386b6eb817fc6ced405462af4a7db" dependencies = [ "once_cell", "paste", "serde", ] [[package]] name = "gufo-exif" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2aff5e56872f03d477b55cccef818e6cdae482485c39c130ff9b3b31b69ea10" dependencies = [ "gufo-common", "thiserror", "tracing", ] [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hermit-abi" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "indexmap" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "jobserver" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] [[package]] name = "lcms2" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "680ec3fa42c36e0af9ca02f20a3742a82229c7f1ee0e6754294de46a80be6f74" dependencies = [ "bytemuck", "foreign-types", "lcms2-sys", ] [[package]] name = "lcms2-sys" version = "4.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "593265f9a3172180024fb62580ee31348f31be924b19416da174ebb7fb623d2e" dependencies = [ "cc", "dunce", "libc", "pkg-config", ] [[package]] name = "libc" version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", "windows-targets", ] [[package]] name = "libseccomp" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21c57fd8981a80019807b7b68118618d29a87177c63d704fc96e6ecd003ae5b3" dependencies = [ "bitflags 1.3.2", "libc", "libseccomp-sys", "pkg-config", ] [[package]] name = "libseccomp-sys" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a7cbbd4ad467251987c6e5b47d53b11a5a05add08f2447a9e2d70aef1e0d138" [[package]] name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memfd" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ "rustix", ] [[package]] name = "memmap2" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] [[package]] name = "memoffset" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] [[package]] name = "miniz_oxide" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ "hermit-abi 0.3.9", "libc", "wasi", "windows-sys", ] [[package]] name = "nix" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.6.0", "cfg-if", "cfg_aliases", "libc", "memoffset", ] [[package]] name = "num-traits" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "object" version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "ordered-stream" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" dependencies = [ "futures-core", "pin-project-lite", ] [[package]] name = "pango" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54768854025df6903061d0084fd9702a253ddfd60db7d9b751d43b76689a7f0a" dependencies = [ "gio", "glib", "libc", "pango-sys", ] [[package]] name = "pango-sys" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07cc57d10cee4ec661f718a6902cee18c2f4cfae08e87e5a390525946913390" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", ] [[package]] name = "parking" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pin-project-lite" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piper" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae1d5c74c9876f070d3e8fd503d748c7d974c3e48da8f41350fa5222ef9b4391" dependencies = [ "atomic-waker", "fastrand", "futures-io", ] [[package]] name = "pkg-config" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "polling" version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", "rustix", "tracing", "windows-sys", ] [[package]] name = "ppv-lite86" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ "zerocopy", ] [[package]] name = "proc-macro-crate" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", "rand_core", ] [[package]] name = "rand_chacha" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", ] [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] [[package]] name = "rmp" version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" dependencies = [ "byteorder", "num-traits", "paste", ] [[package]] name = "rmp-serde" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" dependencies = [ "byteorder", "rmp", "serde", ] [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", "windows-sys", ] [[package]] name = "serde" version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_repr" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_spanned" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] [[package]] name = "sha1" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", "digest", ] [[package]] name = "signal-hook-registry" version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys", ] [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "system-deps" version = "7.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "070a0a5e7da2d24be457809c4b3baa57a835fd2829ad8b86f9a049052fe71031" dependencies = [ "cfg-expr", "heck", "pkg-config", "toml", "version-compare", ] [[package]] name = "target-lexicon" version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", "rustix", "windows-sys", ] [[package]] name = "thiserror" version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tokio" version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", "mio", "pin-project-lite", "signal-hook-registry", "socket2", "tracing", "windows-sys", ] [[package]] name = "tokio-stream" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", "tokio", ] [[package]] name = "toml" version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", "toml_edit", ] [[package]] name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", "winnow", ] [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "uds_windows" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" dependencies = [ "memoffset", "tempfile", "winapi", ] [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version-compare" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] [[package]] name = "xdg-home" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca91dcf8f93db085f3a0a29358cd0b9d670915468f4290e8b85d118a34211ab8" dependencies = [ "libc", "windows-sys", ] [[package]] name = "yeslogic-fontconfig-sys" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "503a066b4c037c440169d995b869046827dbc71263f6e8f3be6d77d4f3229dbd" dependencies = [ "dlib", "once_cell", "pkg-config", ] [[package]] name = "zbus" version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" dependencies = [ "async-broadcast", "async-executor", "async-fs", "async-io", "async-lock", "async-process", "async-recursion", "async-task", "async-trait", "blocking", "enumflags2", "event-listener", "futures-core", "futures-sink", "futures-util", "hex", "nix", "ordered-stream", "rand", "serde", "serde_repr", "sha1", "static_assertions", "tokio", "tracing", "uds_windows", "windows-sys", "xdg-home", "zbus_macros", "zbus_names", "zvariant", ] [[package]] name = "zbus_macros" version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", "syn", "zvariant_utils", ] [[package]] name = "zbus_names" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" dependencies = [ "serde", "static_assertions", "zvariant", ] [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "zvariant" version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" dependencies = [ "endi", "enumflags2", "serde", "static_assertions", "zvariant_derive", ] [[package]] name = "zvariant_derive" version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", "syn", "zvariant_utils", ] [[package]] name = "zvariant_utils" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" dependencies = [ "proc-macro2", "quote", "syn", ] glycin-2.0.1/Cargo.toml0000644000000063000000000000100103160ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.77" name = "glycin" version = "2.0.1" authors = ["Sophie Herold"] build = false autobins = false autoexamples = false autotests = false autobenches = false description = "Sandboxed image decoding" homepage = "https://gitlab.gnome.org/sophie-h/glycin" readme = "README.md" license = "MPL-2.0 OR LGPL-2.1-or-later" repository = "https://gitlab.gnome.org/sophie-h/glycin" [package.metadata.docs.rs] all-features = true features = [] rustc-args = [ "--cfg", "docsrs", ] rustdoc-args = [ "--cfg", "docsrs", "--generate-link-to-definition", ] [lib] name = "glycin" path = "src/lib.rs" [[example]] name = "glycin-render" path = "examples/glycin-render.rs" required-features = ["gdk4"] [[example]] name = "glycin-rotate-cw" path = "examples/glycin-rotate-cw.rs" [dependencies.async-fs] version = "2.1.0" optional = true [dependencies.async-io] version = "2.3.2" optional = true [dependencies.async-lock] version = "3.3.0" optional = true [dependencies.blocking] version = "1.6.1" optional = true [dependencies.futures-channel] version = "0.3.30" [dependencies.futures-timer] version = "3.0.3" optional = true [dependencies.futures-util] version = "0.3.30" [dependencies.gdk] version = "0.9.0" features = ["v4_12"] optional = true package = "gdk4" [dependencies.gio] version = "0.20.0" [dependencies.glycin-utils] version = "2.0.0" default-features = false [dependencies.gufo-common] version = "0.1.0" features = ["serde"] [dependencies.gufo-exif] version = "0.1.0" [dependencies.lcms2] version = "6.0.3" [dependencies.lcms2-sys] version = "4.0.4" [dependencies.libc] version = "0.2.152" [dependencies.libseccomp] version = "0.3.0" [dependencies.memfd] version = "0.6.3" [dependencies.memmap] version = "0.9.0" package = "memmap2" [dependencies.nix] version = "0.29.0" features = [ "fs", "resource", "signal", "fs", "resource", "signal", ] [dependencies.static_assertions] version = "1.1.0" [dependencies.thiserror] version = "1.0.57" [dependencies.tokio] version = "1.35.1" features = [ "fs", "rt", "rt-multi-thread", ] optional = true [dependencies.tokio-stream] version = "0.1.15" features = ["fs"] optional = true [dependencies.tracing] version = "0.1.40" [dependencies.yeslogic-fontconfig-sys] version = "6.0.0" [dependencies.zbus] version = "4.3.0" features = [ "p2p", "p2p", ] default-features = false [features] async-io = [ "dep:async-fs", "dep:async-io", "dep:async-lock", "dep:blocking", "dep:futures-timer", "glycin-utils/async-io", "zbus/async-io", ] default = ["async-io"] gdk4 = ["dep:gdk"] gobject = ["glycin-utils/gobject"] tokio = [ "dep:tokio", "dep:tokio-stream", "glycin-utils/tokio", "zbus/tokio", ] glycin-2.0.1/Cargo.toml.orig000064400000000000000000000034301046102023000140000ustar 00000000000000[package] name = "glycin" readme = "../README.md" version.workspace = true authors.workspace = true description.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true edition.workspace = true rust-version.workspace = true [features] default = ["async-io"] async-io = [ "dep:async-fs", "dep:async-io", "dep:async-lock", "dep:blocking", "dep:futures-timer", "glycin-utils/async-io", "zbus/async-io", ] tokio = ["dep:tokio", "dep:tokio-stream", "glycin-utils/tokio", "zbus/tokio"] gobject = ["glycin-utils/gobject"] gdk4 = ["dep:gdk"] [dependencies] async-fs = { workspace = true, optional = true } async-io = { workspace = true, optional = true } async-lock = { workspace = true, optional = true } blocking = { workspace = true, optional = true } yeslogic-fontconfig-sys.workspace = true futures-channel.workspace = true futures-timer = { workspace = true, optional = true } futures-util.workspace = true gdk = { workspace = true, optional = true } gio.workspace = true glycin-utils = { workspace = true } gufo-common.workspace = true gufo-exif.workspace = true lcms2.workspace = true lcms2-sys.workspace = true libc.workspace = true libseccomp.workspace = true memfd.workspace = true memmap.workspace = true nix = { workspace = true, features = ["fs", "resource", "signal"] } static_assertions = { workspace = true } thiserror.workspace = true tokio = { workspace = true, optional = true } tokio-stream = { workspace = true, optional = true } tracing.workspace = true zbus = { workspace = true, features = ["p2p"] } [package.metadata.docs.rs] all-features = true rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] features = [] [[example]] name = "glycin-render" required-features = [ "gdk4" ]glycin-2.0.1/LICENSE000064400000000000000000000000341046102023000121130ustar 00000000000000MPL-2.0 OR LGPL-2.1-or-laterglycin-2.0.1/LICENSE-LGPL-2.1000064400000000000000000000635301046102023000131570ustar 00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [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.] Preamble 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 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". 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. 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".) "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. 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. 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. 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. 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: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. 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. 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. (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.) 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. 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. 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. 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. 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. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 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. 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. 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. 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. 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. 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.) 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. 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. 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: 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.) 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. 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. 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. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. 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. 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. 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: 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. 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. 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. 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. 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. 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. 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. 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. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 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. 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. 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. 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. NO WARRANTY 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. 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. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries 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). 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. glycin Copyright (C) 2023 Sophie Herold 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. 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. 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. 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: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! glycin-2.0.1/LICENSE-MPL-2.0000064400000000000000000000405261046102023000130500ustar 00000000000000Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. glycin-2.0.1/README.md000064400000000000000000000204031046102023000123670ustar 00000000000000# Glycin Glycin allows to decode images into [`gdk::Texture`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gdk4/struct.Texture.html)s and to extract image metadata. The decoding happens in sandboxed modular *image loaders*. - [glycin](https://docs.rs/glycin/) – The Rust image library - [libglycin](https://sophie-h.pages.gitlab.gnome.org/glycin/libglycin/) – C-Bindings for the library - [libglycin-gtk4](https://sophie-h.pages.gitlab.gnome.org/glycin/libglycin-gtk4/) – C-Bindings to convert glycin frames to GDK Textures - [glycin-utils](https://docs.rs/glycin-utils/) – Utilities to write loaders for glycin - [loaders](loaders) – Glycin loaders for several formats ## Usage and Packaging The Rust client library is available as [glycin on crates.io](https://docs.rs/glycin/). For other programming languages, the libglycin C client library can be used. For the client libraries to work, **loader binaries must also be installed**. The loader binaries provided by the glycin project cover a lot of common image formats (see below). Both, the loader binaries and libglycin can be built from the released [glycin tarballs](https://download.gnome.org/sources/glycin/). By using `-Dlibglycin=false` or `-Dglycin-loaders=false` it is possible to build only one of these components. In distributions, the loaders are usually packaged as *glycin-loaders*, and libglycin as *libglycin-1*. However, each loader binary could be also packaged as its own package. ### Example ```rust let file = gio::File::for_path("image.jpg"); let image = Loader::new(file).load().await?; let height = image.info().height(); let texture = image.next_frame().await?.texture(); ``` ## Limitations Glycin is based on technologies like memfds, unix sockets, and linux namespaces. It currently only works on Linux. An adoption to other unixoid systems could be possible without usage of the sandbox mechanism. Windows support is currently not planned and might not be feasible. ## Supported Image Formats The following features are supported by the glycin loaders provided in the [loaders](loaders) directory. | Format | Decoder | ICC | CICP | EXIF | XMP | Animation | Library | |----------|----------|-----|------|------|-----|-----------|----------------------------| | AVIF | heif | ✔ | ✔ | ✔ | ✘ | ✘ | libheif-rs + libheif (C++) | | BMP | image-rs | ✘ | — | — | — | — | image-rs | | DDS | image-rs | — | — | — | — | — | image-rs | | farbfeld | no mime | — | — | — | — | — | image-rs | | QOI | image-rs | — | — | — | — | — | image-rs | | GIF | image-rs | ✘ | — | — | ✘ | ✔ | image-rs | | HEIC | heif | ✔ | ✔ | ✔ | ✘ | ✘ | libheif-rs + libheif (C++) | | ICO | image-rs | — | — | — | — | — | image-rs | | JPEG | image-rs | ✔ | — | ✔ | ✘ | — | image-rs | | JPEG XL | jxl | ✔ | ✘ | ✔ | ✘ | ✘ | jpegxl-rs + libjxl (C++) | | OpenEXR | image-rs | — | — | — | — | — | image-rs | | PNG | image-rs | ✔ | ✘ | ✔ | ✘ | ✔ | image-rs | | PNM | image-rs | — | — | — | — | — | image-rs | | SVG | image-rs | ✘ | — | — | ✘ | — | librsvg + gio/cairo (C) | | TGA | image-rs | — | — | — | — | — | image-rs | | TIFF | image-rs | ✔ | — | ✔ | ✘ | — | image-rs | | WEBP | image-rs | ✔ | — | ✔ | ✘ | ✔ | image-rs | | Symbol | Meaning | |--------|---------------------------------------------| | ✔ | Supported | | ✘ | Supported by format but not implemented yet | | — | Not available for this format | ## Image Loader Configuration Loader configurations are read by the client library from `XDG_DATA_DIRS` and `XDG_DATA_HOME`. The location is typically of the from ``` /share/glycin/+/conf.d/.conf ``` so for example ``` /share/glycin/0+/conf.d/glyicn-image-rs.conf ``` The configs are [glib KeyFiles](https://docs.gtk.org/glib/struct.KeyFile.html) of the the form ```ini [loader:image/png] Exec = /usr/libexec/glycin/1+/glycin-image-rs ``` Where the part behind `loader` is a mime-type and the value of `Exec` can be any executable path. ### Existing Compatibility Versions Not every new major version of the library has to break compatibility with the loaders. If a glycin version X breaks compatibility, the new compativility version will be called X+. Only glycin X and newer version will be compatible with X+ until a new compatibilityv version is used. The definition of the API of each compatibility version is available in [`docs/`](docs/). The following compatibility versions currently exist | compat-version | Compatible With | |----------------|--------------------------------| | 0+ | glycin 0.x | | 1+ | glycin 1.x, 2.x; libglycin 1.x | ## Sandboxing and Inner Workings Glycin spawns one process per image file. The communication between glycin and the loader takes place via peer-to-peer D-Bus over a Unix socket. Glycin supports a sandbox mechanism inside and outside of Flatpaks. Outside of Flatpaks, the following mechanisms are used: The image loader binary is spawned via `bwrap`. The bubblewrap configuration only allows for minimal interaction with the host system. Only necessary parts of the filesystem are mounted and only with read access. There is no direct network access. Environment variables are not passed to the sandbox. Before forking the process the memory usage is limited via calling `setrlimit` and syscalls are limited to an allow-list via seccomp filters. Inside of Flatpaks the `flatpak-spawn --sandbox` command is used. This restricts the access to the filesystem in a similar way as the direct `bwrap` call. The memory usage is limited by wrapping the loader call into a `prlimit` command. No additional seccomp filters are applied to the existing Flatpak seccomp rules. The GFile content is streamed to the loader via a Unix socket. This way, loaders can load contents that require network access, without having direct network access themselves. Formats like SVG set the `ExposeBaseDir = true` option in their config. This option causes the original image file's directory to be mounted into the sandbox to include external image files from there. The `ExposeBaseDir` option has no effect for `flatpak-spawn` sandboxes since they don't support this feature. The loaders provide the texture data via a memfd that is sealed by glycin and then given as an mmap to GDK. For animations and SVGs the sandboxed process is kept alive for new frames or tiles as long as needed. For information on how to implement a loader, please consult the [`glycin-utils` docs](https://docs.rs/glycin-utils/). ## Building and Testing - The `-Dloaders` option allows to only build certain loaders. - The `-Dtest_skip_ext` option allows to skip certain image filename extensions during tests. The option `-Dtest_skip_ext=heic` might be needed if x265 is not available. - Running integration tests requires the glycin loaders to be installed. By default, `meson test` creates an separate installation against which the tests are run. This behavior can be changed by setting `-Dtest_skip_install=true`, requiring to manually calling `meson install` before running the tests. - The `glycin` crate has an example, `glycin-render` that will load the image passed as a parameter and render it as a PNG into `output.png` in the current directory. ## Packaging Status [![Packaging Status](https://repology.org/badge/vertical-allrepos/glycin-loaders.svg?exclude_unsupported=1&header=)](https://repology.org/project/glycin-loaders/versions) ## License SPDX-License-Identifier: MPL-2.0 OR LGPL-2.1-or-later glycin-2.0.1/examples/glycin-render.rs000064400000000000000000000011401046102023000160330ustar 00000000000000// SPDX-License-Identifier: MPL-2.0 OR LGPL-2.1-or-later use gdk::prelude::*; use glycin::Loader; fn main() { let Some(path) = std::env::args().nth(1) else { std::process::exit(2) }; let _ = async_io::block_on(render(&path)); } async fn render

(path: P) -> Result<(), Box> where P: AsRef, { let file = gio::File::for_path(path); let image = Loader::new(file).load().await.expect("request failed"); let frame = image.next_frame().await.expect("next frame failed"); frame.texture().save_to_png("output.png")?; Ok(()) } glycin-2.0.1/examples/glycin-rotate-cw.rs000064400000000000000000000014411046102023000164650ustar 00000000000000// SPDX-License-Identifier: MPL-2.0 OR LGPL-2.1-or-later use glycin::{EditOutcome, Editor}; use glycin_utils::operations::{Operation, Operations}; fn main() { let Some(path) = std::env::args().nth(1) else { std::process::exit(2) }; let _ = async_io::block_on(render(&path)); } async fn render

(path: P) -> Result<(), Box> where P: AsRef, { let file = gio::File::for_path(path); let rotate = Operation::Rotate(gufo_common::orientation::Rotation::_90); let operations = Operations::new(vec![rotate]); let result = Editor::new(file.clone()) .apply_sparse(operations) .await .expect("request failed"); assert_eq!(result.apply_to(file).await.unwrap(), EditOutcome::Changed); Ok(()) } glycin-2.0.1/src/api_common.rs000064400000000000000000000113001046102023000143620ustar 00000000000000use std::path::PathBuf; #[cfg(feature = "gobject")] use gio::glib; use gio::prelude::*; use crate::dbus::{GFileWorker, RemoteProcess, ZbusProxy}; use crate::util::RunEnvironment; use crate::{config, Error, MimeType}; #[derive(Debug, Copy, Clone)] /// Sandboxing mechanism for image loading and editing pub enum SandboxMechanism { Bwrap, FlatpakSpawn, NotSandboxed, } impl SandboxMechanism { pub async fn detect() -> Self { match RunEnvironment::cached().await { RunEnvironment::FlatpakDevel => Self::NotSandboxed, RunEnvironment::Flatpak => Self::FlatpakSpawn, RunEnvironment::Host => Self::Bwrap, } } pub fn into_selector(self) -> SandboxSelector { match self { Self::Bwrap => SandboxSelector::Bwrap, Self::FlatpakSpawn => SandboxSelector::FlatpakSpawn, Self::NotSandboxed => SandboxSelector::NotSandboxed, } } } #[derive(Debug, Copy, Clone, Default)] #[cfg_attr(feature = "gobject", derive(gio::glib::Enum))] #[cfg_attr(feature = "gobject", enum_type(name = "GlySandboxSelector"))] #[repr(i32)] /// Method by which the [`SandboxMechanism`] is selected pub enum SandboxSelector { #[default] /// This mode selects `bwrap` outside of Flatpaks and usually /// `flatpak-spawn` inside of Flatpaks. The sandbox is disabled /// automatically inside of Flatpak development environments. See /// details below. /// /// Inside of Flatpaks, `flatpak-spawn` is used to create the sandbox. This /// mechanism starts an installed Flatpak with the same app id. For /// development, Flatpak are usually not installed and the sandbox can /// therefore not be used. If the sandbox has been started via /// `flatpak-builder --run` (i.e. without installed Flatpak) and the app id /// ends with `.Devel`, the sandbox is disabled. Auto, Bwrap, FlatpakSpawn, NotSandboxed, } impl SandboxSelector { pub async fn determine_sandbox_mechanism(self) -> SandboxMechanism { match self { Self::Auto => SandboxMechanism::detect().await, Self::Bwrap => SandboxMechanism::Bwrap, Self::FlatpakSpawn => SandboxMechanism::FlatpakSpawn, Self::NotSandboxed => SandboxMechanism::NotSandboxed, } } } pub(crate) struct RemoteProcessContext<'a, P: ZbusProxy<'a>> { pub process: RemoteProcess<'a, P>, pub gfile_worker: GFileWorker, pub base_dir: Option, pub mime_type: MimeType, pub sandbox_mechanism: SandboxMechanism, } pub(crate) async fn spin_up<'a, P: ZbusProxy<'a> + 'a>( file: &gio::File, cancellable: &gio::Cancellable, sandbox_selector: &SandboxSelector, ) -> Result, Error> { let config = config::Config::cached().await; let gfile_worker = GFileWorker::spawn(file.clone(), cancellable.clone()); let mime_type = guess_mime_type(&gfile_worker).await?; let sandbox_mechanism = sandbox_selector.determine_sandbox_mechanism().await; let process = RemoteProcess::new(&mime_type, config, sandbox_mechanism, file, cancellable).await?; let base_dir: Option = if P::expose_base_dir(config, &mime_type)? { file.parent().and_then(|x| x.path()) } else { None }; Ok(RemoteProcessContext { process, gfile_worker, base_dir, mime_type, sandbox_mechanism, }) } pub(crate) async fn guess_mime_type(gfile_worker: &GFileWorker) -> Result { let head = gfile_worker.head().await?; let (content_type, unsure) = gio::content_type_guess(None::, &head); let mime_type = gio::content_type_get_mime_type(&content_type) .ok_or_else(|| Error::UnknownContentType(content_type.to_string())); // Prefer file extension for TIFF since it can be a RAW format as well let is_tiff = mime_type.clone().ok() == Some("image/tiff".into()); // Prefer file extension for XML since long comment between `` // can falsely guess XML instead of SVG let is_xml = mime_type.clone().ok() == Some("application/xml".into()); // Prefer file extension for gzip since it might be an SVGZ let is_gzip = mime_type.clone().ok() == Some("application/gzip".into()); if unsure || is_tiff || is_xml || is_gzip { if let Some(filename) = gfile_worker.file().basename() { let content_type_fn = gio::content_type_guess(Some(filename), &head).0; return gio::content_type_get_mime_type(&content_type_fn) .ok_or_else(|| Error::UnknownContentType(content_type_fn.to_string())) .map(|x| MimeType(x.to_string())); } } mime_type.map(|x| MimeType(x.to_string())) } glycin-2.0.1/src/api_editor.rs000064400000000000000000000116751046102023000143770ustar 00000000000000use gio::glib; use gio::prelude::{IsA, *}; pub use glycin_utils::operations::{Operation, Operations}; use glycin_utils::{BinaryData, BitChanges, SafeConversion, SparseEditorOutput}; use crate::api_common::*; use crate::error::ResultExt; use crate::{util, Error, ErrorCtx}; /// Image edit builder #[derive(Debug)] pub struct Editor { file: gio::File, cancellable: gio::Cancellable, pub(crate) sandbox_selector: SandboxSelector, } static_assertions::assert_impl_all!(Editor: Send, Sync); impl Editor { /// Create an editor. pub fn new(file: gio::File) -> Self { Self { file, cancellable: gio::Cancellable::new(), sandbox_selector: SandboxSelector::default(), } } /// Sets the method by which the sandbox mechanism is selected. /// /// The default without calling this function is [`SandboxSelector::Auto`]. pub fn sandbox_selector(&mut self, sandbox_selector: SandboxSelector) -> &mut Self { self.sandbox_selector = sandbox_selector; self } /// Set [`Cancellable`](gio::Cancellable) to cancel any editing operations. pub fn cancellable(&mut self, cancellable: impl IsA) -> &mut Self { self.cancellable = cancellable.upcast(); self } /// Apply operations to the image with a potentially sparse result. /// /// Some operations like rotation can be in some cases be conducted by only /// changing one or a few bytes in a file. We call these cases *sparse* and /// a [`SparseEdit::Sparse`] is returned. pub async fn apply_sparse(self, operations: Operations) -> Result { let process_context = spin_up(&self.file, &self.cancellable, &self.sandbox_selector) .await .err_no_context()?; let process = process_context.process; let editor_output = process .editor_apply( &process_context.gfile_worker, process_context.base_dir, operations, ) .await .err_context(&process)?; SparseEdit::try_from(editor_output).err_no_context() } } #[derive(Debug)] /// An image change that is potentially sparse. /// /// See also: [`Editor::apply_sparse()`] pub enum SparseEdit { /// The operations can be applied to the image via only changing a few /// bytes. The [`apply_to()`](Self::apply_to()) function can be used to /// apply these changes. Sparse(BitChanges), /// The operations require to completely rewrite the image. Complete(BinaryData), } #[derive(Debug, PartialEq, Eq)] #[must_use] /// Whether an image could be changed via the chosen method. pub enum EditOutcome { Changed, Unchanged, } impl SparseEdit { /// Apply sparse changes if applicable. /// /// If the type does not carry sparse changes, the function will return an /// [`EditOutcome::Unchanged`] and the complete image needs to be rewritten. pub async fn apply_to(&self, file: gio::File) -> Result { match self { Self::Sparse(bit_changes) => { let bit_changes = bit_changes.clone(); util::spawn_blocking(move || { let stream = file.open_readwrite(gio::Cancellable::NONE)?; let output_stream = stream.output_stream(); for change in bit_changes.changes { stream.seek( change.offset.try_i64()?, glib::SeekType::Set, gio::Cancellable::NONE, )?; let (_, err) = output_stream.write_all(&[change.new_value], gio::Cancellable::NONE)?; if let Some(err) = err { return Err(err.into()); } } Ok(EditOutcome::Changed) }) .await } Self::Complete(_) => Ok(EditOutcome::Unchanged), } } } impl TryFrom for SparseEdit { type Error = Error; fn try_from(value: SparseEditorOutput) -> std::result::Result { if value.bit_changes.is_some() && value.data.is_some() { Err(Error::RemoteError( glycin_utils::RemoteError::InternalLoaderError( "Sparse editor output with 'bit_changes' and 'data' returned.".into(), ), )) } else if let Some(bit_changes) = value.bit_changes { Ok(Self::Sparse(bit_changes)) } else if let Some(data) = value.data { Ok(Self::Complete(data)) } else { Err(Error::RemoteError( glycin_utils::RemoteError::InternalLoaderError( "Sparse editor output with neither 'bit_changes' nor 'data' returned.".into(), ), )) } } } glycin-2.0.1/src/api_loader.rs000064400000000000000000000201141046102023000143430ustar 00000000000000use gio::glib; use gio::prelude::*; #[cfg(feature = "gdk4")] use glycin_utils::save_math::*; use glycin_utils::ImageInfo; pub use glycin_utils::{FrameDetails, MemoryFormat}; use crate::api_common::*; pub use crate::config::MimeType; use crate::dbus::*; use crate::error::ResultExt; use crate::{config, ErrorCtx}; /// Image request builder #[derive(Debug)] pub struct Loader { file: gio::File, cancellable: gio::Cancellable, pub(crate) apply_transformations: bool, pub(crate) sandbox_selector: SandboxSelector, } static_assertions::assert_impl_all!(Loader: Send, Sync); impl Loader { /// Create a new loader pub fn new(file: gio::File) -> Self { Self { file, cancellable: gio::Cancellable::new(), apply_transformations: true, sandbox_selector: SandboxSelector::default(), } } /// Sets the method by which the sandbox mechanism is selected. /// /// The default without calling this function is [`SandboxSelector::Auto`]. pub fn sandbox_selector(&mut self, sandbox_selector: SandboxSelector) -> &mut Self { self.sandbox_selector = sandbox_selector; self } /// Set [`Cancellable`](gio::Cancellable) to cancel any loader operations pub fn cancellable(&mut self, cancellable: impl IsA) -> &mut Self { self.cancellable = cancellable.upcast(); self } /// Set whether to apply transformations to texture /// /// When enabled, transformations like image orientation are applied to the /// texture data. /// /// This option is enabled by default. pub fn apply_transformations(&mut self, apply_transformations: bool) -> &mut Self { self.apply_transformations = apply_transformations; self } /// Load basic image information and enable further operations pub async fn load<'a>(self) -> Result, ErrorCtx> { let process_context = spin_up(&self.file, &self.cancellable, &self.sandbox_selector) .await .err_no_context()?; let process = process_context.process; let info = process .init(process_context.gfile_worker, process_context.base_dir) .await .err_context(&process)?; Ok(Image { process, info, loader: self, mime_type: process_context.mime_type, active_sandbox_mechanism: process_context.sandbox_mechanism, }) } /// Returns a list of mime types for which loaders are configured pub async fn supported_mime_types() -> Vec { config::Config::cached() .await .image_loader .keys() .cloned() .collect() } /// Formats that the default glycin loaders support pub const DEFAULT_MIME_TYPES: &'static [&'static str] = &[ // image-rs "image/jpeg", "image/png", "image/gif", "image/webp", "image/tiff", "image/x-tga", "image/vnd-ms.dds", "image/x-dds", "image/bmp", "image/vnd.microsoft.icon", "image/vnd.radiance", "image/x-exr", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", "image/x-portable-anymap", "image/x-qoi", // HEIF "image/avif", "image/heif", // JXL "image/jxl", // SVG "image/svg+xml", "image/svg+xml-compressed", ]; } /// Image handle containing metadata and allowing frame requests #[derive(Debug)] pub struct Image<'a> { pub(crate) loader: Loader, process: RemoteProcess<'a, LoaderProxy<'a>>, info: ImageInfo, mime_type: MimeType, active_sandbox_mechanism: SandboxMechanism, } static_assertions::assert_impl_all!(Image: Send, Sync); impl<'a> Image<'a> { /// Loads next frame /// /// Loads texture and information of the next frame. For single still /// images, this can only be called once. For animated images, this /// function will loop to the first frame, when the last frame is reached. pub async fn next_frame(&self) -> Result { self.process .request_frame(glycin_utils::FrameRequest::default(), self) .await .map_err(Into::into) .err_context(&self.process) } /// Loads a specific frame /// /// Loads a specific frame from the file. Loaders can ignore parts of the /// instructions in the `FrameRequest`. pub async fn specific_frame(&self, frame_request: FrameRequest) -> Result { self.process .request_frame(frame_request.request, self) .await .map_err(Into::into) .err_context(&self.process) } /// Returns already obtained info pub fn info(&self) -> &ImageInfo { &self.info } /// Returns detected MIME type of the file pub fn mime_type(&self) -> MimeType { self.mime_type.clone() } /// A textual representation of the image format pub fn format_name(&self) -> Option { self.info().details.format_name.as_ref().cloned() } /// File the image was loaded from pub fn file(&self) -> gio::File { self.loader.file.clone() } /// [`Cancellable`](gio::Cancellable) to cancel operations within this image pub fn cancellable(&self) -> gio::Cancellable { self.loader.cancellable.clone() } /// Active sandbox mechanism pub fn active_sandbox_mechanism(&self) -> SandboxMechanism { self.active_sandbox_mechanism } } impl Drop for Loader { fn drop(&mut self) { self.cancellable.cancel(); } } /// A frame of an image often being the complete image #[derive(Debug, Clone)] pub struct Frame { pub(crate) buffer: glib::Bytes, pub(crate) width: u32, pub(crate) height: u32, /// Line stride pub(crate) stride: u32, pub(crate) memory_format: MemoryFormat, pub(crate) delay: Option, pub(crate) details: FrameDetails, } impl Frame { pub fn buf_bytes(&self) -> glib::Bytes { self.buffer.clone() } pub fn buf_slice(&self) -> &[u8] { self.buffer.as_ref() } /// Width in pixels pub fn width(&self) -> u32 { self.width } /// Height in pixels pub fn height(&self) -> u32 { self.height } /// Line stride in bytes pub fn stride(&self) -> u32 { self.stride } pub fn memory_format(&self) -> MemoryFormat { self.memory_format } /// Duration to show frame for animations. /// /// If the value is not set, the image is not animated. pub fn delay(&self) -> Option { self.delay } pub fn details(&self) -> &FrameDetails { &self.details } #[cfg(feature = "gdk4")] pub fn texture(&self) -> gdk::Texture { // Use unwraps here since the compatibility was checked before gdk::MemoryTexture::new( self.width().try_i32().unwrap(), self.height().try_i32().unwrap(), crate::util::gdk_memory_format(self.memory_format()), &self.buffer, self.stride().try_usize().unwrap(), ) .upcast() } } #[derive(Default, Debug)] #[must_use] /// Request information to get a specific frame pub struct FrameRequest { request: glycin_utils::FrameRequest, } impl FrameRequest { pub fn new() -> Self { Self::default() } pub fn scale(mut self, width: u32, height: u32) -> Self { self.request.scale = Some((width, height)); self } pub fn clip(mut self, x: u32, y: u32, width: u32, height: u32) -> Self { self.request.clip = Some((x, y, width, height)); self } } #[cfg(test)] mod test { use super::*; #[allow(dead_code)] fn ensure_futures_are_send() { gio::glib::spawn_future(async { let loader = Loader::new(gio::File::for_uri("invalid")); let image = loader.load().await.unwrap(); image.next_frame().await.unwrap(); }); } } glycin-2.0.1/src/config.rs000064400000000000000000000135641046102023000135240ustar 00000000000000use std::collections::HashMap; use std::ffi::OsStr; use std::path::{Path, PathBuf}; use std::sync::OnceLock; use futures_util::StreamExt; use gio::glib; use crate::util::{read, read_dir}; use crate::Error; #[derive(Clone, Debug, Hash, PartialEq, Eq)] /// Mime type pub struct MimeType(pub(crate) String); impl MimeType { pub fn as_str(&self) -> &str { self.0.as_str() } } impl std::fmt::Display for MimeType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(&self.0) } } const CONFIG_FILE_EXT: &str = "conf"; pub const COMPAT_VERSION: u8 = 1; #[derive(Debug, Clone, Default)] pub struct Config { pub image_loader: HashMap, pub image_editor: HashMap, } pub trait ConfigEntry: Send + Sync { fn fontconfig(&self) -> bool; fn exec(&self) -> PathBuf; } #[derive(Debug, Clone)] pub struct ImageLoaderConfig { pub exec: PathBuf, pub expose_base_dir: bool, pub fontconfig: bool, } impl ConfigEntry for ImageLoaderConfig { fn fontconfig(&self) -> bool { self.fontconfig } fn exec(&self) -> PathBuf { self.exec.clone() } } #[derive(Debug, Clone)] pub struct ImageEditorConfig { pub exec: PathBuf, pub expose_base_dir: bool, pub fontconfig: bool, } impl ConfigEntry for ImageEditorConfig { fn fontconfig(&self) -> bool { self.fontconfig } fn exec(&self) -> PathBuf { self.exec.clone() } } impl Config { pub async fn cached() -> &'static Self { static CONFIG: OnceLock = OnceLock::new(); if let Some(config) = CONFIG.get() { config } else { let config = Self::load().await; CONFIG.get_or_init(|| config) } } pub fn get_loader(&self, mime_type: &MimeType) -> Result<&ImageLoaderConfig, Error> { if self.image_loader.is_empty() { return Err(Error::NoLoadersConfigured(self.clone())); } self.image_loader .get(mime_type) .ok_or_else(|| Error::UnknownImageFormat(mime_type.to_string(), self.clone())) } pub fn get_editor(&self, mime_type: &MimeType) -> Result<&ImageEditorConfig, Error> { self.image_editor .get(mime_type) .ok_or_else(|| Error::UnknownImageFormat(mime_type.to_string(), self.clone())) } async fn load() -> Self { let mut config = Config::default(); for mut data_dir in Self::data_dirs() { data_dir.push("glycin-loaders"); data_dir.push(format!("{COMPAT_VERSION}+")); data_dir.push("conf.d"); if let Ok(mut config_files) = read_dir(data_dir).await { while let Some(result) = config_files.next().await { if let Ok(path) = result { if path.extension() == Some(OsStr::new(CONFIG_FILE_EXT)) { if let Err(err) = Self::load_file(&path, &mut config).await { eprintln!("Failed to load config file: {err}"); } } } } } } config } async fn load_file(path: &Path, config: &mut Config) -> Result<(), Box> { let data = read(path).await?; let bytes = glib::Bytes::from_owned(data); let keyfile = glib::KeyFile::new(); keyfile.load_from_bytes(&bytes, glib::KeyFileFlags::NONE)?; for group in keyfile.groups() { let mut elements = group.trim().split(':'); let kind = elements.next(); let mime_type = elements.next(); if let Some(mime_type) = mime_type { let group = group.trim(); match kind { Some("loader") => { if let Ok(exec) = keyfile.string(group, "Exec") { let expose_base_dir = keyfile.boolean(group, "ExposeBaseDir").unwrap_or_default(); let fontconfig = keyfile.boolean(group, "Fontconfig").unwrap_or_default(); let cfg = ImageLoaderConfig { exec: exec.into(), expose_base_dir, fontconfig, }; config .image_loader .insert(MimeType(mime_type.to_string()), cfg); } } Some("editor") => { if let Ok(exec) = keyfile.string(group, "Exec") { let expose_base_dir = keyfile.boolean(group, "ExposeBaseDir").unwrap_or_default(); let fontconfig = keyfile.boolean(group, "Fontconfig").unwrap_or_default(); let cfg = ImageEditorConfig { exec: exec.into(), expose_base_dir, fontconfig, }; config .image_editor .insert(MimeType(mime_type.to_string()), cfg); } } _ => {} } } } Ok(()) } fn data_dirs() -> Vec { // Force only specific data dir via env variable if let Some(data_dir) = std::env::var_os("GLYCIN_DATA_DIR") { vec![data_dir.into()] } else { let mut data_dirs = glib::system_data_dirs(); data_dirs.push(glib::user_data_dir()); data_dirs } } } glycin-2.0.1/src/dbus.rs000064400000000000000000000444711046102023000132150ustar 00000000000000// Copyright (c) 2024 GNOME Foundation Inc. //! Internal DBus API use std::io::{BufRead, Read}; use std::marker::PhantomData; use std::mem; use std::os::fd::{AsRawFd, OwnedFd, RawFd}; use std::os::unix::net::UnixStream; use std::sync::Arc; use std::time::{Duration, Instant}; use futures_channel::oneshot; use futures_util::{future, FutureExt}; use gio::glib; use gio::prelude::*; use glycin_utils::operations::Operations; use glycin_utils::{ DimensionTooLargerError, EditRequest, Frame, FrameRequest, ImageInfo, InitRequest, InitializationDetails, RemoteError, SafeConversion, SafeMath, SparseEditorOutput, }; use memmap::MmapMut; use nix::sys::signal; use zbus::zvariant; use crate::api_loader::{self}; use crate::config::{Config, ConfigEntry}; use crate::sandbox::Sandbox; use crate::util::{self, block_on, spawn_blocking, spawn_blocking_detached}; use crate::{config, icc, orientation, Error, Image, MimeType, SandboxMechanism}; /// Max texture size 8 GB in bytes pub(crate) const MAX_TEXTURE_SIZE: u64 = 8 * 10u64.pow(9); #[derive(Clone, Debug)] pub struct RemoteProcess<'a, P: ZbusProxy<'a>> { _dbus_connection: zbus::Connection, decoding_instruction: P, mime_type: String, phantom: PhantomData<&'a P>, pub stderr_content: Arc>, pub stdout_content: Arc>, } pub trait ZbusProxy<'a>: Sized + Sync + Send + From> { fn builder(conn: &zbus::Connection) -> zbus::proxy::Builder<'a, Self>; fn expose_base_dir(config: &Config, mime_type: &MimeType) -> Result; fn entry_config(config: &Config, mime_type: &MimeType) -> Result, Error>; } impl<'a> ZbusProxy<'a> for LoaderProxy<'a> { fn builder(conn: &zbus::Connection) -> zbus::proxy::Builder<'a, Self> { Self::builder(conn) } fn expose_base_dir(config: &Config, mime_type: &MimeType) -> Result { Ok(config.get_loader(mime_type)?.expose_base_dir) } fn entry_config(config: &Config, mime_type: &MimeType) -> Result, Error> { Ok(Box::new(config.get_loader(mime_type)?.clone())) } } impl<'a> ZbusProxy<'a> for EditorProxy<'a> { fn builder(conn: &zbus::Connection) -> zbus::proxy::Builder<'a, Self> { Self::builder(conn) } fn expose_base_dir(config: &Config, mime_type: &MimeType) -> Result { Ok(config.get_editor(mime_type)?.expose_base_dir) } fn entry_config(config: &Config, mime_type: &MimeType) -> Result, Error> { Ok(Box::new(config.get_editor(mime_type)?.clone())) } } impl<'a, P: ZbusProxy<'a>> RemoteProcess<'a, P> { pub async fn new( mime_type: &config::MimeType, config: &config::Config, sandbox_mechanism: SandboxMechanism, file: &gio::File, cancellable: &gio::Cancellable, ) -> Result { // UnixStream which facilitates the D-Bus connection. The stream is passed as // stdin to loader binaries. let (unix_stream, loader_stdin) = std::os::unix::net::UnixStream::pair()?; unix_stream.set_nonblocking(true)?; loader_stdin.set_nonblocking(true)?; let config_entry = P::entry_config(config, mime_type)?; let mut sandbox = Sandbox::new(sandbox_mechanism, config_entry, loader_stdin); // Mount dir that contains the file as read only for formats like SVG if P::expose_base_dir(config, mime_type)? { if let Some(base_dir) = file.parent().and_then(|x| x.path()) { sandbox.add_ro_bind(base_dir); } } let spawned_sandbox = sandbox.spawn().await?; let mut subprocess = spawned_sandbox.child; let command_dbg = spawned_sandbox.info.command_dbg; let stderr_content: Arc> = Default::default(); spawn_stdio_reader(&mut subprocess.stderr, &stderr_content); let stdout_content: Arc> = Default::default(); spawn_stdio_reader(&mut subprocess.stdout, &stdout_content); #[cfg(feature = "tokio")] let unix_stream = tokio::net::UnixStream::from_std(unix_stream)?; let guid = zbus::Guid::generate(); let dbus_result = zbus::ConnectionBuilder::unix_stream(unix_stream) .p2p() .server(guid)? .auth_mechanism(zbus::AuthMechanism::Anonymous) .build() .shared(); let subprocess_id = nix::unistd::Pid::from_raw(subprocess.id().try_into().unwrap()); futures_util::select! { _result = dbus_result.clone().fuse() => Ok(()), _result = cancellable.future().fuse() => { let _result = signal::kill(subprocess_id, signal::Signal::SIGKILL); Err(glib::Error::from(gio::Cancelled).into()) }, return_status = spawn_blocking(move || subprocess.wait()).fuse() => match return_status { Ok(status) => Err(Error::PrematureExit { status, cmd: command_dbg }), Err(err) => Err(Error::StdIoError{ err: err.into(), info: command_dbg }), } }?; cancellable.connect_cancelled(move |_| { let _result = signal::kill(subprocess_id, signal::Signal::SIGKILL); }); let dbus_connection = dbus_result.await?; let decoding_instruction = P::builder(&dbus_connection) // Unused since P2P connection .destination("org.gnome.glycin")? .build() .await?; Ok(Self { _dbus_connection: dbus_connection, decoding_instruction, mime_type: mime_type.to_string(), phantom: PhantomData, stderr_content, stdout_content, }) } fn init_request( &self, gfile_worker: &GFileWorker, base_dir: Option, ) -> Result { let (remote_reader, writer) = std::os::unix::net::UnixStream::pair()?; gfile_worker.write_to(writer)?; let fd = zvariant::OwnedFd::from(OwnedFd::from(remote_reader)); let mime_type = self.mime_type.clone(); let mut details = InitializationDetails::default(); details.base_dir = base_dir; Ok(InitRequest { fd, mime_type, details, }) } } impl<'a> RemoteProcess<'a, LoaderProxy<'a>> { pub async fn init( &self, gfile_worker: GFileWorker, base_dir: Option, ) -> Result { let init_request = self.init_request(&gfile_worker, base_dir)?; let image_info = self.decoding_instruction.init(init_request).shared(); let reader_error = gfile_worker.error(); futures_util::pin_mut!(reader_error); futures_util::select! { _result = image_info.clone().fuse() => Ok(()), result = reader_error.fuse() => result, }?; let image_info = image_info.await?; // Seal all memfds if let Some(exif) = &image_info.details.exif { seal_fd(exif).await?; } if let Some(xmp) = &image_info.details.xmp { seal_fd(xmp).await?; } Ok(image_info) } pub async fn request_frame<'b>( &self, frame_request: FrameRequest, image: &Image<'b>, ) -> Result { let mut frame = self.decoding_instruction.frame(frame_request).await?; // Seal all constant data if let Some(iccp) = &frame.details.iccp { seal_fd(iccp).await?; } let raw_fd = frame.texture.as_raw_fd(); let original_mmap = unsafe { MmapMut::map_mut(raw_fd) }?; validate_frame(&frame, &original_mmap)?; let img_buf = ImgBuf::MMap(original_mmap); let img_buf = if image.loader.apply_transformations { orientation::apply_exif_orientation(img_buf, &mut frame, image.info()) } else { img_buf }; let img_buf = if let Some(Ok(icc_profile)) = frame.details.iccp.as_ref().map(|x| x.get()) { // Align stride with pixel size if necessary let mut img_buf = remove_stride_if_needed(img_buf, raw_fd, &mut frame)?; let memory_format = frame.memory_format; let (icc_mmap, icc_result) = spawn_blocking(move || { let result = icc::apply_transformation(&icc_profile, memory_format, &mut img_buf); (img_buf, result) }) .await; if let Err(err) = icc_result { eprintln!("Failed to apply ICC profile: {err}"); } icc_mmap } else { img_buf }; let bytes = match img_buf { ImgBuf::MMap(mmap) => { drop(mmap); seal_fd(raw_fd).await?; unsafe { gbytes_from_mmap(raw_fd)? } } ImgBuf::Vec(vec) => glib::Bytes::from_owned(vec), }; Ok(api_loader::Frame { buffer: bytes, width: frame.width, height: frame.height, stride: frame.stride, memory_format: frame.memory_format, delay: frame.delay.into(), details: frame.details, }) } } impl<'a> RemoteProcess<'a, EditorProxy<'a>> { pub async fn editor_apply( &self, gfile_worker: &GFileWorker, base_dir: Option, operations: Operations, ) -> Result { let init_request = self.init_request(gfile_worker, base_dir)?; let edit_request = EditRequest::for_operations(operations)?; let editor_output = self .decoding_instruction .apply(init_request, edit_request) .shared(); let reader_error = gfile_worker.error(); futures_util::pin_mut!(reader_error); futures_util::select! { _result = editor_output.clone().fuse() => Ok(()), result = reader_error.fuse() => result, }?; let editor_output = editor_output.await?; Ok(editor_output) } } use std::io::{BufReader, Write}; const BUF_SIZE: usize = u16::MAX as usize; #[zbus::proxy( interface = "org.gnome.glycin.Loader", default_path = "/org/gnome/glycin" )] trait Loader { async fn init(&self, init_request: InitRequest) -> Result; async fn frame(&self, frame_request: FrameRequest) -> Result; } #[zbus::proxy( interface = "org.gnome.glycin.Editor", default_path = "/org/gnome/glycin" )] trait Editor { async fn apply( &self, init_request: InitRequest, edit_request: EditRequest, ) -> Result; } pub struct GFileWorker { file: gio::File, writer_send: Mutex>>, first_bytes_recv: future::Shared>>>, error_recv: future::Shared>>, } use std::sync::Mutex; impl GFileWorker { pub fn spawn(file: gio::File, cancellable: gio::Cancellable) -> GFileWorker { let gfile = file.clone(); let (error_send, error_recv) = oneshot::channel(); let (first_bytes_send, first_bytes_recv) = oneshot::channel(); let (writer_send, writer_recv) = oneshot::channel(); spawn_blocking_detached(move || { Self::handle_errors(error_send, move || { let reader = gfile.read(Some(&cancellable))?; let mut buf = vec![0; BUF_SIZE]; let n = reader.read(&mut buf, Some(&cancellable))?; let first_bytes = Arc::new(buf[..n].to_vec()); first_bytes_send .send(first_bytes.clone()) .or(Err(Error::InternalCommunicationCanceled))?; let mut writer: UnixStream = block_on(writer_recv)?; writer.write_all(&first_bytes)?; drop(first_bytes); loop { let n = reader.read(&mut buf, Some(&cancellable))?; if n == 0 { break; } writer.write_all(&buf[..n])?; } Ok(()) }) }); GFileWorker { file, writer_send: Mutex::new(Some(writer_send)), first_bytes_recv: first_bytes_recv.shared(), error_recv: error_recv.shared(), } } fn handle_errors( error_send: oneshot::Sender>, f: impl FnOnce() -> Result<(), Error>, ) { let result = f(); let _result = error_send.send(result); } pub fn write_to(&self, stream: UnixStream) -> Result<(), Error> { let sender = std::mem::take(&mut *self.writer_send.lock().unwrap()); sender // TODO: this fails if write_to is called a second time .unwrap() .send(stream) .or(Err(Error::InternalCommunicationCanceled)) } pub fn file(&self) -> &gio::File { &self.file } pub async fn error(&self) -> Result<(), Error> { match self.error_recv.clone().await { Ok(result) => result, Err(_) => Ok(()), } } pub async fn head(&self) -> Result>, Error> { futures_util::select!( err = self.error_recv.clone() => err?, _bytes = self.first_bytes_recv.clone() => Ok(()), )?; match self.first_bytes_recv.clone().await { Err(_) => self.error_recv.clone().await?.map(|_| Default::default()), Ok(bytes) => Ok(bytes), } } } async fn seal_fd(fd: impl AsRawFd) -> Result<(), memfd::Error> { let raw_fd = fd.as_raw_fd(); let start = Instant::now(); let mfd = memfd::Memfd::try_from_fd(raw_fd).unwrap(); // In rare circumstances the sealing returns a ResourceBusy loop { // 🦭 let seal = mfd.add_seals(&[ memfd::FileSeal::SealShrink, memfd::FileSeal::SealGrow, memfd::FileSeal::SealWrite, memfd::FileSeal::SealSeal, ]); match seal { Ok(_) => break, Err(err) if start.elapsed() > Duration::from_secs(10) => { // Give up after some time and return the error return Err(err); } Err(_) => { // Try again after short waiting time util::sleep(Duration::from_millis(1)).await; } } } mem::forget(mfd); Ok(()) } fn validate_frame(frame: &Frame, mmap: &MmapMut) -> Result<(), Error> { if mmap.len() < frame.n_bytes()? { return Err(Error::TextureTooSmall { texture_size: mmap.len(), frame: format!("{:?}", frame), }); } if frame.stride < frame.width.smul(frame.memory_format.n_bytes().u32())? { return Err(Error::StrideTooSmall(format!("{:?}", frame))); } if frame.width < 1 || frame.height < 1 { return Err(Error::WidgthOrHeightZero(format!("{:?}", frame))); } if (frame.stride as u64).smul(frame.height as u64)? > MAX_TEXTURE_SIZE { return Err(Error::TextureTooLarge); } // Ensure frame.width.try_i32()?; frame.height.try_i32()?; frame.stride.try_usize()?; Ok(()) } unsafe fn gbytes_from_mmap(raw_fd: RawFd) -> Result { let mut error = std::ptr::null_mut(); let mapped_file = glib::ffi::g_mapped_file_new_from_fd(raw_fd, glib::ffi::GFALSE, &mut error); if !error.is_null() { let err: glib::Error = glib::translate::from_glib_full(error); return Err(err.into()); }; let bytes = glib::translate::from_glib_full(glib::ffi::g_mapped_file_get_bytes(mapped_file)); glib::ffi::g_mapped_file_unref(mapped_file); Ok(bytes) } fn remove_stride_if_needed( img_buf: ImgBuf, raw_fd: RawFd, frame: &mut Frame, ) -> Result { if frame.stride.srem(frame.memory_format.n_bytes().u32())? == 0 { return Ok(img_buf); } match img_buf { ImgBuf::Vec(_) => Ok(img_buf), ImgBuf::MMap(mut mmap) => { let borrowed_fd = unsafe { std::os::fd::BorrowedFd::borrow_raw(raw_fd) }; let width = frame .width .try_usize()? .smul(frame.memory_format.n_bytes().usize())?; let stride = frame.stride.try_usize()?; let mut source = vec![0; width]; for row in 1..frame.height.try_usize()? { source.copy_from_slice(&mmap[row.smul(stride)?..row.smul(stride)?.sadd(width)?]); mmap[row.smul(width)?..row.sadd(1)?.smul(width)?].copy_from_slice(&source); } frame.stride = width.try_u32()?; // This mmap would have the wrong size after ftruncate drop(mmap); nix::unistd::ftruncate( borrowed_fd, libc::off_t::try_from(frame.n_bytes()?).map_err(|_| DimensionTooLargerError)?, )?; // Need a new mmap with correct size let mmap = unsafe { memmap::MmapMut::map_mut(raw_fd) }?; Ok(ImgBuf::MMap(mmap)) } } } fn spawn_stdio_reader(stdio: &mut Option, store: &Arc>) { if let Some(stdout) = stdio.take() { let store = store.clone(); util::spawn_blocking_detached(move || { let mut stdout = BufReader::new(stdout); let mut buf = String::new(); while let Ok(len) = stdout.read_line(&mut buf) { if len == 0 { break; } store.lock().unwrap().push_str(&buf); buf.clear(); } }); } } pub enum ImgBuf { MMap(memmap::MmapMut), Vec(Vec), } impl ImgBuf { pub fn as_slice(&self) -> &[u8] { match self { Self::MMap(mmap) => mmap.as_ref(), Self::Vec(v) => v.as_slice(), } } pub fn as_mut_slice(&mut self) -> &mut [u8] { match self { Self::MMap(mmap) => mmap.as_mut(), Self::Vec(v) => v.as_mut_slice(), } } } impl std::ops::Deref for ImgBuf { type Target = [u8]; fn deref(&self) -> &Self::Target { self.as_slice() } } impl std::ops::DerefMut for ImgBuf { fn deref_mut(&mut self) -> &mut Self::Target { self.as_mut_slice() } } glycin-2.0.1/src/error.rs000064400000000000000000000131411046102023000133770ustar 00000000000000use std::ops::Deref; use std::process::ExitStatus; use std::sync::Arc; use futures_channel::oneshot; use gio::glib; use glycin_utils::{DimensionTooLargerError, RemoteError}; use libseccomp::error::SeccompError; use crate::config; use crate::dbus::{RemoteProcess, ZbusProxy, MAX_TEXTURE_SIZE}; #[derive(Debug, Clone)] pub struct ErrorCtx { error: Error, stderr: Option, stdout: Option, } impl Deref for ErrorCtx { type Target = Error; fn deref(&self) -> &Self::Target { self.error() } } impl std::error::Error for ErrorCtx {} impl std::fmt::Display for ErrorCtx { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(&self.error.to_string())?; if let Some(stderr) = &self.stderr { if !stderr.is_empty() { f.write_str("\n\nstderr:\n")?; f.write_str(&stderr)?; } } if let Some(stdout) = &self.stdout { if !stdout.is_empty() { f.write_str("\n\nstdout:\n")?; f.write_str(&stdout)?; } } Ok(()) } } impl ErrorCtx { pub fn from_error(kind: Error) -> Self { ErrorCtx { error: kind, stderr: None, stdout: None, } } pub fn error(&self) -> &Error { &self.error } } pub trait ResultExt { fn err_context<'a, S: ZbusProxy<'a>>( self, process: &RemoteProcess<'a, S>, ) -> Result; fn err_no_context(self) -> Result; } impl ResultExt for Result { fn err_context<'a, S: ZbusProxy<'a>>( self, process: &RemoteProcess<'a, S>, ) -> Result { match self { Ok(x) => Ok(x), Err(kind) => { let stderr = process.stderr_content.lock().ok().map(|x| x.clone()); let stdout = process.stdout_content.lock().ok().map(|x| x.clone()); Err(ErrorCtx { error: kind, stderr, stdout, }) } } } fn err_no_context(self) -> Result { self.map_err(ErrorCtx::from_error) } } #[derive(Debug, Clone, thiserror::Error)] #[non_exhaustive] pub enum Error { #[error("Remote error: {0}")] RemoteError(#[from] RemoteError), #[error("GLib error: {0}")] GLibError(#[from] glib::Error), #[error("Libc error: {0}")] NixError(#[from] nix::errno::Errno), #[error("IO error: {err} {info}")] StdIoError { err: Arc, info: String, }, #[error("D-Bus error: {0}")] DbusError(#[from] zbus::Error), #[error("Internal communication was unexpectedly canceled")] InternalCommunicationCanceled, #[error( "No image loaders are configured. You might need to install a package like glycin-loaders.\nUsed config: {0:#?}" )] NoLoadersConfigured(config::Config), #[error("Unknown image format: {0}\nUsed config: {1:#?}")] UnknownImageFormat(String, config::Config), #[error("Unknown content type: {0}")] UnknownContentType(String), #[error("Loader process exited early with status '{}'Command:\n {cmd}", .status.code().unwrap_or_default())] PrematureExit { status: ExitStatus, cmd: String }, #[error("Conversion too large")] ConversionTooLargerError, #[error("Could not spawn `{cmd}`: {err}")] SpawnError { cmd: String, err: Arc, }, #[error("Texture is only {texture_size} but was announced differently: {frame}")] TextureTooSmall { texture_size: usize, frame: String }, #[error("Texture size exceeds hardcoded limit of {MAX_TEXTURE_SIZE} bytes")] TextureTooLarge, #[error("Stride is smaller than possible: {0}")] StrideTooSmall(String), #[error("Width or height is zero: {0}")] WidgthOrHeightZero(String), #[error("Memfd: {0}")] MemFd(Arc), #[error("Seccomp: {0}")] Seccomp(Arc), #[error("ICC profile: {0}")] IccProfile(#[from] lcms2::Error), } impl Error { /// Returns if the error is related to unsupported formats. /// /// Return the mime type of the unsupported format or [`None`] if the error /// is unrelated to unsupported formats. pub fn unsupported_format(&self) -> Option { match self { Self::UnknownImageFormat(mime_type, _) => Some(mime_type.to_string()), Self::RemoteError(RemoteError::UnsupportedImageFormat(msg)) => Some(msg.clone()), _ => None, } } pub fn is_out_of_memory(&self) -> bool { matches!(self, Self::RemoteError(RemoteError::OutOfMemory(_))) } } impl From for Error { fn from(err: std::io::Error) -> Self { Self::StdIoError { err: Arc::new(err), info: String::new(), } } } impl From> for Error { fn from(err: Arc) -> Self { Self::StdIoError { err, info: String::new(), } } } impl From for Error { fn from(err: memfd::Error) -> Self { Self::MemFd(Arc::new(err)) } } impl From for Error { fn from(err: SeccompError) -> Self { Self::Seccomp(Arc::new(err)) } } impl From for Error { fn from(_err: oneshot::Canceled) -> Self { Self::InternalCommunicationCanceled } } impl From for Error { fn from(_err: DimensionTooLargerError) -> Self { Self::ConversionTooLargerError } } glycin-2.0.1/src/fontconfig.rs000064400000000000000000000042571046102023000144120ustar 00000000000000use std::collections::BTreeSet; use std::ffi::{c_char, CStr}; use std::path::PathBuf; use std::ptr::NonNull; use std::sync::OnceLock; use fontconfig_sys as fc; pub fn cached_paths() -> &'static Option> { static DIRS: OnceLock>> = OnceLock::new(); DIRS.get_or_init(dirs) } fn dirs() -> Option> { unsafe { if fc::FcInit() != 1 { return None; } let config = NonNull::new(fc::FcConfigGetCurrent())?.as_ptr(); let mut paths = cache_dirs(config)?; paths.append(&mut config_files_and_dirs(config)?); paths.append(&mut font_dirs(config)?); Some(paths) } } unsafe fn cache_dirs(config: *mut fc::FcConfig) -> Option> { str_list_to_set(fc::FcConfigGetCacheDirs(config)) } unsafe fn config_files_and_dirs(config: *mut fc::FcConfig) -> Option> { let config_dirs = str_list_to_set(fc::FcConfigGetConfigDirs(config))?; let all_config_files = str_list_to_set(fc::FcConfigGetConfigFiles(config))?; let mut config_files_without_confd = all_config_files .into_iter() .filter(|x| { x.parent().map_or(false, |p| { !config_dirs.contains(p) && !config_dirs.contains(x) }) }) .collect(); let mut all_paths = config_dirs; all_paths.append(&mut config_files_without_confd); Some(all_paths) } unsafe fn font_dirs(config: *mut fc::FcConfig) -> Option> { let font_dirs = str_list_to_set(fc::FcConfigGetFontDirs(config))?; Some( font_dirs .into_iter() .filter(|x| !x.starts_with("/usr/")) .collect(), ) } unsafe fn str_list_to_set(list: *mut fc::FcStrList) -> Option> { let list = NonNull::new(list)?.as_ptr(); let mut vec = BTreeSet::new(); loop { let s = fc::FcStrListNext(list); if s.is_null() { break; } else if let Ok(cs) = CStr::from_ptr(s as *const c_char).to_str() { vec.insert(PathBuf::from(cs)); } else { eprintln!("fontconfig: Invalid path"); } } Some(vec) } glycin-2.0.1/src/gobject/frame.rs000064400000000000000000000015351046102023000147610ustar 00000000000000use std::sync::OnceLock; use gio::glib; use glib::subclass::prelude::*; use crate::Frame; static_assertions::assert_impl_all!(GlyFrame: Send, Sync); pub mod imp { use super::*; #[derive(Default, Debug)] pub struct GlyFrame { pub(super) frame: OnceLock, } #[glib::object_subclass] impl ObjectSubclass for GlyFrame { const NAME: &'static str = "GlyFrame"; type Type = super::GlyFrame; } impl ObjectImpl for GlyFrame {} } glib::wrapper! { /// GObject wrapper for [`Frame`] pub struct GlyFrame(ObjectSubclass); } impl GlyFrame { pub(crate) fn new(frame: Frame) -> Self { let obj = glib::Object::new::(); obj.imp().frame.set(frame).unwrap(); obj } pub fn frame(&self) -> &Frame { self.imp().frame.get().unwrap() } } glycin-2.0.1/src/gobject/image.rs000064400000000000000000000027501046102023000147510ustar 00000000000000use std::sync::OnceLock; use gio::{glib, Cancellable}; use glib::subclass::prelude::*; use glycin_utils::ImageInfo; use super::GlyFrame; use crate::{ErrorCtx, Image}; static_assertions::assert_impl_all!(GlyImage: Send, Sync); pub mod imp { use super::*; #[derive(Default, Debug)] pub struct GlyImage { pub(super) image: OnceLock>, pub(super) mime_type: OnceLock, } #[glib::object_subclass] impl ObjectSubclass for GlyImage { const NAME: &'static str = "GlyImage"; type Type = super::GlyImage; } impl ObjectImpl for GlyImage {} } glib::wrapper! { /// GObject wrapper for [`Image`] pub struct GlyImage(ObjectSubclass); } impl GlyImage { pub(crate) fn new(image: Image<'static>) -> Self { let obj = glib::Object::new::(); obj.imp().image.set(image).unwrap(); obj } pub fn image_info(&self) -> &ImageInfo { self.image().info() } pub async fn next_frame(&self) -> Result { Ok(GlyFrame::new(self.image().next_frame().await?)) } pub fn cancellable(&self) -> Cancellable { self.image().cancellable() } pub fn image(&self) -> &Image { self.imp().image.get().unwrap() } pub fn mime_type(&self) -> &glib::GString { self.imp().mime_type.get_or_init(|| { glib::GString::from(self.imp().image.get().unwrap().mime_type().as_str()) }) } } glycin-2.0.1/src/gobject/loader.rs000064400000000000000000000026601046102023000151350ustar 00000000000000use std::sync::Mutex; use gio::glib; use glib::prelude::*; use glib::subclass::prelude::*; use super::GlyImage; use crate::{Loader, SandboxSelector}; static_assertions::assert_impl_all!(GlyLoader: Send, Sync); pub mod imp { use super::*; #[derive(Default, Debug, glib::Properties)] #[properties(wrapper_type = super::GlyLoader)] pub struct GlyLoader { #[property(get, construct_only)] file: Mutex>, #[property(get, set)] cancellable: Mutex, #[property(get, set, builder(SandboxSelector::default()))] sandbox_selector: Mutex, } #[glib::object_subclass] impl ObjectSubclass for GlyLoader { const NAME: &'static str = "GlyLoader"; type Type = super::GlyLoader; } #[glib::derived_properties] impl ObjectImpl for GlyLoader {} } glib::wrapper! { /// GObject wrapper for [`Loader`] pub struct GlyLoader(ObjectSubclass); } impl GlyLoader { pub fn new(file: &gio::File) -> Self { glib::Object::builder().property("file", file).build() } pub async fn load(&self) -> Result { let mut loader = Loader::new(self.file().unwrap()); loader.sandbox_selector = self.sandbox_selector(); loader.cancellable(self.cancellable()); let image = loader.load().await?; Ok(GlyImage::new(image)) } } glycin-2.0.1/src/gobject.rs000064400000000000000000000001741046102023000136650ustar 00000000000000pub mod frame; pub mod image; pub mod loader; pub use frame::GlyFrame; pub use image::GlyImage; pub use loader::GlyLoader; glycin-2.0.1/src/icc.rs000064400000000000000000000057051046102023000130130ustar 00000000000000use glycin_utils::memory_format::MemoryFormat; use crate::Error; pub fn apply_transformation( iccp: &[u8], memory_format: MemoryFormat, mmap: &mut [u8], ) -> Result<(), Error> { transform(iccp, memory_format, mmap).map_err(Into::into) } fn transform( icc_profile: &[u8], memory_format: MemoryFormat, buf: &mut [u8], ) -> std::result::Result<(), lcms2::Error> { let icc_pixel_format = lcms_pixel_format(memory_format); let src_profile = lcms2::Profile::new_icc(icc_profile)?; let target_profile = if memory_format.n_channels() > 2 { lcms2::Profile::new_srgb() } else { lcms2::Profile::new_gray(lcms2_sys::ffi::CIExyY::d50(), &lcms2::ToneCurve::new(2.2)) .unwrap() }; let transform = lcms2::Transform::new( &src_profile, icc_pixel_format, &target_profile, icc_pixel_format, lcms2::Intent::Perceptual, )?; transform.transform_in_place(buf); Ok(()) } const fn lcms_pixel_format(format: MemoryFormat) -> lcms2::PixelFormat { match format { MemoryFormat::B8g8r8a8Premultiplied => premul(lcms2::PixelFormat::BGRA_8), MemoryFormat::A8r8g8b8Premultiplied => premul(lcms2::PixelFormat::ARGB_8), MemoryFormat::R8g8b8a8Premultiplied => premul(lcms2::PixelFormat::RGBA_8), MemoryFormat::B8g8r8a8 => lcms2::PixelFormat::BGRA_8, MemoryFormat::A8r8g8b8 => lcms2::PixelFormat::ARGB_8, MemoryFormat::R8g8b8a8 => lcms2::PixelFormat::RGBA_8, MemoryFormat::A8b8g8r8 => lcms2::PixelFormat::ABGR_8, MemoryFormat::R8g8b8 => lcms2::PixelFormat::RGB_8, MemoryFormat::B8g8r8 => lcms2::PixelFormat::BGR_8, MemoryFormat::R16g16b16 => lcms2::PixelFormat::RGB_16, MemoryFormat::R16g16b16a16Premultiplied => premul(lcms2::PixelFormat::RGBA_16), MemoryFormat::R16g16b16a16 => lcms2::PixelFormat::RGBA_16, MemoryFormat::R16g16b16Float => lcms2::PixelFormat::RGB_HALF_FLT, MemoryFormat::R16g16b16a16Float => lcms2::PixelFormat::RGBA_HALF_FLT, MemoryFormat::R32g32b32Float => lcms2::PixelFormat::RGB_FLT, MemoryFormat::R32g32b32a32FloatPremultiplied => premul(lcms2::PixelFormat::RGBA_FLT), MemoryFormat::R32g32b32a32Float => lcms2::PixelFormat::RGBA_FLT, MemoryFormat::G8a8Premultiplied => premul(lcms2::PixelFormat::GRAYA_8), MemoryFormat::G8a8 => lcms2::PixelFormat::GRAYA_8, MemoryFormat::G8 => lcms2::PixelFormat::GRAY_8, MemoryFormat::G16a16Premultiplied => premul(lcms2::PixelFormat::GRAYA_16), MemoryFormat::G16a16 => lcms2::PixelFormat::GRAYA_16, MemoryFormat::G16 => lcms2::PixelFormat::GRAY_16, } } const fn premul(format: lcms2::PixelFormat) -> lcms2::PixelFormat { let mut bytes = format.0; bytes |= 0b1 << 23; lcms2::PixelFormat(bytes) } #[test] fn premul_test() { assert!(!lcms2::PixelFormat::RGBA_8.premultiplied()); assert!(premul(lcms2::PixelFormat::RGBA_8).premultiplied()); } glycin-2.0.1/src/lib.rs000064400000000000000000000056251046102023000130240ustar 00000000000000#![deny(clippy::arithmetic_side_effects)] #![deny(clippy::cast_possible_truncation)] #![deny(clippy::cast_possible_wrap)] #![deny(clippy::indexing_slicing)] #![deny(clippy::expect_used)] #![deny(clippy::unwrap_used)] //! Glycin allows to decode images into [`gdk::Texture`]s and to extract image //! metadata. The decoding happens in sandboxed modular image loaders that have //! to be provided as binaries. The [`glycin-utils`](glycin_utils) for more //! details. //! //! # Example //! //! You need to enable the `gdk4` feature for this example to work. //! //! ```no_run //! # use glycin::*; //! # async_global_executor::block_on(async { //! let file = gio::File::for_path("image.jpg"); //! let image = Loader::new(file).load().await?; //! //! let height = image.info().height(); //! let texture = image.next_frame().await?.texture(); //! # Ok::<(), Error>(()) }); //! ``` //! //! You can pass the [`texture`](Frame#structfield.texture) of a [`Frame`] to //! [`gtk4::Image::from_paintable()`] to display the image. //! //! # External Dependencies //! //! Glycin requires the libraries *libglib2.0*, *liblcms2*, *libfontconfig*, and //! *libseccomp* packages to be installed. For the `gdk4` feature, *libgtk-4* is //! required as well. To actually work with images, loaders for the respective //! formats have to be installed. Glycin provides [loaders] for many formats //! that are packaged with many distributions. When working in the default //! sandbox mode, the `bwrap` binary of *bubblewrap* is required as well. The //! required dependencies can usually be installed through commands like //! //! ```sh //! $ apt install libgtk-4-dev liblcms2-dev libfontconfig-dev libseccomp-dev glycin-loaders bubblewrap //! ``` //! //! on Debian/Ubuntu or //! //! ```sh //! $ dnf install gtk4-devel lcms2-devel fontconfig-devel libseccomp-devel glycin-loaders bubblewrap //! ``` //! //! on Fedora. //! //! # Features //! //! - `gdk4` --- Enables interoperability with [`gdk4`](gdk) by enabling to get //! a [`gdk::Texture`] directly. //! - `tokio` --- Makes glycin compatible with [`zbus`] using [`tokio`]. //! //! [`gtk4::Image::from_paintable()`]: https://gtk-rs.org/gtk4-rs/git/docs/gtk4/struct.Image.html#method.from_paintable //! [loaders]: https://gitlab.gnome.org/sophie-h/glycin#supported-image-formats #[cfg(all(not(feature = "async-io"), not(feature = "tokio")))] mod error_message { compile_error!( "\"async-io\" (default) or \"tokio\" must be enabled to provide an async runtime." ); } mod api_common; mod api_editor; mod api_loader; mod config; mod dbus; mod error; mod fontconfig; mod icc; mod orientation; mod sandbox; mod util; #[cfg(feature = "gobject")] pub mod gobject; pub use api_common::*; pub use api_editor::*; pub use api_loader::*; pub use config::COMPAT_VERSION; pub use error::{Error, ErrorCtx}; pub use glycin_utils::{ImageInfo, ImageInfoDetails, RemoteError}; #[cfg(feature = "gdk4")] pub use util::gdk_memory_format; glycin-2.0.1/src/orientation.rs000064400000000000000000000067001046102023000146040ustar 00000000000000use glycin_utils::{Frame, ImageInfo}; use gufo_common::orientation::{Orientation, Rotation}; use crate::dbus::ImgBuf; pub fn apply_exif_orientation( img_buf: ImgBuf, frame: &mut Frame, image_info: &ImageInfo, ) -> ImgBuf { if image_info.details.transformations_applied { img_buf } else if let Some(exif_data) = image_info .details .exif .as_ref() .and_then(|x| x.get_full().ok()) { match gufo_exif::Exif::new(exif_data) { Err(err) => { eprintln!("exif: Failed to parse data: {err:?}"); img_buf } Ok(data) => transform(img_buf, frame, data.orientation()), } } else { img_buf } } #[allow(clippy::arithmetic_side_effects, clippy::cast_possible_truncation)] fn transform(mut img_buf: ImgBuf, frame: &mut Frame, transformation: Orientation) -> ImgBuf { let stride = frame.stride as usize; let width = frame.width as usize; let height = frame.height as usize; let pixel_size = frame.memory_format.n_bytes().usize(); let n_bytes = width * height * pixel_size; if transformation.mirror() { for x in 0..width / 2 { for y in 0..height { for i in 0..pixel_size { let p0 = x * pixel_size + y * stride + i; let p1 = (width - 1 - x) * pixel_size + y * stride + i; img_buf.swap(p0, p1); } } } } match transformation.rotate() { Rotation::_0 => img_buf, Rotation::_270 => { let mut v = vec![0; n_bytes]; frame.width = height as u32; frame.height = width as u32; frame.stride = (height * pixel_size) as u32; for x in 0..width { for y in 0..height { for i in 0..pixel_size { let p0 = x * pixel_size + y * stride + i; let p1 = x * height * pixel_size + (height - 1 - y) * pixel_size + i; v[p1] = img_buf[p0]; } } } ImgBuf::Vec(v) } Rotation::_90 => { let mut v = vec![0; n_bytes]; frame.width = height as u32; frame.height = width as u32; frame.stride = (height * pixel_size) as u32; for x in 0..width { for y in 0..height { for i in 0..pixel_size { let p0 = x * pixel_size + y * stride + i; let p1 = (width - 1 - x) * height * pixel_size + y * pixel_size + i; v[p1] = img_buf[p0]; } } } ImgBuf::Vec(v) } Rotation::_180 => { let mid_col = width / 2; let uneven_cols = width % 2 == 1; for x in 0..width.div_ceil(2) { let y_max = if uneven_cols && mid_col == x { height / 2 } else { height }; for y in 0..y_max { for i in 0..pixel_size { let p0 = x * pixel_size + y * stride + i; let p1 = (width - 1 - x) * pixel_size + (height - 1 - y) * stride + i; img_buf.swap(p0, p1); } } } img_buf } } } glycin-2.0.1/src/sandbox.rs000064400000000000000000000412721046102023000137120ustar 00000000000000// Copyright (c) 2024 GNOME Foundation Inc. use std::ffi::OsString; use std::fs::{canonicalize, DirEntry, File}; use std::io::{self, BufRead, BufReader, Seek}; use std::os::fd::{AsRawFd, OwnedFd}; use std::os::unix::net::UnixStream; use std::os::unix::process::CommandExt; use std::path::PathBuf; use std::process::{Child, Command, Stdio}; use std::sync::Arc; use gio::glib; use libseccomp::error::SeccompError; use libseccomp::{ScmpAction, ScmpFilterContext, ScmpSyscall}; use memfd::{Memfd, MemfdOptions}; use nix::sys::resource; use crate::config::ConfigEntry; use crate::util::{self, new_async_mutex, AsyncMutex}; use crate::{Error, SandboxMechanism}; type SystemSetupStore = Arc>>; static SYSTEM_SETUP: AsyncMutex> = new_async_mutex(None); const ALLOWED_SYSCALLS: &[&str] = &[ "access", "arch_prctl", "brk", "capget", "capset", "chdir", "clock_getres", "clock_gettime", "clock_gettime64", "clone", "clone3", "close", "connect", "creat", "dup", "epoll_create", "epoll_create1", "epoll_ctl", "epoll_pwait", "epoll_wait", "eventfd", "eventfd2", "execve", "exit", "faccessat", "fadvise64", "fadvise64_64", "fchdir", "fcntl", "fcntl", "fcntl64", "fstat", "fstatfs", "fstatfs64", "ftruncate", "futex", "futex_time64", "get_mempolicy", "getcwd", "getdents64", "getegid", "getegid32", "geteuid", "geteuid32", "getgid", "getgid32", "getpid", "getppid", "getrandom", "gettid", "gettimeofday", "getuid", "getuid32", "ioctl", "madvise", "membarrier", "memfd_create", "mmap", "mmap2", "mprotect", "mremap", "munmap", "newfstatat", "open", "openat", "pipe", "pipe2", "pivot_root", "poll", "ppoll", "ppoll_time64", "prctl", "pread64", "prlimit64", "read", "readlink", "readlinkat", "recvfrom", "recvmsg", "rseq", "rt_sigaction", "rt_sigprocmask", "rt_sigreturn", "sched_getaffinity", "sched_yield", "sendmsg", "sendto", "set_mempolicy", "set_mempolicy", "set_robust_list", "set_thread_area", "set_tid_address", "sigaltstack", "signalfd4", "socket", "socketcall", "stat", "statfs", "statfs64", "statx", "sysinfo", "timerfd_create", "timerfd_settime", "timerfd_settime64", "tgkill", "ugetrlimit", "unshare", "wait4", "write", ]; const ALLOWED_SYSCALLS_FONTCONFIG: &[&str] = &[ "link", "linkat", "unlink", "unlinkat", "rename", "renameat", "renameat2", ]; pub struct Sandbox { sandbox_mechanism: SandboxMechanism, config_entry: Box, stdin: UnixStream, ro_bind_extra: Vec, } static_assertions::assert_impl_all!(Sandbox: Send, Sync); pub struct SpawnedSandbox { pub child: Child, // Keep seccomp fd alive until process exits pub _seccomp_fd: Option, pub info: SandboxInfo, } static_assertions::assert_impl_all!(SpawnedSandbox: Send, Sync); pub struct SandboxInfo { pub command_dbg: String, } impl Sandbox { pub fn new( sandbox_mechanism: SandboxMechanism, config_entry: Box, stdin: UnixStream, ) -> Self { Self { sandbox_mechanism, config_entry, stdin, ro_bind_extra: Vec::new(), } } fn exec(&self) -> PathBuf { self.config_entry.exec() } pub fn add_ro_bind(&mut self, path: PathBuf) { self.ro_bind_extra.push(path); } pub async fn spawn(self) -> Result { // Determine command line args let (bin, args, seccomp_fd) = match self.sandbox_mechanism { SandboxMechanism::Bwrap => { let mut args = self.bwrap_args().await?; let seccomp_memfd = Self::seccomp_export_bpf(&self.seccomp_filter()?)?; args.push("--seccomp".into()); args.push(seccomp_memfd.as_raw_fd().to_string().into()); args.push(self.exec()); ("bwrap".into(), args, Some(seccomp_memfd)) } SandboxMechanism::FlatpakSpawn => { let memory_limit = Self::memory_limit(); tracing::debug!("Setting prlimit to {memory_limit} bytes"); let args = vec![ "--sandbox".into(), // die with parent "--watch-bus".into(), // change working directory to something that exists "--directory=/".into(), // Start loader with memory limit "prlimit".into(), format!("--as={memory_limit}").into(), // Loader binary self.exec(), ]; ("flatpak-spawn".into(), args, None) } SandboxMechanism::NotSandboxed => { eprintln!("WARNING: Glycin running without sandbox."); (self.exec(), vec![], None) } }; let mut command = Command::new(bin); command.stdin(OwnedFd::from(self.stdin)); command.args(args); // Clear ENV if matches!(self.sandbox_mechanism, SandboxMechanism::FlatpakSpawn) { // Do not clear environment before `flatpak-spawn` is called. Otherwise, // `flatpak-spawn` will fail to find the D-Bus connection to call the portal. command.arg("--clear-env"); } else { command.env_clear(); } // Inherit some environment variables for env_key in ["RUST_BACKTRACE", "RUST_LOG"] { if let Some(val) = std::env::var_os(env_key) { if matches!(self.sandbox_mechanism, SandboxMechanism::FlatpakSpawn) { let mut arg = OsString::new(); arg.push("--env="); arg.push(env_key); arg.push("="); arg.push(val); command.arg(arg); } else { command.env(env_key, val); } } } // Set memory limit for sandbox if matches!(self.sandbox_mechanism, SandboxMechanism::Bwrap) { unsafe { command.pre_exec(|| { Self::set_memory_limit(); Ok(()) }); } } command.stderr(Stdio::piped()); command.stdout(Stdio::piped()); let command_dbg = format!("{:?}", command); tracing::debug!("Spawning loader/editor:\n {command_dbg}"); let child = command.spawn().map_err(|err| Error::SpawnError { cmd: command_dbg.clone(), err: Arc::new(err), })?; Ok(SpawnedSandbox { child, _seccomp_fd: seccomp_fd, info: SandboxInfo { command_dbg }, }) } async fn bwrap_args(&self) -> Result, Error> { let mut args: Vec = Vec::new(); args.extend( [ "--unshare-all", "--die-with-parent", // change working directory to something that exists "--chdir", "/", // Make /usr available as read only "--ro-bind", "/usr", "/usr", // Make tmpfs dev available "--dev", "/dev", // Additional linker configuration via /etc/ld.so.conf if available "--ro-bind-try", "/etc/ld.so.cache", "/etc/ld.so.cache", // Create a fake HOME for glib to not throw warnings "--tmpfs", "/tmp-home", "--setenv", "HOME", "/tmp-home", // Create a fake runtime dir for glib to not throw warnings "--tmpfs", "/tmp-run", "--setenv", "XDG_RUNTIME_DIR", "/tmp-run", ] .iter() .map(|x| (*x).into()) .collect::>(), ); let system_setup_arc = SystemSetup::cached().await; let system = match system_setup_arc.as_ref().as_ref() { Err(err) => { return Err(err.clone().into()); } Ok(system) => system, }; // Symlink paths like /usr/lib64 to /lib64 for (dest, src) in &system.lib_symlinks { args.push("--symlink".into()); args.push(src.clone()); args.push(dest.clone()); } // Mount paths like /lib64 if they exist for dir in &system.lib_dirs { args.push("--ro-bind".into()); args.push(dir.clone()); args.push(dir.clone()); } // Make extra dirs available for dir in &self.ro_bind_extra { args.push("--ro-bind".into()); args.push(dir.clone()); args.push(dir.clone()); } // Make loader binary available if not in /usr. This is useful for testing and // adding loaders in user (/home) configurations. if !self.exec().starts_with("/usr") { args.push("--ro-bind".into()); args.push(self.exec()); args.push(self.exec()); } // Fontconfig if !self.config_entry.fontconfig() { // TODO: log fontconfig disabled } else if let Some(fc_paths) = crate::fontconfig::cached_paths() { // Expose paths to fonts, configs, and caches for path in fc_paths { args.push("--ro-bind-try".into()); args.push(path.clone()); args.push(path.clone()); } // Fontconfig needs a writeable cache if the cache is outdated let cache_dir = PathBuf::from_iter([ glib::user_cache_dir(), "glycin".into(), self.exec().iter().skip(1).collect(), ]); let fc_cache_dir = PathBuf::from_iter([cache_dir.clone(), "fontconfig".into()]); // Create cache dir match util::spawn_blocking(move || std::fs::create_dir_all(fc_cache_dir)).await { Err(err) => eprintln!("Failed to create cache dir: {err:?}"), Ok(()) => { args.push("--bind-try".into()); args.push(cache_dir.clone()); args.push(cache_dir.clone()); args.push("--setenv".into()); args.push("XDG_CACHE_HOME".into()); args.push(cache_dir); } } } else { eprintln!("WARNING: Failed to load fonftconfig environment"); } Ok(args) } /// Memory limit in bytes that should be applied to sandboxes fn memory_limit() -> resource::rlim_t { // Lookup free memory if let Some(mem_available) = Self::mem_available() { Self::calculate_memory_limit(mem_available) } else { tracing::warn!("glycin: Unable to determine available memory via /proc/meminfo"); // Default to 1 GB memory limit 1024 * 1024 * 1024 } } /// Try to determine how much memory is available on the system fn mem_available() -> Option { if let Ok(file) = File::open("/proc/meminfo") { let meminfo = BufReader::new(file); let mut total_avail_kb: Option = None; for line in meminfo.lines().map_while(Result::ok) { if line.starts_with("MemAvailable:") || line.starts_with("SwapFree:") { tracing::trace!("Using /proc/meminfo: {line}"); if let Some(mem_avail_kb) = line .split(' ') .filter(|x| !x.is_empty()) .nth(1) .and_then(|x| x.parse::().ok()) { total_avail_kb = Some(total_avail_kb.unwrap_or(0).saturating_add(mem_avail_kb)); } } } if let Some(total_avail_kb) = total_avail_kb { let mem_available = total_avail_kb.saturating_mul(1024); tracing::debug!("Memory available: {mem_available} bytes"); return Some(Self::calculate_memory_limit(mem_available)); } } None } /// Calculate memory that the sandbox will be allowed to use fn calculate_memory_limit(mem_available: resource::rlim_t) -> resource::rlim_t { // Consider max of 10 GB free RAM for use let mem_considered = resource::rlim_t::min( mem_available, (1024 as resource::rlim_t) .saturating_pow(3) .saturating_mul(10), ) // Keep at least 200 MB free .saturating_sub(1024 * 1024 * 200); // Allow usage of 80% of considered memory (mem_considered as f64 * 0.8) as resource::rlim_t } /// Set memory limit for the current process fn set_memory_limit() { let limit = Self::memory_limit(); tracing::debug!("Setting process memory limit of {limit} bytes"); if let Err(err) = resource::setrlimit(resource::Resource::RLIMIT_AS, limit, limit) { eprintln!("Error setrlimit(RLIMIT_AS, {limit}): {err}"); } } fn seccomp_filter(&self) -> Result { let mut filter = ScmpFilterContext::new_filter(ScmpAction::Trap)?; let mut syscalls = vec![ALLOWED_SYSCALLS]; if self.config_entry.fontconfig() { // Enable some write operations for fontconfig to update its cache syscalls.push(ALLOWED_SYSCALLS_FONTCONFIG); } for syscall_name in syscalls.into_iter().flatten() { let syscall = ScmpSyscall::from_name(syscall_name)?; filter.add_rule(ScmpAction::Allow, syscall)?; } Ok(filter) } fn seccomp_export_bpf(filter: &ScmpFilterContext) -> Result { let mut memfd = MemfdOptions::default() .close_on_exec(false) .create("seccomp-bpf-filter")?; filter.export_bpf(&mut memfd)?; let mut file = memfd.as_file(); file.rewind()?; Ok(memfd) } } #[derive(Debug, Default)] struct SystemSetup { // Dirs that need to be symlinked (UsrMerge) lib_symlinks: Vec<(PathBuf, PathBuf)>, // Dirs that need mounting (not UsrMerged) lib_dirs: Vec, } impl SystemSetup { async fn cached() -> SystemSetupStore { let mut system_setup = SYSTEM_SETUP.lock().await; if let Some(arc) = &*system_setup { arc.clone() } else { let arc = Arc::new(Self::new().await.map_err(Arc::new)); *system_setup = Some(arc.clone()); arc } } async fn new() -> io::Result { let mut system = SystemSetup::default(); system.load_lib_dirs().await?; Ok(system) } async fn load_lib_dirs(&mut self) -> io::Result<()> { let dir_content = std::fs::read_dir("/"); match dir_content { Ok(dir_content) => { for entry in dir_content { if let Err(err) = self.add_dir(entry).await { eprintln!("Unable to access entry in root directory (/): {err}"); } } } Err(err) => { eprintln!("Unable to list root directory (/) entries: {err}"); } } Ok(()) } async fn add_dir(&mut self, entry: io::Result) -> io::Result<()> { let entry = entry?; let path = entry.path(); if let Some(last_segment) = path.file_name() { if last_segment.as_encoded_bytes().starts_with(b"lib") { let metadata = entry.metadata()?; if metadata.is_dir() { // Lib dirs like /lib self.lib_dirs.push(entry.path()); } else if metadata.is_symlink() { // Symlinks like /lib -> /usr/lib let target = canonicalize(&path)?; // Only use symlinks that link somewhere into /usr/ if target.starts_with("/usr/") { self.lib_symlinks.push((path, target)); } } } }; Ok(()) } } glycin-2.0.1/src/util.rs000064400000000000000000000136471046102023000132360ustar 00000000000000use std::path::{Path, PathBuf}; use std::sync::OnceLock; use futures_util::{Stream, StreamExt}; use gio::glib; #[cfg(feature = "gdk4")] use glycin_utils::MemoryFormat; #[cfg(feature = "gdk4")] pub const fn gdk_memory_format(format: MemoryFormat) -> gdk::MemoryFormat { match format { MemoryFormat::B8g8r8a8Premultiplied => gdk::MemoryFormat::B8g8r8a8Premultiplied, MemoryFormat::A8r8g8b8Premultiplied => gdk::MemoryFormat::A8r8g8b8Premultiplied, MemoryFormat::R8g8b8a8Premultiplied => gdk::MemoryFormat::R8g8b8a8Premultiplied, MemoryFormat::B8g8r8a8 => gdk::MemoryFormat::B8g8r8a8, MemoryFormat::A8r8g8b8 => gdk::MemoryFormat::A8r8g8b8, MemoryFormat::R8g8b8a8 => gdk::MemoryFormat::R8g8b8a8, MemoryFormat::A8b8g8r8 => gdk::MemoryFormat::A8b8g8r8, MemoryFormat::R8g8b8 => gdk::MemoryFormat::R8g8b8, MemoryFormat::B8g8r8 => gdk::MemoryFormat::B8g8r8, MemoryFormat::R16g16b16 => gdk::MemoryFormat::R16g16b16, MemoryFormat::R16g16b16a16Premultiplied => gdk::MemoryFormat::R16g16b16a16Premultiplied, MemoryFormat::R16g16b16a16 => gdk::MemoryFormat::R16g16b16a16, MemoryFormat::R16g16b16Float => gdk::MemoryFormat::R16g16b16Float, MemoryFormat::R16g16b16a16Float => gdk::MemoryFormat::R16g16b16a16Float, MemoryFormat::R32g32b32Float => gdk::MemoryFormat::R32g32b32Float, MemoryFormat::R32g32b32a32FloatPremultiplied => { gdk::MemoryFormat::R32g32b32a32FloatPremultiplied } MemoryFormat::R32g32b32a32Float => gdk::MemoryFormat::R32g32b32a32Float, MemoryFormat::G8a8Premultiplied => gdk::MemoryFormat::G8a8Premultiplied, MemoryFormat::G8a8 => gdk::MemoryFormat::G8a8, MemoryFormat::G8 => gdk::MemoryFormat::G8, MemoryFormat::G16a16Premultiplied => gdk::MemoryFormat::G16a16Premultiplied, MemoryFormat::G16a16 => gdk::MemoryFormat::G16a16, MemoryFormat::G16 => gdk::MemoryFormat::G16, } } #[derive(Debug, Clone, Copy)] pub enum RunEnvironment { /// Not inside Flatpak Host, /// Inside Flatpak Flatpak, /// Inside Flatpak and development environment FlatpakDevel, } impl RunEnvironment { pub async fn cached() -> Self { static RUN_ENVIRONMENT: OnceLock = OnceLock::new(); if let Some(result) = RUN_ENVIRONMENT.get() { *result } else { let run_env = if let Some(devel) = flatpak_devel().await { if devel { Self::FlatpakDevel } else { Self::Flatpak } } else { Self::Host }; *RUN_ENVIRONMENT.get_or_init(|| run_env) } } } /// Returns None if not in Flatpak environment, otherwise true if development async fn flatpak_devel() -> Option { let data = read("/.flatpak-info").await.ok()?; let bytes = glib::Bytes::from_owned(data); let keyfile = glib::KeyFile::new(); keyfile .load_from_bytes(&bytes, glib::KeyFileFlags::NONE) .ok()?; // App is not installed but instead started with `flatpak-builder --run` let Ok(flatpak_builder) = keyfile.boolean("Instance", "build") else { return Some(false); }; let Ok(name) = keyfile.string("Application", "name") else { return Some(false); }; Some(flatpak_builder && name.ends_with(".Devel")) } #[cfg(not(feature = "tokio"))] pub fn block_on(future: F) -> F::Output { async_io::block_on(future) } #[cfg(feature = "tokio")] pub fn block_on(future: F) -> F::Output { static TOKIO_RT: OnceLock = OnceLock::new(); let runtime = TOKIO_RT.get_or_init(|| tokio::runtime::Runtime::new().expect("tokio runtime was created")); runtime.block_on(future) } #[cfg(not(feature = "tokio"))] pub async fn spawn_blocking T + Send + 'static, T: Send + 'static>(f: F) -> T { blocking::unblock(f).await } #[cfg(feature = "tokio")] pub async fn spawn_blocking T + Send + 'static, T: Send + 'static>(f: F) -> T { tokio::task::spawn_blocking(f) .await .expect("task was not aborted") } #[cfg(not(feature = "tokio"))] pub fn spawn_blocking_detached T + Send + 'static, T: Send + 'static>(f: F) { blocking::unblock(f).detach() } #[cfg(feature = "tokio")] pub fn spawn_blocking_detached T + Send + 'static, T: Send + 'static>(f: F) { tokio::task::spawn_blocking(f); } #[cfg(not(feature = "tokio"))] pub type AsyncMutex = async_lock::Mutex; #[cfg(not(feature = "tokio"))] pub const fn new_async_mutex(t: T) -> AsyncMutex { AsyncMutex::new(t) } #[cfg(feature = "tokio")] pub type AsyncMutex = tokio::sync::Mutex; #[cfg(feature = "tokio")] pub const fn new_async_mutex(t: T) -> AsyncMutex { AsyncMutex::const_new(t) } #[cfg(not(feature = "tokio"))] pub async fn read_dir>( path: P, ) -> Result< impl Stream>>, Box, > { Ok(async_fs::read_dir(path) .await? .map(|result| result.map(|entry| entry.path()).map_err(Into::into))) } #[cfg(feature = "tokio")] pub async fn read_dir>( path: P, ) -> Result< impl Stream>>, Box, > { let read_dir = tokio::fs::read_dir(path).await?; Ok(tokio_stream::wrappers::ReadDirStream::new(read_dir) .map(|result| result.map(|entry| entry.path()).map_err(Into::into))) } #[cfg(not(feature = "tokio"))] pub use async_fs::read; #[cfg(feature = "tokio")] pub use tokio::fs::read; #[cfg(not(feature = "tokio"))] pub async fn sleep(duration: std::time::Duration) { futures_timer::Delay::new(duration).await } #[cfg(feature = "tokio")] pub use tokio::time::sleep;