def _setCurrentFile(self, path, dispName=None):
     if get_peers() is not None:
         peerName = get_peers().getDisplayedPeerName(self._peerID)
     else:
         peerName = u"<unknown peer>"
         
     if not path:
         if self._down:
             text = u"%d %s (total %s) \u2190 %s"
         else:
             text = u"%d %s (total %s) \u2192 %s"
         text = text % (self._numFiles, u"file" if self._numFiles is 1 else "files", formatSize(self._totalSize), peerName)
     else:
         if self._down:
             text = u"%s (%stotal %s) \u2190 %s"
         else:
             text = u"%s (%stotal %s) \u2192 %s"
         if dispName is None:
             dispName = os.path.basename(path)
         
         numFilesS = u"" if self._numFiles is 1 else u"%d files, " % self._numFiles
         text = text % (dispName, numFilesS, formatSize(self._totalSize), peerName)
         self._setFileIcon(path)
         
     self._currentFile = path
     self._nameLabel.setText(text)
Ejemplo n.º 2
0
 def getConfirmationMessage(self, _peerID, peerName, msgData):
     size = msgData.get(u"size", -1)
     numFiles = msgData.get(u"count", 1)
     
     if numFiles is 1:
         name = msgData.get(u"name", u"")
         if name == u"":
             name = u"<unknown name>"
         return u"%s wants to send you the file \"%s\" (%s)." % (peerName, name, formatSize(size))
     else:
         return u"%s wants to send you %d files with a total size of %s." % (peerName, numFiles, formatSize(size))