[openpgp] Port to Gtk4

This commit is contained in:
Philipp Hörist
2025-02-08 16:10:31 +01:00
parent 3a5816259c
commit c67e7f341b
19 changed files with 935 additions and 1111 deletions

File diff suppressed because it is too large Load Diff

1
typings/gpg/__init__.py Normal file
View File

@@ -0,0 +1 @@
from .core import Context # noqa: F401

67
typings/gpg/core.pyi Normal file
View File

@@ -0,0 +1,67 @@
from typing import Any
from collections.abc import Iterator
from gpg.results import EncryptResult
from gpg.results import SignResult
class GpgmeWrapper(object): ...
class Context(GpgmeWrapper):
def __init__(
self,
armor: bool = ...,
textmode: bool = ...,
offline: bool = ...,
signers: list[str] = [],
pinentry_mode: str = ...,
protocol: str = ...,
wrapped: Any | None = ...,
home_dir: str | None = ...,
) -> None: ...
def __enter__(self) -> Context: ...
def __exit__(self, type: Any, value: Any, tb: Any) -> bool: ...
def encrypt(
self,
plaintext: bytes,
recipients: list[str] = [],
sign: bool = ...,
sink: Any | None = ...,
passphrase: str | None = ...,
always_trust: bool = ...,
add_encrypt_to: bool = ...,
prepare: bool = ...,
expect_sign: bool = ...,
compress: bool = ...,
) -> tuple[bytes, EncryptResult, SignResult]: ...
def decrypt(
self,
ciphertext: bytes,
sink: Any | None = ...,
passphrase: str | None = ...,
verify: bool = ...,
filter_signatures: bool = ...,
) -> tuple[bytes, str, str]: ...
def key_import(self, data: bytes) -> str: ...
def key_export_minimal(self, pattern: Any | None = ...) -> bytes | None: ...
def keylist(
self,
pattern: Any | None = ...,
secret: bool = ...,
mode: str = ...,
source: Any | None = None,
) -> Iterator[Any]: ...
def create_key(
self,
userid: str,
algorithm: str | None = ...,
expires_in: int = ...,
expires: bool = ...,
sign: bool = ...,
encrypt: bool = ...,
certify: bool = ...,
authenticate: bool = ...,
passphrase: str | None = ...,
force: bool = ...,
) -> str: ...
def get_key(self, fpr: str, secret: bool = ...) -> Any | None: ...

36
typings/gpg/errors.pyi Normal file
View File

@@ -0,0 +1,36 @@
from typing import Any
class GpgError(Exception):
error: Any | None
context: str | None
result: Any | None
@property
def code(self) -> int: ...
@property
def code_str(self) -> str: ...
@property
def source(self) -> int: ...
@property
def source_str(self) -> str: ...
class GPGMEError(GpgError):
@property
def message(self) -> str: ...
def getstring(self) -> str: ...
def getcode(self) -> int: ...
def getsource(self) -> int: ...
class KeyNotFound(GPGMEError, KeyError):
keystr: str
class EncryptionError(GpgError): ...
class InvalidRecipients(EncryptionError): ...
class DecryptionError(GpgError): ...
class UnsupportedAlgorithm(DecryptionError): ...
class SigningError(GpgError): ...
class InvalidSigners(SigningError): ...
class VerificationError(GpgError): ...
class BadSignatures(VerificationError): ...
class MissingSignatures(VerificationError): ...

41
typings/gpg/results.pyi Normal file
View File

@@ -0,0 +1,41 @@
from typing import Any
class Result(object): ...
class InvalidKey(Result): ...
class EncryptResult(Result):
invalid_recipients: list[Any]
class Recipient(Result): ...
class DecryptResult(Result):
recipients: Recipient
class NewSignature(Result): ...
class SignResult(Result):
invalid_signers: InvalidKey
signatures: NewSignature
class Notation(Result): ...
class Signature(Result):
_type = dict(wrong_key_usage=bool, chain_model=bool, is_de_vs=bool)
notations: Notation
class VerifyResult(Result):
signatures: Signature
class ImportStatus(Result): ...
class ImportResult(Result):
imports: ImportStatus
class GenkeyResult(Result):
_type = dict(primary=bool, sub=bool)
class KeylistResult(Result):
_type = dict(truncated=bool)
class VFSMountResult(Result): ...
class EngineInfo(Result): ...