~thisfred/ubuntuone-client/lp-702055

« back to all changes in this revision

Viewing changes to ubuntuone/status/aggregator.py

  • Committer: eric.casteleijn at canonical
  • Date: 2011-02-08 22:12:36 UTC
  • Revision ID: eric.casteleijn@canonical.com-20110208221236-rkoe17g24gx0bh04
moved the callback and the reference to the udf message up, to simplify the code a bit

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
from ubuntuone.logger import basic_formatter, logging
28
28
from ubuntuone.platform.notification import Notification
29
 
from ubuntuone.platform.messaging import Messaging
 
29
from ubuntuone.platform.messaging import Messaging, open_volumes
30
30
 
31
31
LOG_LEVEL = logging.DEBUG
32
32
logger = logging.getLogger('ubuntuone.status')
551
551
        self.aggregator = StatusAggregator(clock=clock)
552
552
        self.notification = Notification()
553
553
        self.messaging = Messaging()
 
554
        self.udf_message = None
554
555
 
555
556
    def file_published(self, public_url):
556
557
        """A file was published."""
598
599
 
599
600
    def new_udf_available(self, udf):
600
601
        """A new udf is available for subscription."""
601
 
        self.messaging.show_message(NEW_UDFS_SENDER, message_count=1)
 
602
        if self.udf_message is not None:
 
603
            self.messaging.update_count(self.udf_message, 1)
 
604
            return
 
605
        self.udf_message = self.messaging.show_message(
 
606
            NEW_UDFS_SENDER, callback=self._callback, message_count=1)
602
607
        self.notification.send_notification(
603
608
            UBUNTUONE_TITLE, UDFAvailableStatus(udf).one())
 
609
 
 
610
    def _callback(self, indicator, message_time=None):
 
611
        """A callback wrapper that resets the udf_message to None."""
 
612
        self.udf_message = None
 
613
        open_volumes(indicator, message_time=message_time)