Mon, 25 Mar 2013 10:03:09 +0100
Fixed another situation in the IRC widget, that could cause a stack trace.
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 | |
2302
f29e9405c851
Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2299
diff
changeset
|
3 | # Copyright (c) 2012 - 2013 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 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | 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
|
11 | import logging |
b7aceb255831
First 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 | |
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
|
13 | from PyQt4.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QTimer |
2268
72ad198bf43e
Some fine tuning to the IRC widget for Mac.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2265
diff
changeset
|
14 | from PyQt4.QtGui import QWidget, QToolButton, QLabel, QTabWidget |
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
|
15 | from PyQt4.QtNetwork import QTcpSocket, QAbstractSocket |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
16 | try: |
2354
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
17 | from PyQt4.QtNetwork import QSslSocket, QSslConfiguration |
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
18 | from E5Network.E5SslErrorHandler import E5SslErrorHandler |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
19 | SSL_AVAILABLE = True |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
20 | except ImportError: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
21 | 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
|
22 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | from E5Gui import E5MessageBox |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | 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
|
26 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | import Preferences |
b7aceb255831
First 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 | import UI.PixmapCache |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
2268
72ad198bf43e
Some fine tuning to the IRC widget for Mac.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2265
diff
changeset
|
30 | from Globals import isMacPlatform |
72ad198bf43e
Some fine tuning to the IRC widget for Mac.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2265
diff
changeset
|
31 | |
2264
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
32 | from UI.Info import Version, Copyright |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
33 | |
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 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | 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
|
36 | """ |
b7aceb255831
First 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 | Class implementing the IRC window. |
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
|
38 | |
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
|
39 | @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
|
40 | """ |
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
|
41 | autoConnected = pyqtSignal() |
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
|
42 | |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
43 | ServerDisconnected = 1 |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
44 | ServerConnected = 2 |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
45 | ServerConnecting = 3 |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
46 | |
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
|
47 | 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
|
48 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | Constructor |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | @param parent reference to the parent widget (QWidget) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | """ |
b7aceb255831
First 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 | super().__init__(parent) |
b7aceb255831
First 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 | self.setupUi(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
|
55 | |
2404
cba0ff902c2b
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2360
diff
changeset
|
56 | 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
|
57 | self.__ircNetworkManager = IrcNetworkManager(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
|
58 | |
b7aceb255831
First 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 | self.__leaveButton = QToolButton(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
|
60 | self.__leaveButton.setIcon(UI.PixmapCache.getIcon("ircCloseChannel.png")) |
b7aceb255831
First 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.__leaveButton.setToolTip(self.trUtf8("Press to leave the current 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
|
62 | self.__leaveButton.clicked[()].connect(self.__leaveChannel) |
b7aceb255831
First 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.__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
|
64 | self.channelsWidget.setCornerWidget(self.__leaveButton, Qt.BottomRightCorner) |
b7aceb255831
First 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.channelsWidget.setTabsClosable(False) |
2268
72ad198bf43e
Some fine tuning to the IRC widget for Mac.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2265
diff
changeset
|
66 | if not isMacPlatform(): |
72ad198bf43e
Some fine tuning to the IRC widget for Mac.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2265
diff
changeset
|
67 | self.channelsWidget.setTabPosition(QTabWidget.South) |
2227
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | |
2271
7dd914b6eb7d
Some corrections and a little addition to the IRC window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2268
diff
changeset
|
69 | height = self.height() |
7dd914b6eb7d
Some corrections and a little addition to the IRC window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2268
diff
changeset
|
70 | self.splitter.setSizes([height * 0.6, height * 0.4]) |
7dd914b6eb7d
Some corrections and a little addition to the IRC window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2268
diff
changeset
|
71 | |
2227
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | self.__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
|
73 | 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
|
74 | self.__userName = "" |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
75 | self.__identityName = "" |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
76 | 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
|
77 | 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
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
82 | self.__connectionState = IrcWidget.ServerDisconnected |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
83 | self.__sslErrorLock = False |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
84 | |
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.__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
|
86 | self.__userPrefix = {} |
b7aceb255831
First 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 | |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
88 | self.__socket = None |
2354
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
89 | if SSL_AVAILABLE: |
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
90 | self.__sslErrorHandler = E5SslErrorHandler(self) |
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
91 | else: |
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
92 | self.__sslErrorHandler = None |
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 | |
b7aceb255831
First 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.__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
|
95 | # :foo_!n=foo@foohost.bar.net PRIVMSG bar_ :some long message |
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
|
96 | (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
|
97 | # :foo.bar.net COMMAND some 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
|
98 | (re.compile(r""":([^ ]+)\s+([A-Z]+)\s+(.+)"""), self.__handleNamedMessage), |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | # :foo.bar.net 123 * :info |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | (re.compile(r""":([^ ]+)\s+(\d{3})\s+(.+)"""), self.__handleNumericMessage), |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | # 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
|
102 | (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
|
103 | ] |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | 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
|
105 | self.__chanTypesRe = re.compile(r""".*\sCHANTYPES=([^ ]+).*""") |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | |
b7aceb255831
First 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 | ircPic = UI.PixmapCache.getPixmap("irc128.png") |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | 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
|
109 | self.__emptyLabel.setPixmap(ircPic) |
b7aceb255831
First 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 | self.__emptyLabel.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | self.channelsWidget.addTab(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
|
112 | |
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
|
113 | # 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
|
114 | 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
|
115 | 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
|
116 | 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
|
117 | self.networkWidget.editNetwork.connect(self.__editNetwork) |
7ba2af1ff785
Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2252
diff
changeset
|
118 | self.networkWidget.joinChannel.connect(self.__joinChannel) |
7ba2af1ff785
Implemented support for the WHO command and the auto user status update function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2252
diff
changeset
|
119 | 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
|
120 | 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
|
121 | 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
|
122 | self.networkWidget.autoConnected.connect(self.autoConnected) |
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
|
123 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | 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
|
125 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | Public method to shut down the widget. |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | @return flag indicating successful shutdown (boolean) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | 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
|
131 | if Preferences.getIrc("AskOnShutdown"): |
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
|
132 | ok = E5MessageBox.yesNo(self, |
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
|
133 | self.trUtf8("Disconnect from Server"), |
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
|
134 | self.trUtf8("""<p>Do you really want to disconnect from""" |
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
|
135 | """ <b>{0}</b>?</p><p>All channels will be closed.""" |
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
|
136 | """</p>""").format(self.__server.getName())) |
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
|
137 | 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
|
138 | 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
|
139 | 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
|
140 | self.__socket.blockSignals(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
|
141 | |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
142 | self.__send("QUIT :" + self.__quitMessage) |
2265
72e6f479987b
Corrected some of the new display strings and completed the German translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2264
diff
changeset
|
143 | self.__socket.flush() |
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
|
144 | self.__socket.close() |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | self.__socket.deleteLater() |
2296
da3757bc5218
Fixed an issue shutting down the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2292
diff
changeset
|
146 | self.__socket = None |
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
|
147 | 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
|
148 | ok = 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
|
149 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | 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
|
151 | self.__ircNetworkManager.close() |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | return 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
|
153 | |
2237
baddb671c326
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2236
diff
changeset
|
154 | def autoConnect(self): |
baddb671c326
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2236
diff
changeset
|
155 | """ |
baddb671c326
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2236
diff
changeset
|
156 | Public method to initiate the IRC auto connection. |
baddb671c326
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2236
diff
changeset
|
157 | """ |
baddb671c326
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2236
diff
changeset
|
158 | self.networkWidget.autoConnect() |
baddb671c326
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2236
diff
changeset
|
159 | |
2339
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
160 | def __connectNetwork(self, name, connect, silent=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
|
161 | """ |
b7aceb255831
First 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 | Private slot to connect to or disconnect from the given network. |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | @param name name of the network to connect to (string) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | @param connect flag indicating to connect (boolean) |
2339
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
166 | @keyparam silent flag indicating a silent connect/disconnect (boolean) |
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
|
167 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | 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
|
169 | network = self.__ircNetworkManager.getNetwork(name) |
2232
47290dad6d0b
Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2227
diff
changeset
|
170 | if network: |
2237
baddb671c326
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2236
diff
changeset
|
171 | self.__server = network.getServer() |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
172 | self.__identityName = network.getIdentityName() |
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
173 | identity = self.__ircNetworkManager.getIdentity(self.__identityName) |
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
174 | self.__userName = identity.getIdent() |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
175 | self.__quitMessage = identity.getQuitMessage() |
2232
47290dad6d0b
Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2227
diff
changeset
|
176 | if self.__server: |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
177 | useSSL = self.__server.useSSL() |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
178 | if useSSL and not SSL_AVAILABLE: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
179 | E5MessageBox.critical(self, |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
180 | self.trUtf8("SSL Connection"), |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
181 | self.trUtf8("""An encrypted connection to the IRC network""" |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
182 | """ was requested but SSL is not available.""" |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
183 | """ Please change the server configuration.""")) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
184 | return |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
185 | |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
186 | if useSSL: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
187 | # create SSL socket |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
188 | self.__socket = QSslSocket(self) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
189 | self.__socket.encrypted.connect(self.__hostConnected) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
190 | self.__socket.sslErrors.connect(self.__sslErrors) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
191 | else: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
192 | # create TCP socket |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
193 | self.__socket = QTcpSocket(self) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
194 | self.__socket.connected.connect(self.__hostConnected) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
195 | self.__socket.hostFound.connect(self.__hostFound) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
196 | self.__socket.disconnected.connect(self.__hostDisconnected) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
197 | self.__socket.readyRead.connect(self.__readyRead) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
198 | self.__socket.error.connect(self.__tcpError) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
199 | |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
200 | self.__connectionState = IrcWidget.ServerConnecting |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
201 | if useSSL: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
202 | self.networkWidget.addServerMessage(self.trUtf8("Info"), |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
203 | self.trUtf8("Looking for server {0} (port {1}) using" |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
204 | " an SSL encrypted connection...").format( |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
205 | self.__server.getName(), self.__server.getPort())) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
206 | self.__socket.connectToHostEncrypted(self.__server.getName(), |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
207 | self.__server.getPort()) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
208 | else: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
209 | self.networkWidget.addServerMessage(self.trUtf8("Info"), |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
210 | self.trUtf8("Looking for server {0} (port {1})...").format( |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
211 | self.__server.getName(), self.__server.getPort())) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
212 | self.__socket.connectToHost(self.__server.getName(), |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
213 | self.__server.getPort()) |
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
|
214 | else: |
2339
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
215 | if silent: |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
216 | ok = True |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
217 | else: |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
218 | ok = E5MessageBox.yesNo(self, |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
219 | self.trUtf8("Disconnect from Server"), |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
220 | self.trUtf8("""<p>Do you really want to disconnect from""" |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
221 | """ <b>{0}</b>?</p><p>All channels will be""" |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
222 | """ closed.</p>""")\ |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
223 | .format(self.__server.getName())) |
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
|
224 | 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
|
225 | self.networkWidget.addServerMessage(self.trUtf8("Info"), |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | self.trUtf8("Disconnecting from server {0}...").format( |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
227 | self.__server.getName())) |
2336
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
228 | self.__closeAllChannels() |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
229 | self.__send("QUIT :" + self.__quitMessage) |
2265
72e6f479987b
Corrected some of the new display strings and completed the German translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2264
diff
changeset
|
230 | self.__socket and self.__socket.flush() |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
231 | self.__socket and self.__socket.close() |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
232 | self.__userName = "" |
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
233 | self.__identityName = "" |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
234 | 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
|
235 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | def __editNetwork(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
|
237 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
238 | 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
|
239 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | @param name name of the network to edit (string) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | """ |
2404
cba0ff902c2b
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2360
diff
changeset
|
242 | from .IrcNetworkListDialog import IrcNetworkListDialog |
2232
47290dad6d0b
Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2227
diff
changeset
|
243 | dlg = IrcNetworkListDialog(self.__ircNetworkManager, self) |
47290dad6d0b
Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2227
diff
changeset
|
244 | dlg.exec_() |
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
|
245 | |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
246 | def __networkDataChanged(self): |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
247 | """ |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
248 | 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
|
249 | """ |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
250 | identity = self.__ircNetworkManager.getIdentity(self.__identityName) |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
251 | if identity: |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
252 | partMsg = identity.getPartMessage() |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
253 | for channel in self.__channelList: |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
254 | channel.setPartMessage(partMsg) |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
255 | |
2234
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
256 | 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
|
257 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | Private slot to join a 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
|
259 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | @param name name of the channel (string) |
2234
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
261 | @param key key of the channel (string) |
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
|
262 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | # 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
|
264 | 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
|
265 | 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
|
266 | return |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | |
2404
cba0ff902c2b
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2360
diff
changeset
|
268 | from .IrcChannelWidget import IrcChannelWidget |
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
|
269 | 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
|
270 | 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
|
271 | channel.setUserName(self.__nickName) |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
272 | identity = self.__ircNetworkManager.getIdentity(self.__identityName) |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
273 | 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
|
274 | 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
|
275 | channel.initAutoWho() |
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
|
276 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | channel.sendData.connect(self.__send) |
2264
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
278 | 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
|
279 | 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
|
280 | channel.openPrivateChat.connect(self.__openPrivate) |
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
|
281 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
282 | 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
|
283 | 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
|
284 | self.channelsWidget.setCurrentWidget(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
|
285 | |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
286 | joinCommand = ["JOIN", name] |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
287 | if key: |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
288 | joinCommand.append(key) |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
289 | 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
|
290 | self.__send("MODE " + 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
|
291 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | 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
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | self.channelsWidget.setTabsClosable(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
|
297 | |
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
|
298 | 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
|
299 | """ |
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
|
300 | Private method to handle a new private connection. |
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
|
301 | |
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
|
302 | @param reference to the match object |
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
|
303 | @return flag indicating, if the message was handled (boolean) |
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
|
304 | """ |
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
|
305 | # 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
|
306 | # 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
|
307 | # 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
|
308 | # group(4) message |
2264
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
309 | 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
|
310 | return self.__handleCtcp(match) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
311 | |
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
|
312 | 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
|
313 | # 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
|
314 | 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
|
315 | channel.addMessage(match.group(1), match.group(4)) |
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
|
316 | channel.setPrivateInfo("{0} - {1}".format(match.group(1), match.group(2))) |
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
|
317 | |
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
|
318 | return True |
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
|
319 | |
2252
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
320 | @pyqtSlot(str) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
321 | def __openPrivate(self, name): |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
322 | """ |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
323 | Private slot to open a private chat with the given user. |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
324 | |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
325 | @param name name of the user (string) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
326 | """ |
2404
cba0ff902c2b
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2360
diff
changeset
|
327 | from .IrcChannelWidget import IrcChannelWidget |
2252
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
328 | channel = IrcChannelWidget(self) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
329 | channel.setName(self.__nickName) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
330 | channel.setUserName(self.__nickName) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
331 | identity = self.__ircNetworkManager.getIdentity(self.__identityName) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
332 | channel.setPartMessage(identity.getPartMessage()) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
333 | channel.setUserPrivilegePrefix(self.__userPrefix) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
334 | channel.setPrivate(True, name) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
335 | channel.addUsers([name, self.__nickName]) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
336 | |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
337 | channel.sendData.connect(self.__send) |
2264
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
338 | 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
|
339 | channel.channelClosed.connect(self.__closeChannel) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
340 | |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
341 | 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
|
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) |
2252
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
344 | |
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
|
345 | @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
|
346 | 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
|
347 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
348 | 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
|
349 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
350 | 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
|
351 | channel.requestLeave() |
b7aceb255831
First 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 | |
2336
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
353 | def __closeAllChannels(self): |
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
354 | """ |
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
355 | Private method to close all channels. |
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
356 | """ |
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
357 | while self.__channelList: |
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
358 | channel = self.__channelList.pop() |
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
359 | 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
|
360 | channel.deleteLater() |
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
361 | channel = None |
2469
20d2166280bb
Fixed an issue in the IRC widget when disconnecting from the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2404
diff
changeset
|
362 | |
20d2166280bb
Fixed an issue in the IRC widget when disconnecting from the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2404
diff
changeset
|
363 | 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
|
364 | 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
|
365 | 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
|
366 | self.channelsWidget.setTabsClosable(False) |
2336
d9e47b8ee1ef
Fixed an issue with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
367 | |
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
|
368 | 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
|
369 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
370 | Private slot handling the closing of a 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
|
371 | |
2280
8e85ca3fabe7
Fixed a few PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2279
diff
changeset
|
372 | @param name name of the closed channel (string) |
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
|
373 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
374 | 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
|
375 | 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
|
376 | self.channelsWidget.removeTab(self.channelsWidget.indexOf(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
|
377 | 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
|
378 | channel.deleteLater() |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | 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
|
381 | 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
|
382 | 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
|
383 | 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
|
384 | self.channelsWidget.setTabsClosable(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
|
385 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | @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
|
387 | 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
|
388 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
389 | 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
|
390 | the channels widget. |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
392 | @param index index of the tab to be closed (integer) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
393 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | 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
|
395 | channel.requestLeave() |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
396 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
397 | 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
|
398 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
399 | Private slot to send data to the IRC server. |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
400 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
401 | @param data data to be sent (string) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
402 | """ |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
403 | if self.__socket: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
404 | self.__socket.write(QByteArray("{0}\r\n".format(data).encode("utf-8"))) |
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
|
405 | |
2264
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
406 | def __sendCtcpReply(self, receiver, text): |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
407 | """ |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
408 | Private slot to send a CTCP reply. |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
409 | |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
410 | @param receiver nick name of the receiver (string) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
411 | @param text text to be sent (string) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
412 | """ |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
413 | self.__send("NOTICE {0} :\x01{1}\x01".format(receiver, text)) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
414 | |
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
|
415 | 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
|
416 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | 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
|
418 | """ |
b7aceb255831
First 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 | self.networkWidget.addServerMessage(self.trUtf8("Info"), |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
420 | self.trUtf8("Server found,connecting...")) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
421 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
422 | 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
|
423 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
424 | Private slot to log in to the server after the connection was established. |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
425 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
426 | self.networkWidget.addServerMessage(self.trUtf8("Info"), |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
427 | self.trUtf8("Connected,logging in...")) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
428 | self.networkWidget.setConnected(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
|
429 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
430 | 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
|
431 | 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
|
432 | 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
|
433 | self.__send("PASS " + 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
|
434 | nick = self.networkWidget.getNickname() |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
435 | 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
|
436 | 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
|
437 | try: |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
438 | nick = 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
|
439 | .getNickNames()[self.__nickIndex] |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
440 | 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
|
441 | 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
|
442 | 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
|
443 | 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
|
444 | 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
|
445 | self.networkWidget.setNickName(nick) |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
446 | realName = self.__ircNetworkManager.getIdentity(self.__identityName).getRealName() |
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
447 | if not realName: |
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
448 | realName = "eric IDE chat" |
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
|
449 | self.__send("NICK " + nick) |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
450 | self.__send("USER " + self.__userName + " 0 * :" + realName) |
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
|
451 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
452 | 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
|
453 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
454 | 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
|
455 | """ |
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
|
456 | 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
|
457 | self.__closeAllChannels() |
688c7ef0a5b0
Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2527
diff
changeset
|
458 | self.networkWidget.addServerMessage(self.trUtf8("Info"), |
688c7ef0a5b0
Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2527
diff
changeset
|
459 | self.trUtf8("Server disconnected.")) |
688c7ef0a5b0
Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2527
diff
changeset
|
460 | 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
|
461 | 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
|
462 | 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
|
463 | 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
|
464 | 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
|
465 | self.__channelTypePrefixes = "" |
688c7ef0a5b0
Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2527
diff
changeset
|
466 | |
688c7ef0a5b0
Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2527
diff
changeset
|
467 | self.__socket.deleteLater() |
688c7ef0a5b0
Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2527
diff
changeset
|
468 | self.__socket = 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
|
469 | |
688c7ef0a5b0
Fixed another situation in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2527
diff
changeset
|
470 | 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
|
471 | self.__sslErrorLock = 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
|
472 | |
b7aceb255831
First 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 | 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
|
474 | """ |
b7aceb255831
First 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 | 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
|
476 | """ |
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
|
477 | if self.__socket: |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
478 | self.__buffer += str(self.__socket.readAll(), |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
479 | Preferences.getSystem("IOEncoding"), |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
480 | 'replace') |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
481 | 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
|
482 | 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
|
483 | 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
|
484 | if 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
|
485 | logging.debug("<IRC> " + 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
|
486 | 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
|
487 | # 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
|
488 | 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
|
489 | 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
|
490 | 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
|
491 | 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
|
492 | 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
|
493 | # 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
|
494 | 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
|
495 | match = patternRe.match(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
|
496 | if match is not None: |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
497 | if patternFunc(match): |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
498 | break |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
499 | 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
|
500 | # 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
|
501 | self.networkWidget.addErrorMessage( |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
502 | self.trUtf8("Message Error"), |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
503 | self.trUtf8("Unknown message received from server:" |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
504 | "<br/>{0}").format(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
|
505 | |
867488bb56b0
Fixed an issue in the IRC widget, that could cause a stack trace.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2469
diff
changeset
|
506 | 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
|
507 | self.__buffer = "" |
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
|
508 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
509 | 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
|
510 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
511 | Private method to handle a server message containing a message 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
|
512 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
513 | @param reference to the match object |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
514 | @return flag indicating, if the message was handled (boolean) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
515 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
516 | 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
|
517 | 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
|
518 | 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
|
519 | 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
|
520 | 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
|
521 | msg = match.group(3) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
522 | 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
|
523 | 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
|
524 | msg = "-{0}- {1}".format(name, msg) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
525 | self.networkWidget.addServerMessage(self.trUtf8("Notice"), msg) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
526 | 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
|
527 | 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
|
528 | 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
|
529 | if ":" in match.group(3): |
b7aceb255831
First 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 | # :detlev_ MODE detlev_ :+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
|
531 | 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
|
532 | sourceNick = match.group(1) |
2256
d07e2e6f3c56
Implemented support for IRC WHOIS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2255
diff
changeset
|
533 | if not self.isChannelName(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
|
534 | if name == 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
|
535 | if sourceNick == 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
|
536 | msg = self.trUtf8( |
2265
72e6f479987b
Corrected some of the new display strings and completed the German translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2264
diff
changeset
|
537 | "You have set your personal modes to <b>[{0}]</b>.")\ |
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
|
538 | .format(modes) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
539 | 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
|
540 | msg = self.trUtf8( |
2265
72e6f479987b
Corrected some of the new display strings and completed the German translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2264
diff
changeset
|
541 | "{0} has changed your personal modes to <b>[{1}]</b>.")\ |
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
|
542 | .format(sourceNick, modes) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
543 | self.networkWidget.addServerMessage( |
b7aceb255831
First 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.trUtf8("Mode"), msg, filterMsg=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
|
545 | 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
|
546 | 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
|
547 | 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
|
548 | 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
|
549 | 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
|
550 | self.networkWidget.addMessage( |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
551 | self.trUtf8("You have left channel {0}.").format(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
|
552 | return True |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
553 | elif name == "QUIT": |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
554 | # don't do anything with it here |
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
555 | 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
|
556 | 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
|
557 | # :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
|
558 | 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
|
559 | 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
|
560 | 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
|
561 | self.networkWidget.addMessage( |
b7aceb255831
First 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.trUtf8("You are now known as {0}.").format(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
|
563 | 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
|
564 | 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
|
565 | 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
|
566 | self.networkWidget.addMessage( |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
567 | self.trUtf8("User {0} is now known as {1}.").format( |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
568 | oldNick, 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
|
569 | return True |
2252
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
570 | elif name == "ERROR": |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
571 | self.networkWidget.addErrorMessage( |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
572 | self.trUtf8("Server Error"), match.group(3).split(":", 1)[1]) |
1fc32bd13be3
Continued with the implementation of the simple IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2246
diff
changeset
|
573 | 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
|
574 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
575 | return 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
|
576 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
577 | 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
|
578 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
579 | Private method to handle a server message containing a numeric code. |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
580 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
581 | @param reference to the match object |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
582 | @return flag indicating, if the message was handled (boolean) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
583 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
584 | 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
|
585 | if code < 400: |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
586 | return self.__handleServerReply(code, match.group(1), match.group(3)) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
587 | 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
|
588 | return self.__handleServerError(code, match.group(1), match.group(3)) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
589 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
590 | def __handleServerError(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
|
591 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
592 | Private slot to handle a server error reply. |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
593 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
594 | @param code numerical code sent by the server (integer) |
b7aceb255831
First 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 | @param server name of the server (string) |
b7aceb255831
First 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 | @param message message sent by the server (string) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
597 | @return flag indicating, if the message was handled (boolean) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
598 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
599 | 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
|
600 | 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
|
601 | 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
|
602 | 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
|
603 | 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
|
604 | 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
|
605 | self.networkWidget.addServerMessage(self.trUtf8("Error"), 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
|
606 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
607 | 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
|
608 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
609 | 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
|
610 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
611 | Private slot to handle a server reply. |
b7aceb255831
First 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 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
613 | @param code numerical code sent by the server (integer) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
614 | @param server name of the server (string) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
615 | @param message message sent by the server (string) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
616 | @return flag indicating, if the message was handled (boolean) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
617 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
618 | # 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
|
619 | if code in [1, 2, 3, 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
|
620 | msgType = self.trUtf8("Welcome") |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
621 | 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
|
622 | msgType = self.trUtf8("Support") |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
623 | elif code in [250, 251, 252, 253, 254, 255, 265, 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
|
624 | msgType = self.trUtf8("User") |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
625 | elif code in [372, 375, 376]: |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
626 | msgType = self.trUtf8("MOTD") |
2245
cbddacb4bc2e
Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2244
diff
changeset
|
627 | elif code in [305, 306]: |
cbddacb4bc2e
Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2244
diff
changeset
|
628 | msgType = self.trUtf8("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
|
629 | 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
|
630 | msgType = self.trUtf8("Info ({0})").format(code) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
631 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
632 | # 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
|
633 | if code == 375: |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
634 | message = self.trUtf8("Message of the day") |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
635 | elif code == 376: |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
636 | message = self.trUtf8("End of message of the day") |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
637 | 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
|
638 | parts = message.strip().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
|
639 | message = self.trUtf8("Server {0} (Version {1}), User-Modes: {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
|
640 | " Channel-Modes: {3}").format(parts[1], parts[2], parts[3], parts[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
|
641 | 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
|
642 | parts = message.strip().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
|
643 | message = self.trUtf8("Current users on {0}: {1}, max. {2}").format( |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
644 | server, parts[1], parts[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
|
645 | 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
|
646 | parts = message.strip().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
|
647 | message = self.trUtf8("Current users on the network: {0}, max. {1}").format( |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
648 | parts[1], parts[2]) |
2245
cbddacb4bc2e
Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2244
diff
changeset
|
649 | elif code == 305: |
cbddacb4bc2e
Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2244
diff
changeset
|
650 | message = self.trUtf8("You are no longer marked as being away.") |
cbddacb4bc2e
Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2244
diff
changeset
|
651 | elif code == 306: |
cbddacb4bc2e
Added code to manually set the AWAY status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2244
diff
changeset
|
652 | message = self.trUtf8("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
|
653 | 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
|
654 | 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
|
655 | 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
|
656 | 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
|
657 | 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
|
658 | message = message.replace(":", "", 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
|
659 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
660 | self.networkWidget.addServerMessage(msgType, 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
|
661 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
662 | 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
|
663 | # register with services after the welcome message |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
664 | 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
|
665 | self.__registerWithServices() |
2244
654aaddbc2b9
Added the messages marker stuff to the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2243
diff
changeset
|
666 | self.networkWidget.setRegistered(True) |
2234
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
667 | 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
|
668 | 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
|
669 | # 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
|
670 | # ... 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
|
671 | 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
|
672 | 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
|
673 | 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
|
674 | # 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
|
675 | # ... 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
|
676 | 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
|
677 | 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
|
678 | self.__setChannelTypePrefixes(m.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
|
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 | 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
|
681 | |
b7aceb255831
First 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 | 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
|
683 | """ |
b7aceb255831
First 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 | 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
|
685 | """ |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
686 | identity = self.__ircNetworkManager.getIdentity(self.__identityName) |
2240
11445430c553
Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2237
diff
changeset
|
687 | service = identity.getServiceName() |
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
|
688 | password = identity.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
|
689 | if service and password: |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
690 | self.__send("PRIVMSG " + service + " :identify " + password) |
b7aceb255831
First 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 | |
2234
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
692 | def __autoJoinChannels(self): |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
693 | """ |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
694 | Private slot to join channels automatically once a server got connected. |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
695 | """ |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
696 | for channel in self.networkWidget.getNetworkChannels(): |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
697 | if channel.autoJoin(): |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
698 | name = channel.getName() |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
699 | key = channel.getKey() |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
700 | self.__joinChannel(name, key) |
1e33501a0d33
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2232
diff
changeset
|
701 | |
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
|
702 | 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
|
703 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
704 | Private slot to handle errors reported by the TCP 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
|
705 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
706 | @param error error code reported by 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
|
707 | (QAbstractSocket.SocketError) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
708 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
709 | if error == QAbstractSocket.RemoteHostClosedError: |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
710 | # ignore this one, it's a disconnect |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
711 | if self.__sslErrorLock: |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
712 | self.networkWidget.addErrorMessage(self.trUtf8("SSL Error"), |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
713 | self.trUtf8("""Connection to server {0} (port {1}) lost while""" |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
714 | """ waiting for user response to an SSL error.""").format( |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
715 | self.__server.getName(), self.__server.getPort())) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
716 | self.__connectionState = IrcWidget.ServerDisconnected |
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
|
717 | elif error == QAbstractSocket.HostNotFoundError: |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
718 | self.networkWidget.addErrorMessage(self.trUtf8("Socket 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
|
719 | self.trUtf8("The host was not found. Please check the host 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
|
720 | " and port settings.")) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
721 | elif error == QAbstractSocket.ConnectionRefusedError: |
b7aceb255831
First 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 | self.networkWidget.addErrorMessage(self.trUtf8("Socket 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
|
723 | self.trUtf8("The connection was refused by the peer. Please check the" |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
724 | " host name and port settings.")) |
2292
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
725 | elif error == QAbstractSocket.SslHandshakeFailedError: |
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 | self.networkWidget.addErrorMessage(self.trUtf8("Socket Error"), |
2292
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
727 | self.trUtf8("The SSL handshake failed.")) |
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
728 | else: |
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
729 | if self.__socket: |
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
730 | self.networkWidget.addErrorMessage(self.trUtf8("Socket Error"), |
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
731 | self.trUtf8("The following network error occurred:<br/>{0}").format( |
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
732 | self.__socket.errorString())) |
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
733 | else: |
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
734 | self.networkWidget.addErrorMessage(self.trUtf8("Socket Error"), |
1e29752b51d7
Fixed an issue in the IRC widget and updated the translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2280
diff
changeset
|
735 | self.trUtf8("A network error occurred.")) |
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
|
736 | |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
737 | def __sslErrors(self, errors): |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
738 | """ |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
739 | Private slot to handle SSL errors. |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
740 | |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
741 | @param errors list of SSL errors (list of QSslError) |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
742 | """ |
2360
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
743 | ignored, defaultChanged = self.__sslErrorHandler.sslErrors( |
2354
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
744 | errors, self.__server.getName(), self.__server.getPort()) |
2360
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
745 | if ignored == E5SslErrorHandler.NotIgnored: |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
746 | self.networkWidget.addErrorMessage(self.trUtf8("SSL Error"), |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
747 | self.trUtf8("""Could not connect to {0} (port {1}) using an SSL""" |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
748 | """ encrypted connection. Either the server does not""" |
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
749 | """ support SSL (did you use the correct port?) or""" |
2354
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
750 | """ you rejected the certificate.""").format( |
c63de4af553d
Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2339
diff
changeset
|
751 | self.__server.getName(), self.__server.getPort())) |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
752 | self.__socket.close() |
2360
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
753 | else: |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
754 | if defaultChanged: |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
755 | self.__socket.setSslConfiguration( |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
756 | QSslConfiguration.defaultConfiguration()) |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
757 | if ignored == E5SslErrorHandler.UserIgnored: |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
758 | self.networkWidget.addErrorMessage(self.trUtf8("SSL Error"), |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
759 | self.trUtf8("""The SSL certificate for the server {0} (port {1})""" |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
760 | """ failed the authenticity check. SSL errors""" |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
761 | """ were accepted by you.""").format( |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
762 | self.__server.getName(), self.__server.getPort())) |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
763 | if self.__connectionState == IrcWidget.ServerConnecting: |
b6bf3925e3e1
Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2354
diff
changeset
|
764 | self.__socket.ignoreSslErrors() |
2241
030924019d88
Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2240
diff
changeset
|
765 | |
2227
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
766 | 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
|
767 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
768 | Private method to set the user privilege prefix. |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
769 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
770 | @param prefix1 first part of the prefix (string) |
b7aceb255831
First 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 | @param prefix2 indictors the first part gets mapped to (string) |
b7aceb255831
First 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 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
773 | # 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
|
774 | # 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
|
775 | # 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
|
776 | 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
|
777 | 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
|
778 | self.__userPrefix["-" + prefix1[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
|
779 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
780 | 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
|
781 | """ |
b7aceb255831
First 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 | Private method to handle a 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
|
783 | |
b7aceb255831
First 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 | @param reference to the match object |
b7aceb255831
First 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 | @return flag indicating, if the message was handled (boolean) |
b7aceb255831
First 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 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
787 | 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
|
788 | 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
|
789 | |
2264
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
790 | def __handleCtcp(self, match): |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
791 | """ |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
792 | Private method to handle a CTCP command. |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
793 | |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
794 | @param reference to the match object |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
795 | @return flag indicating, if the message was handled (boolean) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
796 | """ |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
797 | # group(1) sender user name |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
798 | # group(2) sender user@host |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
799 | # group(3) target nick |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
800 | # group(4) message |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
801 | 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
|
802 | 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
|
803 | if " " in ctcpCommand: |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
804 | ctcpRequest, ctcpArg = ctcpCommand.split(" ", 1) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
805 | else: |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
806 | ctcpRequest, ctcpArg = ctcpCommand, "" |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
807 | ctcpRequest = ctcpRequest.lower() |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
808 | 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
|
809 | if Version.startswith("@@"): |
58d27b642a35
A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2271
diff
changeset
|
810 | vers = "" |
58d27b642a35
A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2271
diff
changeset
|
811 | else: |
58d27b642a35
A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2271
diff
changeset
|
812 | vers = " " + Version |
58d27b642a35
A little extension of the IRC CTCP VERSION command response.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2271
diff
changeset
|
813 | msg = "Eric IRC client{0}, {1}".format(vers, Copyright) |
2264
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
814 | self.networkWidget.addServerMessage(self.trUtf8("CTCP"), |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
815 | self.trUtf8("Received Version request from {0}.").format( |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
816 | match.group(1))) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
817 | 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
|
818 | elif ctcpRequest == "ping": |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
819 | self.networkWidget.addServerMessage(self.trUtf8("CTCP"), |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
820 | self.trUtf8("Received CTCP-PING request from {0}," |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
821 | " sending answer.").format(match.group(1))) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
822 | self.__sendCtcpReply(match.group(1), "PING {0}".format(ctcpArg)) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
823 | elif ctcpRequest == "clientinfo": |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
824 | self.networkWidget.addServerMessage(self.trUtf8("CTCP"), |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
825 | self.trUtf8("Received CTCP-CLIENTINFO request from {0}," |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
826 | " sending answer.").format(match.group(1))) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
827 | self.__sendCtcpReply(match.group(1), |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
828 | "CLIENTINFO CLIENTINFO PING VERSION") |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
829 | else: |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
830 | self.networkWidget.addServerMessage(self.trUtf8("CTCP"), |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
831 | self.trUtf8("Received unknown CTCP-{0} request from {1}.").format( |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
832 | ctcpRequest, match.group(1))) |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
833 | return True |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
834 | |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
835 | return False |
d8176c78c6a6
Added basic CTCP support to the IRC client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2258
diff
changeset
|
836 | |
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
|
837 | 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
|
838 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
839 | 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
|
840 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
841 | 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
|
842 | index = self.channelsWidget.indexOf(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
|
843 | self.channelsWidget.setTabText(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
|
844 | self.trUtf8("{0} ({1})", "channel name, users count").format( |
b7aceb255831
First 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 | channel.name(), channel.getUsersCount())) |
b7aceb255831
First 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 | |
b7aceb255831
First 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 | 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
|
848 | """ |
b7aceb255831
First 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 | 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
|
850 | """ |
b7aceb255831
First 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 | 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
|
852 | try: |
2236
e30d5f978919
Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2234
diff
changeset
|
853 | nick = 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
|
854 | .getNickNames()[self.__nickIndex] |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
855 | 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
|
856 | 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
|
857 | self.networkWidget.addServerMessage(self.trUtf8("Critical"), |
b7aceb255831
First 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 | self.trUtf8("No nickname acceptable to the server configured" |
2339
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
859 | " for <b>{0}</b>. Disconnecting...").format(self.__userName), |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
860 | filterMsg=False) |
4ee173db22c2
Fixed two little issues with the IRC widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2336
diff
changeset
|
861 | self.__connectNetwork("", False, silent=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
|
862 | 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
|
863 | 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
|
864 | return |
b7aceb255831
First 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 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
866 | self.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
|
867 | self.__send("NICK " + 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
|
868 | |
b7aceb255831
First 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 | 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
|
870 | """ |
b7aceb255831
First 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 | 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
|
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 | self.networkWidget.addServerMessage(self.trUtf8("Critical"), |
b7aceb255831
First 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 | self.trUtf8("The given nickname is already in use.")) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
875 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
876 | 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
|
877 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
878 | Private slot to use a new nick 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
|
879 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
880 | @param nick nick name to use (str) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
881 | """ |
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
|
882 | 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
|
883 | self.__send("NICK " + nick) |
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
|
884 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
885 | 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
|
886 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
887 | Private method to set 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
|
888 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
889 | @param prefixes channel prefix characters (string) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
890 | """ |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
891 | self.__channelTypePrefixes = 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
|
892 | |
2256
d07e2e6f3c56
Implemented support for IRC WHOIS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2255
diff
changeset
|
893 | 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
|
894 | """ |
2256
d07e2e6f3c56
Implemented support for IRC WHOIS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2255
diff
changeset
|
895 | PublicisChannelName method to check, if the given name is a channel 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
|
896 | |
b7aceb255831
First 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 | @return flag indicating a channel name (boolean) |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
898 | """ |
b7aceb255831
First 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 | 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
|
900 | return 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
|
901 | |
b7aceb255831
First commit of the simple IRC client for eric. It is usable but not yet complete.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
902 | 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
|
903 | 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
|
904 | 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
|
905 | return name[0] in "#&" |
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
|
906 | |
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
|
907 | 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
|
908 | """ |
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
|
909 | Private slot handling the change of the away state. |
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
|
910 | |
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
|
911 | @param isAway flag indicating the current away state (boolean) |
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
|
912 | """ |
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
|
913 | if isAway and self.__identityName: |
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
|
914 | identity = self.__ircNetworkManager.getIdentity(self.__identityName) |
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
|
915 | if identity.rememberAwayPosition(): |
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
|
916 | 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
|
917 | channel.setMarkerLine() |