|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a QNetworkReply subclass reporting an unknown protocol error. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import * |
|
11 from PyQt4.QtNetwork import QNetworkReply, QNetworkRequest |
|
12 |
|
13 class NetworkProtocolUnknownErrorReply(QNetworkReply): |
|
14 """ |
|
15 Class implementing a QNetworkReply subclass reporting an unknown protocol error. |
|
16 """ |
|
17 def __init__(self, protocol, parent = None): |
|
18 """ |
|
19 Constructor |
|
20 |
|
21 @param protocol protocol name (string) |
|
22 @param parent reference to the parent object (QObject) |
|
23 """ |
|
24 QNetworkReply.__init__(self) |
|
25 self.setError(QNetworkReply.ProtocolUnknownError, |
|
26 self.trUtf8("Protocol '{0}' not supported.").format(protocol)) |
|
27 QTimer.singleShot(0, self.__fireSignals) |
|
28 |
|
29 def __fireSignals(self): |
|
30 """ |
|
31 Private method to send some signals to end the connection. |
|
32 """ |
|
33 self.emit(SIGNAL("error(QNetworkReply::NetworkError)"), |
|
34 QNetworkReply.ProtocolUnknownError) |
|
35 self.emit(SIGNAL("finished()")) |
|
36 |
|
37 def abort(self): |
|
38 """ |
|
39 Public slot to abort the operation. |
|
40 """ |
|
41 # do nothing |
|
42 pass |
|
43 |
|
44 def bytesAvailable(self): |
|
45 """ |
|
46 Public method to determined the bytes available for being read. |
|
47 |
|
48 @return bytes available (integer) |
|
49 """ |
|
50 return 0 |