コード例 #1
0
ファイル: notify.py プロジェクト: hannesrauhe/lunchinator
 def process_message(self, msg, ip, _member_info):
     name = u"[%s]" % get_peers().getDisplayedPeerName(pIP=ip)
     icon = get_peers().getPeerAvatarFile(pIP=ip)
     if not icon:
         icon = self.options[u"icon_file"]
     
     displayNotification(name, msg, self.logger, icon)
コード例 #2
0
 def _installReady(self):
     """Makes the install button enabled/disabled"""
     self._install_ready = True
     get_notification_center().emitApplicationUpdate()
     displayNotification("New Version Available", "Install via Update Plugin", self.logger)
     if self._ui != None:
         self._ui.appInstallReady()    
コード例 #3
0
 def _processOutdated(self):
     nOutdated = get_settings().get_plugin_repositories().getNumOutdated()
     
     if nOutdated > 0:
         displayNotification("Update(s) available", self._getRepoStatus(), self.logger)
     if self._ui != None:
         self._ui.setRepoUpdatesAvailable(nOutdated > 0)
         self._updateRepoStatus(nOutdated)
     self._nOutdated = nOutdated
コード例 #4
0
ファイル: __init__.py プロジェクト: hannesrauhe/lunchinator
 def process_event(self, cmd, value, ip, member_info, _prep):
     if cmd == "HELO_VOTE":
         if self.w is None:
             self.logger.error("Voter: Vote cannot be processed")
             return
         vote = json.loads(value)
         if vote.has_key("time") and vote.has_key("place"):
             self.add_vote(member_info[u"ID"], vote["place"], vote["time"])
             displayNotification("New Vote", "%s voted" % get_peers().getDisplayedPeerName(pIP=ip), self.logger)
         else:
             self.logger.error("Voter: Vote does not look valid: %s", value)
コード例 #5
0
 def _updateMemberStatus(self, _pID=None, _pInfo=None):
     peers = get_server().getLunchPeers()
     readyMembers = peers.getReadyMembers()
     notReadyMembers = peers.getMembers() - readyMembers
     
     # don't display members with unknown status as ready
     readyMembers = [pID for pID in readyMembers if peers.isPeerReadinessKnown(pID=pID)]
     
     everybodyReady = False
     if not readyMembers and not notReadyMembers:
         status = u"No members."
     elif not readyMembers:
         status = u"Nobody is ready for lunch."
     elif not notReadyMembers:
         everybodyReady = True
         status = u"Everybody is ready for lunch."
     else:
         if len(readyMembers) == 1:
             ready = u"1 member"
         else:
             ready = u"%d members" % len(readyMembers)
             
         if len(notReadyMembers) == 1:
             notReady = u"1 member"
         else:
             notReady = u"%d members" % len(notReadyMembers)
         
         status = u"%s ready, %s not ready for lunch." % (ready, notReady)
     if everybodyReady and not self._highlightPeersReady:
         # don't highlight if I am the only member
         if len(readyMembers) > 1 or not get_peers().isMe(pID=iter(readyMembers).next()):
             self._highlightPeersReady = True
             if get_settings().get_notification_if_everybody_ready():
                 displayNotification("Lunch Time",
                                     "Everybody is ready for lunch now",
                                     getCoreLogger(),
                                     get_settings().get_resource("images", "lunchinator.png"))
             self._highlightIcon()
         else:
             status = u"You are the only member."
     elif not everybodyReady and self._highlightPeersReady:
         self._highlightPeersReady = False
         self._highlightIcon()
     self._memberStatusAction.setText(status)
コード例 #6
0
ファイル: __init__.py プロジェクト: hannesrauhe/lunchinator
 def _displayMessage(self, otherID, msgHTML, msgTime, msgDict):
     try:
         recvTime = time()
         chatWindow = self.openChat(otherID, False)
         chatWindow.getChatWidget().addOtherMessage(msgHTML, msgTime, recvTime)
         self._messagesHandler.receivedSuccessfully(otherID, msgHTML, msgTime, msgDict, recvTime)
     except:
         excType, excValue, _tb = sys.exc_info()
         errorMsg = u"Error processing message (%s: %s)" % (unicode(excType.__name__), unicode(excValue))
         self._messagesHandler.errorReceivingMessage(otherID, msgDict, errorMsg)
     
     if not chatWindow.isActiveWindow():
         from PyQt4.QtGui import QTextDocument
         doc = QTextDocument()
         doc.setHtml(msgHTML)
         displayNotification(chatWindow.getChatWidget().getOtherName(),
                             convert_string(doc.toPlainText()),
                             self.logger,
                             chatWindow.getChatWidget().getOtherIconPath())
コード例 #7
0
 def _restartRequired(self, reason):
     reason = convert_string(reason)
     if self._restartReason == reason:
         # same reason again, do not notify
         return
     
     displayNotification(u"Restart required", reason, getCoreLogger())
     
     if self._restartReason:
         # now there are multiple reasons to restart
         self._restartReason = u"Some changes need a restart"
     else:
         self._restartReason = reason
     if self._restartStatusAction != None:
         self._restartStatusAction.setText(self._restartReason)
         self._restartStatusAction.setVisible(True)
         # don't need both actions
         if not self._hasUpdates():
             self._restartAction.setVisible(True)
コード例 #8
0
 def _downloadedPicture(self, category, description, sender, thread, url):
     if self._hasPicture(category, url):
         self.logger.warning("Picture already in storage: %s", url)
         return
     
     name = "New Remote Picture"
     if category != None:
         name = name + " in category %s" % category
         
     # create temporary image file to display in notification
     url = convert_string(url)
     thread.target.flush()
     
     displayNotification(name, description, self.logger, thread.target.name)
     
     self._addPicture(thread.target,
                      thread.target.name if self._storeLocally else None,
                      url,
                      category,
                      description,
                      sender)