6 """ |
6 """ |
7 Module implementing a class representing a peer connection. |
7 Module implementing a class representing a peer connection. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import pyqtSignal, QTimer, QTime, QByteArray |
10 from PyQt4.QtCore import pyqtSignal, QTimer, QTime, QByteArray |
11 from PyQt4.QtNetwork import QTcpSocket |
11 from PyQt4.QtNetwork import QTcpSocket, QHostInfo |
12 |
12 |
13 from E5Gui import E5MessageBox |
13 from E5Gui import E5MessageBox |
14 from E5Gui.E5Application import e5App |
14 from E5Gui.E5Application import e5App |
15 |
15 |
16 import Preferences |
16 import Preferences |
172 except ValueError: |
172 except ValueError: |
173 self.abort() |
173 self.abort() |
174 return |
174 return |
175 self.__serverPort = int(serverPort) |
175 self.__serverPort = int(serverPort) |
176 |
176 |
|
177 hostInfo = QHostInfo.fromName(self.peerAddress().toString()) |
177 self.__username = "{0}@{1}@{2}".format( |
178 self.__username = "{0}@{1}@{2}".format( |
178 user, |
179 user, |
179 self.peerAddress().toString(), |
180 hostInfo.hostName(), |
180 self.peerPort() |
181 self.peerPort() |
181 ) |
182 ) |
182 self.__currentDataType = Connection.Undefined |
183 self.__currentDataType = Connection.Undefined |
183 self.__numBytesForCurrentDataType = 0 |
184 self.__numBytesForCurrentDataType = 0 |
184 self.__buffer.clear() |
185 self.__buffer.clear() |
205 # if we shall accept automatically |
206 # if we shall accept automatically |
206 res = E5MessageBox.yesNo(None, |
207 res = E5MessageBox.yesNo(None, |
207 self.trUtf8("New Connection"), |
208 self.trUtf8("New Connection"), |
208 self.trUtf8("""<p>Accept connection from """ |
209 self.trUtf8("""<p>Accept connection from """ |
209 """<strong>{0}@{1}</strong>?</p>""").format( |
210 """<strong>{0}@{1}</strong>?</p>""").format( |
210 user, self.peerAddress().toString()), |
211 user, hostInfo.hostName()), |
211 yesDefault=True) |
212 yesDefault=True) |
212 if not res: |
213 if not res: |
213 self.abort() |
214 self.abort() |
214 return |
215 return |
215 |
216 |