209 "* Connection attempted by banned user '{0}'.") |
209 "* Connection attempted by banned user '{0}'.") |
210 .format(bannedName)) |
210 .format(bannedName)) |
211 self.abort() |
211 self.abort() |
212 return |
212 return |
213 |
213 |
214 if self.__serverPort != self.peerPort() and \ |
214 if (self.__serverPort != self.peerPort() and |
215 not Preferences.getCooperation("AutoAcceptConnections"): |
215 not Preferences.getCooperation("AutoAcceptConnections")): |
216 # don't ask for reverse connections or |
216 # don't ask for reverse connections or |
217 # if we shall accept automatically |
217 # if we shall accept automatically |
218 res = E5MessageBox.yesNo( |
218 res = E5MessageBox.yesNo( |
219 None, |
219 None, |
220 self.tr("New Connection"), |
220 self.tr("New Connection"), |
298 """ |
298 """ |
299 Private method to get the data length for the current data type. |
299 Private method to get the data length for the current data type. |
300 |
300 |
301 @return data length (integer) |
301 @return data length (integer) |
302 """ |
302 """ |
303 if self.bytesAvailable() <= 0 or \ |
303 if (self.bytesAvailable() <= 0 or |
304 self.__readDataIntoBuffer() <= 0 or \ |
304 self.__readDataIntoBuffer() <= 0 or |
305 not self.__buffer.endsWith(SeparatorToken_b): |
305 not self.__buffer.endsWith(SeparatorToken_b)): |
306 return 0 |
306 return 0 |
307 |
307 |
308 self.__buffer.chop(len(SeparatorToken_b)) |
308 self.__buffer.chop(len(SeparatorToken_b)) |
309 number = self.__buffer.toInt()[0] |
309 number = self.__buffer.toInt()[0] |
310 self.__buffer.clear() |
310 self.__buffer.clear() |
344 self.__currentDataType = Connection.Undefined |
344 self.__currentDataType = Connection.Undefined |
345 self.abort() |
345 self.abort() |
346 return False |
346 return False |
347 |
347 |
348 self.__buffer.clear() |
348 self.__buffer.clear() |
349 self.__numBytesForCurrentDataType = \ |
349 self.__numBytesForCurrentDataType = ( |
350 self.__dataLengthForCurrentDataType() |
350 self.__dataLengthForCurrentDataType()) |
351 return True |
351 return True |
352 |
352 |
353 def __hasEnoughData(self): |
353 def __hasEnoughData(self): |
354 """ |
354 """ |
355 Private method to check, if enough data is available. |
355 Private method to check, if enough data is available. |
359 if self.__transferTimerId: |
359 if self.__transferTimerId: |
360 self.killTimer(self.__transferTimerId) |
360 self.killTimer(self.__transferTimerId) |
361 self.__transferTimerId = 0 |
361 self.__transferTimerId = 0 |
362 |
362 |
363 if self.__numBytesForCurrentDataType <= 0: |
363 if self.__numBytesForCurrentDataType <= 0: |
364 self.__numBytesForCurrentDataType = \ |
364 self.__numBytesForCurrentDataType = ( |
365 self.__dataLengthForCurrentDataType() |
365 self.__dataLengthForCurrentDataType()) |
366 |
366 |
367 if self.bytesAvailable() < self.__numBytesForCurrentDataType or \ |
367 if (self.bytesAvailable() < self.__numBytesForCurrentDataType or |
368 self.__numBytesForCurrentDataType <= 0: |
368 self.__numBytesForCurrentDataType <= 0): |
369 self.__transferTimerId = self.startTimer(TransferTimeout) |
369 self.__transferTimerId = self.startTimer(TransferTimeout) |
370 return False |
370 return False |
371 |
371 |
372 return True |
372 return True |
373 |
373 |
397 participantsList = [] |
397 participantsList = [] |
398 else: |
398 else: |
399 participantsList = msg.split(SeparatorToken) |
399 participantsList = msg.split(SeparatorToken) |
400 self.participants.emit(participantsList[:]) |
400 self.participants.emit(participantsList[:]) |
401 elif self.__currentDataType == Connection.Editor: |
401 elif self.__currentDataType == Connection.Editor: |
402 hashStr, fn, msg = \ |
402 hashStr, fn, msg = ( |
403 str(self.__buffer, encoding="utf-8").split(SeparatorToken) |
403 str(self.__buffer, encoding="utf-8").split(SeparatorToken)) |
404 self.editorCommand.emit(hashStr, fn, msg) |
404 self.editorCommand.emit(hashStr, fn, msg) |
405 |
405 |
406 self.__currentDataType = Connection.Undefined |
406 self.__currentDataType = Connection.Undefined |
407 self.__numBytesForCurrentDataType = 0 |
407 self.__numBytesForCurrentDataType = 0 |
408 self.__buffer.clear() |
408 self.__buffer.clear() |