Example #1
0
class Notifications(object):
    """
    <node>
        <interface name="org.freedesktop.Notifications">
            <signal name="NotificationClosed">
                <arg direction="out" type="u" name="id"/>
                <arg direction="out" type="u" name="reason"/>
            </signal>
            <signal name="ActionInvoked">
                <arg direction="out" type="u" name="id"/>
                <arg direction="out" type="s" name="action_key"/>
            </signal>
            <method name="Notify">
                <arg direction="out" type="u"/>
                <arg direction="in" type="s" name="app_name"/>
                <arg direction="in" type="u" name="replaces_id"/>
                <arg direction="in" type="s" name="app_icon"/>
                <arg direction="in" type="s" name="summary"/>
                <arg direction="in" type="s" name="body"/>
                <arg direction="in" type="as" name="actions"/>
                <arg direction="in" type="a{sv}" name="hints"/>
                <arg direction="in" type="i" name="timeout"/>
            </method>
            <method name="CloseNotification">
                <arg direction="in" type="u" name="id"/>
            </method>
            <method name="GetCapabilities">
                <arg direction="out" type="as" name="caps"/>
            </method>
            <method name="GetServerInformation">
                <arg direction="out" type="s" name="name"/>
                <arg direction="out" type="s" name="vendor"/>
                <arg direction="out" type="s" name="version"/>
                <arg direction="out" type="s" name="spec_version"/>
            </method>
        </interface>
    </node>
    """

    NotificationClosed = signal()
    ActionInvoked = signal()

    def __init__(self, window):
        self.window = window

    def Notify(self, app_name, replaces_id, app_icon, summary, body, actions, hints, timeout):
        log("Received notification: {} {} {} {} {} {} {} {}".format(app_name, replaces_id, app_icon, summary, body,
                                                                    actions, hints, timeout))
        self.window.show_notification(summary, body, timeout)
        return 4  # chosen by fair dice roll. guaranteed to be random.

    def CloseNotification(self, id):
        pass

    def GetCapabilities(self):
        return []

    def GetServerInformation(self):
        return ("pydbus.examples.notifications_server", "pydbus", "?", "1.1")
Example #2
0
class SystemdTestDaemon(object):
    """
        <node>
            <interface name='us.rbasn.systemd.test'>
                <signal name='signalReceived'>
                    <arg type='s' name='value' direction='out'/>
                </signal>
                <method name='receive_signal'>
                    <arg type='s' name='response' direction='in'/>
                </method>
                <method name='quit'/>
            </interface>
        </node>
    """
    signalReceived = signal()

    def __init__(self):
        pass

    def receive_signal(self, value):
        """adds a drive to the list to ensure its toggle value and other information can be maintained"""
        self.signalReceived(value)

    def quit(self):
        """removes this object from the DBUS connection and exits"""
        loop.quit()
Example #3
0
class Example(object):
    """
	<node>
		<interface name="net.lew21.pydbus.TutorialExample">
			<method name="EchoString">
				<arg type="s" name="a" direction="in"/>
				<arg type="s" name="response" direction="out"/>
			</method>
			<property name="SomeProperty" type="s" access="readwrite">
				<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
			</property>
		</interface>
	</node>
	"""
    def EchoString(self, s):
        """returns whatever is passed to it"""
        return s

    def __init__(self):
        self._someProperty = "initial value"

    @property
    def SomeProperty(self):
        return self._someProperty

    @SomeProperty.setter
    def SomeProperty(self, value):
        self._someProperty = value
        self.PropertiesChanged("net.lew21.pydbus.TutorialExample",
                               {"SomeProperty": self.SomeProperty}, [])

    PropertiesChanged = signal()
Example #4
0
class PladderConnector:
    # Note: methods of this class are called in the separate GLib main
    # loop thread.

    dbus = PLADDER_CONNECTOR_XML

    def __init__(self, db, bus):
        self.db = db
        bus.publish(f"se.raek.PladderConnector.{NETWORK}", self)

    def GetConfig(self):
        return {
            "network": NETWORK,
        }

    def SendMessage(self, channel, text):
        return "Sending is not supported"

    def GetChannels(self):
        return self.db.list_tokens()

    def GetChannelUsers(self, channel):
        token = self.db.get_token(token_name=channel)
        if token:
            return [UNKNOWN_USER]
        else:
            return []

    def TriggerReload(self):
        return False

    ReloadComplete = signal()
Example #5
0
class MyDBUSParent(object):
    """
        <node>
            <interface name='net.lew21.pydbus.ClientServerParent'>
                <method name='Echo'>
                    <arg type='s' name='a' direction='in'/>
                    <arg type='s' name='response' direction='out'/>
                </method>
            </interface>
        </node>
    """
    PropertiesChanged = signal()

    def __init__(self):
        self._someProperty = "Some initial value!"

    @property
    def SomeProperty(self):
        print("Get SomeProperty with value:", self._someProperty)
        return self._someProperty

    @SomeProperty.setter
    def SomeProperty(self, value):
        print("Set SomeProperty to value:", value)
        self._someProperty = value

        # Emit signal: Use the correct object path???
        self.PropertiesChanged.emit("net.lew21.pydbus.ClientServerExample",
                                    {"SomeProperty": self._someProperty}, [])

    def Echo(self, s):
        """Returns whatever is passed to it"""
        print("Echo was called.")
        return s
Example #6
0
class FXManagerAPI(ManagedService):
    """
    <node>
        <interface name='org.chemlab.UChroma.FXManager'>
            <method name='SetFX'>
                <arg direction='in' type='s' name='name' />
                <arg direction='in' type='a{sv}' name='args' />
                <arg direction='out' type='b' name='status' />
            </method>

            <property name='CurrentFX' type='(sa{sv})' access='read'>
                    <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='true' />
            </property>

            <property name='AvailableFX' type='a{sa{sa{sv}}}' access='read' />
        </interface>
    </node>
    """
    def __init__(self, parent):
        super(FXManagerAPI, self).__init__(parent)

        self._fx_manager = self._driver.fx_manager

        self._current_fx = None
        self._available_fx = dbus_prepare({k: v.class_traits() \
                for k, v in self._fx_manager.available_fx.items()})[0]

        self._fx_manager.observe(self._fx_changed, names=['current_fx'])

    def _fx_changed(self, change):
        self._logger.info("Effects changed: %s", change)
        self._current_fx = (change.new[0].lower(),
                            dbus_prepare(change.new[1]._trait_values,
                                         variant=True)[0])
        self.PropertiesChanged('org.chemlab.UChroma.FXManager',
                               {'CurrentFX': self.CurrentFX}, [])

    @property
    def AvailableFX(self):
        return self._available_fx

    @property
    def CurrentFX(self):
        """
        Get the currently active FX and arguments
        """
        if self._current_fx is None:
            return ('disable', {})

        return self._current_fx

    def SetFX(self, name: str, args: dict) -> bool:
        """
        Set the desired FX, with options as a dict.
        """
        return self._fx_manager.activate(name, **args)

    PropertiesChanged = signal()
Example #7
0
class Root(object):  # noqa
    """<!DOCTYPE node PUBLIC
      "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
      "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">

    <node>
    <interface name="org.mpris.MediaPlayer2">
        <property name="CanQuit"                type="b"    access="read"/>
        <property name="Fullscreen"             type="b"    access="readwrite">
            <annotation name="org.mpris.MediaPlayer2.property.optional" value="true"/>
        </property>
        <property name="CanSetFullscreen"       type="b"    access="read">
            <annotation name="org.mpris.MediaPlayer2.property.optional" value="true"/>
        </property>
        <property name="CanRaise"               type="b"    access="read"/>
        <property name="HasTrackList"           type="b"    access="read"/>
        <property name="Identity"               type="s"    access="read"/>
        <property name="DesktopEntry"           type="s"    access="read">
            <annotation name="org.mpris.MediaPlayer2.property.optional" value="true"/>
        </property>
        <property name="SupportedUriSchemes"    type="as" access="read"/>
        <property name="SupportedMimeTypes"     type="as" access="read"/>

        <method name="Raise"/>
        <method name="Quit"/>
    </interface>
    </node>
    """  # noqa

    PropertiesChanged = signal()

    def __init__(self, can_quit=False, can_raise=False,
                 can_set_fullscreen=False, has_tracklist=False,
                 supported_mime_types=None, supported_uri_schemes=None,
                 fullscreen=False, identity="MediaPlayer2", desktop_entry=None,
                 **kwargs):
        super().__init__(**kwargs)
        self.CanQuit = can_quit
        self.CanRaise = can_raise
        self.HasTrackList = has_tracklist
        self.SupportedMimeTypes = (supported_mime_types
                                   if supported_mime_types is not None else [])
        self.SupportedUriSchemes = (supported_uri_schemes
                                    if supported_uri_schemes is not None else [])  # noqa: E501

        self.CanSetFullscreen = can_set_fullscreen
        self.Fullscreen = fullscreen
        self.DesktopEntry = desktop_entry

        self.Identity = identity

    def Raise(self):  # noqa: N802
        pass

    def Quit(self):  # noqa: N802
        if not self.CanQuit:
            return
Example #8
0
class Interface:
    def __init__(self, config, core):
        self.config = config
        self.core = core

    PropertiesChanged = signal()

    def log_trace(self, *args, **kwargs):
        logger.log(TRACE_LOG_LEVEL, *args, **kwargs)
Example #9
0
class LgAvnAudioManagerService(object):
    """
    <?xml version="1.0" encoding="UTF-8" ?>
    <node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">

    <interface name="org.genivi.audiomanager.commandinterface">
        <method name="Connect">
            <arg type="q" name="sourceID" direction="in"/>
            <arg type="q" name="sinkID" direction="in"/>
            <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
            <arg type="q" name="mainConnectionID" direction="out"/>
        </method>
        <method name="Disconnect">
            <arg type="q" name="mainConnectionID" direction="in"/>
            <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
        </method>

        <signal name="MainConnectionStateChanged">
            <arg type="q" name="connectionID" direction="out"/>
            <arg type="n" name="connectionState" direction="out"/>
        </signal>
        <signal name="SourceNotification">
            <arg type="q" name="sourceID" direction="out"/>
            <arg type="n" name="type" direction="out"/> <!-- am_notification_e type; int16_t value; -->
            <arg type="n" name="value" direction="out"/> <!-- am_notification_e type; int16_t value; -->
        </signal>
    </interface>
    </node>
    """

    MainConnectionStateChanged = signal()
    SourceNotification = signal()

    def Connect(self, sourceId, sinkId):
        print("LG AVN DBus Server - method name: Connect, sourceId: " + str(sourceId) + ", sinkId: " + str(sinkId))
        self.MainConnectionStateChanged(1, 1)
        self.SourceNotification(123, 0, 1)
        return (0, 1)

    def Disconnect(self, s):
        print("LG AVN DBus Server - method name: Disconnect" + ", parameters: " + s)
        return (0)
Example #10
0
class MprisInterface(ABC):
    INTERFACE: Final[str] = ROOT_INTERFACE

    PropertiesChanged: Final[signal] = signal()

    def __init__(self,
                 name: str = NAME,
                 adapter: Optional['MprisAdapter'] = None):
        self.name = name
        self.adapter = adapter

    def log_trace(self, *args, **kwargs):
        logging.log(TRACE_LOG_LEVEL, *args, **kwargs)
Example #11
0
class DBusService_XML():
    """
    DBus Service XML definition. 
    type="i" for integer, "s" string, "d" double, "as" list of string data.
    """
    dbus = """
    <node>
        <interface name="{}">
            <signal name="integer_signal">
                <arg type="i"/>
            </signal>
            <method name="echo_string">
                <arg type="s" name="input" direction="in">
                </arg>
                <arg type="s" name="output" direction="out">
                </arg>
            </method>
            <method name="greeting">
                <arg type="s" name="person" direction="in">
                </arg>
            </method>
            <method name="get_time_stamp">
                <arg type="d" name="response" direction="out">
                </arg>
            </method>
            <method name="server_no_args">
            </method>
        </interface>
    </node>
    """.format(BUS)
    integer_signal = signal()

    def echo_string(self, input_string):
        "From Client 4. Echo the string"
        return input_string

    def greeting(self, name):
        "From Cleint 3. Return Hello and the persons name"
        print("From Client 3: Hello {}".format(name))
        return

    def get_time_stamp(self):
        "From Client 2. Return a Unix time. Seconds since epoch"
        return time.time()  # 1511326564.8677926

    def server_no_args(self):
        "From Client 1. No arguments, Server has a message on the console."
        global message_count
        print("From Client 1: This is message {}".format(message_count))
        message_count += 1
        return
Example #12
0
class WallGenDBUSService(object):
    dbus = """
    <node>
    	<interface name="de.thm.mni.mhpp11.WallGen">
    		<signal name="Closed" />
    		<method name="NewWallpaper">
    			<arg direction="in" type="s" name="type"/>
    			<arg direction="in" type="s" name="subredit"/>
    			<arg direction="in" type="s" name="directory"/>
    			<arg direction="in" type="s" name="output"/>
    			<arg direction="in" type="b" name="generate_only"/>
    		</method>
    		<method name="Close" />
    	</interface>
    </node>
    """
    Closed = signal()

    def __init__(self, loop):
        self.loop = loop

    def NewWallpaper(self, type, subreddit, directory, output, generate_only):
        print("Create a new Wallpaper...")
        bus = SessionBus()
        dc = bus.get('org.gnome.Mutter.DisplayConfig')

        if type == 'reddit':
            generator = reddit_generator
            option = subreddit
        else:
            generator = local_generator
            option = directory

        active_monitors = []
        for monitor in dc.GetResources()[1]:
            if monitor[6] > -1:
                active_monitors.append(monitor)
        (max_width, max_height) = get_maximum_resolution(active_monitors)
        with Image(width=max_width, height=max_height) as wallpaper:
            for monitor in active_monitors:
                image = generator.get_image(option,
                                            width=monitor[4],
                                            height=monitor[5])
                wallpaper.composite(image, left=monitor[2], top=monitor[3])
                with wallpaper.convert('png') as converted:
                    save(converted, output, generate_only)

    def Close(self):
        self.Closed()
        self.loop.quit()
Example #13
0
class MyDBUSService(object):
    """
        <node>
            <interface name='org.me.test1'>
                <method name='hello'>
                    <arg type='s' name='response' direction='out' />
                </method>
                <method name='quit' />
                <property name='Who' type='s' access='readwrite'>
                    <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='true'/>
                </property>
                <property name='State' type='s' access='read'>
                    <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='true'/>
                </property>
            </interface>
            <interface name='org.me.test1.swear'>
                <method name='whatsup'>
                    <arg type='s' name='response' direction='out' />
                </method>
            </interface>
        </node>
    """

    def __init__(self):
        self._who = "human"
        self._state = "good"

    def hello(self):
        return "Hello %s!" % self._who

    def quit(self):
        loop.quit()

    def whatsup(self):
        return "@!#$*&@!, %s!" % self._who

    @property
    def State(self):
        return self._state

    @property
    def Who(self):
        return self._who

    @Who.setter
    def Who(self, value):
        self._who = value
        self.PropertiesChanged("org.me.test1", {"Who": self._who}, [])

    PropertiesChanged = signal()
Example #14
0
class CSLEliteWheel(object):
    """
    <node>
      <interface name='org.fanatec.CSLElite.Wheel'>
        <property name="Display" type="i" access="write">
          <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
        </property>   
      </interface>
    </node>
  """
    def __init__(self):
        pass

    @staticmethod
    def get_sysfs(name, device=CSL_ELITE_PS4_WHEELBASE_DEVICE_ID):
        return "%s/%s" % (get_sysfs_base(device), name)

    @staticmethod
    def get_sysfs_rpm(device=CSL_ELITE_PS4_WHEELBASE_DEVICE_ID):
        sysfs_base = get_sysfs_base(device)
        return "%s/leds/0003:0EB7:%s.%s::RPM" % (sysfs_base, device,
                                                 sysfs_base.split(".")[-1])

    @staticmethod
    def set_sysfs_rpm(values, device=CSL_ELITE_PS4_WHEELBASE_DEVICE_ID):
        return list(
            map(
                lambda i: open(
                    '%s%i/brightness' % (CSLEliteWheel.get_sysfs_rpm(
                        device), i[0] + 1), 'w').write('1' if i[1] else '0'),
                enumerate(values)))

    @property
    def Display(self):
        return 0

    @property
    def RPM(self):
        return 0

    @Display.setter
    def Display(self, value):
        return int(open(self.get_sysfs('display'), 'w').write(str(value)))

    @RPM.setter
    def RPM(self, values):
        return set_sysfs_rpm(values)

    PropertiesChanged = signal()
Example #15
0
class DBusService_XML():
    """
    DBus Service XML definition. 
    type="i" for integer, "s" string, "d" double, "as" list of string data.
    """
    dbus = """
    <node>
        <interface name="{}">
            <signal name="integer_signal">
                <arg type="i"/>
            </signal>
        </interface>
    </node>
    """.format(BUS)
    integer_signal = signal()
class IoMenderAuthenticationIface:
    """
<node>
	<interface name="io.mender.Authentication1">
		<method name="GetJwtToken">
			<arg type="s" name="token" direction="out"/>
			<arg type="s" name="server_url" direction="out"/>
		</method>
		<method name="FetchJwtToken">
			<arg type="b" name="success" direction="out"/>
		</method>
        <signal name="JwtTokenStateChange">
			<arg type="s" name="token"/>
			<arg type="s" name="server_url"/>
		</signal>
		<method name="MockSetJwtToken">
			<arg type="s" name="token" direction="in"/>
			<arg type="s" name="server_url" direction="in"/>
		</method>
		<method name="MockSetJwtTokenAndEmitSignal">
			<arg type="s" name="token" direction="in"/>
			<arg type="s" name="server_url" direction="in"/>
		</method>
	</interface>
</node>
	"""
    def __init__(self):
        self.token = ""
        self.server_url = ""

    def GetJwtToken(self):
        return self.token, self.server_url

    def FetchJwtToken(self):
        return True

    JwtTokenStateChange = signal()

    def MockSetJwtToken(self, token, server_url):
        self.token = token
        self.server_url = server_url
        return True

    def MockSetJwtTokenAndEmitSignal(self, token, server_url):
        self.token = token
        self.server_url = server_url
        self.JwtTokenStateChange(self.token, self.server_url)
        return True
Example #17
0
class NotepadDbus(object):
    """
      <node>
        <interface name='soundcraft.utils.notepad.device'>
          <property name='name' type='s' access='read' />
          <property name='fixedRouting' type='a((ss)(ss))' access='read' />
          <property name='routingTarget' type='(ss)' access='read' />
          <property name='sources' type='a{s(ss)}' access='read' />
          <property name='routingSource' type='s' access='readwrite'>
            <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
          </property>
        </interface>
      </node>
    """

    InterfaceName = "soundcraft.utils.notepad.device"

    def __init__(self, dev):
        self._dev = dev

    @property
    def name(self):
        return self._dev.name

    @property
    def fixedRouting(self):
        return self._dev.fixedRouting

    @property
    def routingTarget(self):
        return self._dev.routingTarget

    @property
    def sources(self):
        return self._dev.sources

    @property
    def routingSource(self):
        return self._dev.routingSource

    @routingSource.setter
    def routingSource(self, request):
        self._dev.routingSource = request
        self.PropertiesChanged(
            self.InterfaceName, {"routingSource": self.routingSource}, []
        )

    PropertiesChanged = signal()
Example #18
0
class Server_XML(object):
    """
    Server_XML definition. 
    type='i' for integer, type='d' for double/float, type='s' for string 
    type='ai' for list of 32-bit signed integers, type='as' for string list
    """
    dbus = """
    <node>
        <interface name="org.example.ca.server">
            <signal name="app_signal">
                <arg type='s'/>
            </signal>
        </interface>
    </node>
    """
    app_signal = signal()
class AvnService(object):
    """
    <?xml version="1.0" encoding="UTF-8" ?>
    <node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">

    <interface name="com.ssangyong.AutomotiveProxy.AudioManager">

    <method name="Get">
        <arg name="request" type="s" direction="in"/>
        <arg name="resp_result" type="b" direction="out"/>
        <arg name="resp_data" type="s" direction="out"/>
    </method>
    <method name="Set">
        <arg name="request" type="s" direction="in"/>
        <arg name="resp_result" type="b" direction="out"/>
        <arg name="resp_data" type="s" direction="out"/>
    </method>
    <method name="AddListener">
        <arg name="request" type="s" direction="in"/>
        <arg name="resp_result" type="b" direction="out"/>
        <arg name="resp_data" type="s" direction="out"/>
    </method>

    <signal name="UpdateInfo">
        <arg type="s" name="info"/>
    </signal>

    </interface>
    </node>
    """

    UpdateInfo = signal()

    def Get(self, s):
        print("com.ssangyong.AutomotiveProxy.AudioManager " + "Get : " + s)
        return (True, "{\"Data\":{\"Mute\":false,\"Volume\":1},\"Result\":{\"Message\":\"Success\",\"Status\":true}}")

    def Set(self, s):
        print("com.ssangyong.AutomotiveProxy.AudioManager " + "Set : " + s)
        return "Audio Manager - Set"

    def AddListener(self, s):
        print("com.ssangyong.AutomotiveProxy.AudioManager " + "AddListener : " + s)
        self.UpdateInfo("{\"Cmd\":123,\"Data\":{\"Action\":\"VrStartEvent123\"}}")
        return (True, "{\"Data\":null,\"Result\":{\"Message\":\"TEST Success\",\"Status\":true}}")
Example #20
0
class MyDBUSService(object):
    """
        <node>
            <interface name='net.lew21.pydbus.ClientServerExample'>
                <method name='Echo'>
                    <arg type='s' name='s' direction='in'/>
                    <arg type='s' name='response' direction='out'/>
                </method>
                <method name='Quit'/>
                <property name="SomeProperty" type="s" access="readwrite">
                    <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
                </property>
            </interface>
        </node>
    """

    PropertiesChanged = signal()

    def __init__(self):
        self._someProperty = "Some initial value!"

    @property
    def SomeProperty(self):
        print("Get SomeProperty with value:", self._someProperty)
        return self._someProperty

    @SomeProperty.setter
    def SomeProperty(self, value):
        print("Set SomeProperty to value:", value)
        self._someProperty = value

        # Emit signal.
        self.PropertiesChanged.emit("net.lew21.pydbus.ClientServerExample",
                                    {"SomeProperty": self._someProperty}, [])

    def Echo(self, s):
        """Returns whatever is passed to it"""
        print("Echo was called.")
        return s

    def Quit(self):
        """Removes this object from the DBUS connection and exits"""
        print("Quit was called.")
        loop.quit()
Example #21
0
class LocationService(object):
	"""
		<?xml version="1.0" encoding="UTF-8" ?>
		<node name="/com/ssangyong/AutomotiveProxy/LocationManager" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">

		<interface name="com.ssangyong.AutomotiveProxy.LocationManager">

		<method name="Get">
		   <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
		   <arg name="request" type="s" direction="in"/>
		   <arg name="response" type="s" direction="out"/>
		</method>

		<method name="Set">
			<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
			<arg name="request" type="s" direction="in"/>
			<arg name="response" type="s" direction="out"/>
		</method>

		<method name="AddListener">
		   <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
		   <arg name="request" type="s" direction="in"/>
		   <arg name="response" type="s" direction="out"/>
		</method>

		<signal name="UpdateInfo">
			<arg type="s" name="info"/>
		</signal>

		</interface>
		</node>

	"""
	UpdateInfo = signal()
	def Get(self, s):
		print("com.ssangyong.AutomotiveProxy.LocationManager " + "Get : " + s)
		return "Location Manager - Get"
	def Set(self, s):
		print("com.ssangyong.AutomotiveProxy.LocationManager " + "Set : " + s)
		return "Location Manager - Set"

	def AddListener(self, s):
		print("com.ssangyong.AutomotiveProxy.LocationManager " + "AddListener : " + s)
		return "Location Manager - AddLister"
Example #22
0
class Example(object):
    """
    <node>
        <interface name='com.HACGI.example'>
            //test
            <property name='SomeProperty' type='s' access='readwrite'>
                <annotation
                name='org.freedesktop.DBus.Property.EmitsChangedSignal'
                value='true'/>
            </property>

            <method name='EchoString'>
                <arg type='s' name='a' direction='in'/>
                <arg type='s' name='response' direction='out'/>
            </method>
            <method name='Quit'>
            </method>
        </interface>
    </node>
    """
    def EchoString(self, s):
        """return whatever is passed to it"""
        return s

    def __init__(self):
        self._someProperty = 'initial value'

    @property
    def SomeProperty(self):
        return self._someProperty

    @SomeProperty.setter
    def SomeProperty(self, value):
        self._someProperty = value
        self.PropertiesChanged('com.HACGI.example',
                               {'SomeProperty': self.SomeProperty}, [])

    PropertiesChanged = signal()

    def Quit(self):
        global loop
        loop.quit()
Example #23
0
class TestFakeDbusBluezAdapter():
    dbus = """
       <node>
         <interface name='BluetoothAudioBridge.FakeDbusObject.Adapter1'>
           <method name='StartDiscovery'>
           </method>
           <method name='StopDiscovery'>
           </method>
           <property name="Address" type="s" access="read">
           </property>
         </interface>
       </node>"""

    def StartDiscovery(self):
        """start discovery"""
        print("startDiscovery")
        self.fakes.TestResult = self.fakes.TestResult + 1

    def StopDiscovery(self):
        """stop discovery"""
        print("stopDiscovery")
        self.fakes.TestResult = self.fakes.TestResult + 2

    def __init__(self, fakes):
        self._address = "initial value"
        self.fakes = fakes

    @property
    def Address(self):
        return self._address

    @Address.setter
    def Address(self, value):
        self._address = value
        self.PropertiesChanged("BluetoothAudioBridge.FakeDbusObject.Adapter1",
                               {"Address": self._address}, [])

    PropertiesChanged = signal()
Example #24
0
class Interface(object):
    """
        <node>
            <interface name='com.github.radium226.whistleblower.Whistleblower'>
                <signal name='MessageReceived'>
                    <arg type='s' />
                </signal>
                <method name='SendMessage'>
                    <arg name='keys' type='s' direction='in'/>
                </method>
            </interface>
        </node>
    """

    SERVICE_NAME = "com.github.radium226.Whistleblower"

    MessageReceived = signal()

    def __init__(self, server):
        self.server = server

    def SendMessage(self, text):
        self.server.send_message(text)
Example #25
0
class PladderConnector:
    # Note: methods of this class are called in the separate GLib main
    # loop thread.

    dbus = PLADDER_CONNECTOR_XML

    def __init__(self, bus, config, client):
        self.client = client
        self.config = config
        bus.publish(f"se.raek.PladderConnector.{config.network}", self)

    def GetConfig(self):
        return {
            "network": self.config.network,
            "host": self.config.host,
            "port": str(self.config.port),
            "user": str(self.config.user),
            "application": str(self.config.application),
        }

    def SendMessage(self, channel, text):
        if channel not in self.client.get_channels():
            return f"No such channel: {channel}"
        else:
            self.client.send_message(channel, text)
            return "Message sent."

    def GetChannels(self):
        return self.client.get_channels()

    def GetChannelUsers(self, channel):
        return self.client.get_channel_users(channel)

    def TriggerReload(self):
        return False

    ReloadComplete = signal()
Example #26
0
class CSLElitePedals(object):
    """
    <node>
      <interface name='org.fanatec.CSLElite.Pedals'>
        <property name="Load" type="i" access="readwrite">
          <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
        </property>
        <property name="Rumble" type="i" access="write">
          <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
        </property>        
      </interface>
    </node>
  """
    def __init__(self):
        pass

    @staticmethod
    def get_sysfs(self, name, device=CSL_ELITE_PEDALS_DEVICE_ID):
        return "%s/%s" % (get_sysfs_base(device), name)

    @property
    def Load(self):
        return int(open(self.get_sysfs('load'), 'r').read())

    @Load.setter
    def Load(self, value):
        return int(open(self.get_sysfs('load'), 'w').write(str(value)))

    @property
    def Rumble(self):
        pass

    @Rumble.setter
    def Rumble(self, value):
        return int(open(self.get_sysfs('rumble'), 'w').write(str(value)))

    PropertiesChanged = signal()
Example #27
0
class WallGenDBUSService(object):
    dbus = """
    <node>
    	<interface name="de.thm.mni.mhpp11.WallGen">
    		<signal name="Closed" />
    		<method name="NewWallpaper" />
    		<method name="Close" />
    	</interface>
    </node>
    """
    Closed = signal()

    def __init__(self, loop):
        self.config = Config()
        self.loop = loop

    def NewWallpaper(self, _=None):
        builder = None
        print("Create a new Wallpaper...")
        bus = SessionBus()

        if self.config.type == 'reddit':
            generator = RedditGenerator(self.config.subreddit)
        else:
            generator = LocalGenerator(self.config.directory)

        if self.config.is_gnome():
            builder = GnomeWallpaperBuilder(bus, self.config)
        elif self.config.is_kde():
            builder = KDEWallpaperBuilder(bus, self.config)

        builder.build(generator)

    def Close(self):
        self.Closed()
        self.loop.quit()
Example #28
0
class LgAvnCanService(object):
    """
    <?xml version="1.0" encoding="UTF-8" ?>
    <node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">

    <interface name="com.lge.car.micom.can">
        <method name="TriggerTest"/>

        <signal name="NotifyKeyFrontPannelEvent">
            <arg name="front" direction="out" type="ay"/>
        </signal>
    </interface>
    </node>
    """

    NotifyKeyFrontPannelEvent = signal()

    def TriggerTest(self):
        keyEvent = [0x16, 0x01]
        print(
            "LG AVN Can DBus Server - method name: TriggerTest, key value: " +
            str(keyEvent[0]) + ", type1: " + str(keyEvent[1]))
        self.NotifyKeyFrontPannelEvent(keyEvent)
        pass
Example #29
0
class DBusSignals(object):
    """
    <node>
        <interface name='respeakerd.signal'>
            <signal name='ready'></signal>
            <signal name='connecting'></signal>
            <signal name='on_listen'></signal>
            <signal name='on_think'></signal>
            <signal name='on_speak'></signal>
            <signal name='on_idle'></signal>
        </interface>
    </node>
    """
    ready = signal()
    connecting = signal()
    on_listen = signal()
    on_think = signal()
    on_speak = signal()
    on_idle = signal()
Example #30
0
class Playlists(Interface):
    """
    <node>
      <interface name="org.mpris.MediaPlayer2.Playlists">
        <method name="ActivatePlaylist">
          <arg name="PlaylistId" type="o" direction="in"/>
        </method>
        <method name="GetPlaylists">
          <arg name="Index" type="u" direction="in"/>
          <arg name="MaxCount" type="u" direction="in"/>
          <arg name="Order" type="s" direction="in"/>
          <arg name="ReverseOrder" type="b" direction="in"/>
          <arg name="Playlists" type="a(oss)" direction="out"/>
        </method>
        <signal name="PlaylistChanged">
          <arg name="Playlist" type="oss"/>
        </signal>
        <property name="PlaylistCount" type="u" access="read"/>
        <property name="Orderings" type="as" access="read"/>
        <property name="ActivePlaylist" type="(b(oss))" access="read"/>
      </interface>
    </node>
    """

    INTERFACE = "org.mpris.MediaPlayer2.Playlists"

    def ActivatePlaylist(self, playlist_id):
        logger.debug("%s.ActivatePlaylist(%r) called", self.INTERFACE,
                     playlist_id)
        playlist_uri = get_playlist_uri(playlist_id)
        playlist = self.core.playlists.lookup(playlist_uri).get()
        if playlist and playlist.tracks:
            tl_tracks = self.core.tracklist.add(playlist.tracks).get()
            self.core.playback.play(tlid=tl_tracks[0].tlid).get()

    def GetPlaylists(self, index, max_count, order, reverse):
        logger.debug(
            "%s.GetPlaylists(%r, %r, %r, %r) called",
            self.INTERFACE,
            index,
            max_count,
            order,
            reverse,
        )
        playlists = self.core.playlists.as_list().get()
        if order == "Alphabetical":
            playlists.sort(key=lambda p: p.name, reverse=reverse)
        elif order == "User" and reverse:
            playlists.reverse()
        slice_end = index + max_count
        playlists = playlists[index:slice_end]
        results = [(get_playlist_id(p.uri), p.name, "") for p in playlists]
        return results

    PlaylistChanged = signal()

    @property
    def PlaylistCount(self):
        self.log_trace("Getting %s.PlaylistCount", self.INTERFACE)
        return len(self.core.playlists.as_list().get())

    @property
    def Orderings(self):
        self.log_trace("Getting %s.Orderings", self.INTERFACE)
        return [
            "Alphabetical",  # Order by playlist.name
            "User",  # Don't change order
        ]

    @property
    def ActivePlaylist(self):
        self.log_trace("Getting %s.ActivePlaylist", self.INTERFACE)
        playlist_is_valid = False
        playlist = ("/", "None", "")
        return (playlist_is_valid, playlist)