Merge lp:~chipaca/ubuntuone-client/connect-on-startup-maybe into lp:ubuntuone-client

Proposed by John Lenton
Status: Merged
Approved by: dobey
Approved revision: 467
Merged at revision: not available
Proposed branch: lp:~chipaca/ubuntuone-client/connect-on-startup-maybe
Merge into: lp:ubuntuone-client
Diff against target: 151 lines (+98/-0)
5 files modified
Makefile.am (+1/-0)
bin/ubuntuone-launch (+78/-0)
data/Makefile.am (+6/-0)
data/oauth_registration.d/ubuntuone (+6/-0)
data/ubuntuone-launch.desktop.in (+7/-0)
To merge this branch: bzr merge lp:~chipaca/ubuntuone-client/connect-on-startup-maybe
Reviewer Review Type Date Requested Status
dobey (community) Approve
Joshua Hoover (community) ran branch and verified functionality Approve
Review via email: mp+22542@code.launchpad.net

Commit message

Add autostart wrapper for Ubuntu One start-up on log-in

Description of the change

This adds ubuntuone-launch, the fabled, mythical, connect-my-ubuntuone-on-startup helper.

To post a comment you must log in.
Revision history for this message
dobey (dobey) wrote :

Personally, I would avoid using twisted here, as there's no need for it. The glib main loop would suffice.

However, given that the script is poking at the keyring, you should also add the necessary bits to the data files, so that it gets added to the keyring acl when a token is gotten, to avoid popping up the keyring access when the user logs in. But once the keyring acls data is updated here, I'll approve. :)

review: Needs Fixing
Revision history for this message
John Lenton (chipaca) wrote :

On Wed, Mar 31, 2010 at 03:20:09PM -0000, Rodney Dawes wrote:
> Review: Needs Fixing
> Personally, I would avoid using twisted here, as there's no need for it. The glib main loop would suffice.
>
> However, given that the script is poking at the keyring, you should also add the necessary bits to the data files, so that it gets added to the keyring acl when a token is gotten, to avoid popping up the keyring access when the user logs in. But once the keyring acls data is updated here, I'll approve. :)

fixed, I think :)

465. By John Lenton

fixes as per dobey

466. By John Lenton

added the directory check straight into the .desktop file

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
dobey (dobey) wrote :

Oh. Also, the ubuntuone-launch.desktop.in should have Icon=ubuntuone added to it. :)

review: Needs Fixing
467. By John Lenton

added an icon to the .desktop file

Revision history for this message
Joshua Hoover (joshuahoover) wrote :

Approved. Removed ubuntuone-* packages and then installed John's branch (copying bin/ubuntuone-syncdaemon to /usr/libexec/). Restarted and waited 30 seconds. Ran u1sdtool -s and saw I was connected and syncdaemon was doing its thing. Also did the same test without a u1 token and got the expected results: nothing happens. :)

review: Approve (ran branch and verified functionality)
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Nicola Larosa (teknico) wrote :

I don't know much about the client's architecture, just a couple Twisted-related comments.

1) Nothing seems to involve Twisted's reactor, are deferreds going to work even without it?

2) I'm not familiar with the idiom of firing a deferred *before* hooking up callbacks and errbacks. It might work, but then why use deferreds at all?

I must be missing something. :-)

468. By John Lenton

and a blank Comment line to make gnome-session-properties prettier

Revision history for this message
Guillermo Gonzalez (verterok) wrote :

Hi,

Nicola,

Deferreds should work without the reactor, and in this case the deferred callback/errback is triggered by a dbus reply/error handler.

John,
/me really likes the inlineCallbacks version

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2010-02-04 23:47:35 +0000
3+++ Makefile.am 2010-03-31 18:09:30 +0000
4@@ -19,6 +19,7 @@
5 # Install our scripts and extra data here
6 bin_SCRIPTS = \
7 bin/ubuntuone-preferences \
8+ bin/ubuntuone-launch \
9 bin/u1sdtool \
10 bin/u1sync
11
12
13=== added file 'bin/ubuntuone-launch'
14--- bin/ubuntuone-launch 1970-01-01 00:00:00 +0000
15+++ bin/ubuntuone-launch 2010-03-31 18:09:30 +0000
16@@ -0,0 +1,78 @@
17+#!/usr/bin/python
18+
19+# ubuntuone-start - Ubuntu One storage synchronization daemon startup helper
20+#
21+# Author: John Lenton <john.lenton@canonical.com>
22+#
23+# Copyright 2010 Canonical Ltd.
24+#
25+# This program is free software: you can redistribute it and/or modify it
26+# under the terms of the GNU General Public License version 3, as published
27+# by the Free Software Foundation.
28+#
29+# This program is distributed in the hope that it will be useful, but
30+# WITHOUT ANY WARRANTY; without even the implied warranties of
31+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
32+# PURPOSE. See the GNU General Public License for more details.
33+#
34+# You should have received a copy of the GNU General Public License along
35+# with this program. If not, see <http://www.gnu.org/licenses/>.
36+
37+import sys
38+import os
39+
40+U1ROOT=os.path.expanduser('~/Ubuntu One/')
41+
42+if __name__ == '__main__':
43+ # this check is done early to speed up startup on people who are not
44+ # (yet) using the service (this way avoids all the imports).
45+ if not os.path.isdir(U1ROOT):
46+ # no directory, just quit
47+ sys.exit(1)
48+
49+import dbus
50+import glib
51+import gobject
52+import gnomekeyring
53+from dbus.mainloop.glib import DBusGMainLoop
54+from ubuntuone.syncdaemon.tools import SyncDaemonTool, is_running
55+from twisted.internet import defer
56+
57+def stage_two(node, sync_daemon_tool):
58+ """do the last few checks and ask for a connect if all is ok"""
59+ d = None
60+ if node['node_id'] is not None:
61+ items = gnomekeyring.find_items_sync(
62+ gnomekeyring.ITEM_GENERIC_SECRET,
63+ {'ubuntuone-realm': 'https://ubuntuone.com'})
64+ if items:
65+ d = sync_daemon_tool.connect()
66+ if d is None:
67+ d = defer.fail(RuntimeError("bad node"))
68+ return d
69+
70+def main():
71+ """Start syncdaemon and ask it to connect, if possible."""
72+ gobject.set_application_name("ubuntuone-launch")
73+ loop = DBusGMainLoop(set_as_default=True)
74+ bus = dbus.SessionBus(mainloop=loop)
75+ sync_daemon_tool = SyncDaemonTool(bus)
76+
77+ if not is_running():
78+ try:
79+ d = sync_daemon_tool.start()
80+ except dbus.exception.DBusException, e:
81+ d = defer.fail(e)
82+ else:
83+ d = defer.succeed(True)
84+
85+ d.addCallback(lambda _: sync_daemon_tool.get_metadata(U1ROOT))
86+ d.addCallback(stage_two, sync_daemon_tool)
87+ # os._exit feels like it's cheating, but it's simple and fast
88+ d.addCallbacks(lambda _: os._exit(0), lambda _: os._exit(1))
89+
90+ mainloop = glib.MainLoop()
91+ mainloop.run()
92+
93+if __name__ == '__main__':
94+ main()
95
96=== modified file 'data/Makefile.am'
97--- data/Makefile.am 2010-02-17 17:42:26 +0000
98+++ data/Makefile.am 2010-03-31 18:09:30 +0000
99@@ -23,6 +23,10 @@
100 desktop_in_files = ubuntuone-preferences.desktop.in
101 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
102
103+autostartdir = $(sysconfdir)/xdg/autostart
104+autostart_in_files = ubuntuone-launch.desktop.in
105+autostart_DATA = $(autostart_in_files:.desktop.in=.desktop)
106+
107 @INTLTOOL_DESKTOP_RULE@
108
109 %.conf: %.conf.in
110@@ -132,6 +136,7 @@
111 $(config_in_files) \
112 $(memenu_in_files) \
113 $(desktop_in_files) \
114+ $(autostart_in_files) \
115 $(service_in_files) \
116 $(emblem_in_files) \
117 $(icon_in_files) \
118@@ -144,6 +149,7 @@
119 CLEANFILES = \
120 $(memenu_DATA) \
121 $(desktop_DATA) \
122+ $(autostart_DATA) \
123 $(service_DATA) \
124 $(emblem_files) \
125 hicolor
126
127=== modified file 'data/oauth_registration.d/ubuntuone'
128--- data/oauth_registration.d/ubuntuone 2010-03-10 21:11:45 +0000
129+++ data/oauth_registration.d/ubuntuone 2010-03-31 18:09:30 +0000
130@@ -15,3 +15,9 @@
131 consumer_key = ubuntuone
132 exe_path = /usr/bin/python
133 application_name = ubuntuone-preferences
134+
135+[launcher]
136+realm = https://ubuntuone.com
137+consumer_key = ubuntuone
138+exe_path = /usr/bin/python
139+application_name = ubuntuone-launch
140
141=== added file 'data/ubuntuone-launch.desktop.in'
142--- data/ubuntuone-launch.desktop.in 1970-01-01 00:00:00 +0000
143+++ data/ubuntuone-launch.desktop.in 2010-03-31 18:09:30 +0000
144@@ -0,0 +1,7 @@
145+[Desktop Entry]
146+Name=Ubuntu One
147+Exec=/bin/sh -c '[ -d "$HOME/Ubuntu One" ] && ubuntuone-launch'
148+Type=Application
149+X-GNOME-Autostart-Delay=30
150+Icon=ubuntuone
151+Comment= 

Subscribers

People subscribed via source and target branches