src/eric7/Network/IRC/IrcWidget.py

Wed, 20 Dec 2023 14:58:58 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 20 Dec 2023 14:58:58 +0100
branch
eric7
changeset 10428
a071d4065202
parent 10069
435cc5875135
child 10439
21c28b0f9e41
permissions
-rw-r--r--

Converted some source code documentation to the new style.

2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
9653
e67609152c5e Updated copyright for 2023.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9624
diff changeset
3 # Copyright (c) 2012 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the IRC window.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
10 import logging
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import re
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
13 from PyQt6.QtCore import QByteArray, QDateTime, Qt, QTimer, pyqtSignal, pyqtSlot
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
14 from PyQt6.QtNetwork import QAbstractSocket, QTcpSocket
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
15 from PyQt6.QtWidgets import QLabel, QTabWidget, QToolButton, QWidget
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
16
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
17 try:
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
18 from PyQt6.QtNetwork import QSslConfiguration, QSslSocket
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
19
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
20 from eric7.EricNetwork.EricSslErrorHandler import (
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
21 EricSslErrorHandler,
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
22 EricSslErrorState,
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
23 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
24
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
25 SSL_AVAILABLE = True
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
26 except ImportError:
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
27 SSL_AVAILABLE = False
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
29 from eric7 import Preferences
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
30 from eric7.EricGui import EricPixmapCache
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
31 from eric7.EricWidgets import EricMessageBox
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
32 from eric7.SystemUtilities import OSUtilities
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
33 from eric7.UI.Info import Copyright, Version
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
35 from .IrcNetworkManager import IrcNetworkManager
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 from .Ui_IrcWidget import Ui_IrcWidget
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 class IrcWidget(QWidget, Ui_IrcWidget):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Class implementing the IRC window.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
42
2258
9ca42fd3ecc0 Added a signal to the IRC widget fired after the autoconnect was initiated. This will make the IRC pane the current one on the right side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2256
diff changeset
43 @signal autoConnected() emitted after an automatic connection was initiated
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45
2258
9ca42fd3ecc0 Added a signal to the IRC widget fired after the autoconnect was initiated. This will make the IRC pane the current one on the right side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2256
diff changeset
46 autoConnected = pyqtSignal()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
47
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
48 ServerDisconnected = 1
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
49 ServerConnected = 2
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
50 ServerConnecting = 3
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 def __init__(self, parent=None):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
55
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
56 @param parent reference to the parent widget
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
57 @type QWidget
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
59 super().__init__(parent)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.setupUi(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
61
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.__ircNetworkManager = IrcNetworkManager(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
63
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__leaveButton = QToolButton(self)
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
65 self.__leaveButton.setIcon(EricPixmapCache.getIcon("ircCloseChannel"))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
66 self.__leaveButton.setToolTip(self.tr("Press to leave the current channel"))
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
67 self.__leaveButton.clicked.connect(self.__leaveChannel)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__leaveButton.setEnabled(False)
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
69 self.channelsWidget.setCornerWidget(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
70 self.__leaveButton, Qt.Corner.BottomRightCorner
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.channelsWidget.setTabsClosable(False)
9624
b47dfa7a137d Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9576
diff changeset
73 if not OSUtilities.isMacPlatform():
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
74 self.channelsWidget.setTabPosition(QTabWidget.TabPosition.South)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
75
2271
7dd914b6eb7d Some corrections and a little addition to the IRC window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2268
diff changeset
76 height = self.height()
8647
cdbce48aded8 Corrected some int-type related issues unfolded by Python 3.10.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8366
diff changeset
77 self.splitter.setSizes([int(height * 0.6), int(height * 0.4)])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__channelList = []
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__channelTypePrefixes = ""
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__userName = ""
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
82 self.__identityName = ""
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
83 self.__quitMessage = ""
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.__nickIndex = -1
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__nickName = ""
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__server = None
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__registering = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
89 self.__connectionState = IrcWidget.ServerDisconnected
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
90 self.__sslErrorLock = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
91
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__buffer = ""
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.__userPrefix = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
94
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
95 self.__socket = None
2354
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2339
diff changeset
96 if SSL_AVAILABLE:
8354
12ebd3934fef Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
97 self.__sslErrorHandler = EricSslErrorHandler(self)
2354
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2339
diff changeset
98 else:
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2339
diff changeset
99 self.__sslErrorHandler = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
100
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__patterns = [
2255
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
102 # :foo_!n=foo@foohost.bar.net PRIVMSG bar_ :some long message
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
103 (re.compile(r":([^!]+)!([^ ]+)\sPRIVMSG\s([^ ]+)\s:(.*)"), self.__query),
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 # :foo.bar.net COMMAND some message
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
105 (re.compile(r""":([^ ]+)\s+([A-Z]+)\s+(.+)"""), self.__handleNamedMessage),
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 # :foo.bar.net 123 * :info
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
107 (re.compile(r""":([^ ]+)\s+(\d{3})\s+(.+)"""), self.__handleNumericMessage),
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 # PING :ping message
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 (re.compile(r"""PING\s+:(.*)"""), self.__ping),
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 ]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.__prefixRe = re.compile(r""".*\sPREFIX=\((.*)\)([^ ]+).*""")
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.__chanTypesRe = re.compile(r""".*\sCHANTYPES=([^ ]+).*""")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
113
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
114 ircPic = EricPixmapCache.getPixmap("irc128")
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.__emptyLabel = QLabel()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.__emptyLabel.setPixmap(ircPic)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
117 self.__emptyLabel.setAlignment(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
118 Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignHCenter
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
119 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.channelsWidget.addTab(self.__emptyLabel, "")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
121
2253
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
122 # all initialized, do connections now
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
123 self.__ircNetworkManager.dataChanged.connect(self.__networkDataChanged)
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
124 self.networkWidget.initialize(self.__ircNetworkManager)
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
125 self.networkWidget.connectNetwork.connect(self.__connectNetwork)
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
126 self.networkWidget.editNetwork.connect(self.__editNetwork)
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
127 self.networkWidget.joinChannel.connect(self.joinChannel)
2253
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
128 self.networkWidget.nickChanged.connect(self.__changeNick)
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
129 self.networkWidget.sendData.connect(self.__send)
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
130 self.networkWidget.away.connect(self.__away)
2258
9ca42fd3ecc0 Added a signal to the IRC widget fired after the autoconnect was initiated. This will make the IRC pane the current one on the right side.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2256
diff changeset
131 self.networkWidget.autoConnected.connect(self.autoConnected)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
132
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 def shutdown(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 Public method to shut down the widget.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
136
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
137 @return flag indicating successful shutdown
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
138 @rtype bool
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 if self.__server:
2299
73285f9b53d4 Added an option to confirm a shutdown of eric5 when there is still a connection to an IRC server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2296
diff changeset
141 if Preferences.getIrc("AskOnShutdown"):
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8354
diff changeset
142 ok = EricMessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
143 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
144 self.tr("Disconnect from Server"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
145 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
146 """<p>Do you really want to disconnect from"""
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
147 """ <b>{0}</b>?</p><p>All channels will be closed."""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
148 """</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
149 ).format(self.__server.getName()),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
150 )
2299
73285f9b53d4 Added an option to confirm a shutdown of eric5 when there is still a connection to an IRC server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2296
diff changeset
151 else:
73285f9b53d4 Added an option to confirm a shutdown of eric5 when there is still a connection to an IRC server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2296
diff changeset
152 ok = True
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if ok:
5564
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
154 self.__connectNetwork("", False, True)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 else:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 ok = True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
157
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 if ok:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.__ircNetworkManager.close()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
160
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 return ok
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
162
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
163 def autoConnect(self):
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
164 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
165 Public method to initiate the IRC auto connection.
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
166 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
167 self.networkWidget.autoConnect()
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
168
4630
7b0e38956b5c Refined the online state change behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
169 def __connectNetwork(self, name, connect, silent):
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 Private slot to connect to or disconnect from the given network.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
172
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
173 @param name name of the network to connect to
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
174 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
175 @param connect flag indicating to connect
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
176 @type bool
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
177 @param silent flag indicating a silent connect/disconnect
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
178 @type bool
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 if connect:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 network = self.__ircNetworkManager.getNetwork(name)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
182 if network:
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
183 self.__server = network.getServer()
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
184 self.__identityName = network.getIdentityName()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
185 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
186 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
187 self.__userName = identity.getIdent()
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
188 self.__quitMessage = identity.getQuitMessage()
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
189 if self.__server:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
190 useSSL = self.__server.useSSL()
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
191 if useSSL and not SSL_AVAILABLE:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8354
diff changeset
192 EricMessageBox.critical(
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
193 self,
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
194 self.tr("SSL Connection"),
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
195 self.tr(
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
196 """An encrypted connection to the IRC"""
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
197 """ network was requested but SSL is not"""
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
198 """ available. Please change the server"""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
199 """ configuration."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
200 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
201 )
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
202 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
203
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
204 if useSSL:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
205 # create SSL socket
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
206 self.__socket = QSslSocket(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
207 self.__socket.encrypted.connect(self.__hostConnected)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
208 self.__socket.sslErrors.connect(self.__sslErrors)
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
209 else:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
210 # create TCP socket
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
211 self.__socket = QTcpSocket(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
212 self.__socket.connected.connect(self.__hostConnected)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
213 self.__socket.hostFound.connect(self.__hostFound)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
214 self.__socket.disconnected.connect(self.__hostDisconnected)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
215 self.__socket.readyRead.connect(self.__readyRead)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
216 self.__socket.errorOccurred.connect(self.__tcpError)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
217
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
218 self.__connectionState = IrcWidget.ServerConnecting
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
219 if useSSL:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
220 self.networkWidget.addServerMessage(
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
221 self.tr("Info"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
222 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
223 "Looking for server {0} (port {1})"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
224 " using an SSL encrypted connection"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
225 "..."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
226 ).format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
227 self.__server.getName(), self.__server.getPort()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
228 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
229 )
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
230 self.__socket.connectToHostEncrypted(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
231 self.__server.getName(), self.__server.getPort()
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
232 )
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
233 else:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
234 self.networkWidget.addServerMessage(
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
235 self.tr("Info"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
236 self.tr("Looking for server {0} (port {1})...").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
237 self.__server.getName(), self.__server.getPort()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
238 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
239 )
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
240 self.__socket.connectToHost(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
241 self.__server.getName(), self.__server.getPort()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
242 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 else:
2339
4ee173db22c2 Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2336
diff changeset
244 if silent:
4ee173db22c2 Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2336
diff changeset
245 ok = True
4ee173db22c2 Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2336
diff changeset
246 else:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8354
diff changeset
247 ok = EricMessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
248 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
249 self.tr("Disconnect from Server"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
250 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
251 """<p>Do you really want to disconnect from"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
252 """ <b>{0}</b>?</p><p>All channels will be"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
253 """ closed.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
254 ).format(self.__server.getName()),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
255 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 if ok:
5089
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
257 if self.__server is not None:
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
258 self.networkWidget.addServerMessage(
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
259 self.tr("Info"),
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
260 self.tr("Disconnecting from server {0}...").format(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
261 self.__server.getName()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
262 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
263 )
5089
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
264 elif name:
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
265 self.networkWidget.addServerMessage(
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
266 self.tr("Info"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
267 self.tr("Disconnecting from network {0}...").format(name),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
268 )
5089
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
269 else:
700fc0934424 Fixed an issue in the IRC widget causing a traceback when a computer is put to sleep (seems to be related to disconnecting twice from a chat server).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
270 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
271 self.tr("Info"), self.tr("Disconnecting from server.")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
272 )
2336
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
273 self.__closeAllChannels()
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
274 self.__send("QUIT :" + self.__quitMessage)
5564
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
275 if self.__socket:
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
276 self.__socket.flush()
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
277 self.__socket.close()
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
278 if self.__socket:
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
279 # socket is still existing
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
280 self.__socket.deleteLater()
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
281 self.__socket = None
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
282 self.__userName = ""
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
283 self.__identityName = ""
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
284 self.__quitMessage = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
285
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
286 @pyqtSlot()
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
287 def __editNetwork(self):
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 Private slot to edit the network configuration.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2360
diff changeset
291 from .IrcNetworkListDialog import IrcNetworkListDialog
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
292
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
293 dlg = IrcNetworkListDialog(self.__ircNetworkManager, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
294 dlg.exec()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
295
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
296 def __networkDataChanged(self):
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
297 """
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
298 Private slot handling changes of the network and identity definitions.
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
299 """
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
300 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
301 if identity:
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
302 partMsg = identity.getPartMessage()
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
303 for channel in self.__channelList:
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
304 channel.setPartMessage(partMsg)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
305
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
306 def joinChannel(self, name, key=""):
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 """
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
308 Public slot to join a channel.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
309
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
310 @param name name of the channel
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
311 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
312 @param key key of the channel
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
313 @type str
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
315 from .IrcChannelWidget import IrcChannelWidget
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
316
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 # step 1: check, if this channel is already joined
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 for channel in self.__channelList:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 if channel.name() == name:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
321
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 channel = IrcChannelWidget(self)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 channel.setName(name)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 channel.setUserName(self.__nickName)
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
325 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
326 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
327 channel.setPartMessage(identity.getPartMessage())
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 channel.setUserPrivilegePrefix(self.__userPrefix)
2253
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
329 channel.initAutoWho()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
330
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 channel.sendData.connect(self.__send)
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
332 channel.sendCtcpRequest.connect(self.__sendCtcpRequest)
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
333 channel.sendCtcpReply.connect(self.__sendCtcpReply)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 channel.channelClosed.connect(self.__closeChannel)
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
335 channel.openPrivateChat.connect(self.__openPrivate)
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
336 channel.awayCommand.connect(self.networkWidget.handleAwayCommand)
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
337 channel.leaveChannels.connect(self.__leaveChannels)
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
338 channel.leaveAllChannels.connect(self.__leaveAllChannels)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
339
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 self.channelsWidget.addTab(channel, name)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 self.__channelList.append(channel)
2253
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
342 self.channelsWidget.setCurrentWidget(channel)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
343
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
344 joinCommand = ["JOIN", name]
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
345 if key:
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
346 joinCommand.append(key)
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
347 self.__send(" ".join(joinCommand))
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 self.__send("MODE " + name)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
349
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 emptyIndex = self.channelsWidget.indexOf(self.__emptyLabel)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 if emptyIndex > -1:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 self.channelsWidget.removeTab(emptyIndex)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 self.__leaveButton.setEnabled(True)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 self.channelsWidget.setTabsClosable(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
355
2255
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
356 def __query(self, match):
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
357 """
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
358 Private method to handle a new private connection.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
359
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
360 @param match reference to the match object
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
361 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
362 @return flag indicating, if the message was handled
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
363 @rtype bool
2255
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
364 """
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
365 # group(1) sender user name
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
366 # group(2) sender user@host
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
367 # group(3) target nick
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
368 # group(4) message
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
369 if match.group(4).startswith("\x01"):
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
370 return self.__handleCtcp(match)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
371
2255
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
372 self.__openPrivate(match.group(1))
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
373 # the above call sets the new channel as the current widget
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
374 channel = self.channelsWidget.currentWidget()
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
375 channel.addMessage(match.group(1), match.group(4))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
376 channel.setPrivateInfo("{0} - {1}".format(match.group(1), match.group(2)))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
377
2255
3e728bfc178c Added a specialized line edit for entering IRC messages, which supports a non-persistent edit history.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2253
diff changeset
378 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
379
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
380 @pyqtSlot(str)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
381 def __openPrivate(self, name):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
382 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
383 Private slot to open a private chat with the given user.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
384
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
385 @param name name of the user
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
386 @type str
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
387 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2360
diff changeset
388 from .IrcChannelWidget import IrcChannelWidget
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
389
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
390 channel = IrcChannelWidget(self)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
391 channel.setName(self.__nickName)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
392 channel.setUserName(self.__nickName)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
393 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
394 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
395 channel.setPartMessage(identity.getPartMessage())
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
396 channel.setUserPrivilegePrefix(self.__userPrefix)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
397 channel.setPrivate(True, name)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
398 channel.addUsers([name, self.__nickName])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
399
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
400 channel.sendData.connect(self.__send)
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
401 channel.sendCtcpRequest.connect(self.__sendCtcpRequest)
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
402 channel.sendCtcpReply.connect(self.__sendCtcpReply)
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
403 channel.channelClosed.connect(self.__closeChannel)
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
404 channel.awayCommand.connect(self.networkWidget.handleAwayCommand)
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
405 channel.leaveChannels.connect(self.__leaveChannels)
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
406 channel.leaveAllChannels.connect(self.__leaveAllChannels)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
407
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
408 self.channelsWidget.addTab(channel, name)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
409 self.__channelList.append(channel)
2253
7ba2af1ff785 Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2252
diff changeset
410 self.channelsWidget.setCurrentWidget(channel)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
411
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 @pyqtSlot()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 def __leaveChannel(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 Private slot to leave a channel and close the associated tab.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 channel = self.channelsWidget.currentWidget()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 channel.requestLeave()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
419
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
420 @pyqtSlot(list)
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
421 def __leaveChannels(self, channelNames):
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
422 """
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
423 Private slot to leave a list of channels and close their associated
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
424 tabs.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
425
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
426 @param channelNames list of channels to leave
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
427 @type list of str
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
428 """
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
429 for channelName in channelNames:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
430 for channel in self.__channelList:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
431 if channel.name() == channelName:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
432 channel.leaveChannel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
433
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
434 @pyqtSlot()
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
435 def __leaveAllChannels(self):
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
436 """
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
437 Private slot to leave all channels and close their tabs.
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
438 """
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
439 while self.__channelList:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
440 channel = self.__channelList[0]
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
441 channel.leaveChannel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
442
2336
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
443 def __closeAllChannels(self):
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
444 """
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
445 Private method to close all channels.
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
446 """
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
447 while self.__channelList:
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
448 channel = self.__channelList.pop()
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
449 self.channelsWidget.removeTab(self.channelsWidget.indexOf(channel))
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
450 channel.deleteLater()
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
451 channel = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
452
2469
20d2166280bb Fixed an issue in the IRC widget when disconnecting from the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
453 self.channelsWidget.addTab(self.__emptyLabel, "")
20d2166280bb Fixed an issue in the IRC widget when disconnecting from the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
454 self.__emptyLabel.show()
20d2166280bb Fixed an issue in the IRC widget when disconnecting from the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
455 self.__leaveButton.setEnabled(False)
20d2166280bb Fixed an issue in the IRC widget when disconnecting from the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
456 self.channelsWidget.setTabsClosable(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
457
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 def __closeChannel(self, name):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 Private slot handling the closing of a channel.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
461
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
462 @param name name of the closed channel
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
463 @type str
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 for channel in self.__channelList:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 if channel.name() == name:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
467 self.channelsWidget.removeTab(self.channelsWidget.indexOf(channel))
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 self.__channelList.remove(channel)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 channel.deleteLater()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
470
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 if self.channelsWidget.count() == 0:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 self.channelsWidget.addTab(self.__emptyLabel, "")
2271
7dd914b6eb7d Some corrections and a little addition to the IRC window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2268
diff changeset
473 self.__emptyLabel.show()
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 self.__leaveButton.setEnabled(False)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 self.channelsWidget.setTabsClosable(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
476
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 @pyqtSlot(int)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 def on_channelsWidget_tabCloseRequested(self, index):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 Private slot to close a channel by pressing the close button of
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 the channels widget.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
482
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
483 @param index index of the tab to be closed
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
484 @type int
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 channel = self.channelsWidget.widget(index)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 channel.requestLeave()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
488
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 def __send(self, data):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 Private slot to send data to the IRC server.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
492
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
493 @param data data to be sent
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
494 @type str
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 """
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
496 if self.__socket:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
497 self.__socket.write(QByteArray("{0}\r\n".format(data).encode("utf-8")))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
498
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
499 def __sendCtcpRequest(self, receiver, request, arguments):
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
500 """
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
501 Private slot to send a CTCP request.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
502
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
503 @param receiver nick name of the receiver
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
504 @type str
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
505 @param request CTCP request to be sent
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
506 @type str
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
507 @param arguments arguments to be sent
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
508 @type str
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
509 """
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
510 request = request.upper()
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
511 if request == "PING":
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
512 arguments = "Eric IRC {0}".format(QDateTime.currentMSecsSinceEpoch())
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
513
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
514 self.__send("PRIVMSG {0} :\x01{1} {2}\x01".format(receiver, request, arguments))
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
515
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
516 def __sendCtcpReply(self, receiver, text):
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
517 """
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
518 Private slot to send a CTCP reply.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
519
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
520 @param receiver nick name of the receiver
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
521 @type str
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
522 @param text text to be sent
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
523 @type str
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
524 """
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
525 self.__send("NOTICE {0} :\x01{1}\x01".format(receiver, text))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
526
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 def __hostFound(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 Private slot to indicate the host was found.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
531 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
532 self.tr("Info"), self.tr("Server found,connecting...")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
533 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
534
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 def __hostConnected(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
537 Private slot to log in to the server after the connection was
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
538 established.
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
540 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
541 self.tr("Info"), self.tr("Connected,logging in...")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
542 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 self.networkWidget.setConnected(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
544
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 self.__registering = True
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 serverPassword = self.__server.getPassword()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 if serverPassword:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 self.__send("PASS " + serverPassword)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
549
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
550 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 nick = self.networkWidget.getNickname()
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
552 if not nick and identity:
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 self.__nickIndex = 0
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 try:
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
555 nick = identity.getNickNames()[self.__nickIndex]
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 except IndexError:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 nick = ""
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 if not nick:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 nick = self.__userName
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 self.__nickName = nick
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 self.networkWidget.setNickName(nick)
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
562 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
563 realName = identity.getRealName()
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
564 if not realName:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
565 realName = "eric IDE chat"
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
566 self.__send("NICK " + nick)
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
567 self.__send("USER " + self.__userName + " 0 * :" + realName)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
568
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 def __hostDisconnected(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 Private slot to indicate the host was disconnected.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 """
2528
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
573 if self.networkWidget.isConnected():
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
574 self.__closeAllChannels()
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
575 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
576 self.tr("Info"), self.tr("Server disconnected.")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
577 )
2528
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
578 self.networkWidget.setRegistered(False)
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
579 self.networkWidget.setConnected(False)
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
580 self.__server = None
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
581 self.__nickName = ""
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
582 self.__nickIndex = -1
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
583 self.__channelTypePrefixes = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
584
7096
6ce0678583e5 IrcWidget: fixed an issue disconnecting the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
585 if self.__socket:
6ce0678583e5 IrcWidget: fixed an issue disconnecting the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
586 self.__socket.deleteLater()
2528
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
587 self.__socket = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
588
2528
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
589 self.__connectionState = IrcWidget.ServerDisconnected
688c7ef0a5b0 Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2527
diff changeset
590 self.__sslErrorLock = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
591
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 def __readyRead(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 Private slot to read data from the socket.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 """
2527
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
596 if self.__socket:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
597 self.__buffer += str(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
598 self.__socket.readAll(), Preferences.getSystem("IOEncoding"), "replace"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
599 )
2527
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
600 if self.__buffer.endswith("\r\n"):
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
601 for line in self.__buffer.splitlines():
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
602 line = line.strip()
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
603 if line:
6181
2ae7e332b941 Fixed logging format issues detected by the latest code style checker additions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
604 logging.debug("<IRC> %s", line)
2527
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
605 handled = False
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
606 # step 1: give channels a chance to handle the message
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
607 for channel in self.__channelList:
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
608 handled = channel.handleMessage(line)
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
609 if handled:
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
610 break
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 else:
2527
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
612 # step 2: try to process the message ourselves
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
613 for patternRe, patternFunc in self.__patterns:
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
614 match = patternRe.match(line)
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
615 if match is not None and patternFunc(match):
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
616 break
2527
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
617 else:
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
618 # Oops, the message wasn't handled
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
619 self.networkWidget.addErrorMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
620 self.tr("Message Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
621 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
622 "Unknown message received from server:"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
623 "<br/>{0}"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
624 ).format(line),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
625 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
626
2527
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
627 self.__updateUsersCount()
867488bb56b0 Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2469
diff changeset
628 self.__buffer = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
629
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
630 def __handleCtcpReply(self, match):
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
631 """
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
632 Private method to handle a server message containing a CTCP reply.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
633
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
634 @param match reference to the match object
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
635 @type re.Match
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
636 """
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
637 if "!" in match.group(1):
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
638 sender = match.group(1).split("!", 1)[0]
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
639
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
640 try:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
641 ctcpCommand = match.group(3).split(":", 1)[1]
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
642 except IndexError:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
643 ctcpCommand = match.group(3)
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
644 ctcpCommand = ctcpCommand[1:].split("\x01", 1)[0]
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
645 if " " in ctcpCommand:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
646 ctcpReply, ctcpArg = ctcpCommand.split(" ", 1)
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
647 else:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
648 ctcpReply, ctcpArg = ctcpCommand, ""
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
649 ctcpReply = ctcpReply.upper()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
650
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
651 if ctcpReply == "PING" and ctcpArg.startswith("Eric IRC "):
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
652 # it is a response to a ping request
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
653 pingDateTime = int(ctcpArg.split()[-1])
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
654 latency = QDateTime.currentMSecsSinceEpoch() - pingDateTime
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
655 self.networkWidget.addServerMessage(
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
656 self.tr("CTCP"),
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
657 self.tr(
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
658 "Received CTCP-PING response from {0} with latency"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
659 " of {1} ms."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
660 ).format(sender, latency),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
661 )
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
662 else:
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
663 self.networkWidget.addServerMessage(
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
664 self.tr("CTCP"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
665 self.tr("Received unknown CTCP-{0} response from {1}.").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
666 ctcpReply, sender
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
667 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
668 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
669
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 def __handleNamedMessage(self, match):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 Private method to handle a server message containing a message name.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
673
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
674 @param match reference to the match object
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
675 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
676 @return flag indicating, if the message was handled
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
677 @rtype bool
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 name = match.group(2)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 if name == "NOTICE":
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 try:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 msg = match.group(3).split(":", 1)[1]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 except IndexError:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 msg = match.group(3)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
685
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
686 if msg.startswith("\x01"):
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
687 self.__handleCtcpReply(match)
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
688 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
689
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
690 if "!" in match.group(1):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
691 name = match.group(1).split("!", 1)[0]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 msg = "-{0}- {1}".format(name, msg)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
693 self.networkWidget.addServerMessage(self.tr("Notice"), msg)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 return True
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 elif name == "MODE":
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 self.__registering = False
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697 if ":" in match.group(3):
5564
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
698 # :foo MODE foo :+i
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699 name, modes = match.group(3).split(" :")
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 sourceNick = match.group(1)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
701 if not self.isChannelName(name) and name == self.__nickName:
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
702 if sourceNick == self.__nickName:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
703 msg = self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
704 "You have set your personal modes to <b>[{0}]</b>."
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
705 ).format(modes)
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
706 else:
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
707 msg = self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
708 "{0} has changed your personal modes to <b>[{1}]</b>."
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
709 ).format(sourceNick, modes)
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
710 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
711 self.tr("Mode"), msg, filterMsg=False
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
712 )
8222
5994b80b8760 Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
713 return True
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 elif name == "PART":
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 nick = match.group(1).split("!", 1)[0]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 if nick == self.__nickName:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 channel = match.group(3).split(None, 1)[0]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 self.networkWidget.addMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
719 self.tr("You have left channel {0}.").format(channel)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
720 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 return True
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
722 elif name == "QUIT":
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
723 # don't do anything with it here
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
724 return True
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 elif name == "NICK":
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 # :foo_!n=foo@foohost.bar.net NICK :newnick
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 oldNick = match.group(1).split("!", 1)[0]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 newNick = match.group(3).split(":", 1)[1]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 if oldNick == self.__nickName:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 self.networkWidget.addMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
731 self.tr("You are now known as {0}.").format(newNick)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
732 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 self.__nickName = newNick
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 self.networkWidget.setNickName(newNick)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 else:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 self.networkWidget.addMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
737 self.tr("User {0} is now known as {1}.").format(oldNick, newNick)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
738 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 return True
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
740 elif name == "PONG":
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
741 nick = match.group(3).split(":", 1)[1]
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
742 self.networkWidget.addMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
743 self.tr("Received PONG from {0}").format(nick)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
744 )
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
745 return True
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
746 elif name == "ERROR":
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
747 self.networkWidget.addErrorMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
748 self.tr("Server Error"), match.group(3).split(":", 1)[1]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
749 )
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
750 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
751
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
753
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 def __handleNumericMessage(self, match):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 Private method to handle a server message containing a numeric code.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
757
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
758 @param match reference to the match object
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
759 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
760 @return flag indicating, if the message was handled
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
761 @rtype bool
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 code = int(match.group(2))
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 if code < 400:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
765 return self.__handleServerReply(code, match.group(1), match.group(3))
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 else:
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
767 return self.__handleServerError(code, match.group(3))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
768
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
769 def __handleServerError(self, code, message):
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 Private slot to handle a server error reply.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
772
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
773 @param code numerical code sent by the server
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
774 @type int
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
775 @param message message sent by the server
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
776 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
777 @return flag indicating, if the message was handled
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
778 @rtype bool
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 if code == 433:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 if self.__registering:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 self.__handleNickInUseLogin()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 else:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 self.__handleNickInUse()
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
786 self.networkWidget.addServerMessage(self.tr("Error"), message)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
787
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
789
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 def __handleServerReply(self, code, server, message):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 Private slot to handle a server reply.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
793
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
794 @param code numerical code sent by the server
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
795 @type int
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
796 @param server name of the server
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
797 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
798 @param message message sent by the server
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
799 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
800 @return flag indicating, if the message was handled
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
801 @rtype bool
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 # determine message type
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 if code in [1, 2, 3, 4]:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
805 msgType = self.tr("Welcome")
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806 elif code == 5:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
807 msgType = self.tr("Support")
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 elif code in [250, 251, 252, 253, 254, 255, 265, 266]:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
809 msgType = self.tr("User")
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 elif code in [372, 375, 376]:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
811 msgType = self.tr("MOTD")
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
812 elif code in [305, 306]:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
813 msgType = self.tr("Away")
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
815 msgType = self.tr("Info ({0})").format(code)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
816
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 # special treatment for some messages
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 if code == 375:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
819 message = self.tr("Message of the day")
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 elif code == 376:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
821 message = self.tr("End of message of the day")
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 elif code == 4:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 parts = message.strip().split()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
824 message = self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
825 "Server {0} (Version {1}), User-Modes: {2}, Channel-Modes: {3}"
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
826 ).format(parts[1], parts[2], parts[3], parts[4])
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 elif code == 265:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 parts = message.strip().split()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
829 message = self.tr("Current users on {0}: {1}, max. {2}").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
830 server, parts[1], parts[2]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
831 )
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 elif code == 266:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833 parts = message.strip().split()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
834 message = self.tr("Current users on the network: {0}, max. {1}").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
835 parts[1], parts[2]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
836 )
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
837 elif code == 305:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
838 message = self.tr("You are no longer marked as being away.")
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
839 elif code == 306:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
840 message = self.tr("You have been marked as being away.")
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 else:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842 first, message = message.split(None, 1)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
843 if message.startswith(":"):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 message = message[1:]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 else:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 message = message.replace(":", "", 1)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
847
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 self.networkWidget.addServerMessage(msgType, message)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
849
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850 if code == 1:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 # register with services after the welcome message
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
852 self.__connectionState = IrcWidget.ServerConnected
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 self.__registerWithServices()
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2243
diff changeset
854 self.networkWidget.setRegistered(True)
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
855 QTimer.singleShot(1000, self.__autoJoinChannels)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 elif code == 5:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 # extract the user privilege prefixes
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 # ... PREFIX=(ov)@+ ...
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 m = self.__prefixRe.match(message)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 if m:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 self.__setUserPrivilegePrefix(m.group(1), m.group(2))
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 # extract the channel type prefixes
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 # ... CHANTYPES=# ...
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 m = self.__chanTypesRe.match(message)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 if m:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 self.__setChannelTypePrefixes(m.group(1))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
867
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
869
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 def __registerWithServices(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 Private method to register to services.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
874 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
875 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
876 service = identity.getServiceName()
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
877 password = identity.getPassword()
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
878 if service and password:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
879 self.__send("PRIVMSG " + service + " :identify " + password)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
880
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
881 def __autoJoinChannels(self):
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
882 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
883 Private slot to join channels automatically once a server got
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
884 connected.
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
885 """
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
886 for channel in self.networkWidget.getNetworkChannels():
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
887 if channel.autoJoin():
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
888 name = channel.getName()
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
889 key = channel.getKey()
6514
f11a703e4664 IRC: added support for the /query, /notice, /ping, /ignore, /unignore, /away, /join, /part and /partall commands.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6181
diff changeset
890 self.joinChannel(name, key)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
891
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892 def __tcpError(self, error):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
894 Private slot to handle errors reported by the TCP socket.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
895
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
896 @param error error code reported by the socket
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
897 @type QAbstractSocket.SocketError
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898 """
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
899 if error == QAbstractSocket.SocketError.RemoteHostClosedError:
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 # ignore this one, it's a disconnect
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
901 if self.__sslErrorLock:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
902 self.networkWidget.addErrorMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
903 self.tr("SSL Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
904 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
905 """Connection to server {0} (port {1}) lost while"""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
906 """ waiting for user response to an SSL error."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
907 ).format(self.__server.getName(), self.__server.getPort()),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
908 )
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
909 self.__connectionState = IrcWidget.ServerDisconnected
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
910 elif error == QAbstractSocket.SocketError.HostNotFoundError:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
911 self.networkWidget.addErrorMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
912 self.tr("Socket Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
913 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
914 "The host was not found. Please check the host name"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
915 " and port settings."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
916 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
917 )
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
918 elif error == QAbstractSocket.SocketError.ConnectionRefusedError:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
919 self.networkWidget.addErrorMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
920 self.tr("Socket Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
921 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
922 "The connection was refused by the peer. Please check the"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
923 " host name and port settings."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
924 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
925 )
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
926 elif error == QAbstractSocket.SocketError.SslHandshakeFailedError:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
927 self.networkWidget.addErrorMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
928 self.tr("Socket Error"), self.tr("The SSL handshake failed.")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
929 )
2292
1e29752b51d7 Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2280
diff changeset
930 else:
1e29752b51d7 Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2280
diff changeset
931 if self.__socket:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
932 self.networkWidget.addErrorMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
933 self.tr("Socket Error"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
934 self.tr("The following network error occurred:<br/>{0}").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
935 self.__socket.errorString()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
936 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
937 )
2292
1e29752b51d7 Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2280
diff changeset
938 else:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
939 self.networkWidget.addErrorMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
940 self.tr("Socket Error"), self.tr("A network error occurred.")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
941 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
942
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
943 def __sslErrors(self, errors):
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
944 """
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
945 Private slot to handle SSL errors.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
946
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
947 @param errors list of SSL errors
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
948 @type list of QSslError
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
949 """
2360
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
950 ignored, defaultChanged = self.__sslErrorHandler.sslErrors(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
951 errors, self.__server.getName(), self.__server.getPort()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
952 )
8354
12ebd3934fef Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
953 if ignored == EricSslErrorState.NOT_IGNORED:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
954 self.networkWidget.addErrorMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
955 self.tr("SSL Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
956 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
957 """Could not connect to {0} (port {1}) using an SSL"""
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
958 """ encrypted connection. Either the server does not"""
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
959 """ support SSL (did you use the correct port?) or"""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
960 """ you rejected the certificate."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
961 ).format(self.__server.getName(), self.__server.getPort()),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
962 )
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
963 self.__socket.close()
2360
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
964 else:
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
965 if defaultChanged:
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
966 self.__socket.setSslConfiguration(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
967 QSslConfiguration.defaultConfiguration()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
968 )
8354
12ebd3934fef Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
969 if ignored == EricSslErrorState.USER_IGNORED:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
970 self.networkWidget.addErrorMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
971 self.tr("SSL Error"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
972 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
973 """The SSL certificate for the server {0} (port {1})"""
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
974 """ failed the authenticity check. SSL errors"""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
975 """ were accepted by you."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
976 ).format(self.__server.getName(), self.__server.getPort()),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
977 )
2360
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
978 if self.__connectionState == IrcWidget.ServerConnecting:
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
979 self.__socket.ignoreSslErrors()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
980
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 def __setUserPrivilegePrefix(self, prefix1, prefix2):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 Private method to set the user privilege prefix.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
984
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
985 @param prefix1 first part of the prefix
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
986 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
987 @param prefix2 indictors the first part gets mapped to
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
988 @type str
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
990 # PREFIX=(ov)@+
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 # o = @ -> @ircbot , channel operator
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
992 # v = + -> +userName , voice operator
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993 for i in range(len(prefix1)):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 self.__userPrefix["+" + prefix1[i]] = prefix2[i]
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
995 self.__userPrefix["-" + prefix1[i]] = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
996
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997 def __ping(self, match):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 Private method to handle a PING message.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1000
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
1001 @param match reference to the match object
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1002 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1003 @return flag indicating, if the message was handled
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1004 @rtype bool
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1006 self.__send("PONG " + match.group(1))
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1008
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1009 def __handleCtcp(self, match):
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1010 """
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1011 Private method to handle a CTCP command.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1012
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
1013 @param match reference to the match object
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1014 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1015 @return flag indicating, if the message was handled
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1016 @rtype bool
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1017 """
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1018 # group(1) sender user name
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1019 # group(2) sender user@host
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1020 # group(3) target nick
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1021 # group(4) message
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1022 if match.group(4).startswith("\x01"):
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1023 ctcpCommand = match.group(4)[1:].split("\x01", 1)[0]
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1024 if " " in ctcpCommand:
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1025 ctcpRequest, ctcpArg = ctcpCommand.split(" ", 1)
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1026 else:
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1027 ctcpRequest, ctcpArg = ctcpCommand, ""
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1028 ctcpRequest = ctcpRequest.lower()
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1029 if ctcpRequest == "version":
2273
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1030 if Version.startswith("@@"):
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1031 vers = ""
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1032 else:
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1033 vers = " " + Version
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1034 msg = "Eric IRC client{0}, {1}".format(vers, Copyright)
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1035 self.networkWidget.addServerMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1036 self.tr("CTCP"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1037 self.tr("Received Version request from {0}.").format(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1038 match.group(1)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1039 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1040 )
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1041 self.__sendCtcpReply(match.group(1), "VERSION " + msg)
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1042 elif ctcpRequest == "ping":
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1043 self.networkWidget.addServerMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1044 self.tr("CTCP"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1045 self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
1046 "Received CTCP-PING request from {0}, sending answer."
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1047 ).format(match.group(1)),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1048 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1049 self.__sendCtcpReply(match.group(1), "PING {0}".format(ctcpArg))
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1050 elif ctcpRequest == "clientinfo":
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1051 self.networkWidget.addServerMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1052 self.tr("CTCP"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1053 self.tr(
9576
be9f8e7e42e0 Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
1054 "Received CTCP-CLIENTINFO request from {0}, sending answer."
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1055 ).format(match.group(1)),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1056 )
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1057 self.__sendCtcpReply(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1058 match.group(1), "CLIENTINFO CLIENTINFO PING VERSION"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1059 )
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1060 else:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1061 self.networkWidget.addServerMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1062 self.tr("CTCP"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1063 self.tr("Received unknown CTCP-{0} request from {1}.").format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1064 ctcpRequest, match.group(1)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1065 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1066 )
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1067 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1068
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1069 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1070
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1071 def __updateUsersCount(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1072 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1073 Private method to update the users count on the channel tabs.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1074 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1075 for channel in self.__channelList:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1076 index = self.channelsWidget.indexOf(channel)
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1077 self.channelsWidget.setTabText(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1078 index,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1079 self.tr("{0} ({1})", "channel name, users count").format(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1080 channel.name(), channel.getUsersCount()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1081 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1082 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1083
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1084 def __handleNickInUseLogin(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1085 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086 Private method to handle a 443 server error at login.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1087 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1088 self.__nickIndex += 1
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1089 try:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1090 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1091 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1092 nick = identity.getNickNames()[self.__nickIndex]
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1093 self.__nickName = nick
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1094 else:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1095 self.__connectNetwork("", False, True)
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1096 self.__nickName = ""
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1097 self.__nickIndex = -1
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1098 return
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1099 except IndexError:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1100 self.networkWidget.addServerMessage(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1101 self.tr("Critical"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1102 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1103 "No nickname acceptable to the server configured"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1104 " for <b>{0}</b>. Disconnecting..."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1105 ).format(self.__userName),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1106 filterMsg=False,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1107 )
4630
7b0e38956b5c Refined the online state change behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
1108 self.__connectNetwork("", False, True)
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1109 self.__nickName = ""
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1110 self.__nickIndex = -1
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1111 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1112
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1113 self.networkWidget.setNickName(nick)
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1114 self.__send("NICK " + nick)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1115
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1116 def __handleNickInUse(self):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1117 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1118 Private method to handle a 443 server error.
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1119 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1120 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1121 self.tr("Critical"), self.tr("The given nickname is already in use.")
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1122 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1123
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1124 def __changeNick(self, nick):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1125 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1126 Private slot to use a new nick name.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1127
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1128 @param nick nick name to use
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1129 @type str
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1130 """
2279
cbf90feec16f Fixed a non-fatal issue in the IRC widget related to changing an identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2273
diff changeset
1131 if nick and nick != self.__nickName:
2271
7dd914b6eb7d Some corrections and a little addition to the IRC window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2268
diff changeset
1132 self.__send("NICK " + nick)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1133
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1134 def __setChannelTypePrefixes(self, prefixes):
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1135 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1136 Private method to set the channel type prefixes.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1137
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1138 @param prefixes channel prefix characters
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1139 @type str
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1140 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1141 self.__channelTypePrefixes = prefixes
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1142
2256
d07e2e6f3c56 Implemented support for IRC WHOIS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2255
diff changeset
1143 def isChannelName(self, name):
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1144 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
1145 Public method to check, if the given name is a channel name.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1146
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1147 @param name name to check
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1148 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1149 @return flag indicating a channel name
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1150 @rtype bool
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1151 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1152 if not name:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1153 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1154
2227
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1155 if self.__channelTypePrefixes:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1156 return name[0] in self.__channelTypePrefixes
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1157 else:
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1158 return name[0] in "#&"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1159
2246
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
1160 def __away(self, isAway):
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
1161 """
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
1162 Private slot handling the change of the away state.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1163
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1164 @param isAway flag indicating the current away state
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1165 @type bool
2246
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
1166 """
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
1167 if isAway and self.__identityName:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1168 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1169 if identity and identity.rememberAwayPosition():
2246
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
1170 for channel in self.__channelList:
fdf22a29fbf4 Removed the "Auto Away" stuff because there is no universal way to check the computer for user inactivity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2245
diff changeset
1171 channel.setMarkerLine()

eric ide

mercurial