~didrocks/ubuntuone-client/use_result_var

« back to all changes in this revision

Viewing changes to ubuntuone/status/aggregator.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-03-18 15:32:09 UTC
  • mfrom: (1.1.47 upstream)
  • Revision ID: james.westby@ubuntu.com-20110318153209-eiao2x342xppviid
Tags: 1.5.7-0ubuntu1
* New upstream release.
  - Connection notifications are pointless (LP: #734895)
  - Use a single platform Notification instance (LP: #734985)
* 01_reset-udf-typeerror.patch:
  - Removed patch which is now included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
 
141
141
    enabled = True
142
142
 
143
 
    def build_notification(self):
 
143
    def __init__(self):
 
144
        self.toggleable_notification = ToggleableNotification(self)
 
145
 
 
146
    def get_notification(self):
144
147
        """Return a new notification instance."""
145
 
        return ToggleableNotification(self)
 
148
        return self.toggleable_notification
146
149
 
147
150
    def enable_notifications(self):
148
151
        """Turn the switch on."""
435
438
 
436
439
    def _start(self):
437
440
        """The first file was found, so start gathering."""
438
 
        self.notification = self.status_aggregator.build_notification()
 
441
        self.notification = self.status_aggregator.get_notification()
439
442
        self._change_state(FileDiscoveryGatheringState)
440
443
 
441
444
    def _popup(self):
484
487
        self.timer = Timer(self.sleep_delay, clock=self.clock)
485
488
        self.timer.addCallback(self._timeout)
486
489
 
487
 
    def _timeout(self, result):
 
490
    def _timeout(self, _):
488
491
        """Show the bubble."""
489
 
        self.notification = self.status_aggregator.build_notification()
 
492
        self.notification = self.status_aggregator.get_notification()
490
493
        text = self.status_aggregator.get_progress_message()
491
494
        self.notification.send_notification(UBUNTUONE_TITLE, text)
492
495
        self.restart()
584
587
 
585
588
    def show(self):
586
589
        """Show the final status notification."""
587
 
        self.notification = self.status_aggregator.build_notification()
 
590
        self.notification = self.status_aggregator.get_notification()
588
591
        text = self.status_aggregator.get_final_status_message()
589
592
        self.notification.send_notification(UBUNTUONE_TITLE, text)
590
593
 
610
613
        self.reset()
611
614
        self.progress_bar = ProgressBar(clock=self.clock)
612
615
 
613
 
    def build_notification(self):
 
616
    def get_notification(self):
614
617
        """Create a new toggleable notification object."""
615
 
        return self.notification_switch.build_notification()
 
618
        return self.notification_switch.get_notification()
616
619
 
617
620
    # pylint: disable=W0201
618
621
    def reset(self):
771
774
    def __init__(self, clock=reactor):
772
775
        """Initialize this instance."""
773
776
        self.aggregator = StatusAggregator(clock=clock)
774
 
        self.notification = self.aggregator.build_notification()
 
777
        self.notification = self.aggregator.get_notification()
775
778
        self.messaging = Messaging()
776
779
        self.udf_message = None
777
780
 
831
834
        self.notification.send_notification(
832
835
            UBUNTUONE_TITLE, UDFAvailableStatus(udf=udf).one())
833
836
 
834
 
    # pylint: disable=W0613
835
837
    def _reset_udf_message_callback(self, indicator, message_time=None):
836
838
        """A callback wrapper that resets the udf_message to None."""
837
839
        self.udf_message = None
838
 
        self.messaging.create_callback()()
839
 
    # pylint: enable=W0613
 
840
        callback = self.messaging.create_callback()
 
841
        callback(indicator, message_time=message_time)
840
842
 
841
843
    def server_connection_lost(self):
842
844
        """The client lost the connection to the server."""
843
845
        logger.debug("server connection lost")
844
 
        self.notification.send_notification(
845
 
            UBUNTUONE_TITLE, ConnectionLostStatus().one())
846
846
        self.aggregator.connection_lost()
847
847
 
848
848
    def server_connection_made(self):
849
849
        """The client made the connection to the server."""
850
850
        logger.debug("server connection made")
851
 
        self.notification.send_notification(
852
 
            UBUNTUONE_TITLE, ConnectionMadeStatus().one())
853
851
        self.aggregator.connection_made()
854
852
 
855
853
    def set_show_all_notifications(self, value):