1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# -*- coding: utf-8 -*-
#
# Copyright 2012 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""The syncdaemon client."""
import warnings
# pylint: disable=E0611
from ubuntuone.platform import tools
# pylint: enable=E0611
from ubuntuone.controlpanel.logger import setup_logging
logger = setup_logging('sd_client')
class SyncDaemonClient(object):
"""An abstraction to SyncDaemonTool."""
def __init__(self):
"""Get a proxy for the SyncDaemonTool."""
self.proxy = tools.SyncDaemonTool()
def get_throttling_limits(self):
"""Get the speed limits from the syncdaemon."""
return self.proxy.get_throttling_limits()
def set_throttling_limits(self, limits):
"""Set the speed limits on the syncdaemon."""
dload = int(limits["download"])
uload = int(limits["upload"])
return self.proxy.set_throttling_limits(dload, uload)
def bandwidth_throttling_enabled(self):
"""Get the state of throttling in the syncdaemon."""
return self.proxy.is_throttling_enabled()
def enable_bandwidth_throttling(self):
"""Enable the speed limits in the syncdaemon."""
return self.proxy.enable_throttling(True)
def disable_bandwidth_throttling(self):
"""Disable the speed limits in the syncdaemon."""
return self.proxy.enable_throttling(False)
def autoconnect_enabled(self):
"""Get the state of autoconnect in the syncdaemon."""
return self.proxy.is_autoconnect_enabled()
def enable_autoconnect(self):
"""Enable autoconnect in the syncdaemon."""
return self.proxy.enable_autoconnect(True)
def disable_autoconnect(self):
"""Disable autoconnect in the syncdaemon."""
return self.proxy.enable_autoconnect(False)
def show_all_notifications_enabled(self):
"""Get the state of show_all_notifications in the syncdaemon."""
return self.proxy.is_show_all_notifications_enabled()
def enable_show_all_notifications(self):
"""Enable show_all_notifications in the syncdaemon."""
return self.proxy.enable_show_all_notifications(True)
def disable_show_all_notifications(self):
"""Disable show_all_notifications in the syncdaemon."""
return self.proxy.enable_show_all_notifications(False)
def share_autosubscribe_enabled(self):
"""Get the state of share_autosubscribe in the syncdaemon."""
return self.proxy.is_share_autosubscribe_enabled()
def enable_share_autosubscribe(self):
"""Enable share_autosubscribe in the syncdaemon."""
return self.proxy.enable_share_autosubscribe(True)
def disable_share_autosubscribe(self):
"""Disable share_autosubscribe in the syncdaemon."""
return self.proxy.enable_share_autosubscribe(False)
def udf_autosubscribe_enabled(self):
"""Get the state of udf_autosubscribe in the syncdaemon."""
return self.proxy.is_udf_autosubscribe_enabled()
def enable_udf_autosubscribe(self):
"""Enable udf_autosubscribe in the syncdaemon."""
return self.proxy.enable_udf_autosubscribe(True)
def disable_udf_autosubscribe(self):
"""Disable udf_autosubscribe in the syncdaemon."""
return self.proxy.enable_udf_autosubscribe(False)
def get_home_dir(self):
"""Retrieve the root information from syncdaemon."""
return self.proxy.get_home_dir()
def get_root_dir(self):
"""Retrieve the root information from syncdaemon."""
return self.proxy.get_root_dir()
def get_shares_dir(self):
"""Retrieve the shares information from syncdaemon."""
return self.proxy.get_shares_dir()
def get_shares_dir_link(self):
"""Retrieve the shares information from syncdaemon."""
return self.proxy.get_shares_dir_link()
def get_folders(self):
"""Retrieve the folders information from syncdaemon."""
return self.proxy.get_folders()
def validate_path(self, path):
"""Validates 'path' to create a new folder through syncdaemon."""
return self.proxy.validate_path(path)
def create_folder(self, path):
"""Create a new folder through syncdaemon."""
return self.proxy.create_folder(path)
def subscribe_folder(self, folder_id):
"""Subscribe to 'folder_id'."""
return self.proxy.subscribe_folder(folder_id)
def unsubscribe_folder(self, folder_id):
"""Unsubscribe 'folder_id'."""
return self.proxy.unsubscribe_folder(folder_id)
def get_shares(self):
"""Retrieve the shares information from syncdaemon."""
return self.proxy.get_shares()
def subscribe_share(self, share_id):
"""Subscribe to 'share_id'."""
return self.proxy.subscribe_share(share_id)
def unsubscribe_share(self, share_id):
"""Unsubscribe 'share_id'."""
return self.proxy.unsubscribe_share(share_id)
def get_current_status(self):
"""Retrieve the current status from syncdaemon."""
return self.proxy.get_status()
def file_sync_enabled(self):
"""Get if file sync service is enabled."""
return self.proxy.is_files_sync_enabled()
def enable_file_sync(self):
"""Enable the file sync service."""
return self.proxy.enable_files_sync(True)
def disable_file_sync(self):
"""Enable the file sync service."""
return self.proxy.enable_files_sync(False)
def files_sync_enabled(self):
"""Get if file sync service is enabled."""
warnings.warn('use file_sync_enabled instead', DeprecationWarning)
return self.file_sync_enabled()
def set_files_sync_enabled(self, enabled):
"""Set the file sync service to be 'enabled'."""
warnings.warn('use {enable/disable}_file_sync instead',
DeprecationWarning)
if enabled:
return self.enable_file_sync()
else:
return self.disable_file_sync()
def connect_file_sync(self):
"""Connect the file sync service."""
return self.proxy.connect()
def disconnect_file_sync(self):
"""Disconnect the file sync service."""
return self.proxy.disconnect()
def start_file_sync(self):
"""Start the file sync service."""
return self.proxy.start()
def stop_file_sync(self):
"""Stop the file sync service."""
return self.proxy.quit()
def set_status_changed_handler(self, handler):
"""Set the status handler function."""
return self.proxy.connect_signal('StatusChanged', handler)
def refresh_volumes(self):
"""Refresh the volumes information from syncdaemon."""
return self.proxy.refresh_volumes()
def sync_menu(self):
"""Get the sync menu data from syncdaemon."""
return self.proxy.sync_menu()
def get_public_files(self):
"""Trigger an action to get the list of public files."""
return self.proxy.get_public_files()
def set_public_files_list_handler(self, handler):
"""Set the public files list handler."""
return self.proxy.connect_signal('PublicFilesList', handler)
def change_public_access(self, path, is_public):
"""Change the access type of the file."""
return self.proxy.change_public_access(path, is_public)
def set_public_access_changed_handler(self, handler):
"""Set the status handler function."""
return self.proxy.connect_signal('PublicAccessChanged', handler)
def set_public_access_change_error_handler(self, handler):
"""Set the status handler function."""
return self.proxy.connect_signal('PublicAccessChangeError', handler)
def search_files(self, pattern):
"""Search for this pattern in the name of u1 files."""
return self.proxy.search_files(pattern)
|