Merge lp:~thisfred/ubuntuone-client/science-fiction-double-feature into lp:ubuntuone-client

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 831
Merged at revision: 831
Proposed branch: lp:~thisfred/ubuntuone-client/science-fiction-double-feature
Merge into: lp:ubuntuone-client
Diff against target: 215 lines (+105/-17)
7 files modified
tests/status/test_aggregator.py (+25/-5)
ubuntuone/platform/linux/messaging.py (+12/-4)
ubuntuone/platform/linux/notification.py (+7/-0)
ubuntuone/platform/windows/messaging.py (+44/-0)
ubuntuone/platform/windows/notification.py (+5/-0)
ubuntuone/status/messaging.py (+6/-4)
ubuntuone/status/notification.py (+6/-4)
To merge this branch: bzr merge lp:~thisfred/ubuntuone-client/science-fiction-double-feature
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Alejandro J. Cura (community) Approve
Review via email: mp+48169@code.launchpad.net

Commit message

- Notifications can now be updated as well as appended to
- Messages can have a count, which can be updated after they are displayed

Description of the change

- Notifications can now be updated as well as appended to
- Messages can have a count, which can be updated after they are displayed

To test these features, put this in a python script, and run it from the root of the branch, (PYTHONPATH=. python /path/to/the/script.py):

from ubuntuone.platform import messaging, notification

n = notification.Notification("Is this thing on?")
mah_notification = n.send_notification("Mon titre", "Ceci, n'est pas updated.")
n.update_notification(
    mah_notification, "New Titles Please", "The updated message. Yay!")

def callback(indicator, message_time=None):
    """Hide the message again."""
    messaging.hide_message(indicator)

m = messaging.Messaging()
m.show_message("mom", callback, message_count=2)
raw_input(
    "The messaging menu should be at alert, with a message that has"
    "count 2. (Don't click it.) Hit enter to continue.")
m.update_count("mom", 5)
raw_input(
    "The messaging menu should be at alert, with a message that has"
    "count 5. Hit enter to continue.")

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

Really like the branch, but I would like to see some tests for the notification and messaging modules.

After discussing this with thisfred, he told me he would be doing said tests in a new branch.

review: Approve
Revision history for this message
Facundo Batista (facundo) wrote :

Ok!

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.

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

The attempt to merge lp:~thisfred/ubuntuone-client/science-fiction-double-feature 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 recogniz...

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

The attempt to merge lp:~thisfred/ubuntuone-client/science-fiction-double-feature 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 recogniz...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/status/test_aggregator.py'
2--- tests/status/test_aggregator.py 2011-01-31 18:11:09 +0000
3+++ tests/status/test_aggregator.py 2011-02-01 19:10:23 +0000
4@@ -25,11 +25,13 @@
5
6 from ubuntuone.devtools.handlers import MementoHandler
7 from ubuntuone.status import aggregator
8+from ubuntuone.status.notification import AbstractNotification
9+
10 from ubuntuone.syncdaemon.status_listener import StatusListener
11 from ubuntuone.syncdaemon.volume_manager import Share, UDF
12
13
14-class FakeNotification(object):
15+class FakeNotification(AbstractNotification):
16 """A fake notification class."""
17
18 def __init__(self, application_name="fake app"):
19@@ -40,19 +42,37 @@
20 def send_notification(self, title, message, icon=None, append=False):
21 """Show a notification to the user."""
22 self.notifications_shown.append((title, message, icon, append))
23+ return len(self.notifications_shown)
24+
25+ def update_notification(self, notification, new_title, new_message,
26+ new_icon=None):
27+ """Update the notification with a new message body."""
28+ title, old_message, icon, append = self.notifications_shown[
29+ notification]
30+ if new_icon is not None:
31+ icon = new_icon
32+ self.notifications_shown[notification] = (
33+ new_title, new_message, icon, append)
34
35
36 class FakeMessaging(object):
37 """A fake messaging class."""
38
39 def __init__(self, application_name="fake app"):
40- self.messages_shown = []
41+ self.messages_shown = {}
42 self.application_name = application_name
43
44- def show_message(self, subtype, sender, body, callback, message_time=None):
45+ def show_message(self, sender, callback, message_time=None,
46+ message_count=None, icon=None):
47 """Show a message to the user."""
48- self.messages_shown.append(
49- (subtype, sender, body, callback, message_time))
50+ self.messages_shown[sender] = (
51+ callback, message_time, message_count, icon)
52+
53+ def update_count(self, sender, new_count):
54+ """Update the count for an existing indicator."""
55+ callback, message_time, _, icon = self.messages_shown[sender]
56+ self.messages_shown[sender] = (
57+ callback, message_time, new_count, icon)
58
59
60 class DelayedBufferTestCase(TestCase):
61
62=== modified file 'ubuntuone/platform/linux/messaging.py'
63--- ubuntuone/platform/linux/messaging.py 2011-01-28 18:50:34 +0000
64+++ ubuntuone/platform/linux/messaging.py 2011-02-01 19:10:23 +0000
65@@ -48,7 +48,8 @@
66 self.server.set_desktop_file(
67 "/usr/share/applications/ubuntuone-control-panel-gtk.desktop")
68
69- def show_message(self, sender, callback, message_time=None, icon=None):
70+ def show_message(self, sender, callback, message_time=None,
71+ message_count=None, icon=None):
72 """Show a message in the messaging menu."""
73 if USE_INDICATE:
74 indicator = self.indicators[sender] = indicate.Indicator()
75@@ -59,13 +60,20 @@
76
77 if icon is not None:
78 indicator.set_property_icon("icon", icon)
79- if message_time is None:
80- message_time = time()
81- indicator.set_property_time("time", message_time)
82+ if message_count is not None:
83+ indicator.set_property("count", str(message_count))
84+ else:
85+ if message_time is None:
86+ message_time = time()
87+ indicator.set_property_time("time", message_time)
88 indicator.set_property("draw-attention", "true")
89 self.server.show()
90 indicator.show()
91
92+ def update_count(self, sender, new_count):
93+ """Update the count for an existing indicator."""
94+ self.indicators[sender].set_property("count", str(new_count))
95+
96
97 def hide_message(indicator):
98 """Remove the message once it has been dealt with."""
99
100=== modified file 'ubuntuone/platform/linux/notification.py'
101--- ubuntuone/platform/linux/notification.py 2011-01-28 16:30:01 +0000
102+++ ubuntuone/platform/linux/notification.py 2011-02-01 19:10:23 +0000
103@@ -49,3 +49,10 @@
104 notification.set_hint_string('append', '')
105 notification.show()
106 return notification
107+
108+ def update_notification(self, notification, new_title, new_message,
109+ new_icon=None):
110+ """Update the notification with a new message body."""
111+ if USE_PYNOTIFY:
112+ notification.update(new_title, new_message, new_icon)
113+ notification.show()
114
115=== added file 'ubuntuone/platform/windows/messaging.py'
116--- ubuntuone/platform/windows/messaging.py 1970-01-01 00:00:00 +0000
117+++ ubuntuone/platform/windows/messaging.py 2011-02-01 19:10:23 +0000
118@@ -0,0 +1,44 @@
119+# ubuntuone.syncdaemon.platform.messaging - Messages to the user
120+#
121+# Author: Eric Casteleijn <eric.casteleijn@canonical.com>
122+#
123+# Copyright 2011 Canonical Ltd.
124+#
125+# This program is free software: you can redistribute it and/or modify it
126+# under the terms of the GNU General Public License version 3, as published
127+# by the Free Software Foundation.
128+#
129+# This program is distributed in the hope that it will be useful, but
130+# WITHOUT ANY WARRANTY; without even the implied warranties of
131+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
132+# PURPOSE. See the GNU General Public License for more details.
133+#
134+# You should have received a copy of the GNU General Public License along
135+# with this program. If not, see <http://www.gnu.org/licenses/>.
136+"""Module that implements sending messages to the end user."""
137+
138+# TODO: We may want to enable different messaging systems. When none
139+# of them are available, we should fall back to silently discarding
140+# messages.
141+
142+from ubuntuone.status.messaging import AbstractMessaging
143+
144+APPLICATION_NAME = 'Ubuntu One Client'
145+
146+
147+class Messaging(AbstractMessaging):
148+ """Notification of the end user."""
149+
150+ def show_message(self, sender, callback, message_time=None,
151+ message_count=None, icon=None):
152+ """Show a message in the messaging menu."""
153+ pass
154+
155+ def update_count(self, sender, new_count):
156+ """Update the count for an existing indicator."""
157+ pass
158+
159+
160+def hide_message(indicator):
161+ """Remove the message once it has been dealt with."""
162+ pass
163
164=== modified file 'ubuntuone/platform/windows/notification.py'
165--- ubuntuone/platform/windows/notification.py 2011-01-18 22:27:02 +0000
166+++ ubuntuone/platform/windows/notification.py 2011-02-01 19:10:23 +0000
167@@ -34,3 +34,8 @@
168 """Send a notification using the underlying library."""
169 # TODO: Send notifications. Dummy class is here to not break
170 # on windows.
171+
172+ def update_notification(self, notification, new_title, new_message,
173+ new_icon=None):
174+ """Update the notification with a new message body."""
175+
176
177=== modified file 'ubuntuone/status/messaging.py'
178--- ubuntuone/status/messaging.py 2011-01-26 23:30:46 +0000
179+++ ubuntuone/status/messaging.py 2011-02-01 19:10:23 +0000
180@@ -27,9 +27,11 @@
181
182 __metaclass__ = ABCMeta
183
184- # pylint: disable=W0613,R0201
185 @abstractmethod
186- def show_message(self, sender, callback, message_time=None, icon=None):
187+ def show_message(self, sender, callback, message_time=None,
188+ message_count=None, icon=None):
189 """Show a message in the messaging menu."""
190- return NotImplemented
191- # pylint: enable=W0613,R0201
192+
193+ @abstractmethod
194+ def update_count(self, sender, new_count):
195+ """Update the count for an existing indicator."""
196
197=== modified file 'ubuntuone/status/notification.py'
198--- ubuntuone/status/notification.py 2011-01-13 20:39:08 +0000
199+++ ubuntuone/status/notification.py 2011-02-01 19:10:23 +0000
200@@ -27,9 +27,11 @@
201
202 __metaclass__ = ABCMeta
203
204- # pylint: disable=W0613,R0201
205 @abstractmethod
206- def send_notification(self, title, message, icon, append):
207+ def send_notification(self, title, message, icon=None, append=False):
208 """Send a notification to the end user."""
209- return NotImplemented
210- # pylint: enable=W0613,R0201
211+
212+ @abstractmethod
213+ def update_notification(self, notification, new_title, new_message,
214+ new_icon=None):
215+ """Update the notification with a new message body."""

Subscribers

People subscribed via source and target branches