Skip to content

Commit

Permalink
Moved dbus and notifications object to separated files
Browse files Browse the repository at this point in the history
  • Loading branch information
igo95862 committed Feb 7, 2021
1 parent 316c4b0 commit 7b5cd03
Show file tree
Hide file tree
Showing 4 changed files with 273 additions and 219 deletions.
128 changes: 6 additions & 122 deletions src/sdbus/async_proxies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,126 +19,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import annotations

from typing import Any, Dict, List, Optional, Tuple
from .freedesktop import (FreedesktopDbus, FreedesktopNotifications,
NotificationsInterface)

from .._proxies_common import NotificationsHelper
from ..dbus_proxy_async import (DbusInterfaceCommonAsync, dbus_method_async,
dbus_property_async, dbus_signal_async)
from ..sd_bus_internals import SdBus


class FreedesktopDbus(DbusInterfaceCommonAsync,
interface_name='org.freedesktop.DBus'):

def __init__(self, bus: Optional[SdBus] = None):
super().__init__()
self._connect(
'org.freedesktop.DBus',
'/org/freedesktop/DBus',
bus,
)

@dbus_method_async('s', method_name='GetConnectionUnixProcessID')
async def get_connection_pid(self, service_name: str) -> int:
raise NotImplementedError

@dbus_method_async('s', method_name='GetConnectionUnixUser')
async def get_connection_uid(self, service_name: str) -> int:
raise NotImplementedError

@dbus_method_async()
async def get_id(self) -> str:
raise NotImplementedError

@dbus_method_async('s')
async def get_name_owner(self, service_name: str) -> str:
raise NotImplementedError

@dbus_method_async()
async def list_activatable_names(self) -> List[str]:
raise NotImplementedError

@dbus_method_async()
async def list_names(self) -> List[str]:
raise NotImplementedError

@dbus_method_async('s')
async def name_has_owner(self, service_name: str) -> bool:
raise NotImplementedError

@dbus_method_async('su')
async def start_service_by_name(
self,
service_name: str,
flags: int = 0) -> int:
raise NotImplementedError

@dbus_property_async('as')
def features(self) -> List[str]:
raise NotImplementedError

@dbus_property_async('as')
def interfaces(self) -> List[str]:
raise NotImplementedError

@dbus_signal_async()
def name_acquired(self) -> str:
raise NotImplementedError

@dbus_signal_async()
def name_lost(self) -> str:
raise NotImplementedError

@dbus_signal_async()
def name_owner_changed(self) -> Tuple[str, str, str]:
raise NotImplementedError


class NotificationsInterface(
NotificationsHelper,
DbusInterfaceCommonAsync,
interface_name='org.freedesktop.Notifications'):

@dbus_method_async('u')
async def close_notification(self, notif_id: int) -> None:
raise NotImplementedError

@dbus_method_async()
async def get_capabilities(self) -> List[str]:
raise NotImplementedError

@dbus_method_async()
async def get_server_infomation(self) -> Tuple[str, str, str, str]:
raise NotImplementedError

@dbus_method_async("susssasa{sv}i")
async def notify(
self,
app_name: str = '',
replaces_id: int = 0,
app_icon: str = '',
summary: str = '',
body: str = '',
actions: List[str] = [],
hints: Dict[str, Tuple[str, Any]] = {},
expire_timeout: int = -1, ) -> int:

raise NotImplementedError

@dbus_signal_async()
def action_invoked(self) -> Tuple[int, int]:
raise NotImplementedError

@dbus_signal_async()
def notification_closed(self) -> Tuple[int, int]:
raise NotImplementedError


class FreedesktopNotifications(NotificationsInterface):
def __init__(self, bus: Optional[SdBus] = None) -> None:
super().__init__()
self._connect(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
bus,
)
__all__ = [
'FreedesktopDbus', 'FreedesktopNotifications',
'NotificationsInterface',
]
144 changes: 144 additions & 0 deletions src/sdbus/async_proxies/freedesktop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

# Copyright (C) 2020, 2021 igo95862

# This file is part of python-sdbus

# 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
from __future__ import annotations

from typing import Any, Dict, List, Optional, Tuple

from .._proxies_common import NotificationsHelper
from ..dbus_proxy_async import (DbusInterfaceCommonAsync, dbus_method_async,
dbus_property_async, dbus_signal_async)
from ..sd_bus_internals import SdBus


class FreedesktopDbus(DbusInterfaceCommonAsync,
interface_name='org.freedesktop.DBus'):

def __init__(self, bus: Optional[SdBus] = None):
super().__init__()
self._connect(
'org.freedesktop.DBus',
'/org/freedesktop/DBus',
bus,
)

@dbus_method_async('s', method_name='GetConnectionUnixProcessID')
async def get_connection_pid(self, service_name: str) -> int:
raise NotImplementedError

@dbus_method_async('s', method_name='GetConnectionUnixUser')
async def get_connection_uid(self, service_name: str) -> int:
raise NotImplementedError

@dbus_method_async()
async def get_id(self) -> str:
raise NotImplementedError

@dbus_method_async('s')
async def get_name_owner(self, service_name: str) -> str:
raise NotImplementedError

@dbus_method_async()
async def list_activatable_names(self) -> List[str]:
raise NotImplementedError

@dbus_method_async()
async def list_names(self) -> List[str]:
raise NotImplementedError

@dbus_method_async('s')
async def name_has_owner(self, service_name: str) -> bool:
raise NotImplementedError

@dbus_method_async('su')
async def start_service_by_name(
self,
service_name: str,
flags: int = 0) -> int:
raise NotImplementedError

@dbus_property_async('as')
def features(self) -> List[str]:
raise NotImplementedError

@dbus_property_async('as')
def interfaces(self) -> List[str]:
raise NotImplementedError

@dbus_signal_async()
def name_acquired(self) -> str:
raise NotImplementedError

@dbus_signal_async()
def name_lost(self) -> str:
raise NotImplementedError

@dbus_signal_async()
def name_owner_changed(self) -> Tuple[str, str, str]:
raise NotImplementedError


class NotificationsInterface(
NotificationsHelper,
DbusInterfaceCommonAsync,
interface_name='org.freedesktop.Notifications'):

@dbus_method_async('u')
async def close_notification(self, notif_id: int) -> None:
raise NotImplementedError

@dbus_method_async()
async def get_capabilities(self) -> List[str]:
raise NotImplementedError

@dbus_method_async()
async def get_server_infomation(self) -> Tuple[str, str, str, str]:
raise NotImplementedError

@dbus_method_async("susssasa{sv}i")
async def notify(
self,
app_name: str = '',
replaces_id: int = 0,
app_icon: str = '',
summary: str = '',
body: str = '',
actions: List[str] = [],
hints: Dict[str, Tuple[str, Any]] = {},
expire_timeout: int = -1, ) -> int:

raise NotImplementedError

@dbus_signal_async()
def action_invoked(self) -> Tuple[int, int]:
raise NotImplementedError

@dbus_signal_async()
def notification_closed(self) -> Tuple[int, int]:
raise NotImplementedError


class FreedesktopNotifications(NotificationsInterface):
def __init__(self, bus: Optional[SdBus] = None) -> None:
super().__init__()
self._connect(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
bus,
)
101 changes: 4 additions & 97 deletions src/sdbus/proxies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,101 +19,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import annotations

from typing import Any, Dict, List, Optional, Tuple
from .freedesktop import FreedesktopDbus, FreedesktopNotifications

from .._proxies_common import NotificationsHelper
from ..dbus_proxy_sync import DbusInterfaceCommon, dbus_method, dbus_property
from ..sd_bus_internals import SdBus


class FreedesktopDbus(DbusInterfaceCommon,
interface_name='org.freedesktop.DBus'):

def __init__(self, bus: Optional[SdBus] = None):
super().__init__(
'org.freedesktop.DBus',
'/org/freedesktop/DBus',
bus,
)

@dbus_method('s', method_name='GetConnectionUnixProcessID')
def get_connection_pid(self, service_name: str) -> int:
raise NotImplementedError

@dbus_method('s', method_name='GetConnectionUnixUser')
def get_connection_uid(self, service_name: str) -> int:
raise NotImplementedError

@dbus_method()
def get_id(self) -> str:
raise NotImplementedError

@dbus_method('s')
def get_name_owner(self, service_name: str) -> str:
raise NotImplementedError

@dbus_method()
def list_activatable_names(self) -> List[str]:
raise NotImplementedError

@dbus_method()
def list_names(self) -> List[str]:
raise NotImplementedError

@dbus_method('s')
def name_has_owner(self, service_name: str) -> bool:
raise NotImplementedError

@dbus_method('su')
def start_service_by_name(
self,
service_name: str,
flags: int = 0) -> int:
raise NotImplementedError

@dbus_property('as')
def features(self) -> List[str]:
raise NotImplementedError

@dbus_property('as')
def interfaces(self) -> List[str]:
raise NotImplementedError


class FreedesktopNotifications(
NotificationsHelper,
DbusInterfaceCommon,
interface_name='org.freedesktop.Notifications'):

def __init__(self, bus: Optional[SdBus] = None) -> None:
super().__init__(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
bus,
)

@dbus_method('u')
def close_notification(self, notif_id: int) -> None:
raise NotImplementedError

@dbus_method()
def get_capabilities(self) -> List[str]:
raise NotImplementedError

@dbus_method()
def get_server_infomation(self) -> Tuple[str, str, str, str]:
raise NotImplementedError

@dbus_method('susssasa{sv}i')
def notify(
self,
app_name: str = '',
replaces_id: int = 0,
app_icon: str = '',
summary: str = '',
body: str = '',
actions: List[str] = [],
hints: Dict[str, Tuple[str, Any]] = {},
expire_timeout: int = -1, ) -> int:

raise NotImplementedError
__all__ = [
'FreedesktopDbus', 'FreedesktopNotifications'
]

0 comments on commit 7b5cd03

Please sign in to comment.