Network/IRC/IrcWidget.py

branch
5_3_x
changeset 2534
d7d9bdb53ca5
parent 2471
36eb585339fc
child 2535
bc7460f3ef1a
equal deleted inserted replaced
2524:34ab99b2fbff 2534:d7d9bdb53ca5
466 466
467 def __readyRead(self): 467 def __readyRead(self):
468 """ 468 """
469 Private slot to read data from the socket. 469 Private slot to read data from the socket.
470 """ 470 """
471 self.__buffer += str(self.__socket.readAll(), 471 if self.__socket:
472 Preferences.getSystem("IOEncoding"), 472 self.__buffer += str(self.__socket.readAll(),
473 'replace') 473 Preferences.getSystem("IOEncoding"),
474 if self.__buffer.endswith("\r\n"): 474 'replace')
475 for line in self.__buffer.splitlines(): 475 if self.__buffer.endswith("\r\n"):
476 line = line.strip() 476 for line in self.__buffer.splitlines():
477 if line: 477 line = line.strip()
478 logging.debug("<IRC> " + line) 478 if line:
479 handled = False 479 logging.debug("<IRC> " + line)
480 # step 1: give channels a chance to handle the message 480 handled = False
481 for channel in self.__channelList: 481 # step 1: give channels a chance to handle the message
482 handled = channel.handleMessage(line) 482 for channel in self.__channelList:
483 if handled: 483 handled = channel.handleMessage(line)
484 break 484 if handled:
485 else: 485 break
486 # step 2: try to process the message ourselves
487 for patternRe, patternFunc in self.__patterns:
488 match = patternRe.match(line)
489 if match is not None:
490 if patternFunc(match):
491 break
492 else: 486 else:
493 # Oops, the message wasn't handled 487 # step 2: try to process the message ourselves
494 self.networkWidget.addErrorMessage( 488 for patternRe, patternFunc in self.__patterns:
495 self.trUtf8("Message Error"), 489 match = patternRe.match(line)
496 self.trUtf8("Unknown message received from server:" 490 if match is not None:
497 "<br/>{0}").format(line)) 491 if patternFunc(match):
498 492 break
499 self.__updateUsersCount() 493 else:
500 self.__buffer = "" 494 # Oops, the message wasn't handled
495 self.networkWidget.addErrorMessage(
496 self.trUtf8("Message Error"),
497 self.trUtf8("Unknown message received from server:"
498 "<br/>{0}").format(line))
499
500 self.__updateUsersCount()
501 self.__buffer = ""
501 502
502 def __handleNamedMessage(self, match): 503 def __handleNamedMessage(self, match):
503 """ 504 """
504 Private method to handle a server message containing a message name. 505 Private method to handle a server message containing a message name.
505 506

eric ide

mercurial