40
37
def remote(function):
41
38
"""Decorate the function to make the remote call."""
43
def remote_wrapper(*args, **kwargs):
41
def remote_wrapper(self, *args, **kwargs):
44
42
"""Return the deferred for the remote call."""
46
logger.info('Performing %s as a remote call.', function.func_name)
47
return args[0].remote.callRemote(function.func_name, *fixed_args,
43
fname = function.__name__
44
logger.debug('Performing %s as a remote call (%r, %r).',
46
return self.remote.callRemote(fname, *args, **kwargs)
49
48
return remote_wrapper
52
51
def signal(function):
53
52
"""Decorate a function to perform the signal callback."""
55
def callback_wrapper(*args, **kwargs):
55
def callback_wrapper(self, *args, **kwargs):
56
56
"""Return the result of the callback if present."""
57
callback = getattr(args[0], function.func_name + '_cb', None)
57
fname = function.__name__
58
function(self, *args, **kwargs)
59
callback = getattr(self, fname + '_cb', None)
58
60
if callback is not None:
61
return callback(*fixed_args)
62
return callback(*fixed_args, **kwargs)
61
return callback(*args, **kwargs)
63
63
return callback_wrapper
143
143
'on_metaqueue_changed',
146
def __init__(self, remote_status):
147
"""Creates the instance."""
148
super(StatusClient, self).__init__(remote_status)
151
147
def current_status(self):
152
"""Return the current status of the system, one of: local_rescan,
148
"""Return the current status of the system.
150
The status can be one of: local_rescan,
153
151
offline, trying_to_connect, server_rescan or online.
257
255
# calls that will be accessible remotely
258
256
signal_handlers = ['on_root_mismatch', 'on_quota_exceeded']
260
def __init__(self, remote_daemon):
261
"""Creates the instance."""
262
super(SyncDaemonClient, self).__init__(remote_daemon)
265
259
def connect(self):
266
260
"""Connect to the server."""
269
263
def disconnect(self):
270
""" Disconnect from the server. """
264
"""Disconnect from the server."""
273
267
def get_rootdir(self):
274
""" Returns the root dir/mount point. """
268
"""Return the root dir/mount point."""
277
271
def get_sharesdir(self):
278
""" Returns the shares dir/mount point. """
272
"""Return the shares dir/mount point."""
281
275
def get_sharesdir_link(self):
282
""" Returns the shares dir/mount point. """
276
"""Return the shares dir/mount point. """
284
278
@callbacks(callbacks_names=[('reply_handler', 2), ('error_handler', 3)])
286
280
def wait_for_nirvana(self, last_event_interval,
287
281
reply_handler=None, error_handler=None):
288
""" call the reply handler when there are no more
282
"""Call the reply handler when there are no more events/transfers."""
292
@callbacks(callbacks_names=[('reply_handler', 1), ('error_handler', 2)])
294
285
def quit(self, reply_handler=None, error_handler=None):
295
""" shutdown the syncdaemon. """
286
"""Shutdown the syncdaemon."""
298
289
def rescan_from_scratch(self, volume_id):
351
338
'on_share_unsubscribe_error',
354
def __init__(self, remote_shares):
355
"""Create the instance."""
356
super(SharesClient, self).__init__(remote_shares)
359
342
def get_shares(self):
360
343
"""Return a list of dicts, each dict represents a share."""
362
@callbacks(callbacks_names=[('reply_handler', 2), ('error_handler', 3)])
364
346
def accept_share(self, share_id, reply_handler=None, error_handler=None):
365
347
"""Accept a share.
441
423
def on_share_answer_response(self, answer_info):
442
"""Emits ShareAnswerResponse signal."""
424
"""Emit ShareAnswerResponse signal."""
445
427
def on_new_share(self, share):
446
"""Emits NewShare signal."""
428
"""Emit NewShare signal."""
449
431
def on_share_subscribed(self, share):
450
"""Emit the ShareSubscribed signal"""
432
"""Emit the ShareSubscribed signal."""
453
435
def on_share_subscribe_error(self, share_id, error):
454
"""Emit the ShareSubscribeError signal"""
436
"""Emit the ShareSubscribeError signal."""
457
439
def on_share_unsubscribed(self, share):
458
"""Emit the ShareUnSubscribed signal"""
440
"""Emit the ShareUnSubscribed signal."""
461
443
def on_share_unsubscribe_error(self, share_id, error):
462
"""Emit the ShareUnSubscribeError signal"""
444
"""Emit the ShareUnSubscribeError signal."""
465
447
class ConfigClient(RemoteClient):
466
448
"""The Syncdaemon config/settings ipc interface. """
468
def __init__(self, remote_config):
469
""" Creates the instance."""
470
super(ConfigClient, self).__init__(remote_config)
472
@callbacks(callbacks_names=[('reply_handler', 1), ('error_handler', 2)])
474
451
def get_throttling_limits(self, reply_handler=None, error_handler=None):
475
452
"""Get the read/write limit from AQ and return a dict.
476
Returns a dict(download=int, upload=int), if int is -1 the value isn't
454
Return a dict(download=int, upload=int), if int is -1 the value isn't
478
The values are bytes/second
456
The values are bytes/second.
481
@callbacks(callbacks_names=[('reply_handler', 3), ('error_handler', 4)])
483
def set_throttling_limits(self, download, upload,
484
reply_handler=None, error_handler=None):
460
def set_throttling_limits(self, download, upload):
485
461
"""Set the read and write limits. The expected values are bytes/sec."""
487
@callbacks(callbacks_names=[('reply_handler', 1), ('error_handler', 2)])
489
def enable_bandwidth_throttling(self, reply_handler=None,
464
def enable_bandwidth_throttling(self):
491
465
"""Enable bandwidth throttling."""
493
@callbacks(callbacks_names=[('reply_handler', 1), ('error_handler', 2)])
495
def disable_bandwidth_throttling(self, reply_handler=None,
468
def disable_bandwidth_throttling(self):
497
469
"""Disable bandwidth throttling."""
499
@callbacks(callbacks_names=[('reply_handler', 1), ('error_handler', 2)])
501
def bandwidth_throttling_enabled(self, reply_handler=None,
503
"""Returns True (actually 1) if bandwidth throttling is enabled and
472
def bandwidth_throttling_enabled(self):
473
"""Return if the bandwidth throttling is enabled."""
508
476
def udf_autosubscribe_enabled(self):
532
500
def set_files_sync_enabled(self, enabled):
533
"""Enable/disable file sync service."""
501
"""Enable/disable file sync service.
536
508
def files_sync_enabled(self):
537
509
"""Return the files_sync_enabled config value."""
512
def enable_files_sync(self):
513
"""Enable the file sync service."""
516
def disable_files_sync(self):
517
"""Disable the file sync service."""
540
520
def autoconnect_enabled(self):
541
521
"""Return the autoconnect config value."""
524
def enable_autoconnect(self):
525
"""Enable the autoconnect config value."""
528
def disable_autoconnect(self):
529
"""Disable the autoconnect config value."""
544
532
def set_autoconnect_enabled(self, enabled):
545
"""Enable syncdaemon autoconnect."""
533
"""Enable syncdaemon autoconnect.
548
540
def show_all_notifications_enabled(self):
670
def on_public_access_changed(self, share_id, node_id, is_public,
655
def on_public_access_changed(self, file_info):
672
656
"""Emit the PublicAccessChanged signal."""
675
def on_public_access_change_error(self, share_id, node_id, error):
659
def on_public_access_change_error(self, file_info, error):
676
660
"""Emit the PublicAccessChangeError signal."""