Miscellaneous fixes/changes incl. loadingscreen fix (v2.4.1)

This commit is contained in:
Dpeta 2022-07-05 21:45:16 +02:00
parent 66e838ebf4
commit b90c258604
12 changed files with 224 additions and 174 deletions

View file

@ -1,6 +1,24 @@
# Changelog # Changelog
(This document uses YYYY-MM-DD) (This document uses YYYY-MM-DD)
## [v2.4.1] - 2022-07-05
### Added
- Support for more IRC replies/commands that imply a (forced) nick/handle change.
### Fixed
- Connecting dialog not disappearing when theme was changed.
- Client not sending QUIT on manual reconnect or exit via tray.
- Manual reconnect occasionally failing.
### Changed
- LoadingScreen/connecting dialog is no longer blocking.
- Console output is less verbose.
### Deprecated
- Removed the weird metadata support timeout thingy, I think ought to just get the full 005 before we try to get moods.
- Replaced instances of socket.error excepts with OSError, since it's depreciated.
## [v2.4] - 2022-06-30 ## [v2.4] - 2022-06-30
### Added ### Added

147
irc.py
View file

@ -46,16 +46,14 @@ class PesterIRC(QtCore.QThread):
self.NickServ = services.NickServ() self.NickServ = services.NickServ()
self.ChanServ = services.ChanServ() self.ChanServ = services.ChanServ()
def IRCConnect(self): def IRCConnect(self):
server = self.config.server()
port = self.config.port()
ssl = self.config.ssl()
self.cli = IRCClient(PesterHandler, self.cli = IRCClient(PesterHandler,
host=server, host=self.config.server(),
port=port, port=self.config.port(),
ssl=self.config.ssl(),
nick=self.mainwindow.profile().handle, nick=self.mainwindow.profile().handle,
real_name='pcc31', username='pcc31',
timeout=120, realname='pcc31',
ssl=ssl) timeout=120)
self.cli.command_handler.parent = self self.cli.command_handler.parent = self
self.cli.command_handler.mainwindow = self.mainwindow self.cli.command_handler.mainwindow = self.mainwindow
self.cli.connect() self.cli.connect()
@ -90,8 +88,8 @@ class PesterIRC(QtCore.QThread):
self.connected.emit() self.connected.emit()
def setConnectionBroken(self): def setConnectionBroken(self):
PchumLog.critical("setconnection broken") PchumLog.critical("setconnection broken")
self.reconnectIRC() self.disconnectIRC()
#self.brokenConnection = True #self.brokenConnection = True # Unused
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def updateIRC(self): def updateIRC(self):
try: try:
@ -101,19 +99,17 @@ class PesterIRC(QtCore.QThread):
return True return True
else: else:
raise se raise se
except socket.error as se: except OSError as se:
raise se raise se
except (OSError, IndexError) as se: except (OSError,
ValueError,
IndexError) as se:
raise se raise se
except StopIteration: except StopIteration:
self.conn = self.cli.conn() self.conn = self.cli.conn()
return True return True
else: else:
return res return res
@QtCore.pyqtSlot()
def reconnectIRC(self):
PchumLog.warning("reconnectIRC() from thread %s" % (self))
self.cli.close()
@QtCore.pyqtSlot(PesterProfile) @QtCore.pyqtSlot(PesterProfile)
def getMood(self, *chums): def getMood(self, *chums):
@ -127,7 +123,7 @@ class PesterIRC(QtCore.QThread):
t = str(text) t = str(text)
try: try:
helpers.notice(self.cli, h, t) helpers.notice(self.cli, h, t)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(QString, QString)
@ -174,7 +170,7 @@ class PesterIRC(QtCore.QThread):
try: try:
for t in textl: for t in textl:
helpers.msg(self.cli, h, t) helpers.msg(self.cli, h, t)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString, QString,) @QtCore.pyqtSlot(QString, QString,)
@ -184,7 +180,7 @@ class PesterIRC(QtCore.QThread):
#msg = msg.replace(cmd, '') #msg = msg.replace(cmd, '')
try: try:
helpers.ctcp(self.cli, handle, text) helpers.ctcp(self.cli, handle, text)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString, bool) @QtCore.pyqtSlot(QString, bool)
@ -194,7 +190,7 @@ class PesterIRC(QtCore.QThread):
helpers.msg(self.cli, h, "COLOR >%s" % (self.mainwindow.profile().colorcmd())) helpers.msg(self.cli, h, "COLOR >%s" % (self.mainwindow.profile().colorcmd()))
if initiated: if initiated:
helpers.msg(self.cli, h, "PESTERCHUM:BEGIN") helpers.msg(self.cli, h, "PESTERCHUM:BEGIN")
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
@ -202,7 +198,7 @@ class PesterIRC(QtCore.QThread):
h = str(handle) h = str(handle)
try: try:
helpers.msg(self.cli, h, "PESTERCHUM:CEASE") helpers.msg(self.cli, h, "PESTERCHUM:CEASE")
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
@ -211,7 +207,7 @@ class PesterIRC(QtCore.QThread):
handle = me.handle handle = me.handle
try: try:
helpers.nick(self.cli, handle) helpers.nick(self.cli, handle)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
self.mainwindow.closeConversations(True) self.mainwindow.closeConversations(True)
@ -225,13 +221,13 @@ class PesterIRC(QtCore.QThread):
# Moods via metadata # Moods via metadata
try: try:
helpers.metadata(self.cli, '*', "set", "mood", str(me.mood.value())) helpers.metadata(self.cli, '*', "set", "mood", str(me.mood.value()))
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
# Backwards compatibility # Backwards compatibility
try: try:
helpers.msg(self.cli, "#pesterchum", "MOOD >%d" % (me.mood.value())) helpers.msg(self.cli, "#pesterchum", "MOOD >%d" % (me.mood.value()))
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
@ -241,7 +237,7 @@ class PesterIRC(QtCore.QThread):
for h in list(self.mainwindow.convos.keys()): for h in list(self.mainwindow.convos.keys()):
try: try:
helpers.msg(self.cli, h, "COLOR >%s" % (self.mainwindow.profile().colorcmd())) helpers.msg(self.cli, h, "COLOR >%s" % (self.mainwindow.profile().colorcmd()))
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
@ -249,7 +245,7 @@ class PesterIRC(QtCore.QThread):
h = str(handle) h = str(handle)
try: try:
helpers.msg(self.cli, h, "PESTERCHUM:BLOCK") helpers.msg(self.cli, h, "PESTERCHUM:BLOCK")
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
@ -257,7 +253,7 @@ class PesterIRC(QtCore.QThread):
h = str(handle) h = str(handle)
try: try:
helpers.msg(self.cli, h, "PESTERCHUM:UNBLOCK") helpers.msg(self.cli, h, "PESTERCHUM:UNBLOCK")
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
@ -265,14 +261,14 @@ class PesterIRC(QtCore.QThread):
c = str(channel) c = str(channel)
try: try:
helpers.names(self.cli, c) helpers.names(self.cli, c)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def requestChannelList(self): def requestChannelList(self):
try: try:
helpers.channel_list(self.cli) helpers.channel_list(self.cli)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
@ -281,7 +277,7 @@ class PesterIRC(QtCore.QThread):
try: try:
helpers.join(self.cli, c) helpers.join(self.cli, c)
helpers.mode(self.cli, c, "", None) helpers.mode(self.cli, c, "", None)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
@ -290,7 +286,7 @@ class PesterIRC(QtCore.QThread):
try: try:
helpers.part(self.cli, c) helpers.part(self.cli, c)
self.cli.command_handler.joined = False self.cli.command_handler.joined = False
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(QString, QString)
@ -307,7 +303,7 @@ class PesterIRC(QtCore.QThread):
reason = "" reason = ""
try: try:
helpers.kick(self.cli, h, c, reason) helpers.kick(self.cli, h, c, reason)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString, QString, QString) @QtCore.pyqtSlot(QString, QString, QString)
@ -320,7 +316,7 @@ class PesterIRC(QtCore.QThread):
cmd = None cmd = None
try: try:
helpers.mode(self.cli, c, m, cmd) helpers.mode(self.cli, c, m, cmd)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
@ -328,7 +324,7 @@ class PesterIRC(QtCore.QThread):
c = str(channel) c = str(channel)
try: try:
helpers.names(self.cli, c) helpers.names(self.cli, c)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(QString, QString)
@ -337,7 +333,7 @@ class PesterIRC(QtCore.QThread):
c = str(channel) c = str(channel)
try: try:
helpers.invite(self.cli, h, c) helpers.invite(self.cli, h, c)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@ -345,7 +341,7 @@ class PesterIRC(QtCore.QThread):
def pingServer(self): def pingServer(self):
try: try:
self.cli.send("PING %s" % int(time.time())) self.cli.send("PING %s" % int(time.time()))
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@ -356,7 +352,7 @@ class PesterIRC(QtCore.QThread):
self.cli.send("AWAY Idle") self.cli.send("AWAY Idle")
else: else:
self.cli.send("AWAY") self.cli.send("AWAY")
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
@ -366,12 +362,16 @@ class PesterIRC(QtCore.QThread):
h = str(handle) h = str(handle)
try: try:
helpers.ctcp(self.cli, c, "NOQUIRKS", h) helpers.ctcp(self.cli, c, "NOQUIRKS", h)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.setConnectionBroken() self.setConnectionBroken()
def quit_dc(self): @QtCore.pyqtSlot()
helpers.quit(self.cli, _pcVersion + " <3") def disconnectIRC(self):
if hasattr(self, 'cli'):
helpers.quit(self.cli, _pcVersion + " <3")
self.cli._end = True
self.cli.close()
moodUpdated = QtCore.pyqtSignal('QString', Mood) moodUpdated = QtCore.pyqtSignal('QString', Mood)
colorUpdated = QtCore.pyqtSignal('QString', QtGui.QColor) colorUpdated = QtCore.pyqtSignal('QString', QtGui.QColor)
@ -383,6 +383,7 @@ class PesterIRC(QtCore.QThread):
namesReceived = QtCore.pyqtSignal('QString', PesterList) namesReceived = QtCore.pyqtSignal('QString', PesterList)
channelListReceived = QtCore.pyqtSignal(PesterList) channelListReceived = QtCore.pyqtSignal(PesterList)
nickCollision = QtCore.pyqtSignal('QString', 'QString') nickCollision = QtCore.pyqtSignal('QString', 'QString')
getSvsnickedOn = QtCore.pyqtSignal('QString', 'QString')
myHandleChanged = QtCore.pyqtSignal('QString') myHandleChanged = QtCore.pyqtSignal('QString')
chanInviteOnly = QtCore.pyqtSignal('QString') chanInviteOnly = QtCore.pyqtSignal('QString')
modesUpdated = QtCore.pyqtSignal('QString', 'QString') modesUpdated = QtCore.pyqtSignal('QString', 'QString')
@ -450,8 +451,8 @@ class PesterHandler(DefaultCommandHandler):
if (x != None) and (x != ''): if (x != None) and (x != ''):
reason += x + ' ' reason += x + ' '
self.parent.stopIRC = reason.strip() self.parent.stopIRC = reason.strip()
self.parent.reconnectIRC() self.parent.disconnectIRC()
def privmsg(self, nick, chan, msg): def privmsg(self, nick, chan, msg):
handle = nick[0:nick.find("!")] handle = nick[0:nick.find("!")]
if len(msg) == 0: if len(msg) == 0:
@ -559,7 +560,7 @@ class PesterHandler(DefaultCommandHandler):
if (x != None) and (x != ''): if (x != None) and (x != ''):
reason += x + ' ' reason += x + ' '
self.parent.stopIRC = reason.strip() self.parent.stopIRC = reason.strip()
self.parent.reconnectIRC() self.parent.disconnectIRC()
def keyvalue(self, target, handle_us, handle_owner, key, visibility, *value): def keyvalue(self, target, handle_us, handle_owner, key, visibility, *value):
# The format of the METADATA server notication is: # The format of the METADATA server notication is:
@ -577,7 +578,7 @@ class PesterHandler(DefaultCommandHandler):
chumglub = "GETMOOD " chumglub = "GETMOOD "
try: try:
helpers.msg(self.client, "#pesterchum", chumglub + failed_handle) helpers.msg(self.client, "#pesterchum", chumglub + failed_handle)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.parent.setConnectionBroken() self.parent.setConnectionBroken()
@ -587,7 +588,7 @@ class PesterHandler(DefaultCommandHandler):
chumglub = "GETMOOD " chumglub = "GETMOOD "
try: try:
helpers.msg(self.client, "#pesterchum", chumglub + failed_handle) helpers.msg(self.client, "#pesterchum", chumglub + failed_handle)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.parent.setConnectionBroken() self.parent.setConnectionBroken()
@ -597,11 +598,12 @@ class PesterHandler(DefaultCommandHandler):
chumglub = "GETMOOD " chumglub = "GETMOOD "
try: try:
helpers.msg(self.client, "#pesterchum", chumglub + failed_handle) helpers.msg(self.client, "#pesterchum", chumglub + failed_handle)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.parent.setConnectionBroken() self.parent.setConnectionBroken()
def featurelist(self, target, handle, *params): def featurelist(self, target, handle, *params):
# Better to do this via CAP ACK/CAP NEK
# RPL_ISUPPORT # RPL_ISUPPORT
features = params[:-1] features = params[:-1]
PchumLog.info("Server featurelist: " + str(features)) PchumLog.info("Server featurelist: " + str(features))
@ -609,12 +611,23 @@ class PesterHandler(DefaultCommandHandler):
if x.upper().startswith("METADATA"): if x.upper().startswith("METADATA"):
PchumLog.info("Server supports metadata.") PchumLog.info("Server supports metadata.")
self.parent.metadata_supported = True self.parent.metadata_supported = True
def cap(self, server, nick, subcommand, tag):
PchumLog.info("CAP %s %s %s %s" % (server, nick, subcommand, tag))
#if tag == "message-tags":
# if subcommand == "ACK":
def nicknameinuse(self, server, cmd, nick, msg): def nicknameinuse(self, server, cmd, nick, msg):
newnick = "pesterClient%d" % (random.randint(100,999)) newnick = "pesterClient%d" % (random.randint(100,999))
helpers.nick(self.client, newnick) helpers.nick(self.client, newnick)
self.parent.nickCollision.emit(nick, newnick) self.parent.nickCollision.emit(nick, newnick)
def nickcollision(self, server, cmd, nick, msg):
newnick = "pesterClient%d" % (random.randint(100,999))
helpers.nick(self.client, newnick)
self.parent.nickCollision.emit(nick, newnick)
def quit(self, nick, reason): def quit(self, nick, reason):
handle = nick[0:nick.find("!")] handle = nick[0:nick.find("!")]
PchumLog.info("---> recv \"QUIT %s: %s\"" % (handle, reason)) PchumLog.info("---> recv \"QUIT %s: %s\"" % (handle, reason))
@ -730,7 +743,13 @@ class PesterHandler(DefaultCommandHandler):
#except IndexError: #except IndexError:
#self.parent.userPresentUpdate.emit("", channel, m+":%s" % (op)) #self.parent.userPresentUpdate.emit("", channel, m+":%s" % (op))
def nick(self, oldnick, newnick): def nick(self, oldnick, newnick, hopcount=0):
# NICK from/to us
if oldnick == self.mainwindow.profile().handle:
# Server changed our handle, svsnick?
self.parent.getSvsnickedOn.emit(oldnick, newnick)
# NICK from/to someone else
oldhandle = oldnick[0:oldnick.find("!")] oldhandle = oldnick[0:oldnick.find("!")]
if oldhandle == self.mainwindow.profile().handle: if oldhandle == self.mainwindow.profile().handle:
self.parent.myHandleChanged.emit(newnick) self.parent.myHandleChanged.emit(newnick)
@ -824,26 +843,8 @@ class PesterHandler(DefaultCommandHandler):
self.client.send('PONG', server) self.client.send('PONG', server)
def getMood(self, *chums): def getMood(self, *chums):
# Try to get mood via metadata get. """Get mood via metadata if supported"""
# If it fails the old code is excecuted.
# If services/bot, assume mood 18.
# * This doesn't actually seem to work.
#for c in chums:
# if c.handle.upper() in BOTNAMES:
# print("True")
# print(c.handle)
# PchumLog.info("%s is a bot, setting mood to 18." % (c.handle))
# self.parent.moodUpdated.emit(c.handle, Mood(18))
# Wait for server to send welcome to verify RPL_ISUPPORT has been send.
# Apparently 005 is send after 001 so nvm we gotta wait longer :"3
timeout = 0
while ((self.parent.registeredIRC == False)
or ((timeout < 15)
and (self.parent.metadata_supported == False))):
time.sleep(0.1)
timeout += 1
# Get via metadata or via legacy method # Get via metadata or via legacy method
if self.parent.metadata_supported == True: if self.parent.metadata_supported == True:
# Metadata # Metadata
@ -851,7 +852,7 @@ class PesterHandler(DefaultCommandHandler):
chandle = c.handle chandle = c.handle
try: try:
helpers.metadata(self.client, chandle, "get", "mood") helpers.metadata(self.client, chandle, "get", "mood")
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.parent.setConnectionBroken() self.parent.setConnectionBroken()
else: else:
@ -863,7 +864,7 @@ class PesterHandler(DefaultCommandHandler):
if len(chumglub+chandle) >= 350: if len(chumglub+chandle) >= 350:
try: try:
helpers.msg(self.client, "#pesterchum", chumglub) helpers.msg(self.client, "#pesterchum", chumglub)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.parent.setConnectionBroken() self.parent.setConnectionBroken()
chumglub = "GETMOOD " chumglub = "GETMOOD "
@ -871,7 +872,7 @@ class PesterHandler(DefaultCommandHandler):
if chumglub != "GETMOOD ": if chumglub != "GETMOOD ":
try: try:
helpers.msg(self.client, "#pesterchum", chumglub) helpers.msg(self.client, "#pesterchum", chumglub)
except socket.error as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.parent.setConnectionBroken() self.parent.setConnectionBroken()
@ -883,12 +884,12 @@ class PesterHandler(DefaultCommandHandler):
# if len(chandle) >= 200: # if len(chandle) >= 200:
# try: # try:
# self.client.send("ISON", ":%s" % (isonNicks)) # self.client.send("ISON", ":%s" % (isonNicks))
# except socket.error: # except OSError:
# self.parent.setConnectionBroken() # self.parent.setConnectionBroken()
# isonNicks = "" # isonNicks = ""
# isonNicks += " " + chandle # isonNicks += " " + chandle
# if isonNicks != "": # if isonNicks != "":
# try: # try:
# self.client.send("ISON", ":%s" % (isonNicks)) # self.client.send("ISON", ":%s" % (isonNicks))
# except socket.error: # except OSError:
# self.parent.setConnectionBroken() # self.parent.setConnectionBroken()

View file

@ -791,7 +791,7 @@ class PesterChooseTheme(QtWidgets.QDialog):
self.rejected.connect(parent.closeTheme) self.rejected.connect(parent.closeTheme)
class PesterChooseProfile(QtWidgets.QDialog): class PesterChooseProfile(QtWidgets.QDialog):
def __init__(self, userprofile, config, theme, parent, collision=None): def __init__(self, userprofile, config, theme, parent, collision=None, svsnick=None):
QtWidgets.QDialog.__init__(self, parent) QtWidgets.QDialog.__init__(self, parent)
self.userprofile = userprofile self.userprofile = userprofile
self.theme = theme self.theme = theme
@ -848,6 +848,9 @@ class PesterChooseProfile(QtWidgets.QDialog):
if collision: if collision:
collision_warning = QtWidgets.QLabel("%s is taken already! Pick a new profile." % (collision)) collision_warning = QtWidgets.QLabel("%s is taken already! Pick a new profile." % (collision))
layout_0.addWidget(collision_warning) layout_0.addWidget(collision_warning)
elif svsnick != None:
svsnick_warning = QtWidgets.QLabel("Your handle got changed from %s to %s! Pick a new profile." % svsnick)
layout_0.addWidget(svsnick_warning)
else: else:
layout_0.addWidget(self.currentHandle, alignment=QtCore.Qt.AlignmentFlag.AlignHCenter) layout_0.addWidget(self.currentHandle, alignment=QtCore.Qt.AlignmentFlag.AlignHCenter)
layout_0.addLayout(layout_1) layout_0.addLayout(layout_1)
@ -1753,6 +1756,8 @@ class LoadingScreen(QtWidgets.QDialog):
self.mainwindow = parent self.mainwindow = parent
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
#self.setWindowModality(QtCore.Qt.WindowModality.NonModal) # useless
#self.setAttribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose) # useless
self.loadinglabel = QtWidgets.QLabel("CONN3CT1NG", self) self.loadinglabel = QtWidgets.QLabel("CONN3CT1NG", self)
self.cancel = QtWidgets.QPushButton("QU1T >:?", self) self.cancel = QtWidgets.QPushButton("QU1T >:?", self)
self.ok = QtWidgets.QPushButton("R3CONN3CT >:]", self) self.ok = QtWidgets.QPushButton("R3CONN3CT >:]", self)
@ -1761,6 +1766,7 @@ class LoadingScreen(QtWidgets.QDialog):
self.ok.setAutoDefault(True) self.ok.setAutoDefault(True)
self.cancel.clicked.connect(self.reject) self.cancel.clicked.connect(self.reject)
self.ok.clicked.connect(self.tryAgain) self.ok.clicked.connect(self.tryAgain)
#self.finished.connect(self.finishedEvent)
self.layout = QtWidgets.QVBoxLayout() self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.loadinglabel) self.layout.addWidget(self.loadinglabel)
@ -1774,6 +1780,9 @@ class LoadingScreen(QtWidgets.QDialog):
self.ok.setDefault(True) self.ok.setDefault(True)
self.ok.setFocus() self.ok.setFocus()
self.timer = None self.timer = None
#def finishedEvent(self, result):
# self.close()
def hideReconnect(self, safe=True): def hideReconnect(self, safe=True):
self.ok.hide() self.ok.hide()
@ -1792,8 +1801,6 @@ class LoadingScreen(QtWidgets.QDialog):
def enableQuit(self): def enableQuit(self):
self.cancel.setEnabled(True) self.cancel.setEnabled(True)
tryAgain = QtCore.pyqtSignal()
class AboutPesterchum(QtWidgets.QDialog): class AboutPesterchum(QtWidgets.QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent) QtWidgets.QDialog.__init__(self, parent)

View file

@ -82,7 +82,8 @@ class IRCClient:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.nick = None self.nick = None
self.real_name = None self.realname = None
self.username = None
self.host = None self.host = None
self.port = None self.port = None
self.connect_cb = None self.connect_cb = None
@ -131,6 +132,12 @@ class IRCClient:
try: try:
tries = 1 tries = 1
while tries < 10: while tries < 10:
# Check if alive
if self._end == True:
break
if self.socket.fileno() == -1:
self._end = True
break
try: try:
ready_to_read, ready_to_write, in_error = select.select([], [self.socket], []) ready_to_read, ready_to_write, in_error = select.select([], [self.socket], [])
for x in ready_to_write: for x in ready_to_write:
@ -156,9 +163,8 @@ class IRCClient:
raise socket.timeout raise socket.timeout
except (OSError, except (OSError,
IndexError, IndexError,
ValueError) as e: ValueError,
# Unknown error, might as well retry? Exception) as e:
# index/value can happen if the socket breaks.
PchumLog.warning("Unkown error on send, " + str(e)) PchumLog.warning("Unkown error on send, " + str(e))
if tries >= 9: if tries >= 9:
raise e raise e
@ -168,7 +174,7 @@ class IRCClient:
PchumLog.debug("ready_to_write (len %s): " % str(len(ready_to_write)) + str(ready_to_write)) PchumLog.debug("ready_to_write (len %s): " % str(len(ready_to_write)) + str(ready_to_write))
except Exception as se: except Exception as se:
PchumLog.warning("socket.error %s" % str(se)) PchumLog.warning("Send Exception %s" % str(se))
try: try:
if not self.blocking and se.errno == 11: if not self.blocking and se.errno == 11:
pass pass
@ -190,7 +196,7 @@ class IRCClient:
context.check_hostname = False context.check_hostname = False
context.verify_mode = ssl.CERT_NONE context.verify_mode = ssl.CERT_NONE
bare_sock = socket.create_connection(("%s" % self.host, self.port)) bare_sock = socket.create_connection((self.host, self.port))
self.socket = context.wrap_socket(bare_sock, self.socket = context.wrap_socket(bare_sock,
server_hostname=self.host, server_hostname=self.host,
do_handshake_on_connect=False) do_handshake_on_connect=False)
@ -206,7 +212,7 @@ class IRCClient:
PchumLog.info("secure sockets version is %s" % self.socket.version()) PchumLog.info("secure sockets version is %s" % self.socket.version())
else: else:
self.socket = socket.create_connection(("%s" % self.host, self.port)) self.socket = socket.create_connection((self.host, self.port))
# setblocking is a shorthand for timeout, # setblocking is a shorthand for timeout,
# we shouldn't use both. # we shouldn't use both.
@ -218,7 +224,7 @@ class IRCClient:
self.socket.setblocking(True) self.socket.setblocking(True)
helpers.nick(self, self.nick) helpers.nick(self, self.nick)
helpers.user(self, self.nick, self.real_name) helpers.user(self, self.username, self.realname)
if self.connect_cb: if self.connect_cb:
self.connect_cb(self) self.connect_cb(self)
@ -231,6 +237,12 @@ class IRCClient:
try: try:
tries = 1 tries = 1
while tries < 10: while tries < 10:
# Check if alive
if self._end == True:
break
if self.socket.fileno() == -1:
self._end = True
break
try: try:
ready_to_read, ready_to_write, in_error = select.select([self.socket], [], []) ready_to_read, ready_to_write, in_error = select.select([self.socket], [], [])
for x in ready_to_read: for x in ready_to_read:
@ -249,14 +261,16 @@ class IRCClient:
except ssl.SSLEOFError as e: except ssl.SSLEOFError as e:
# ssl.SSLEOFError guarantees a broken connection. # ssl.SSLEOFError guarantees a broken connection.
PchumLog.warning("ssl.SSLEOFError in on send, " + str(e)) PchumLog.warning("ssl.SSLEOFError in on send, " + str(e))
raise ssl.SSLEOFError raise e
except (socket.timeout, TimeoutError) as e: except (socket.timeout, TimeoutError) as e:
# socket.timeout is deprecated in 3.10 # socket.timeout is deprecated in 3.10
PchumLog.warning("TimeoutError in on send, " + str(e)) PchumLog.warning("TimeoutError in on send, " + str(e))
raise socket.timeout raise socket.timeout
except (OSError, IndexError) as e: except (OSError,
# Unknown error, might as well retry? IndexError,
PchumLog.warning("Unkown error, " + str(e)) ValueError,
Exception) as e:
PchumLog.warning("Unkown error in conn, " + str(e))
if tries >= 9: if tries >= 9:
raise e raise e
tries += 1 tries += 1
@ -268,8 +282,8 @@ class IRCClient:
if self._end: if self._end:
break break
raise e raise e
except ssl.SSLEOFError: except ssl.SSLEOFError as e:
raise ssl.SSLEOFError raise e
except OSError as e: except OSError as e:
PchumLog.warning("conn exception %s in %s" % (e, self)) PchumLog.warning("conn exception %s in %s" % (e, self))
if self._end: if self._end:
@ -287,7 +301,7 @@ class IRCClient:
break break
if len(buffer) == 0 and self.blocking: if len(buffer) == 0 and self.blocking:
PchumLog.debug("len(buffer) = 0") PchumLog.debug("len(buffer) = 0")
raise socket.error("Connection closed") raise OSError("Connection closed")
data = buffer.split(bytes("\n", "UTF-8")) data = buffer.split(bytes("\n", "UTF-8"))
buffer = data.pop() buffer = data.pop()
@ -303,13 +317,13 @@ class IRCClient:
else: else:
self.command_handler.run(command, prefix, *args) self.command_handler.run(command, prefix, *args)
except CommandError as e: except CommandError as e:
PchumLog.debug("CommandError %s" % str(e)) PchumLog.warning("CommandError %s" % str(e))
yield True yield True
except socket.timeout as se: except socket.timeout as se:
PchumLog.debug("passing timeout") PchumLog.debug("passing timeout")
raise se raise se
except (socket.error, ssl.SSLEOFError) as se: except (OSError, ssl.SSLEOFError) as se:
PchumLog.debug("problem: %s" % (str(se))) PchumLog.debug("problem: %s" % (str(se)))
if self.socket: if self.socket:
PchumLog.info('error: closing socket') PchumLog.info('error: closing socket')
@ -333,15 +347,11 @@ class IRCClient:
try: try:
self.socket.shutdown(socket.SHUT_RDWR) self.socket.shutdown(socket.SHUT_RDWR)
except OSError as e: except OSError as e:
PchumLog.warning("Error while shutting down socket, already broken? %s" % str(e)) PchumLog.debug("Error while shutting down socket, already broken? %s" % str(e))
try: try:
self.socket.close() self.socket.close()
except OSError as e: except OSError as e:
PchumLog.warning("Error while closing socket, already broken? %s" % str(e)) PchumLog.debug("Error while closing socket, already broken? %s" % str(e))
def quit(self, msg):
PchumLog.info("QUIT")
self.socket.sendall(bytes(msg + "\n", "UTF-8"))
class IRCApp: class IRCApp:
""" This class manages several IRCClient instances without the use of threads. """ This class manages several IRCClient instances without the use of threads.

View file

@ -97,7 +97,8 @@ class CommandHandler(object):
try: try:
f = self.get(command) f = self.get(command)
except NoSuchCommandError: except NoSuchCommandError as e:
PchumLog.info(e)
self.__unhandled__(command, *args) self.__unhandled__(command, *args)
return return
@ -106,7 +107,9 @@ class CommandHandler(object):
try: try:
f(*args) f(*args)
except TypeError as e: except TypeError as e:
logging.exception("Failed to pass command, did the server pass an unsupported paramater?\n%s" % str(e)) logging.warning("Failed to pass command, did the server pass an unsupported paramater? " + str(e))
except Exception as e:
logging.warning("Failed to pass command, %s" % str(e))
@protected @protected
def __unhandled__(self, cmd, *args): def __unhandled__(self, cmd, *args):

View file

@ -101,14 +101,14 @@ def identify(cli, passwd, authuser="NickServ"):
msg(cli, authuser, "IDENTIFY %s" % passwd) msg(cli, authuser, "IDENTIFY %s" % passwd)
def quit(cli, msg): def quit(cli, msg):
msg = "QUIT :%s" % msg cli.send("QUIT %s" % (msg))
cli.quit(msg)
cli.close()
cli._end = 1
def user(cli, username, realname=None): def user(cli, username, realname):
cli.send("USER", realname or username, cli.host, cli.host, cli.send("USER",
realname or username) username,
'0',
'*',
':' + realname)
_simple = ( _simple = (
'join', 'join',
@ -140,4 +140,3 @@ def _addNumerics():
setattr(m, name, numericcmd(num, name)) setattr(m, name, numericcmd(num, name))
_addNumerics() _addNumerics()

View file

@ -223,8 +223,10 @@ protocol_events = [
"quit", "quit",
"invite", "invite",
"pong", "pong",
"metadata", # Metadata specification "nick", # We can get svsnicked
"tagmsg", # IRCv3 message tags extension "metadata", # Metadata specification
"tagmsg", # IRCv3 message tags extension
"cap" # IRCv3 Client Capability Negotiation
] ]
all_events = (generated_events all_events = (generated_events

View file

@ -26,7 +26,6 @@ logging.config.fileConfig(_datadir + "logging.ini")
PchumLog = logging.getLogger('pchumLogger') PchumLog = logging.getLogger('pchumLogger')
def parse_raw_irc_command(element): def parse_raw_irc_command(element):
print(element)
""" """
This function parses a raw irc command and returns a tuple This function parses a raw irc command and returns a tuple
of (prefix, command, args). of (prefix, command, args).

View file

@ -704,14 +704,7 @@ def kxhandleInput(ctx, text=None, flavor=None):
msgbox.exec() msgbox.exec()
return return
# Debug output. PchumLog.info("--> recv \"%s\"" % msg)
try:
# Turns out that Windows consoles can't handle unicode, heh...who'da
# thunk. We have to repr() this, as such.
print(repr(msg))
except Exception as err:
print("(Couldn't print processed message: {!s})".format(err))
# karxi: We have a list...but I'm not sure if we ever get anything else, so # karxi: We have a list...but I'm not sure if we ever get anything else, so
# best to play it safe. I may remove this during later refactoring. # best to play it safe. I may remove this during later refactoring.
if isinstance(msg, list): if isinstance(msg, list):
@ -728,10 +721,10 @@ def kxhandleInput(ctx, text=None, flavor=None):
msg = kxlexMsg(msg) msg = kxlexMsg(msg)
# Debug output. # Debug output.
try: #try:
print(repr(msg)) # print(repr(msg))
except Exception as err: #except Exception as err:
print("(Couldn't print lexed message: {!s})".format(err)) # print("(Couldn't print lexed message: {!s})".format(err))
# Remove coloring if this is a /me! # Remove coloring if this is a /me!
if is_action: if is_action:

View file

@ -1171,7 +1171,7 @@ class TrollSlumWindow(QtWidgets.QFrame):
unblockChumSignal = QtCore.pyqtSignal('QString') unblockChumSignal = QtCore.pyqtSignal('QString')
class PesterWindow(MovingWindow): class PesterWindow(MovingWindow):
reconnectIRC = QtCore.pyqtSignal() disconnectIRC = QtCore.pyqtSignal()
sendMessage = QtCore.pyqtSignal('QString', 'QString') sendMessage = QtCore.pyqtSignal('QString', 'QString')
def __init__(self, options, parent=None, app=None): def __init__(self, options, parent=None, app=None):
@ -1292,7 +1292,7 @@ class PesterWindow(MovingWindow):
opts.triggered.connect(self.openOpts) opts.triggered.connect(self.openOpts)
exitaction = QtGui.QAction(self.theme["main/menus/client/exit"], self) exitaction = QtGui.QAction(self.theme["main/menus/client/exit"], self)
self.exitaction = exitaction self.exitaction = exitaction
exitaction.triggered.connect(self.quit) exitaction.triggered.connect(self.killApp, QtCore.Qt.ConnectionType.QueuedConnection)
userlistaction = QtGui.QAction(self.theme["main/menus/client/userlist"], self) userlistaction = QtGui.QAction(self.theme["main/menus/client/userlist"], self)
self.userlistaction = userlistaction self.userlistaction = userlistaction
userlistaction.triggered.connect(self.showAllUsers) userlistaction.triggered.connect(self.showAllUsers)
@ -1305,7 +1305,7 @@ class PesterWindow(MovingWindow):
self.idleaction.setCheckable(True) self.idleaction.setCheckable(True)
self.idleaction.toggled[bool].connect(self.toggleIdle) self.idleaction.toggled[bool].connect(self.toggleIdle)
self.reconnectAction = QtGui.QAction(self.theme["main/menus/client/reconnect"], self) self.reconnectAction = QtGui.QAction(self.theme["main/menus/client/reconnect"], self)
self.reconnectAction.triggered.connect(self.reconnectIRC) self.reconnectAction.triggered.connect(self.disconnectIRC)
self.menu = QtWidgets.QMenuBar(self) self.menu = QtWidgets.QMenuBar(self)
self.menu.setNativeMenuBar(False) self.menu.setNativeMenuBar(False)
@ -1583,7 +1583,6 @@ class PesterWindow(MovingWindow):
self.hide() self.hide()
self.closeToTraySignal.emit() self.closeToTraySignal.emit()
def closeEvent(self, event): def closeEvent(self, event):
# This gets called directly if Pesterchum is closed from the taskbar, annoyingly enough.
if hasattr(self, 'trollslum') and self.trollslum: if hasattr(self, 'trollslum') and self.trollslum:
self.trollslum.close() self.trollslum.close()
try: try:
@ -1597,8 +1596,7 @@ class PesterWindow(MovingWindow):
self.closeToTray() self.closeToTray()
elif setting == 2: # quit elif setting == 2: # quit
self.closeConversations() self.closeConversations()
self.quit() # Shut down IRC & Pesterchum fully. self.closeSignal.emit()
self.closeSignal.emit() # <-- A close signal here on it's own shuts down QT but not the Python and the IRC connection :(
event.accept() event.accept()
def newMessage(self, handle, msg): def newMessage(self, handle, msg):
if handle in self.config.getBlocklist(): if handle in self.config.getBlocklist():
@ -1863,11 +1861,16 @@ class PesterWindow(MovingWindow):
self.chumList.showOnlineNumbers() self.chumList.showOnlineNumbers()
def changeProfile(self, collision=None): def changeProfile(self, collision=None, svsnick=None):
if not hasattr(self, 'chooseprofile'): if not hasattr(self, 'chooseprofile'):
self.chooseprofile = None self.chooseprofile = None
if not self.chooseprofile: if not self.chooseprofile:
self.chooseprofile = PesterChooseProfile(self.userprofile, self.config, self.theme, self, collision=collision) self.chooseprofile = PesterChooseProfile(self.userprofile,
self.config,
self.theme,
self,
collision=collision,
svsnick=svsnick)
self.chooseprofile.exec() self.chooseprofile.exec()
def themePicker(self): def themePicker(self):
@ -2338,7 +2341,7 @@ class PesterWindow(MovingWindow):
def userPresentUpdate(self, handle, channel, update): def userPresentUpdate(self, handle, channel, update):
c = str(channel) c = str(channel)
n = str(handle) n = str(handle)
print("c=%s\nn=%s\nupdate=%s\n" % (c, n, update)) #print("c=%s\nn=%s\nupdate=%s\n" % (c, n, update))
if update == "nick": if update == "nick":
l = n.split(":") l = n.split(":")
oldnick = l[0] oldnick = l[0]
@ -3180,6 +3183,11 @@ class PesterWindow(MovingWindow):
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(QString, QString)
def nickCollision(self, handle, tmphandle): def nickCollision(self, handle, tmphandle):
if hasattr(self, 'loadingscreen'):
if self.loadingscreen != None:
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
self.loadingscreen = None
self.mychumhandle.setText(tmphandle) self.mychumhandle.setText(tmphandle)
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0)))
self.changeTheme(self.userprofile.getTheme()) self.changeTheme(self.userprofile.getTheme())
@ -3189,6 +3197,24 @@ class PesterWindow(MovingWindow):
if not self.chooseprofile: if not self.chooseprofile:
h = str(handle) h = str(handle)
self.changeProfile(collision=h) self.changeProfile(collision=h)
@QtCore.pyqtSlot(QString, QString)
def getSvsnickedOn(self, oldhandle, newhandle):
if hasattr(self, 'loadingscreen'):
if self.loadingscreen != None:
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
self.loadingscreen = None
self.mychumhandle.setText(newhandle)
self.userprofile = userProfile(PesterProfile(newhandle,
QtGui.QColor("black"),
Mood(0)))
self.changeTheme(self.userprofile.getTheme())
if not hasattr(self, 'chooseprofile'):
self.chooseprofile = None
if not self.chooseprofile:
self.changeProfile(svsnick=(oldhandle, newhandle))
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
def myHandleChanged(self, handle): def myHandleChanged(self, handle):
if self.profile().handle == handle: if self.profile().handle == handle:
@ -3223,28 +3249,17 @@ class PesterWindow(MovingWindow):
self.forbiddenChan.emit(channel, reason) self.forbiddenChan.emit(channel, reason)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def quit(self): def killApp(self):
try: self.disconnectIRC.emit()
self.irc.quit_dc() # Actually send QUIT to server self.parent.trayicon.hide()
except Exception as e: self.app.quit()
# Not connected?
PchumLog.warning("QUIT failed: " + str(e))
try:
self.parent.trayicon.hide() #
self.app.quit()
except AttributeError as e:
# Called from outside main Window?
PchumLog.warning("Unelegant quit: " + str(e))
sys.exit()
def passIRC(self, irc): def passIRC(self, irc):
self.irc = irc self.irc = irc
def updateServerJson(self): def updateServerJson(self):
PchumLog.info(self.customServerPrompt_qline.text() + " chosen") PchumLog.info(self.customServerPrompt_qline.text() + " chosen")
server_and_port = self.customServerPrompt_qline.text().split(':') server_and_port = self.customServerPrompt_qline.text().split(':')
try: try:
server = { server = {
"server": server_and_port[0], "server": server_and_port[0],
@ -3539,7 +3554,7 @@ class PesterWindow(MovingWindow):
# Connect # Connect
self.chooseServerWidged.accepted.connect(self.setServer) self.chooseServerWidged.accepted.connect(self.setServer)
self.chooseServerWidged.rejected.connect(self.quit) self.chooseServerWidged.rejected.connect(self.killApp, QtCore.Qt.ConnectionType.QueuedConnection)
# Show # Show
self.chooseServerWidged.show() self.chooseServerWidged.show()
@ -3575,7 +3590,7 @@ class PesterWindow(MovingWindow):
inviteOnlyChan = QtCore.pyqtSignal('QString') inviteOnlyChan = QtCore.pyqtSignal('QString')
forbiddenChan = QtCore.pyqtSignal('QString', 'QString') forbiddenChan = QtCore.pyqtSignal('QString', 'QString')
closeSignal = QtCore.pyqtSignal() closeSignal = QtCore.pyqtSignal()
reconnectIRC = QtCore.pyqtSignal() disconnectIRC = QtCore.pyqtSignal()
gainAttention = QtCore.pyqtSignal(QtWidgets.QWidget) gainAttention = QtCore.pyqtSignal(QtWidgets.QWidget)
pingServer = QtCore.pyqtSignal() pingServer = QtCore.pyqtSignal()
setAway = QtCore.pyqtSignal(bool) setAway = QtCore.pyqtSignal(bool)
@ -3627,7 +3642,7 @@ class MainProgram(QtCore.QObject):
self.app = QtWidgets.QApplication(sys.argv) self.app = QtWidgets.QApplication(sys.argv)
self.app.setApplicationName("Pesterchum") self.app.setApplicationName("Pesterchum")
self.app.setQuitOnLastWindowClosed(False) #self.app.setQuitOnLastWindowClosed(False)
options = self.oppts(sys.argv[1:]) options = self.oppts(sys.argv[1:])
@ -3678,7 +3693,7 @@ class MainProgram(QtCore.QObject):
miniAction = QtGui.QAction("MINIMIZE", self) miniAction = QtGui.QAction("MINIMIZE", self)
miniAction.triggered.connect(self.widget.showMinimized) miniAction.triggered.connect(self.widget.showMinimized)
exitAction = QtGui.QAction("EXIT", self) exitAction = QtGui.QAction("EXIT", self)
exitAction.triggered.connect(PesterWindow.quit) exitAction.triggered.connect(self.widget.killApp, QtCore.Qt.ConnectionType.QueuedConnection)
self.traymenu.addAction(miniAction) self.traymenu.addAction(miniAction)
self.traymenu.addAction(exitAction) self.traymenu.addAction(exitAction)
@ -3698,8 +3713,21 @@ class MainProgram(QtCore.QObject):
self.widget.passIRC(self.irc) # Maybe this is absolutely terrible in practice, but screw it. self.widget.passIRC(self.irc) # Maybe this is absolutely terrible in practice, but screw it.
self.widget.gainAttention[QtWidgets.QWidget].connect(self.alertWindow) self.widget.gainAttention[QtWidgets.QWidget].connect(self.alertWindow)
#self.app.lastWindowClosed.connect(self.lastWindow)
self.app.aboutToQuit.connect(self.death)
def death(self):
# app murder in progress
#print("death inbound")
if hasattr(self, 'widget'):
self.widget.killApp()
#def lastWindow(self):
# print("all windows closed")
# if hasattr(self, 'widget'):
# self.widget.killApp()
@QtCore.pyqtSlot(QtWidgets.QWidget) @QtCore.pyqtSlot(QtWidgets.QWidget)
def alertWindow(self, widget): def alertWindow(self, widget):
self.app.alert(widget) self.app.alert(widget)
@ -3708,9 +3736,8 @@ class MainProgram(QtCore.QObject):
def trayiconShow(self): def trayiconShow(self):
self.trayicon.show() self.trayicon.show()
if self.widget.config.trayMessage(): if self.widget.config.trayMessage():
self.trayicon.showMessage("Pesterchum", "Pesterchum is still running in the system tray.\n\ self.trayicon.showMessage("Pesterchum", ("Pesterchum is still running in the system tray."
Right click to close it.\n\ + '\n' + "Right click to close it."))
Click this message to never see this again.")
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def trayMessageClick(self): def trayMessageClick(self):
@ -3752,7 +3779,7 @@ Click this message to never see this again.")
('setAway(bool)', 'setAway(bool)'), ('setAway(bool)', 'setAway(bool)'),
('killSomeQuirks(QString, QString)', ('killSomeQuirks(QString, QString)',
'killSomeQuirks(QString, QString)'), 'killSomeQuirks(QString, QString)'),
('reconnectIRC()', 'reconnectIRC()') ('disconnectIRC()', 'disconnectIRC()')
] ]
# IRC --> Main window # IRC --> Main window
irc2widget = [('connected()', 'connected()'), irc2widget = [('connected()', 'connected()'),
@ -3770,6 +3797,8 @@ Click this message to never see this again.")
'deliverInvite(QString, QString)'), 'deliverInvite(QString, QString)'),
('nickCollision(QString, QString)', ('nickCollision(QString, QString)',
'nickCollision(QString, QString)'), 'nickCollision(QString, QString)'),
('getSvsnickedOn(QString, QString)',
'getSvsnickedOn(QString, QString)'),
('myHandleChanged(QString)', ('myHandleChanged(QString)',
'myHandleChanged(QString)'), 'myHandleChanged(QString)'),
('namesReceived(QString, PyQt_PyObject)', ('namesReceived(QString, PyQt_PyObject)',
@ -3818,7 +3847,7 @@ Click this message to never see this again.")
(widget.pingServer, irc.pingServer), (widget.pingServer, irc.pingServer),
(widget.setAway, irc.setAway), (widget.setAway, irc.setAway),
(widget.killSomeQuirks, irc.killSomeQuirks), (widget.killSomeQuirks, irc.killSomeQuirks),
(widget.reconnectIRC, irc.reconnectIRC), (widget.disconnectIRC, irc.disconnectIRC),
# Main window --> IRC # Main window --> IRC
(irc.connected, widget.connected), (irc.connected, widget.connected),
(irc.moodUpdated, widget.updateMoodSlot), (irc.moodUpdated, widget.updateMoodSlot),
@ -3828,6 +3857,7 @@ Click this message to never see this again.")
(irc.noticeReceived, widget.deliverNotice), (irc.noticeReceived, widget.deliverNotice),
(irc.inviteReceived, widget.deliverInvite), (irc.inviteReceived, widget.deliverInvite),
(irc.nickCollision, widget.nickCollision), (irc.nickCollision, widget.nickCollision),
(irc.getSvsnickedOn, widget.getSvsnickedOn),
(irc.myHandleChanged, widget.myHandleChanged), (irc.myHandleChanged, widget.myHandleChanged),
(irc.namesReceived, widget.updateNames), (irc.namesReceived, widget.updateNames),
(irc.userPresentUpdate, widget.userPresentUpdate), (irc.userPresentUpdate, widget.userPresentUpdate),
@ -3887,17 +3917,7 @@ Click this message to never see this again.")
widget.loadingscreen.showReconnect() widget.loadingscreen.showReconnect()
else: else:
widget.loadingscreen.hideReconnect() widget.loadingscreen.hideReconnect()
status = widget.loadingscreen.exec() widget.loadingscreen.open()
if status == QtWidgets.QDialog.DialogCode.Rejected:
sys.exit(0)
else:
if self.widget.tabmemo:
for c in self.widget.tabmemo.convos:
self.irc.joinChannel(c)
else:
for c in list(self.widget.memos.values()):
self.irc.joinChannel(c.channel)
return True
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def connected(self): def connected(self):
@ -3911,8 +3931,7 @@ Click this message to never see this again.")
self.widget.loadingscreen = None self.widget.loadingscreen = None
self.attempts += 1 self.attempts += 1
if hasattr(self, 'irc') and self.irc: if hasattr(self, 'irc') and self.irc:
self.irc.reconnectIRC() self.irc.disconnectIRC()
self.irc.quit()
else: else:
self.restartIRC() self.restartIRC()
@QtCore.pyqtSlot() @QtCore.pyqtSlot()

View file

@ -189,7 +189,6 @@ class ToastMachine(object):
class PesterToast(QtWidgets.QWidget, DefaultToast): class PesterToast(QtWidgets.QWidget, DefaultToast):
def __init__(self, machine, title, msg, icon, time=3000, parent=None): def __init__(self, machine, title, msg, icon, time=3000, parent=None):
PchumLog.info(isinstance(parent, QtWidgets.QWidget))
kwds = dict(machine=machine, title=title, msg=msg, icon=icon) kwds = dict(machine=machine, title=title, msg=msg, icon=icon)
super().__init__(parent, **kwds) super().__init__(parent, **kwds)

View file

@ -1,2 +1,2 @@
_pcVersion = "Alt. v2.4" _pcVersion = "Alt. v2.4.1"
buildVersion = "v2.4" buildVersion = "v2.4.1"