src/eric7/Network/IRC/IrcWidget.py

Wed, 03 Jan 2024 18:09:15 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 03 Jan 2024 18:09:15 +0100
branch
eric7
changeset 10475
ee41fab001f2
parent 10439
21c28b0f9e41
child 10481
9aea3575bd16
permissions
-rw-r--r--

Added a bunch of TODO markers to convert some definitions to an enum.

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
10439
21c28b0f9e41 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10428
diff changeset
3 # Copyright (c) 2012 - 2024 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
10475
ee41fab001f2 Added a bunch of TODO markers to convert some definitions to an enum.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
48 # TODO: change this to an enum
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
49 ServerDisconnected = 1
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
50 ServerConnected = 2
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
51 ServerConnecting = 3
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
52
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
53 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
54 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
56
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
57 @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
58 @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
59 """
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
60 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
61 self.setupUi(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
62
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
63 self.__ircNetworkManager = IrcNetworkManager(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
64
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
65 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
66 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
67 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
68 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
69 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
70 self.channelsWidget.setCornerWidget(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
71 self.__leaveButton, Qt.Corner.BottomRightCorner
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
72 )
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
73 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
74 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
75 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
76
2271
7dd914b6eb7d Some corrections and a little addition to the IRC window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2268
diff changeset
77 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
78 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
79
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
80 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
81 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
82 self.__userName = ""
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
83 self.__identityName = ""
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
84 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
85 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
86 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
87 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
88 self.__registering = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
89
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
90 self.__connectionState = IrcWidget.ServerDisconnected
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
91 self.__sslErrorLock = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
92
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
93 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
94 self.__userPrefix = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
95
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
96 self.__socket = None
2354
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2339
diff changeset
97 if SSL_AVAILABLE:
8354
12ebd3934fef Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
98 self.__sslErrorHandler = EricSslErrorHandler(self)
2354
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2339
diff changeset
99 else:
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2339
diff changeset
100 self.__sslErrorHandler = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
101
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
102 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
103 # :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
104 (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
105 # :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
106 (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
107 # :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
108 (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
109 # 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
110 (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
111 ]
b7aceb255831 First 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.__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
113 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
114
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
115 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
116 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
117 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
118 self.__emptyLabel.setAlignment(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
119 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
120 )
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
121 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
122
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
123 # 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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132 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
133
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
134 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
135 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 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
137
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
138 @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
139 @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
140 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 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
142 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
143 ok = EricMessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
144 self,
3190
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("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
146 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
147 """<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
148 """ <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
149 """</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
150 ).format(self.__server.getName()),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
151 )
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
152 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
153 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
154 if ok:
5564
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
155 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
156 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
157 ok = True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
158
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
159 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
160 self.__ircNetworkManager.close()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
161
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
162 return ok
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
163
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
164 def autoConnect(self):
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
165 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
166 Public method to initiate the IRC auto connection.
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
167 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
168 self.networkWidget.autoConnect()
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
169
4630
7b0e38956b5c Refined the online state change behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
170 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
171 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 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
173
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
174 @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
175 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
176 @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
177 @type bool
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
178 @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
179 @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
180 """
b7aceb255831 First 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 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
182 network = self.__ircNetworkManager.getNetwork(name)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
183 if network:
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
184 self.__server = network.getServer()
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
185 self.__identityName = network.getIdentityName()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186 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
187 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
188 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
189 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
190 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
191 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
192 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
193 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
194 self,
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("SSL Connection"),
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
196 self.tr(
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
197 """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
198 """ 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
199 """ 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
200 """ configuration."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
201 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
202 )
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
203 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
204
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
205 if useSSL:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
206 # 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
207 self.__socket = QSslSocket(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
208 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
209 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
210 else:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
211 # 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
212 self.__socket = QTcpSocket(self)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
213 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
214 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
215 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
216 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
217 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
218
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
219 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
220 if useSSL:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
221 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
222 self.tr("Info"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
223 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
224 "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
225 " using an SSL encrypted connection"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
226 "..."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
227 ).format(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
228 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
229 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
230 )
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
231 self.__socket.connectToHostEncrypted(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
232 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
233 )
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
234 else:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
235 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
236 self.tr("Info"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
237 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
238 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
239 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
240 )
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
241 self.__socket.connectToHost(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
242 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
243 )
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
244 else:
2339
4ee173db22c2 Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2336
diff changeset
245 if silent:
4ee173db22c2 Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2336
diff changeset
246 ok = True
4ee173db22c2 Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2336
diff changeset
247 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
248 ok = EricMessageBox.yesNo(
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
249 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
250 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
251 self.tr(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
252 """<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
253 """ <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
254 """ closed.</p>"""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
255 ).format(self.__server.getName()),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
256 )
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
257 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
258 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
259 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
260 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
261 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
262 self.__server.getName()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
263 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
264 )
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
265 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
266 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
267 self.tr("Info"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
268 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
269 )
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
270 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
271 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
272 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
273 )
2336
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
274 self.__closeAllChannels()
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
275 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
276 if self.__socket:
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
277 self.__socket.flush()
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
278 self.__socket.close()
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
279 if self.__socket:
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
280 # socket is still existing
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
281 self.__socket.deleteLater()
d670b282b5b5 Modified the shutdown procedure of the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
282 self.__socket = None
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
283 self.__userName = ""
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
284 self.__identityName = ""
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
285 self.__quitMessage = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
286
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
287 @pyqtSlot()
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
288 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
289 """
b7aceb255831 First 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 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
291 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2360
diff changeset
292 from .IrcNetworkListDialog import IrcNetworkListDialog
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
293
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2227
diff changeset
294 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
295 dlg.exec()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
296
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
297 def __networkDataChanged(self):
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
298 """
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
299 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
300 """
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
301 identity = self.__ircNetworkManager.getIdentity(self.__identityName)
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
302 if identity:
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
303 partMsg = identity.getPartMessage()
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
304 for channel in self.__channelList:
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
305 channel.setPartMessage(partMsg)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
306
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
307 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
308 """
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
309 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
310
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
311 @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
312 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
313 @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
314 @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
315 """
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
316 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
317
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
318 # 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
319 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
320 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
321 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
322
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
323 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
324 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
325 channel.setUserName(self.__nickName)
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
326 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
327 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
328 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
329 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
330 channel.initAutoWho()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
331
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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340
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
341 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
342 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
343 self.channelsWidget.setCurrentWidget(channel)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
344
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
345 joinCommand = ["JOIN", name]
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
346 if key:
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
347 joinCommand.append(key)
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
348 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
349 self.__send("MODE " + name)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
350
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
351 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
352 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
353 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
354 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
355 self.channelsWidget.setTabsClosable(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
356
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
357 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
358 """
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
359 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
360
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
361 @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
362 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
363 @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
364 @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
365 """
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(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
367 # 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
368 # 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
369 # group(4) message
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
370 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
371 return self.__handleCtcp(match)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
372
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
373 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
374 # 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
375 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
376 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
377 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
378
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
379 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
380
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
381 @pyqtSlot(str)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
382 def __openPrivate(self, name):
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
383 """
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
384 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
385
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
386 @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
387 @type str
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
388 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2360
diff changeset
389 from .IrcChannelWidget import IrcChannelWidget
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
390
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
391 channel = IrcChannelWidget(self)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
392 channel.setName(self.__nickName)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
393 channel.setUserName(self.__nickName)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
394 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
395 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
396 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
397 channel.setUserPrivilegePrefix(self.__userPrefix)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
398 channel.setPrivate(True, name)
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
399 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
400
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
401 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
402 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
403 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
404 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
405 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
406 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
407 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
408
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
409 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
410 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
411 self.channelsWidget.setCurrentWidget(channel)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
412
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
413 @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
414 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
415 """
b7aceb255831 First 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 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
417 """
b7aceb255831 First 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 = 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
419 channel.requestLeave()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
420
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
421 @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
422 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
423 """
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 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
425 tabs.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
426
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
427 @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
428 @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
429 """
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 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
431 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
432 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
433 channel.leaveChannel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
434
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
435 @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
436 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
437 """
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 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
439 """
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 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
441 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
442 channel.leaveChannel()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
443
2336
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
444 def __closeAllChannels(self):
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
445 """
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
446 Private method to close all channels.
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
447 """
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
448 while self.__channelList:
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
449 channel = self.__channelList.pop()
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
450 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
451 channel.deleteLater()
d9e47b8ee1ef Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
452 channel = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
453
2469
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.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
455 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
456 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
457 self.channelsWidget.setTabsClosable(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
458
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
459 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
460 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 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
462
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
463 @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
464 @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
465 """
b7aceb255831 First 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 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
467 if channel.name() == name:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
468 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
469 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
470 channel.deleteLater()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
471
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
472 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
473 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
474 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
475 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
476 self.channelsWidget.setTabsClosable(False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
477
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
478 @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
479 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
480 """
b7aceb255831 First 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 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
482 the channels widget.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
483
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
484 @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
485 @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
486 """
b7aceb255831 First 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 = 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
488 channel.requestLeave()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
489
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
490 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
491 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 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
493
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
494 @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
495 @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
496 """
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
497 if self.__socket:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
498 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
499
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
500 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
501 """
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
502 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
503
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
504 @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
505 @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
506 @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
507 @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
508 @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
509 @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
510 """
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 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
512 if request == "PING":
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
513 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
514
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
515 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
516
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
517 def __sendCtcpReply(self, receiver, text):
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
518 """
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
519 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
520
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
521 @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
522 @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
523 @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
524 @type str
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
525 """
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
526 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
527
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
528 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
529 """
b7aceb255831 First 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 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
531 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
532 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
533 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
534 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
535
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
536 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
537 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
538 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
539 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
540 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
541 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
542 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
543 )
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
544 self.networkWidget.setConnected(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
545
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
546 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
547 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
548 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
549 self.__send("PASS " + serverPassword)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
550
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
551 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
552 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
553 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
554 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
555 try:
6587
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
556 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
557 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
558 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 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
560 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
561 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
562 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
563 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
564 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
565 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
566 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
567 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
568 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
569
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
570 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
571 """
b7aceb255831 First 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 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
573 """
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
574 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
575 self.__closeAllChannels()
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
576 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
577 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
578 )
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
579 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
580 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
581 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
582 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
583 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
584 self.__channelTypePrefixes = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
585
7096
6ce0678583e5 IrcWidget: fixed an issue disconnecting the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
586 if self.__socket:
6ce0678583e5 IrcWidget: fixed an issue disconnecting the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
587 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
588 self.__socket = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
589
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
590 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
591 self.__sslErrorLock = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
592
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
593 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
594 """
b7aceb255831 First 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 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
596 """
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
597 if self.__socket:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
598 self.__buffer += str(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
599 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
600 )
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
601 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
602 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
603 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
604 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
605 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
606 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
607 # 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
608 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
609 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
610 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
611 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
612 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
613 # 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
614 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
615 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
616 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
617 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
618 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
619 # 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
620 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
621 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
622 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
623 "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
624 "<br/>{0}"
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
625 ).format(line),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
626 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
627
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
628 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
629 self.__buffer = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
630
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
631 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
632 """
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
633 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
634
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
635 @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
636 @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
637 """
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 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
639 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
640
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
641 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
642 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
643 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
644 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
645 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
646 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
647 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
648 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
649 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
650 ctcpReply = ctcpReply.upper()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
651
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
652 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
653 # 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
654 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
655 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
656 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
657 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
658 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
659 "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
660 " of {1} ms."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
661 ).format(sender, latency),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
662 )
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
663 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
664 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
665 self.tr("CTCP"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
666 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
667 ctcpReply, sender
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 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
670
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
671 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
672 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 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
674
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
675 @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
676 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
677 @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
678 @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
679 """
b7aceb255831 First 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 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
681 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
682 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
683 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
684 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
685 msg = match.group(3)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
686
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
687 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
688 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
689 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
690
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
691 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
692 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
693 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
694 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
695 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
696 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
697 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
698 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
699 # :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
700 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
701 sourceNick = match.group(1)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
702 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
703 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
704 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
705 "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
706 ).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
707 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
708 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
709 "{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
710 ).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
711 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
712 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
713 )
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
714 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
715 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
716 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
717 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
718 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
719 self.networkWidget.addMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
720 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
721 )
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
722 return True
2240
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
723 elif name == "QUIT":
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
724 # don't do anything with it here
11445430c553 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
725 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
726 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
727 # :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
728 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
729 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
730 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
731 self.networkWidget.addMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
732 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
733 )
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
734 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
735 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
736 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
737 self.networkWidget.addMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
738 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
739 )
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
740 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
741 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
742 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
743 self.networkWidget.addMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
744 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
745 )
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
746 return True
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
747 elif name == "ERROR":
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
748 self.networkWidget.addErrorMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
749 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
750 )
2252
1fc32bd13be3 Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2246
diff changeset
751 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
752
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
753 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
754
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
755 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
756 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 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
758
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
759 @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
760 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
761 @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
762 @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
763 """
b7aceb255831 First 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 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
765 if code < 400:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
766 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
767 else:
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
768 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
769
10069
435cc5875135 Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
770 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
771 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 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
773
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
774 @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
775 @type int
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
776 @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
777 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
778 @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
779 @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
780 """
b7aceb255831 First 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 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
782 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
783 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
784 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
785 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
786 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
787 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
788
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
789 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
790
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
791 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
792 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 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
794
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
795 @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
796 @type int
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
797 @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
798 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
799 @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
800 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
801 @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
802 @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
803 """
b7aceb255831 First 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 # 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
805 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
806 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
807 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
808 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
809 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
810 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
811 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
812 msgType = self.tr("MOTD")
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
813 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
814 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
815 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
816 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
817
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
818 # 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
819 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
820 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
821 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
822 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
823 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
824 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
825 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
826 "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
827 ).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
828 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
829 parts = message.strip().split()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
830 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
831 server, parts[1], parts[2]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
832 )
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
833 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
834 parts = message.strip().split()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
835 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
836 parts[1], parts[2]
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
837 )
2245
cbddacb4bc2e Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2244
diff changeset
838 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
839 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
840 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
841 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
842 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
843 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
844 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
845 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
846 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
847 message = message.replace(":", "", 1)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
848
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
849 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
850
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
851 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
852 # register with services after the welcome message
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
853 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
854 self.__registerWithServices()
2244
654aaddbc2b9 Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2243
diff changeset
855 self.networkWidget.setRegistered(True)
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
856 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
857 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
858 # 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
859 # ... 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
860 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
861 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
862 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
863 # 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
864 # ... 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
865 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
866 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
867 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
868
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
869 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
870
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
871 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
872 """
b7aceb255831 First 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 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
874 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
875 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
876 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
877 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
878 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
879 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
880 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
881
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
882 def __autoJoinChannels(self):
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
883 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
884 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
885 connected.
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
886 """
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
887 for channel in self.networkWidget.getNetworkChannels():
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
888 if channel.autoJoin():
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
889 name = channel.getName()
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
890 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
891 self.joinChannel(name, key)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
892
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
893 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
894 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 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
896
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
897 @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
898 @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
899 """
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
900 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
901 # ignore this one, it's a disconnect
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
902 if self.__sslErrorLock:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
903 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
904 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
905 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
906 """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
907 """ 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
908 ).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
909 )
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
910 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
911 elif error == QAbstractSocket.SocketError.HostNotFoundError:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
912 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
913 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
914 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
915 "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
916 " and port settings."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
917 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
918 )
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
919 elif error == QAbstractSocket.SocketError.ConnectionRefusedError:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
920 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
921 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
922 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
923 "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
924 " host name and port settings."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
925 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
926 )
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
927 elif error == QAbstractSocket.SocketError.SslHandshakeFailedError:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
928 self.networkWidget.addErrorMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
929 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
930 )
2292
1e29752b51d7 Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2280
diff changeset
931 else:
1e29752b51d7 Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2280
diff changeset
932 if self.__socket:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
933 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
934 self.tr("Socket Error"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
935 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
936 self.__socket.errorString()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
937 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
938 )
2292
1e29752b51d7 Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2280
diff changeset
939 else:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
940 self.networkWidget.addErrorMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
941 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
942 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
943
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
944 def __sslErrors(self, errors):
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
945 """
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
946 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
947
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
948 @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
949 @type list of QSslError
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
950 """
2360
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
951 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
952 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
953 )
8354
12ebd3934fef Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
954 if ignored == EricSslErrorState.NOT_IGNORED:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
955 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
956 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
957 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
958 """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
959 """ 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
960 """ 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
961 """ you rejected the certificate."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
962 ).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
963 )
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2240
diff changeset
964 self.__socket.close()
2360
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
965 else:
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
966 if defaultChanged:
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
967 self.__socket.setSslConfiguration(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
968 QSslConfiguration.defaultConfiguration()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
969 )
8354
12ebd3934fef Renamed 'E5Utilities' to 'EricUtilities' and 'E5Network' to 'EricNetwork'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
970 if ignored == EricSslErrorState.USER_IGNORED:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
971 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
972 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
973 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
974 """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
975 """ 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
976 """ were accepted by you."""
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
977 ).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
978 )
2360
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
979 if self.__connectionState == IrcWidget.ServerConnecting:
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
980 self.__socket.ignoreSslErrors()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
981
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
982 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
983 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984 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
985
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
986 @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
987 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
988 @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
989 @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
990 """
b7aceb255831 First 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 # 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
992 # 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
993 # 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
994 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
995 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
996 self.__userPrefix["-" + prefix1[i]] = ""
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
997
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
998 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
999 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000 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
1001
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
1002 @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
1003 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1004 @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
1005 @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
1006 """
b7aceb255831 First 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 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
1008 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1009
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1010 def __handleCtcp(self, match):
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1011 """
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1012 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
1013
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
1014 @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
1015 @type re.Match
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1016 @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
1017 @rtype bool
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1018 """
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1019 # group(1) sender user name
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1020 # group(2) sender user@host
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1021 # group(3) target nick
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1022 # group(4) message
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1023 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
1024 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
1025 if " " in ctcpCommand:
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1026 ctcpRequest, ctcpArg = ctcpCommand.split(" ", 1)
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1027 else:
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1028 ctcpRequest, ctcpArg = ctcpCommand, ""
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1029 ctcpRequest = ctcpRequest.lower()
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1030 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
1031 if Version.startswith("@@"):
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1032 vers = ""
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1033 else:
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1034 vers = " " + Version
58d27b642a35 A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2271
diff changeset
1035 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
1036 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
1037 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
1038 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
1039 match.group(1)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1040 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1041 )
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1042 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
1043 elif ctcpRequest == "ping":
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1044 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
1045 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
1046 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
1047 "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
1048 ).format(match.group(1)),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1049 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1050 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
1051 elif ctcpRequest == "clientinfo":
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1052 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
1053 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
1054 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
1055 "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
1056 ).format(match.group(1)),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1057 )
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1058 self.__sendCtcpReply(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1059 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
1060 )
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1061 else:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1062 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
1063 self.tr("CTCP"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1064 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
1065 ctcpRequest, match.group(1)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1066 ),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1067 )
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1068 return True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1069
2264
d8176c78c6a6 Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2258
diff changeset
1070 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1071
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
1072 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
1073 """
b7aceb255831 First 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 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
1075 """
b7aceb255831 First 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 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
1077 index = self.channelsWidget.indexOf(channel)
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1078 self.channelsWidget.setTabText(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1079 index,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
1080 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
1081 channel.name(), channel.getUsersCount()
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 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1084
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
1085 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
1086 """
b7aceb255831 First 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 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
1088 """
b7aceb255831 First 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 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
1090 try:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1091 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
1092 if identity:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1093 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
1094 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
1095 else:
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1096 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
1097 self.__nickName = ""
a04952159050 IrcWidget, IrcNetworkWidget: fixed an issue related to a non-existing identity.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6514
diff changeset
1098 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
1099 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
1100 except IndexError:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1101 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
1102 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
1103 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
1104 "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
1105 " for <b>{0}</b>. Disconnecting..."
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1106 ).format(self.__userName),
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1107 filterMsg=False,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1108 )
4630
7b0e38956b5c Refined the online state change behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
1109 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
1110 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
1111 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
1112 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1113
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
1114 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
1115 self.__send("NICK " + nick)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1116
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
1117 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
1118 """
b7aceb255831 First 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 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
1120 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
1121 self.networkWidget.addServerMessage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1122 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
1123 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1124
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
1125 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
1126 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1127 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
1128
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1129 @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
1130 @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
1131 """
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
1132 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
1133 self.__send("NICK " + nick)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1134
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
1135 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
1136 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1137 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
1138
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1139 @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
1140 @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
1141 """
b7aceb255831 First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1142 self.__channelTypePrefixes = prefixes
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1143
2256
d07e2e6f3c56 Implemented support for IRC WHOIS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2255
diff changeset
1144 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
1145 """
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2528
diff changeset
1146 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
1147
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1148 @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
1149 @type str
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1150 @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
1151 @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
1152 """
b7aceb255831 First 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 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
1154 return False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1155
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
1156 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
1157 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
1158 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
1159 return name[0] in "#&"
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
1160
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
1161 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
1162 """
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
1163 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
1164
10428
a071d4065202 Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10069
diff changeset
1165 @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
1166 @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
1167 """
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
1168 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
1169 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
1170 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
1171 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
1172 channel.setMarkerLine()

eric ide

mercurial