1
# -*- coding: utf-8 -*-
3
# Authors: Alejandro J. Cura <alecu@canonical.com>
4
# Authors: Natalia B. Bidart <nataliabidart@canonical.com>
6
# Copyright 2010 Canonical Ltd.
8
# This program is free software: you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License version 3, as published
10
# by the Free Software Foundation.
12
# This program is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranties of
14
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
# PURPOSE. See the GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License along
18
# with this program. If not, see <http://www.gnu.org/licenses/>.
20
"""Client to use other DBus services."""
24
from ubuntuone.controlpanel.logger import setup_logging
27
logger = setup_logging('sd_client')
30
def get_syncdaemon_proxy(object_path, dbus_interface):
31
"""Get a DBus proxy for syncdaemon at 'object_path':'dbus_interface'."""
32
logger.debug('get_syncdaemon_proxy: object_path %r, dbus_interface %r',
33
object_path, dbus_interface)
34
bus = dbus.SessionBus()
35
obj = bus.get_object(bus_name='com.ubuntuone.SyncDaemon',
36
object_path=object_path,
37
follow_name_owner_changes=True)
38
proxy = dbus.Interface(object=obj, dbus_interface=dbus_interface)
42
def set_status_changed_handler(handler):
43
"""Connect 'handler' with syncdaemon's StatusChanged signal."""
44
proxy = get_syncdaemon_proxy('/status', 'com.ubuntuone.SyncDaemon.Status')
45
sig = proxy.connect_to_signal('StatusChanged', handler)