All checks were successful
buildbot/nix-build .#checks.x86_64-linux.clan-dep-e2fsprogs Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-bash Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-no-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-fakeroot Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-age Build done.
buildbot/nix-build .#checks.x86_64-linux.check-for-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-pytest Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.x86_64-linux.borgbackup Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-test-backup Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-flash-installer Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-iso-installer Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-git Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-openssh Build done.
buildbot/nix-build .#checks.x86_64-linux."clan-dep-python3.11-mypy" Build done.
buildbot/nix-build .#checks.x86_64-linux."clan-dep-python3.11-qemu" Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-rsync Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sops Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sshpass Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-tor Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-zbar Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-without-core Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-nix Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-with-core Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-example-valid Build done.
buildbot/nix-build .#checks.x86_64-linux.container Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.deltachat Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-default Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-ts-api Build done.
buildbot/nix-build .#checks.x86_64-linux.package-default Build done.
buildbot/nix-build .#checks.x86_64-linux.matrix-synapse Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.x86_64-linux.package-editor Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-install-test-ubuntu-22-04 Build done.
buildbot/nix-build .#checks.x86_64-linux.test-backups Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-apk Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-archlinux Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-deb Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-rpm Build done.
buildbot/nix-build .#checks.x86_64-linux.package-impure-checks Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-nix-unit-tests Build done.
buildbot/nix-build .#checks.x86_64-linux.package-deploy-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-moonlight-sunshine-accept Build done.
buildbot/nix-build .#checks.x86_64-linux.package-pending-reviews Build done.
buildbot/nix-build .#checks.x86_64-linux.package-tea-create-pr Build done.
buildbot/nix-build .#checks.x86_64-linux.package-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotier-members Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotierone Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.package-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.renderClanOptions Build done.
buildbot/nix-build .#checks.x86_64-linux.package-function-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.package-merge-after-ci Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.secrets Build done.
buildbot/nix-build .#checks.x86_64-linux.treefmt Build done.
buildbot/nix-build .#checks.x86_64-linux.wayland-proxy-virtwl Build done.
buildbot/nix-build .#checks.x86_64-linux.zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.package-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.syncthing Build done.
checks / checks-impure (pull_request) Successful in 2m19s
buildbot/nix-build .#checks.x86_64-linux.flash Build done.
buildbot/nix-build .#checks.x86_64-linux.test-installation Build done.
buildbot/nix-eval Build done.
107 lines
3.1 KiB
Python
107 lines
3.1 KiB
Python
import logging
|
|
import threading
|
|
from collections.abc import Callable
|
|
from typing import Any, ClassVar, cast
|
|
|
|
import gi
|
|
from clan_cli.clan_uri import ClanURI
|
|
from clan_cli.history.add import HistoryEntry, add_history
|
|
|
|
from clan_app.components.gkvstore import GKVStore
|
|
from clan_app.singletons.use_vms import ClanStore
|
|
|
|
gi.require_version("Gtk", "4.0")
|
|
gi.require_version("Adw", "1")
|
|
from gi.repository import Gio, GLib, GObject
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class JoinValue(GObject.Object):
|
|
__gsignals__: ClassVar = {
|
|
"join_finished": (GObject.SignalFlags.RUN_FIRST, None, []),
|
|
}
|
|
|
|
url: ClanURI
|
|
entry: HistoryEntry | None
|
|
|
|
def _join_finished_task(self) -> bool:
|
|
self.emit("join_finished")
|
|
return GLib.SOURCE_REMOVE
|
|
|
|
def __init__(self, url: ClanURI) -> None:
|
|
super().__init__()
|
|
self.url: ClanURI = url
|
|
self.entry: HistoryEntry | None = None
|
|
|
|
def __join(self) -> None:
|
|
new_entry = add_history(self.url)
|
|
self.entry = new_entry
|
|
GLib.idle_add(self._join_finished_task)
|
|
|
|
def join(self) -> None:
|
|
threading.Thread(target=self.__join).start()
|
|
|
|
|
|
class JoinList:
|
|
"""
|
|
This is a singleton.
|
|
It is initialized with the first call of use()
|
|
"""
|
|
|
|
_instance: "None | JoinList" = None
|
|
list_store: Gio.ListStore
|
|
|
|
# Make sure the VMS class is used as a singleton
|
|
def __init__(self) -> None:
|
|
raise RuntimeError("Call use() instead")
|
|
|
|
@classmethod
|
|
def use(cls: Any) -> "JoinList":
|
|
if cls._instance is None:
|
|
cls._instance = cls.__new__(cls)
|
|
cls.list_store = Gio.ListStore.new(JoinValue)
|
|
|
|
ClanStore.use().register_on_deep_change(cls._instance._rerender_join_list)
|
|
|
|
return cls._instance
|
|
|
|
def _rerender_join_list(
|
|
self, source: GKVStore, position: int, removed: int, added: int
|
|
) -> None:
|
|
self.list_store.items_changed(
|
|
0, self.list_store.get_n_items(), self.list_store.get_n_items()
|
|
)
|
|
|
|
def is_empty(self) -> bool:
|
|
return self.list_store.get_n_items() == 0
|
|
|
|
def push(self, uri: ClanURI, after_join: Callable[[JoinValue], None]) -> None:
|
|
"""
|
|
Add a join request.
|
|
This method can add multiple join requests if called subsequently for each request.
|
|
"""
|
|
|
|
value = JoinValue(uri)
|
|
if value.url.machine.get_id() in [
|
|
cast(JoinValue, item).url.machine.get_id() for item in self.list_store
|
|
]:
|
|
log.info(f"Join request already exists: {value.url}. Ignoring.")
|
|
return
|
|
|
|
value.connect("join_finished", self._on_join_finished)
|
|
value.connect("join_finished", after_join)
|
|
|
|
self.list_store.append(value)
|
|
|
|
def _on_join_finished(self, source: JoinValue) -> None:
|
|
log.info(f"Join finished: {source.url}")
|
|
self.discard(source)
|
|
assert source.entry is not None
|
|
ClanStore.use().push_history_entry(source.entry)
|
|
|
|
def discard(self, value: JoinValue) -> None:
|
|
(has, idx) = self.list_store.find(value)
|
|
if has:
|
|
self.list_store.remove(idx)
|