Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

.vscode/
.idea/
.DS_Store
.DS_Store
15 changes: 15 additions & 0 deletions ui/opensnitch/plugins/list_subscriptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is part of OpenSnitch.
#
# OpenSnitch is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenSnitch 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenSnitch. If not, see <http://www.gnu.org/licenses/>.

57 changes: 57 additions & 0 deletions ui/opensnitch/plugins/list_subscriptions/_annotations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from typing import TYPE_CHECKING, Any, Protocol

if TYPE_CHECKING:
from PyQt6 import QtCore, QtGui, QtWidgets


class RuleOperatorLike(Protocol):
operand: str
data: str | None
list: list["RuleOperatorLike"]


class RuleLike(Protocol):
name: str | None
enabled: bool
operator: RuleOperatorLike


class StatsDialogProto(Protocol):
"""Typed subset of StatsDialog used by the plugin.

actionsButton is injected by uic from stats.ui and otherwise appears
as unknown to static analyzers.
"""

actionsButton: "QtWidgets.QPushButton"

def windowIcon(self) -> "QtGui.QIcon": ...


class RulesEditorDialogProto(Protocol):
"""Typed subset of RulesEditorDialog used by the plugin controllers."""

_old_rule_name: str
buttonBox: "QtWidgets.QDialogButtonBox"
ruleNameEdit: "QtWidgets.QLineEdit"
ruleDescEdit: "QtWidgets.QPlainTextEdit"
nodesCombo: "QtWidgets.QComboBox"
nodeApplyAllCheck: "QtWidgets.QCheckBox"
uidCombo: "QtWidgets.QComboBox"
uidCheck: "QtWidgets.QCheckBox"
enableCheck: "QtWidgets.QCheckBox"
durationCombo: "QtWidgets.QComboBox"
dstListsCheck: "QtWidgets.QCheckBox"
dstListsLine: "QtWidgets.QLineEdit"

def installEventFilter(self, filterObj: "QtCore.QObject") -> None: ...

def hide(self) -> None: ...

def raise_(self) -> None: ...

def activateWindow(self) -> None: ...

def new_rule(self) -> None: ...

def edit_rule(self, records: Any, _addr: str | None = None) -> None: ...
10 changes: 10 additions & 0 deletions ui/opensnitch/plugins/list_subscriptions/_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Runtime compatibility shim for StatsDialog across OpenSnitch versions."""


# Runtime class kept for isinstance checks.
try:
from opensnitch.dialogs.events import StatsDialog
except ImportError:
from opensnitch.dialogs.stats import StatsDialog # type: ignore[assignment]

__all__ = ["StatsDialog"]
Loading