1
1
# ubuntuone.platform.linux - linux platform imports
3
# Author: Lucio Torre <lucio.torre@canonical.com>
5
# Copyright 2009 Canonical Ltd.
3
# Copyright 2009-2011 Canonical Ltd.
7
5
# This program is free software: you can redistribute it and/or modify it
8
6
# under the terms of the GNU General Public License version 3, as published
59
from ubuntuone.platform.linux.logger import setup_filesystem_logging, get_filesystem_logger
60
from ubuntuone.platform.linux.filesystem_notifications import FilesystemMonitor
61
from ubuntuone.platform.linux.notification import Notification
64
class ExternalInterface(object):
65
"""An ExternalInterface implemented with a DBus interface."""
67
def __init__(self, main, glib_loop=False, broadcast_events=False,
69
# avoid circular dependencies
71
if dbus_iface is None:
72
from ubuntuone.platform.linux import dbus_interface
74
self.bus = dbus.SessionBus()
76
loop = DBusGMainLoop(set_as_default=True)
77
self.bus = dbus.SessionBus(loop)
79
self.dbus_iface = dbus_interface.DBusInterface(
80
self.bus, main, send_events=broadcast_events)
83
self.dbus_iface = dbus_iface
86
def _get_credentials(self):
87
return self.dbus_iface.oauth_credentials
89
def _set_credentials(self, credentials):
90
self.dbus_iface.oauth_credentials = credentials
92
oauth_credentials = property(fget=_get_credentials, fset=_set_credentials)
94
def shutdown(self, with_restart):
95
self.dbus_iface.shutdown(with_restart)
97
def connect(self, *args, **kwargs):
98
self.dbus_iface.connect(*args, **kwargs)
101
def is_already_running():
102
"""Check if there is another instance registered in DBus."""
103
from ubuntuone.platform.linux import dbus_interface
104
bus = dbus.SessionBus()
105
request = bus.request_name(dbus_interface.DBUS_IFACE_NAME,
106
dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
107
if request == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
108
return defer.succeed(True)
110
return defer.succeed(False)
55
from ubuntuone.platform.linux.logger import (
56
setup_filesystem_logging,
57
get_filesystem_logger,
59
from ubuntuone.platform.linux.filesystem_notifications import (
61
_GeneralINotifyProcessor,
63
from ubuntuone.platform.linux import notification
64
from ubuntuone.platform.linux.dbus_interface import (
65
DBusInterface as ExternalInterface,