diff --git a/forgewatch/constants.py b/forgewatch/constants.py new file mode 100644 index 0000000..81cecb8 --- /dev/null +++ b/forgewatch/constants.py @@ -0,0 +1,10 @@ +"""Shared D-Bus constants for the forgewatch daemon. + +These values are used by both the daemon (``dbus_service``) and the +indicator client so that the bus name, object path, and interface name +stay in sync across processes. +""" + +BUS_NAME = "org.forgewatch.Daemon" +OBJECT_PATH = "/org/forgewatch/Daemon" +INTERFACE_NAME = "org.forgewatch.Daemon" diff --git a/forgewatch/dbus_service.py b/forgewatch/dbus_service.py index d393c02..2e33ad2 100644 --- a/forgewatch/dbus_service.py +++ b/forgewatch/dbus_service.py @@ -16,6 +16,8 @@ from dbus_next.aio.message_bus import MessageBus from dbus_next.service import ServiceInterface, method, signal +from .constants import BUS_NAME, INTERFACE_NAME, OBJECT_PATH + if TYPE_CHECKING: from collections.abc import Awaitable, Callable @@ -24,11 +26,6 @@ logger = logging.getLogger(__name__) -# D-Bus naming constants -BUS_NAME = "org.forgewatch.Daemon" -OBJECT_PATH = "/org/forgewatch/Daemon" -INTERFACE_NAME = "org.forgewatch.Daemon" - # --------------------------------------------------------------------------- # Serialisation helpers diff --git a/forgewatch/indicator/client.py b/forgewatch/indicator/client.py index ab6da76..09a7419 100644 --- a/forgewatch/indicator/client.py +++ b/forgewatch/indicator/client.py @@ -17,6 +17,8 @@ from dbus_next.constants import MessageType from dbus_next.errors import DBusError +from forgewatch.constants import BUS_NAME, INTERFACE_NAME, OBJECT_PATH + from .models import DaemonStatus, PRInfo if TYPE_CHECKING: @@ -27,13 +29,6 @@ logger = logging.getLogger(__name__) -# D-Bus coordinates — duplicated from dbus_service.py intentionally -# because the indicator is a separate process and should not import -# daemon internals. -BUS_NAME = "org.forgewatch.Daemon" -OBJECT_PATH = "/org/forgewatch/Daemon" -INTERFACE_NAME = "org.forgewatch.Daemon" - _RECONNECT_INTERVAL_S = 10