Network/IRC/IrcWidget.py

changeset 2234
1e33501a0d33
parent 2232
47290dad6d0b
child 2236
e30d5f978919
equal deleted inserted replaced
2233:26b34180a943 2234:1e33501a0d33
8 """ 8 """
9 9
10 import re 10 import re
11 import logging 11 import logging
12 12
13 from PyQt4.QtCore import pyqtSlot, Qt, QByteArray 13 from PyQt4.QtCore import pyqtSlot, Qt, QByteArray, QTimer
14 from PyQt4.QtGui import QWidget, QToolButton, QLabel 14 from PyQt4.QtGui import QWidget, QToolButton, QLabel
15 from PyQt4.QtNetwork import QTcpSocket, QAbstractSocket 15 from PyQt4.QtNetwork import QTcpSocket, QAbstractSocket
16 16
17 from E5Gui import E5MessageBox 17 from E5Gui import E5MessageBox
18 18
162 """ 162 """
163 # TODO: implement this 163 # TODO: implement this
164 dlg = IrcNetworkListDialog(self.__ircNetworkManager, self) 164 dlg = IrcNetworkListDialog(self.__ircNetworkManager, self)
165 dlg.exec_() 165 dlg.exec_()
166 166
167 def __joinChannel(self, name): 167 def __joinChannel(self, name, key=""):
168 """ 168 """
169 Private slot to join a channel. 169 Private slot to join a channel.
170 170
171 @param name name of the channel (string) 171 @param name name of the channel (string)
172 @param key key of the channel (string)
172 """ 173 """
173 # step 1: check, if this channel is already joined 174 # step 1: check, if this channel is already joined
174 for channel in self.__channelList: 175 for channel in self.__channelList:
175 if channel.name() == name: 176 if channel.name() == name:
176 return 177 return
185 channel.channelClosed.connect(self.__closeChannel) 186 channel.channelClosed.connect(self.__closeChannel)
186 187
187 self.channelsWidget.addTab(channel, name) 188 self.channelsWidget.addTab(channel, name)
188 self.__channelList.append(channel) 189 self.__channelList.append(channel)
189 190
190 self.__send("JOIN " + name) 191 self.__send("JOIN " + name) # TODO: add channel key
191 self.__send("MODE " + name) 192 self.__send("MODE " + name)
192 193
193 emptyIndex = self.channelsWidget.indexOf(self.__emptyLabel) 194 emptyIndex = self.channelsWidget.indexOf(self.__emptyLabel)
194 if emptyIndex > -1: 195 if emptyIndex > -1:
195 self.channelsWidget.removeTab(emptyIndex) 196 self.channelsWidget.removeTab(emptyIndex)
462 self.networkWidget.addServerMessage(msgType, message) 463 self.networkWidget.addServerMessage(msgType, message)
463 464
464 if code == 1: 465 if code == 1:
465 # register with services after the welcome message 466 # register with services after the welcome message
466 self.__registerWithServices() 467 self.__registerWithServices()
468 QTimer.singleShot(1000, self.__autoJoinChannels)
467 elif code == 5: 469 elif code == 5:
468 # extract the user privilege prefixes 470 # extract the user privilege prefixes
469 # ... PREFIX=(ov)@+ ... 471 # ... PREFIX=(ov)@+ ...
470 m = self.__prefixRe.match(message) 472 m = self.__prefixRe.match(message)
471 if m: 473 if m:
485 identity = self.__ircNetworkManager.getIdentity(self.__userName) 487 identity = self.__ircNetworkManager.getIdentity(self.__userName)
486 service = identity.getName() 488 service = identity.getName()
487 password = identity.getPassword() 489 password = identity.getPassword()
488 if service and password: 490 if service and password:
489 self.__send("PRIVMSG " + service + " :identify " + password) 491 self.__send("PRIVMSG " + service + " :identify " + password)
492
493 def __autoJoinChannels(self):
494 """
495 Private slot to join channels automatically once a server got connected.
496 """
497 for channel in self.networkWidget.getNetworkChannels():
498 if channel.autoJoin():
499 name = channel.getName()
500 key = channel.getKey()
501 self.__joinChannel(name, key)
490 502
491 def __tcpError(self, error): 503 def __tcpError(self, error):
492 """ 504 """
493 Private slot to handle errors reported by the TCP socket. 505 Private slot to handle errors reported by the TCP socket.
494 506

eric ide

mercurial