2013-03-18 01:06:52 +04:00
#
2013-10-28 00:59:46 +04:00
# Copyright 2011, 2013 Red Hat, Inc.
2013-03-18 01:06:52 +04:00
#
2018-04-04 16:35:41 +03:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 22:00:02 +03:00
# See the COPYING file in the top-level directory.
2013-03-18 01:06:52 +04:00
2019-05-13 22:10:38 +03:00
from . char import CharSource
2018-03-20 19:18:35 +03:00
from . device import Device
2019-05-14 18:14:28 +03:00
from . . xmlbuilder import XMLBuilder , XMLChildProperty , XMLProperty
class _Certificate ( XMLBuilder ) :
XML_NAME = " certificate "
value = XMLProperty ( " ./. " )
2013-03-18 01:06:52 +04:00
2013-04-13 22:34:52 +04:00
2018-03-20 19:18:35 +03:00
class DeviceSmartcard ( Device ) :
2018-03-21 17:53:34 +03:00
XML_NAME = " smartcard "
2018-09-02 02:58:24 +03:00
_XML_PROP_ORDER = [ " mode " , " type " ]
2013-03-18 01:06:52 +04:00
2018-09-02 02:58:24 +03:00
mode = XMLProperty ( " ./@mode " )
type = XMLProperty ( " ./@type " )
2019-05-13 22:10:38 +03:00
source = XMLChildProperty ( CharSource , is_single = True )
2013-03-18 01:06:52 +04:00
2019-05-14 18:14:28 +03:00
database = XMLProperty ( " ./database " )
certificates = XMLChildProperty ( _Certificate )
2013-03-18 01:06:52 +04:00
2018-09-02 02:58:24 +03:00
##################
# Default config #
##################
2013-03-18 01:06:52 +04:00
2018-09-02 02:58:24 +03:00
def default_type ( self ) :
return self . mode == " passthrough " and " spicevmc " or " tcp "
2013-03-18 01:06:52 +04:00
2018-09-02 02:58:24 +03:00
def set_defaults ( self , guest ) :
if not self . mode :
self . mode = " passthrough "
if not self . type :
self . type = self . default_type ( )