Example #1
0
 def __init__(self, main, action_queue):
     """ Creates the instance."""
     super(Config, self).__init__()
     self.syncdaemon_config = SyncdaemonConfig(main, action_queue)
Example #2
0
class Config(object, Referenceable):
    """ The Syncdaemon config/settings ipc interface. """

    __metaclass__ = RemoteMeta

    # calls that will be accessible remotely
    remote_calls = [
        'get_throttling_limits',
        'set_throttling_limits',
        'disable_udf_autosubscribe',
        'enable_udf_autosubscribe',
        'enable_bandwidth_throttling',
        'disable_bandwidth_throttling',
        'bandwidth_throttling_enabled',
        'udf_autosubscribe_enabled',
        'enable_udf_autosubscribe',
        'share_autosubscribe_enabled',
        'enable_share_autosubscribe',
        'disable_share_autosubscribe',
        'set_files_sync_enabled',
        'files_sync_enabled',
        'autoconnect_enabled',
        'set_autoconnect_enabled',
        'show_all_notifications_enabled',
        'enable_show_all_notifications',
        'disable_show_all_notifications'
    ]

    def __init__(self, main, action_queue):
        """ Creates the instance."""
        super(Config, self).__init__()
        self.syncdaemon_config = SyncdaemonConfig(main, action_queue)

    def get_throttling_limits(self, reply_handler=None, error_handler=None):
        """Get the read/write limit from AQ and return a dict.
        Returns a dict(download=int, upload=int), if int is -1 the value isn't
        configured.
        The values are bytes/second
        """
        logger.debug("called get_throttling_limits")
        return self.syncdaemon_config.get_throttling_limits(
            remote_handler(reply_handler), remote_handler(error_handler))

    def set_throttling_limits(self, download, upload,
                         reply_handler=None, error_handler=None):
        """Set the read and write limits. The expected values are bytes/sec."""
        logger.debug("called set_throttling_limits")
        self.syncdaemon_config.set_throttling_limits(download, upload,
            remote_handler(reply_handler), remote_handler(error_handler))

    def enable_bandwidth_throttling(self, reply_handler=None,
                                    error_handler=None):
        """Enable bandwidth throttling."""
        self.syncdaemon_config.enable_bandwidth_throttling(
            remote_handler(reply_handler), remote_handler(error_handler))

    def disable_bandwidth_throttling(self, reply_handler=None,
                                     error_handler=None):
        """Disable bandwidth throttling."""
        self.syncdaemon_config.disable_bandwidth_throttling(
            remote_handler(reply_handler), remote_handler(error_handler))

    def bandwidth_throttling_enabled(self, reply_handler=None,
                                     error_handler=None):
        """Returns True (actually 1) if bandwidth throttling is enabled and
        False (0) otherwise.
        """
        return self.syncdaemon_config.bandwidth_throttling_enabled(
            remote_handler(reply_handler), remote_handler(error_handler))

    def udf_autosubscribe_enabled(self):
        """Return the udf_autosubscribe config value."""
        return self.syncdaemon_config.udf_autosubscribe_enabled()

    def enable_udf_autosubscribe(self):
        """Enable UDF autosubscribe."""
        self.syncdaemon_config.enable_udf_autosubscribe()

    def disable_udf_autosubscribe(self):
        """Enable UDF autosubscribe."""
        self.syncdaemon_config.disable_udf_autosubscribe()

    def share_autosubscribe_enabled(self):
        """Return the share_autosubscribe config value."""
        return self.syncdaemon_config.share_autosubscribe_enabled()

    def enable_share_autosubscribe(self):
        """Enable UDF autosubscribe."""
        self.syncdaemon_config.enable_share_autosubscribe()

    def disable_share_autosubscribe(self):
        """Enable UDF autosubscribe."""
        self.syncdaemon_config.disable_share_autosubscribe()

    def set_files_sync_enabled(self, enabled):
        """Enable/disable file sync service."""
        logger.debug('called set_files_sync_enabled %d', enabled)
        self.syncdaemon_config.set_files_sync_enabled(enabled)

    def files_sync_enabled(self):
        """Return the files_sync_enabled config value."""
        logger.debug('called files_sync_enabled')
        return self.syncdaemon_config.files_sync_enabled()

    def autoconnect_enabled(self):
        """Return the autoconnect config value."""
        return self.syncdaemon_config.autoconnect_enabled()

    def set_autoconnect_enabled(self, enabled):
        """Enable syncdaemon autoconnect."""
        self.syncdaemon_config.set_autoconnect_enabled(enabled)

    def show_all_notifications_enabled(self):
        """Return the show_all_notifications config value."""
        return self.syncdaemon_config.show_all_notifications_enabled()

    def enable_show_all_notifications(self):
        """Enable showing all notifications."""
        self.syncdaemon_config.enable_show_all_notifications()

    def disable_show_all_notifications(self):
        """Disable showing all notifications."""
        self.syncdaemon_config.disable_show_all_notifications()