Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Move Domain & Label to package qubesdbus.models
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkin committed Jun 27, 2017
1 parent 48c39d6 commit 3cb36bf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion qubesdbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from __future__ import absolute_import

from .constants import * # pylint: disable=wildcard-import
from .domain import Domain
from .models import Domain, Label
from .domain_manager import DomainManager
from .labels import Labels
from .constants import NAME_PREFIX, PATH_PREFIX, VERSION
Expand Down
2 changes: 1 addition & 1 deletion qubesdbus/domain_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import qubesadmin
import qubesdbus.serialize
from qubesdbus.domain import Domain
from qubesdbus.models import Domain
from qubesdbus.service import ObjectManager, PropertiesObject

import gi # isort:skip
Expand Down
12 changes: 1 addition & 11 deletions qubesdbus/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import qubesadmin
import qubesdbus.serialize
from qubesdbus.service import ObjectManager, PropertiesObject
from qubesdbus.models import Label

import gi # isort:skip
gi.require_version('Gtk', '3.0') # isort:skip
Expand All @@ -50,17 +51,6 @@ def _new_label(self, label_data):
return Label(self.bus, self.bus_name, self.bus_path, label_data)


class Label(PropertiesObject):
''' Represents a qubes label. Its D-Bus object path is
`org/qubes/Labels1/labels/COLORNAME`
'''

def __init__(self, bus, bus_name, bus_path, data):
bus_path = '/'.join([bus_path, 'labels', data['name']])
name = data['name']
super(Label, self).__init__(name, 'org.qubes.Label1', data, bus=bus,
bus_name=bus_name, bus_path=bus_path)


def main(args=None):
''' Main function ''' # pylint: disable=unused-argument
Expand Down
19 changes: 18 additions & 1 deletion qubesdbus/domain.py → qubesdbus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# The Qubes OS Project, https://www.qubes-os.org/
#
# Copyright (C) 2016 Bahtiar `kalkin-` Gadimov <[email protected]>
#
# This program 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 2 of the License, or
Expand All @@ -17,7 +18,12 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''' D-Bus Domain object '''
''' Contains models for D-Bus instances we provide.
Contains the folowing interface implementations:
* *org.qubes.Domain*
* *org.qubes.Label*
'''

from typing import Any, Dict, Union

Expand Down Expand Up @@ -117,3 +123,14 @@ def valid_state_change(cur_state: DBusString, state: DBusString) -> bool:
return True

return False

class Label(qubesdbus.service.PropertiesObject):
''' Represents a qubes label. Its D-Bus object path is
`org/qubes/Labels1/labels/COLORNAME`
'''

def __init__(self, bus, bus_name, bus_path, data):
bus_path = '/'.join([bus_path, 'labels', data['name']])
name = data['name']
super(Label, self).__init__(name, 'org.qubes.Label1', data, bus=bus,
bus_name=bus_name, bus_path=bus_path)

0 comments on commit 3cb36bf

Please sign in to comment.