Merge lp:~thisfred/ubuntuone-client/fix-server-show into lp:ubuntuone-client

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 892
Merged at revision: 890
Proposed branch: lp:~thisfred/ubuntuone-client/fix-server-show
Merge into: lp:ubuntuone-client
Diff against target: 191 lines (+46/-29)
3 files modified
tests/platform/linux/test_messaging.py (+19/-12)
ubuntuone/platform/linux/messaging.py (+23/-15)
ubuntuone/status/aggregator.py (+4/-2)
To merge this branch: bzr merge lp:~thisfred/ubuntuone-client/fix-server-show
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Alejandro J. Cura (community) Approve
Review via email: mp+50962@code.launchpad.net

Commit message

This adds the correct callback for the server entry in the messaging menu, and calls server.show() only once, rather than every time a message is added.

Description of the change

This adds the correct callback for the server entry in the messaging menu, and calls server.show() only once, rather than every time a message is added.

To post a comment you must log in.
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Working for me as intended

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

This branch fixes the opening of the control panel when clicking in the messaging entry. I still have 2 entries when syncdaemon is not running.

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (31.9 KiB)

The attempt to merge lp:~thisfred/ubuntuone-client/fix-server-show into lp:ubuntuone-client failed. Below is the output from the failed tests.

/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
  testing autoconf2.50... not found.
  testing autoconf... found 2.67
checking for automake >= 1.10...
  testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
  testing libtoolize... found 2.2.6b
checking for intltool >= 0.30...
  testing intltoolize... found 0.41.1
checking for pkg-config >= 0.14.0...
  testing pkg-config... found 0.25
checking for gtk-doc >= 1.0...
  testing gtkdocize... found 1.16
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure --enable-gtk-doc --enable-debug ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent lib...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/platform/linux/test_messaging.py'
--- tests/platform/linux/test_messaging.py 2011-02-08 22:12:36 +0000
+++ tests/platform/linux/test_messaging.py 2011-02-23 23:47:32 +0000
@@ -22,10 +22,10 @@
22"""22"""
2323
2424
25from mocker import Mocker25from mocker import Mocker, ANY
26from twisted.trial.unittest import TestCase26from twisted.trial.unittest import TestCase
2727
28from ubuntuone.platform.linux.messaging import Messaging, hide_message28from ubuntuone.platform.linux.messaging import Messaging, _server_callback
2929
30FAKE_TIME = 12330FAKE_TIME = 123
31FAKE_TIME2 = 45631FAKE_TIME2 = 456
@@ -51,22 +51,24 @@
5151
52 # pylint: disable=R091352 # pylint: disable=R0913
53 def _show_message_setup(self, message_time=None, message_count=None,53 def _show_message_setup(self, message_time=None, message_count=None,
54 icon=None, update_count=None, hide=False):54 icon=None, update_count=None, real_callback=False):
55 """Set up the mocker expectations for show_method."""55 """Set up the mocker expectations for show_method."""
56 indicate = self.mocker.replace("indicate")56 indicate = self.mocker.replace("indicate")
57 mock_server = self.mocker.mock()57 mock_server = self.mocker.mock()
58 indicate.indicate_server_ref_default()58 indicate.indicate_server_ref_default()
59 self.mocker.result(mock_server)59 self.mocker.result(mock_server)
60 mock_server.connect('server-display', _server_callback)
60 mock_server.set_type("message.u1")61 mock_server.set_type("message.u1")
61 mock_server.set_desktop_file(62 mock_server.set_desktop_file(
62 "/usr/share/applications/ubuntuone-control-panel-gtk.desktop")63 "/usr/share/applications/ubuntuone-control-panel-gtk.desktop")
64 mock_server.show()
63 mock_indicator = self.mocker.mock()65 mock_indicator = self.mocker.mock()
64 indicate.Indicator()66 indicate.Indicator()
65 self.mocker.result(mock_indicator)67 self.mocker.result(mock_indicator)
66 mock_indicator.set_property("subtype", "u1")68 mock_indicator.set_property("subtype", "u1")
67 mock_indicator.set_property("name", FAKE_SENDER)69 mock_indicator.set_property("name", FAKE_SENDER)
68 mock_indicator.set_property("sender", FAKE_SENDER)70 mock_indicator.set_property("sender", FAKE_SENDER)
69 mock_indicator.connect("user-display", callback)71 mock_indicator.connect("user-display", ANY)
70 if icon is not None:72 if icon is not None:
71 mock_indicator.set_property_icon("icon", icon)73 mock_indicator.set_property_icon("icon", icon)
72 if message_count is not None:74 if message_count is not None:
@@ -80,15 +82,17 @@
80 else:82 else:
81 mock_indicator.set_property_time("time", message_time)83 mock_indicator.set_property_time("time", message_time)
82 mock_indicator.set_property("draw-attention", "true")84 mock_indicator.set_property("draw-attention", "true")
83 mock_server.show()
84 if update_count:85 if update_count:
85 mock_indicator.get_property("count")86 mock_indicator.get_property("count")
86 self.mocker.result("1200")87 self.mocker.result("1200")
87 mock_indicator.set_property("count", '2500')88 mock_indicator.set_property("count", '2500')
88 if hide:89 mock_indicator.show()
90 if real_callback:
91 open_volumes = self.mocker.replace(
92 "ubuntuone.platform.linux.messaging.open_volumes")
93 open_volumes()
89 mock_indicator.set_property('draw-attention', 'false')94 mock_indicator.set_property('draw-attention', 'false')
90 mock_indicator.hide()95 mock_indicator.hide()
91 mock_indicator.show()
92 self.mocker.replay()96 self.mocker.replay()
93 # pylint: enable=R091397 # pylint: enable=R0913
9498
@@ -124,9 +128,12 @@
124 FAKE_SENDER, callback, message_count=1200)128 FAKE_SENDER, callback, message_count=1200)
125 messaging.update_count(indicator, 1300)129 messaging.update_count(indicator, 1300)
126130
127 def test_hide_message(self):131 def test_callback(self):
128 """On message hide, libnotify receives the proper calls."""132 """When the callback fires, libnotify receives the proper calls."""
129 self._show_message_setup(hide=True)133 self._show_message_setup(real_callback=True)
130 messaging = Messaging()134 messaging = Messaging()
131 mock_indicator = messaging.show_message(FAKE_SENDER, callback)135 mock_indicator = messaging.show_message(FAKE_SENDER)
132 hide_message(mock_indicator)136 self.assertEquals(1, len(messaging.indicators))
137 actual_callback = messaging.create_callback()
138 actual_callback(mock_indicator)
139 self.assertEquals(0, len(messaging.indicators))
133140
=== modified file 'ubuntuone/platform/linux/messaging.py'
--- ubuntuone/platform/linux/messaging.py 2011-02-08 22:12:36 +0000
+++ ubuntuone/platform/linux/messaging.py 2011-02-23 23:47:32 +0000
@@ -36,34 +36,31 @@
36APPLICATION_NAME = 'Ubuntu One Client'36APPLICATION_NAME = 'Ubuntu One Client'
3737
3838
39def hide_message(indicator):
40 """Remove the message once it has been dealt with."""
41 if USE_INDICATE:
42 indicator.set_property("draw-attention", "false")
43 indicator.hide()
44
45
46# pylint: disable=W061339# pylint: disable=W0613
47def open_volumes(the_indicator, message_time=None):40def open_volumes():
48 """Open the control panel to the shares tab."""41 """Open the control panel to the shares tab."""
49 subprocess.Popen(42 subprocess.Popen(
50 ['ubuntuone-control-panel-gtk', '--switch-to', 'volumes'])43 ['ubuntuone-control-panel-gtk', '--switch-to', 'volumes'])
51 hide_message(the_indicator)44
45
46def _server_callback(the_indicator, message_time=None):
47 """Open the control panel to the shares tab."""
48 subprocess.Popen(['ubuntuone-control-panel-gtk'])
52# pylint: enable=W061349# pylint: enable=W0613
5350
5451
55class Messaging(AbstractMessaging):52class Messaging(AbstractMessaging):
56 """Notification of the end user."""53 """Notification of the end user."""
5754
58 def __init__(self, server_callback=None): # pylint: disable=W023155 def __init__(self, server_callback=_server_callback):
59 if USE_INDICATE:56 if USE_INDICATE:
60 self.indicators = {}57 self.indicators = []
61 self.server = indicate.indicate_server_ref_default()58 self.server = indicate.indicate_server_ref_default()
62 if server_callback is not None:59 self.server.connect("server-display", server_callback)
63 self.server.connect("server-display", server_callback)
64 self.server.set_type("message.u1")60 self.server.set_type("message.u1")
65 self.server.set_desktop_file(61 self.server.set_desktop_file(
66 "/usr/share/applications/ubuntuone-control-panel-gtk.desktop")62 "/usr/share/applications/ubuntuone-control-panel-gtk.desktop")
63 self.server.show()
6764
68 # pylint: disable=R091365 # pylint: disable=R0913
69 def show_message(self, sender, callback=None, message_time=None,66 def show_message(self, sender, callback=None, message_time=None,
@@ -76,7 +73,7 @@
76 indicator.set_property("sender", sender)73 indicator.set_property("sender", sender)
7774
78 if callback is None:75 if callback is None:
79 callback = open_volumes76 callback = self.create_callback()
80 indicator.connect("user-display", callback)77 indicator.connect("user-display", callback)
8178
82 if icon is not None:79 if icon is not None:
@@ -88,11 +85,22 @@
88 message_time = time()85 message_time = time()
89 indicator.set_property_time("time", message_time)86 indicator.set_property_time("time", message_time)
90 indicator.set_property("draw-attention", "true")87 indicator.set_property("draw-attention", "true")
91 self.server.show()
92 indicator.show()88 indicator.show()
89 self.indicators.append(indicator)
93 return indicator90 return indicator
94 # pylint: enable=R091391 # pylint: enable=R0913
9592
93 def create_callback(self, ):
94 """Create the callback to be used."""
95
96 def callback(indicator, message_time=None): # pylint: disable=W0613
97 """Callback to be executed when message is clicked."""
98 open_volumes()
99 indicator.set_property("draw-attention", "false")
100 indicator.hide()
101 self.indicators.remove(indicator)
102 return callback
103
96 def update_count(self, indicator, add_count):104 def update_count(self, indicator, add_count):
97 """Update the count for an existing indicator."""105 """Update the count for an existing indicator."""
98 if USE_INDICATE:106 if USE_INDICATE:
99107
=== modified file 'ubuntuone/status/aggregator.py'
--- ubuntuone/status/aggregator.py 2011-02-23 00:11:12 +0000
+++ ubuntuone/status/aggregator.py 2011-02-23 23:47:32 +0000
@@ -30,7 +30,7 @@
30from ubuntuone.logger import basic_formatter, logging30from ubuntuone.logger import basic_formatter, logging
31from ubuntuone.platform import session31from ubuntuone.platform import session
32from ubuntuone.platform.notification import Notification32from ubuntuone.platform.notification import Notification
33from ubuntuone.platform.messaging import Messaging, open_volumes33from ubuntuone.platform.messaging import Messaging
34from ubuntuone.platform.unity import UbuntuOneLauncher34from ubuntuone.platform.unity import UbuntuOneLauncher
3535
36Q_ = lambda string: gettext.dgettext(GETTEXT_PACKAGE, string)36Q_ = lambda string: gettext.dgettext(GETTEXT_PACKAGE, string)
@@ -757,10 +757,12 @@
757 self.notification.send_notification(757 self.notification.send_notification(
758 UBUNTUONE_TITLE, UDFAvailableStatus(udf=udf).one())758 UBUNTUONE_TITLE, UDFAvailableStatus(udf=udf).one())
759759
760 # pylint: disable=W0613
760 def _reset_udf_message_callback(self, indicator, message_time=None):761 def _reset_udf_message_callback(self, indicator, message_time=None):
761 """A callback wrapper that resets the udf_message to None."""762 """A callback wrapper that resets the udf_message to None."""
762 self.udf_message = None763 self.udf_message = None
763 open_volumes(indicator, message_time=message_time)764 self.messaging.create_callback()()
765 # pylint: enable=W0613
764766
765 def server_connection_lost(self):767 def server_connection_lost(self):
766 """The client lost the connection to the server."""768 """The client lost the connection to the server."""

Subscribers

People subscribed via source and target branches