Merge lp:~nataliabidart/ubuntuone-client/autoconnect into lp:ubuntuone-client
- autoconnect
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||
Approved revision: | 772 | ||||
Merged at revision: | 770 | ||||
Proposed branch: | lp:~nataliabidart/ubuntuone-client/autoconnect | ||||
Merge into: | lp:ubuntuone-client | ||||
Diff against target: |
398 lines (+194/-13) 10 files modified
bin/ubuntuone-preferences (+10/-4) data/syncdaemon.conf (+5/-0) tests/platform/linux/test_dbus.py (+43/-0) tests/syncdaemon/test_config.py (+52/-2) tests/syncdaemon/test_main.py (+36/-3) tests/test_preferences.py (+5/-2) ubuntuone/platform/linux/__init__.py (+15/-1) ubuntuone/platform/linux/dbus_interface.py (+14/-0) ubuntuone/syncdaemon/config.py (+9/-0) ubuntuone/syncdaemon/main.py (+5/-1) |
||||
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-client/autoconnect | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guillermo Gonzalez | Approve | ||
Chad Miller (community) | Approve | ||
Review via email: mp+43385@code.launchpad.net |
Commit message
* Added new config option 'autoconnect' (LP: #688694).
Description of the change
To test, you should:
* quit syncdaemon (u1sdtool -q)
* edit ~/.config/
autoconnect = True
* ./autogen.sh && make
* start syncdaemon from this branch with:
PYTHONPATH=. ./bin/ubuntuone
Monitor syncdaemon status either thru the logs or using u1sdtool and you'll see how it progresses further than READY, reaching QUEUE_MANAGER state.
To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote : | # |
looks good, tests pass.
review:
Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/ubuntuone-preferences' | |||
2 | --- bin/ubuntuone-preferences 2010-11-30 17:53:14 +0000 | |||
3 | +++ bin/ubuntuone-preferences 2010-12-10 22:10:15 +0000 | |||
4 | @@ -123,6 +123,7 @@ | |||
5 | 123 | except DBusException, e: | 123 | except DBusException, e: |
6 | 124 | error_handler(e) | 124 | error_handler(e) |
7 | 125 | 125 | ||
8 | 126 | |||
9 | 126 | def really_do_rest_request(url, method, conn): | 127 | def really_do_rest_request(url, method, conn): |
10 | 127 | """Second-order helper that does the REST request. | 128 | """Second-order helper that does the REST request. |
11 | 128 | 129 | ||
12 | @@ -136,6 +137,7 @@ | |||
13 | 136 | conn.send(result) | 137 | conn.send(result) |
14 | 137 | logger.debug("end really_do_rest_request (%s:%s)", method, url) | 138 | logger.debug("end really_do_rest_request (%s:%s)", method, url) |
15 | 138 | 139 | ||
16 | 140 | |||
17 | 139 | def do_rest_request(proc, conn, callback): | 141 | def do_rest_request(proc, conn, callback): |
18 | 140 | """Helper that handles the REST request.""" | 142 | """Helper that handles the REST request.""" |
19 | 141 | pid = os.getpid() | 143 | pid = os.getpid() |
20 | @@ -149,6 +151,7 @@ | |||
21 | 149 | callback(result) | 151 | callback(result) |
22 | 150 | logger.debug("end do_rest_request (%d)", pid) | 152 | logger.debug("end do_rest_request (%d)", pid) |
23 | 151 | 153 | ||
24 | 154 | |||
25 | 152 | def make_rest_request(url=None, method='GET', callback=None): | 155 | def make_rest_request(url=None, method='GET', callback=None): |
26 | 153 | """Helper that makes an oauth-wrapped REST request.""" | 156 | """Helper that makes an oauth-wrapped REST request.""" |
27 | 154 | logger.debug("make_rest_request (%s:%s)", method, url) | 157 | logger.debug("make_rest_request (%s:%s)", method, url) |
28 | @@ -159,6 +162,7 @@ | |||
29 | 159 | Thread(target=do_rest_request, args=(p, conn1, callback)).start() | 162 | Thread(target=do_rest_request, args=(p, conn1, callback)).start() |
30 | 160 | logger.debug("end make_rest_request (%s:%s)", method, url) | 163 | logger.debug("end make_rest_request (%s:%s)", method, url) |
31 | 161 | 164 | ||
32 | 165 | |||
33 | 162 | class DevicesWidget(gtk.Table): | 166 | class DevicesWidget(gtk.Table): |
34 | 163 | """ | 167 | """ |
35 | 164 | the Devices tab. | 168 | the Devices tab. |
36 | @@ -471,9 +475,9 @@ | |||
37 | 471 | DBUS_CREDENTIALS_PATH, | 475 | DBUS_CREDENTIALS_PATH, |
38 | 472 | follow_name_owner_changes=True) | 476 | follow_name_owner_changes=True) |
39 | 473 | iface = dbus.Interface(client, DBUS_CREDENTIALS_IFACE) | 477 | iface = dbus.Interface(client, DBUS_CREDENTIALS_IFACE) |
43 | 474 | iface.clear_token(clientdefs.APP_NAME, | 478 | iface.clear_credentials(clientdefs.APP_NAME, {}, |
44 | 475 | reply_handler=local_removal_cb, | 479 | reply_handler=local_removal_cb, |
45 | 476 | error_handler=self.error) | 480 | error_handler=self.error) |
46 | 477 | except DBusException, e: | 481 | except DBusException, e: |
47 | 478 | self.error(e) | 482 | self.error(e) |
48 | 479 | 483 | ||
49 | @@ -1054,8 +1058,10 @@ | |||
50 | 1054 | self.present() | 1058 | self.present() |
51 | 1055 | logger.info("Got credentials for %s", app_name) | 1059 | logger.info("Got credentials for %s", app_name) |
52 | 1056 | 1060 | ||
54 | 1057 | def got_credentialserror(self, app_name, message, detailed_error): | 1061 | def got_credentialserror(self, app_name, error_dict): |
55 | 1058 | """Got an error during authentication.""" | 1062 | """Got an error during authentication.""" |
56 | 1063 | message = error_dict.get('error_msg', '') | ||
57 | 1064 | detailed_error = error_dict.get('detailed_error', '') | ||
58 | 1059 | if app_name == clientdefs.APP_NAME: | 1065 | if app_name == clientdefs.APP_NAME: |
59 | 1060 | logger.error("Credentials error for %s: %s - %s" % | 1066 | logger.error("Credentials error for %s: %s - %s" % |
60 | 1061 | (app_name, message, detailed_error)) | 1067 | (app_name, message, detailed_error)) |
61 | 1062 | 1068 | ||
62 | === modified file 'data/syncdaemon.conf' | |||
63 | --- data/syncdaemon.conf 2010-11-12 21:39:37 +0000 | |||
64 | +++ data/syncdaemon.conf 2010-12-10 22:10:15 +0000 | |||
65 | @@ -64,6 +64,11 @@ | |||
66 | 64 | udf_autosubscribe.help = Autosubsribe to new User Defined Folders, 'off' by default. | 64 | udf_autosubscribe.help = Autosubsribe to new User Defined Folders, 'off' by default. |
67 | 65 | (accepted values: 1/0, on/off, true/false and yes/no) | 65 | (accepted values: 1/0, on/off, true/false and yes/no) |
68 | 66 | 66 | ||
69 | 67 | autoconnect.default = True | ||
70 | 68 | autoconnect.parser = bool | ||
71 | 69 | autoconnect.help = Autoconnect the syncdaemon when is ready to start file synchronization against the server, 'on' by default. | ||
72 | 70 | (accepted values: 1/0, on/off, true/false and yes/no) | ||
73 | 71 | |||
74 | 67 | ignore.parser = lines | 72 | ignore.parser = lines |
75 | 68 | ignore.help = The list of (Python, not bash) regexes of the files that | 73 | ignore.help = The list of (Python, not bash) regexes of the files that |
76 | 69 | SD should ignore. | 74 | SD should ignore. |
77 | 70 | 75 | ||
78 | === modified file 'tests/platform/linux/test_dbus.py' | |||
79 | --- tests/platform/linux/test_dbus.py 2010-12-06 21:34:56 +0000 | |||
80 | +++ tests/platform/linux/test_dbus.py 2010-12-10 22:10:15 +0000 | |||
81 | @@ -2425,6 +2425,49 @@ | |||
82 | 2425 | error_handler=self.error_handler) | 2425 | error_handler=self.error_handler) |
83 | 2426 | return d | 2426 | return d |
84 | 2427 | 2427 | ||
85 | 2428 | def test_autoconnect_enabled(self): | ||
86 | 2429 | """Test for Config.autoconnect_enabled.""" | ||
87 | 2430 | client = self.get_client() | ||
88 | 2431 | d = defer.Deferred() | ||
89 | 2432 | |||
90 | 2433 | def reply_handler_disabled(result): | ||
91 | 2434 | """Handle the reply.""" | ||
92 | 2435 | self.assertFalse(result) | ||
93 | 2436 | config.get_user_config().set_autoconnect(not result) | ||
94 | 2437 | d.callback(True) | ||
95 | 2438 | |||
96 | 2439 | def reply_handler_enabled(result): | ||
97 | 2440 | """Handle the reply.""" | ||
98 | 2441 | self.assertTrue(result) | ||
99 | 2442 | config.get_user_config().set_autoconnect(not result) | ||
100 | 2443 | client.call_method('autoconnect_enabled', | ||
101 | 2444 | reply_handler=reply_handler_disabled, | ||
102 | 2445 | error_handler=self.error_handler) | ||
103 | 2446 | |||
104 | 2447 | client.call_method('autoconnect_enabled', | ||
105 | 2448 | reply_handler=reply_handler_enabled, | ||
106 | 2449 | error_handler=self.error_handler) | ||
107 | 2450 | return d | ||
108 | 2451 | |||
109 | 2452 | def test_set_autoconnect_enabled(self): | ||
110 | 2453 | """Test for Config.set_autoconnect_enabled.""" | ||
111 | 2454 | client = self.get_client() | ||
112 | 2455 | d = defer.Deferred() | ||
113 | 2456 | orig = config.get_user_config().get_autoconnect() | ||
114 | 2457 | # restore autoconnect to original value | ||
115 | 2458 | self.addCleanup(lambda: config.get_user_config().set_autoconnect(orig)) | ||
116 | 2459 | |||
117 | 2460 | def reply_handler(_): | ||
118 | 2461 | """Handle the reply.""" | ||
119 | 2462 | self.assertEqual(config.get_user_config().get_autoconnect(), | ||
120 | 2463 | not orig) | ||
121 | 2464 | d.callback(True) | ||
122 | 2465 | |||
123 | 2466 | client.call_method('set_autoconnect_enabled', not orig, | ||
124 | 2467 | reply_handler=reply_handler, | ||
125 | 2468 | error_handler=self.error_handler) | ||
126 | 2469 | return d | ||
127 | 2470 | |||
128 | 2428 | 2471 | ||
129 | 2429 | class DBusOAuthTestCase(BaseTwistedTestCase): | 2472 | class DBusOAuthTestCase(BaseTwistedTestCase): |
130 | 2430 | """Tests the interaction between dbus_interface and ubuntu-sso-client.""" | 2473 | """Tests the interaction between dbus_interface and ubuntu-sso-client.""" |
131 | 2431 | 2474 | ||
132 | === modified file 'tests/syncdaemon/test_config.py' | |||
133 | --- tests/syncdaemon/test_config.py 2010-11-30 17:53:14 +0000 | |||
134 | +++ tests/syncdaemon/test_config.py 2010-12-10 22:10:15 +0000 | |||
135 | @@ -235,7 +235,8 @@ | |||
136 | 235 | 235 | ||
137 | 236 | def test_load_udf_autosubscribe(self): | 236 | def test_load_udf_autosubscribe(self): |
138 | 237 | """Test load/set/override of udf_autosubscribe config value.""" | 237 | """Test load/set/override of udf_autosubscribe config value.""" |
140 | 238 | conf_file = os.path.join(self.test_root, 'test_udf_autosubscribe_config.conf') | 238 | conf_file = os.path.join(self.test_root, |
141 | 239 | 'test_udf_autosubscribe_config.conf') | ||
142 | 239 | # write some throttling values to the config file | 240 | # write some throttling values to the config file |
143 | 240 | with open(conf_file, 'w') as fp: | 241 | with open(conf_file, 'w') as fp: |
144 | 241 | fp.write('[__main__]\n') | 242 | fp.write('[__main__]\n') |
145 | @@ -275,11 +276,60 @@ | |||
146 | 275 | overridden_opts = [('__main__', 'udf_autosubscribe', False)] | 276 | overridden_opts = [('__main__', 'udf_autosubscribe', False)] |
147 | 276 | conf.override_options(overridden_opts) | 277 | conf.override_options(overridden_opts) |
148 | 277 | self.assertFalse(conf.get_udf_autosubscribe()) | 278 | self.assertFalse(conf.get_udf_autosubscribe()) |
150 | 278 | self.assertFalse(conf.get_udf_autosubscribe() == conf_orig.get_udf_autosubscribe()) | 279 | self.assertNotEqual(conf.get_udf_autosubscribe(), |
151 | 280 | conf_orig.get_udf_autosubscribe()) | ||
152 | 279 | conf.save() | 281 | conf.save() |
153 | 280 | conf_1 = config._Config(conf_file) | 282 | conf_1 = config._Config(conf_file) |
154 | 281 | self.assertEquals(True, conf_1.get_udf_autosubscribe()) | 283 | self.assertEquals(True, conf_1.get_udf_autosubscribe()) |
155 | 282 | 284 | ||
156 | 285 | def test_load_autoconnect(self): | ||
157 | 286 | """Test load/set/override of autoconnect config value.""" | ||
158 | 287 | conf_file = os.path.join(self.test_root, | ||
159 | 288 | 'test_autoconnect_config.conf') | ||
160 | 289 | # ensure that autoconnect is True | ||
161 | 290 | with open(conf_file, 'w') as fp: | ||
162 | 291 | fp.write('[__main__]\n') | ||
163 | 292 | fp.write('autoconnect = True\n') | ||
164 | 293 | |||
165 | 294 | # keep a original around | ||
166 | 295 | conf_orig = config._Config(conf_file) | ||
167 | 296 | |||
168 | 297 | # assert default is correct | ||
169 | 298 | self.assertTrue(conf_orig.get_autoconnect(), | ||
170 | 299 | 'autoconnect is True by default.') | ||
171 | 300 | |||
172 | 301 | # load the config | ||
173 | 302 | conf = config._Config(conf_file) | ||
174 | 303 | self.assertTrue(conf.get_autoconnect()) | ||
175 | 304 | |||
176 | 305 | # change it to False | ||
177 | 306 | conf.set_autoconnect(False) | ||
178 | 307 | self.assertFalse(conf.get_autoconnect()) | ||
179 | 308 | |||
180 | 309 | # save, load and check | ||
181 | 310 | conf.save() | ||
182 | 311 | conf_1 = config._Config(conf_file) | ||
183 | 312 | self.assertFalse(conf_1.get_autoconnect()) | ||
184 | 313 | # change it to True | ||
185 | 314 | conf.set_autoconnect(True) | ||
186 | 315 | self.assertTrue(conf.get_autoconnect()) | ||
187 | 316 | # save, load and check | ||
188 | 317 | conf.save() | ||
189 | 318 | conf_1 = config._Config(conf_file) | ||
190 | 319 | self.assertTrue(conf_1.get_autoconnect()) | ||
191 | 320 | |||
192 | 321 | # load the config, check the override of the value | ||
193 | 322 | conf = config._Config(conf_file) | ||
194 | 323 | self.assertTrue(conf.get_autoconnect()) | ||
195 | 324 | overridden_opts = [('__main__', 'autoconnect', False)] | ||
196 | 325 | conf.override_options(overridden_opts) | ||
197 | 326 | self.assertFalse(conf.get_autoconnect()) | ||
198 | 327 | self.assertNotEqual(conf.get_autoconnect(), | ||
199 | 328 | conf_orig.get_autoconnect()) | ||
200 | 329 | conf.save() | ||
201 | 330 | conf_1 = config._Config(conf_file) | ||
202 | 331 | self.assertEquals(True, conf_1.get_autoconnect()) | ||
203 | 332 | |||
204 | 283 | 333 | ||
205 | 284 | class ConfigglueParsersTests(BaseTwistedTestCase): | 334 | class ConfigglueParsersTests(BaseTwistedTestCase): |
206 | 285 | """Tests for our custom configglue parsers""" | 335 | """Tests for our custom configglue parsers""" |
207 | 286 | 336 | ||
208 | === modified file 'tests/syncdaemon/test_main.py' | |||
209 | --- tests/syncdaemon/test_main.py 2010-11-30 17:53:14 +0000 | |||
210 | +++ tests/syncdaemon/test_main.py 2010-12-10 22:10:15 +0000 | |||
211 | @@ -23,9 +23,9 @@ | |||
212 | 23 | 23 | ||
213 | 24 | from twisted.internet import defer, reactor | 24 | from twisted.internet import defer, reactor |
214 | 25 | 25 | ||
216 | 26 | from ubuntuone.syncdaemon.main import Main | 26 | from ubuntuone.syncdaemon import main as main_mod |
217 | 27 | from contrib.testing.testcase import ( | 27 | from contrib.testing.testcase import ( |
219 | 28 | BaseTwistedTestCase, | 28 | BaseTwistedTestCase, FAKED_CREDENTIALS, |
220 | 29 | ) | 29 | ) |
221 | 30 | 30 | ||
222 | 31 | 31 | ||
223 | @@ -56,9 +56,10 @@ | |||
224 | 56 | dns_srv=False, ssl=False, | 56 | dns_srv=False, ssl=False, |
225 | 57 | mark_interval=60, | 57 | mark_interval=60, |
226 | 58 | handshake_timeout=2, | 58 | handshake_timeout=2, |
227 | 59 | oauth_credentials=FAKED_CREDENTIALS, | ||
228 | 59 | glib_loop=DBusGMainLoop(set_as_default=True)) | 60 | glib_loop=DBusGMainLoop(set_as_default=True)) |
229 | 60 | params.update(kwargs) | 61 | params.update(kwargs) |
231 | 61 | m = Main(**params) | 62 | m = main_mod.Main(**params) |
232 | 62 | m.local_rescan = lambda *_: m.event_q.push('SYS_LOCAL_RESCAN_DONE') | 63 | m.local_rescan = lambda *_: m.event_q.push('SYS_LOCAL_RESCAN_DONE') |
233 | 63 | return m | 64 | return m |
234 | 64 | 65 | ||
235 | @@ -172,3 +173,35 @@ | |||
236 | 172 | self.assertTrue(os.path.exists(self.shares)) | 173 | self.assertTrue(os.path.exists(self.shares)) |
237 | 173 | self.assertTrue(os.path.exists(self.root)) | 174 | self.assertTrue(os.path.exists(self.root)) |
238 | 174 | main.shutdown() | 175 | main.shutdown() |
239 | 176 | |||
240 | 177 | def test_connect_if_autoconnect_is_enabled(self): | ||
241 | 178 | """If autoconnect option is enabled, connect the syncdaemon.""" | ||
242 | 179 | user_config = main_mod.config.get_user_config() | ||
243 | 180 | orig = user_config.get_autoconnect() | ||
244 | 181 | user_config.set_autoconnect(True) | ||
245 | 182 | self.addCleanup(lambda: user_config.set_autoconnect(orig)) | ||
246 | 183 | |||
247 | 184 | self.connect_called = False | ||
248 | 185 | self.patch(main_mod.ubuntuone.platform.ExternalInterface, 'connect', | ||
249 | 186 | lambda *a: setattr(self, 'connect_called', True)) | ||
250 | 187 | |||
251 | 188 | main = self.build_main() | ||
252 | 189 | self.addCleanup(lambda: main.shutdown()) | ||
253 | 190 | |||
254 | 191 | self.assertTrue(self.connect_called) | ||
255 | 192 | |||
256 | 193 | def test_dont_connect_if_autoconnect_is_disabled(self): | ||
257 | 194 | """If autoconnect option is disabled, do not connect the syncdaemon.""" | ||
258 | 195 | user_config = main_mod.config.get_user_config() | ||
259 | 196 | orig = user_config.get_autoconnect() | ||
260 | 197 | user_config.set_autoconnect(False) | ||
261 | 198 | self.addCleanup(lambda: user_config.set_autoconnect(orig)) | ||
262 | 199 | |||
263 | 200 | self.connect_called = False | ||
264 | 201 | self.patch(main_mod.ubuntuone.platform.ExternalInterface, 'connect', | ||
265 | 202 | lambda *a: setattr(self, 'connect_called', True)) | ||
266 | 203 | |||
267 | 204 | main = self.build_main() | ||
268 | 205 | self.addCleanup(lambda: main.shutdown()) | ||
269 | 206 | |||
270 | 207 | self.assertFalse(self.connect_called) | ||
271 | 175 | 208 | ||
272 | === modified file 'tests/test_preferences.py' | |||
273 | --- tests/test_preferences.py 2010-11-30 17:53:14 +0000 | |||
274 | +++ tests/test_preferences.py 2010-12-10 22:10:15 +0000 | |||
275 | @@ -561,8 +561,11 @@ | |||
276 | 561 | 561 | ||
277 | 562 | def test_got_credentialserror(self): | 562 | def test_got_credentialserror(self): |
278 | 563 | """Test CredentialsError signal.""" | 563 | """Test CredentialsError signal.""" |
281 | 564 | self.login_handler.got_credentialserror(clientdefs.APP_NAME, "Error", "Detailed error") | 564 | error_dict = {'error_msg': 'Test', 'detailed_error': 'My bad'} |
282 | 565 | self.assertTrue(self.memento.check_error(clientdefs.APP_NAME, "Error", "Detailed error")) | 565 | self.login_handler.got_credentialserror(clientdefs.APP_NAME, |
283 | 566 | error_dict) | ||
284 | 567 | self.assertTrue(self.memento.check_error(clientdefs.APP_NAME, | ||
285 | 568 | *error_dict.values())) | ||
286 | 566 | 569 | ||
287 | 567 | def test_got_authdenied(self): | 570 | def test_got_authdenied(self): |
288 | 568 | """Test AuthorizationDenied signal.""" | 571 | """Test AuthorizationDenied signal.""" |
289 | 569 | 572 | ||
290 | === modified file 'ubuntuone/platform/linux/__init__.py' | |||
291 | --- ubuntuone/platform/linux/__init__.py 2010-12-06 21:34:56 +0000 | |||
292 | +++ ubuntuone/platform/linux/__init__.py 2010-12-10 22:10:15 +0000 | |||
293 | @@ -38,12 +38,15 @@ | |||
294 | 38 | open_file, | 38 | open_file, |
295 | 39 | rename, | 39 | rename, |
296 | 40 | ) | 40 | ) |
298 | 41 | from ubuntuone.platform.linux.vm_helper import create_shares_link, get_udf_path_name, get_udf_path, get_share_path, VMMetadataUpgraderMixIn | 41 | from ubuntuone.platform.linux.vm_helper import (create_shares_link, |
299 | 42 | get_udf_path_name, get_udf_path, get_share_path, VMMetadataUpgraderMixIn) | ||
300 | 42 | from ubuntuone.platform.linux import tools | 43 | from ubuntuone.platform.linux import tools |
301 | 43 | from filesystem_notifications import FilesystemMonitor | 44 | from filesystem_notifications import FilesystemMonitor |
302 | 44 | 45 | ||
303 | 45 | 46 | ||
304 | 46 | class ExternalInterface(object): | 47 | class ExternalInterface(object): |
305 | 48 | """An ExternalInterface implemented with a DBus interface.""" | ||
306 | 49 | |||
307 | 47 | def __init__(self, main, glib_loop=False, broadcast_events=False, | 50 | def __init__(self, main, glib_loop=False, broadcast_events=False, |
308 | 48 | dbus_iface=None): | 51 | dbus_iface=None): |
309 | 49 | # avoid circular dependencies | 52 | # avoid circular dependencies |
310 | @@ -63,8 +66,19 @@ | |||
311 | 63 | self.dbus_iface = dbus_iface | 66 | self.dbus_iface = dbus_iface |
312 | 64 | self.bus = None | 67 | self.bus = None |
313 | 65 | 68 | ||
314 | 69 | def _get_credentials(self): | ||
315 | 70 | return self.dbus_iface.oauth_credentials | ||
316 | 71 | |||
317 | 72 | def _set_credentials(self, credentials): | ||
318 | 73 | self.dbus_iface.oauth_credentials = credentials | ||
319 | 74 | |||
320 | 75 | oauth_credentials = property(fget=_get_credentials, fset=_set_credentials) | ||
321 | 76 | |||
322 | 66 | def change_notification(self): | 77 | def change_notification(self): |
323 | 67 | self.dbus_iface.status.emit_content_queue_changed() | 78 | self.dbus_iface.status.emit_content_queue_changed() |
324 | 68 | 79 | ||
325 | 69 | def shutdown(self, with_restart): | 80 | def shutdown(self, with_restart): |
326 | 70 | self.dbus_iface.shutdown(with_restart) | 81 | self.dbus_iface.shutdown(with_restart) |
327 | 82 | |||
328 | 83 | def connect(self): | ||
329 | 84 | self.dbus_iface.connect() | ||
330 | 71 | 85 | ||
331 | === modified file 'ubuntuone/platform/linux/dbus_interface.py' | |||
332 | --- ubuntuone/platform/linux/dbus_interface.py 2010-12-09 13:38:46 +0000 | |||
333 | +++ ubuntuone/platform/linux/dbus_interface.py 2010-12-10 22:10:15 +0000 | |||
334 | @@ -1474,6 +1474,20 @@ | |||
335 | 1474 | logger.debug('called files_sync_enabled') | 1474 | logger.debug('called files_sync_enabled') |
336 | 1475 | return config.get_user_config().get_files_sync_enabled() | 1475 | return config.get_user_config().get_files_sync_enabled() |
337 | 1476 | 1476 | ||
338 | 1477 | @dbus.service.method(DBUS_IFACE_CONFIG_NAME, | ||
339 | 1478 | in_signature='', out_signature='b') | ||
340 | 1479 | def autoconnect_enabled(self): | ||
341 | 1480 | """Return the autoconnect config value.""" | ||
342 | 1481 | return config.get_user_config().get_autoconnect() | ||
343 | 1482 | |||
344 | 1483 | @dbus.service.method(DBUS_IFACE_CONFIG_NAME, | ||
345 | 1484 | in_signature='b', out_signature='') | ||
346 | 1485 | def set_autoconnect_enabled(self, enabled): | ||
347 | 1486 | """Enable syncdaemon autoconnect.""" | ||
348 | 1487 | user_config = config.get_user_config() | ||
349 | 1488 | user_config.set_autoconnect(enabled) | ||
350 | 1489 | user_config.save() | ||
351 | 1490 | |||
352 | 1477 | 1491 | ||
353 | 1478 | class Folders(DBusExposedObject): | 1492 | class Folders(DBusExposedObject): |
354 | 1479 | """A dbus interface to interact with User Defined Folders""" | 1493 | """A dbus interface to interact with User Defined Folders""" |
355 | 1480 | 1494 | ||
356 | === modified file 'ubuntuone/syncdaemon/config.py' | |||
357 | --- ubuntuone/syncdaemon/config.py 2010-08-11 14:05:23 +0000 | |||
358 | +++ ubuntuone/syncdaemon/config.py 2010-12-10 22:10:15 +0000 | |||
359 | @@ -343,6 +343,15 @@ | |||
360 | 343 | def get_files_sync_enabled(self): | 343 | def get_files_sync_enabled(self): |
361 | 344 | return self.get_parsed(MAIN, 'files_sync_enabled') | 344 | return self.get_parsed(MAIN, 'files_sync_enabled') |
362 | 345 | 345 | ||
363 | 346 | @requires_section(MAIN) | ||
364 | 347 | def set_autoconnect(self, enabled): | ||
365 | 348 | self.set(MAIN, 'autoconnect', str(enabled)) | ||
366 | 349 | |||
367 | 350 | @requires_section(MAIN) | ||
368 | 351 | def get_autoconnect(self): | ||
369 | 352 | return self.get_parsed(MAIN, 'autoconnect') | ||
370 | 353 | |||
371 | 354 | |||
372 | 346 | 355 | ||
373 | 347 | def configglue(fileobj, *filenames, **kwargs): | 356 | def configglue(fileobj, *filenames, **kwargs): |
374 | 348 | """Populate an OptionParser with options and defaults taken from a | 357 | """Populate an OptionParser with options and defaults taken from a |
375 | 349 | 358 | ||
376 | === modified file 'ubuntuone/syncdaemon/main.py' | |||
377 | --- ubuntuone/syncdaemon/main.py 2010-12-06 23:47:32 +0000 | |||
378 | +++ ubuntuone/syncdaemon/main.py 2010-12-10 22:10:15 +0000 | |||
379 | @@ -78,7 +78,7 @@ | |||
380 | 78 | mark_interval=120, broadcast_events=False, handshake_timeout=30, | 78 | mark_interval=120, broadcast_events=False, handshake_timeout=30, |
381 | 79 | shares_symlink_name='Shared With Me', | 79 | shares_symlink_name='Shared With Me', |
382 | 80 | read_limit=None, write_limit=None, throttling_enabled=False, | 80 | read_limit=None, write_limit=None, throttling_enabled=False, |
384 | 81 | ignore_files=None): | 81 | ignore_files=None, oauth_credentials=None): |
385 | 82 | self.root_dir = root_dir | 82 | self.root_dir = root_dir |
386 | 83 | self.shares_dir = shares_dir | 83 | self.shares_dir = shares_dir |
387 | 84 | self.shares_dir_link = os.path.join(self.root_dir, shares_symlink_name) | 84 | self.shares_dir_link = os.path.join(self.root_dir, shares_symlink_name) |
388 | @@ -122,6 +122,10 @@ | |||
389 | 122 | 122 | ||
390 | 123 | self.external = ubuntuone.platform.ExternalInterface( | 123 | self.external = ubuntuone.platform.ExternalInterface( |
391 | 124 | self, glib_loop, broadcast_events) | 124 | self, glib_loop, broadcast_events) |
392 | 125 | self.external.oauth_credentials = oauth_credentials | ||
393 | 126 | if user_config.get_autoconnect(): | ||
394 | 127 | self.external.connect() | ||
395 | 128 | |||
396 | 125 | self.action_q.content_queue.set_change_notification_cb( | 129 | self.action_q.content_queue.set_change_notification_cb( |
397 | 126 | self.external.change_notification) | 130 | self.external.change_notification) |
398 | 127 | self.zg_listener = event_logging.ZeitgeistListener(self.fs, self.vm) | 131 | self.zg_listener = event_logging.ZeitgeistListener(self.fs, self.vm) |
Works for me.