author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/comm/keypebble/krfbconnection.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/comm/keypebble/krfbconnection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/comm/keypebble/krfbconnection.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/comm/keypebble/krfbconnection.cpp b/noncore/comm/keypebble/krfbconnection.cpp index e6c33c6..b447046 100644 --- a/noncore/comm/keypebble/krfbconnection.cpp +++ b/noncore/comm/keypebble/krfbconnection.cpp | |||
@@ -19,49 +19,49 @@ KRFBConnection::KRFBConnection( QObject *parent ) | |||
19 | updater = 0; | 19 | updater = 0; |
20 | decoder_ = 0; | 20 | decoder_ = 0; |
21 | buffer_ = 0; | 21 | buffer_ = 0; |
22 | } | 22 | } |
23 | 23 | ||
24 | KRFBConnection::~KRFBConnection() | 24 | KRFBConnection::~KRFBConnection() |
25 | { | 25 | { |
26 | if ( ( currentState_ != Disconnected ) && ( currentState_ != Disconnecting ) && sock ) { | 26 | if ( ( currentState_ != Disconnected ) && ( currentState_ != Disconnecting ) && sock ) { |
27 | disconnectDone(); | 27 | disconnectDone(); |
28 | } | 28 | } |
29 | delete options_; | 29 | delete options_; |
30 | } | 30 | } |
31 | 31 | ||
32 | void KRFBConnection::connectTo( KRFBServer server) | 32 | void KRFBConnection::connectTo( KRFBServer server) |
33 | { | 33 | { |
34 | if ( currentState_ != Disconnected ) | 34 | if ( currentState_ != Disconnected ) |
35 | disconnect(); | 35 | disconnect(); |
36 | 36 | ||
37 | (*options_)=server; | 37 | (*options_)=server; |
38 | 38 | ||
39 | sock = new QSocket( this, "rfbSocket" ); | 39 | sock = new QSocket( this, "rfbSocket" ); |
40 | CHECK_PTR( sock ); | 40 | CHECK_PTR( sock ); |
41 | 41 | ||
42 | // Connect to something to notice connection or error | 42 | // Connect to something to notice connection or error |
43 | connect( sock, SIGNAL( error( int ) ), SLOT( gotSocketError( int ) ) ); | 43 | connect( sock, SIGNAL( error(int) ), SLOT( gotSocketError(int) ) ); |
44 | connect( sock, SIGNAL( connected() ), SLOT( gotSocketConnection() ) ); | 44 | connect( sock, SIGNAL( connected() ), SLOT( gotSocketConnection() ) ); |
45 | 45 | ||
46 | qWarning( "Connecting..." ); | 46 | qWarning( "Connecting..." ); |
47 | 47 | ||
48 | currentState_ = Connecting; | 48 | currentState_ = Connecting; |
49 | sock->connectToHost( options_->hostname.latin1(), portBase_ + options_->display ); | 49 | sock->connectToHost( options_->hostname.latin1(), portBase_ + options_->display ); |
50 | } | 50 | } |
51 | 51 | ||
52 | void KRFBConnection::disconnect() | 52 | void KRFBConnection::disconnect() |
53 | { | 53 | { |
54 | qWarning( "Disconnecting from server" ); | 54 | qWarning( "Disconnecting from server" ); |
55 | 55 | ||
56 | if ( ( currentState_ != Disconnected ) | 56 | if ( ( currentState_ != Disconnected ) |
57 | && ( currentState_ != Disconnecting ) | 57 | && ( currentState_ != Disconnecting ) |
58 | && sock ) { | 58 | && sock ) { |
59 | currentState_ = Disconnecting; | 59 | currentState_ = Disconnecting; |
60 | 60 | ||
61 | connect( sock, SIGNAL( delayedCloseFinished() ), SLOT( disconnectDone() ) ); | 61 | connect( sock, SIGNAL( delayedCloseFinished() ), SLOT( disconnectDone() ) ); |
62 | sock->close(); | 62 | sock->close(); |
63 | 63 | ||
64 | if ( sock->state() != QSocket::Closing ) | 64 | if ( sock->state() != QSocket::Closing ) |
65 | disconnectDone(); | 65 | disconnectDone(); |
66 | } | 66 | } |
67 | } | 67 | } |
@@ -85,50 +85,50 @@ void KRFBConnection::gotSocketConnection() | |||
85 | qWarning( "Connected, logging in..." ); | 85 | qWarning( "Connected, logging in..." ); |
86 | 86 | ||
87 | static QString statusMsg = tr( "Connected" ); | 87 | static QString statusMsg = tr( "Connected" ); |
88 | emit statusChanged( statusMsg ); | 88 | emit statusChanged( statusMsg ); |
89 | 89 | ||
90 | // Do some login stuff | 90 | // Do some login stuff |
91 | login = new KRFBLogin( this ); | 91 | login = new KRFBLogin( this ); |
92 | } | 92 | } |
93 | 93 | ||
94 | void KRFBConnection::gotRFBConnection() | 94 | void KRFBConnection::gotRFBConnection() |
95 | { | 95 | { |
96 | qWarning( "Logged into server" ); | 96 | qWarning( "Logged into server" ); |
97 | 97 | ||
98 | currentState_ = Connected; | 98 | currentState_ = Connected; |
99 | emit connected(); | 99 | emit connected(); |
100 | 100 | ||
101 | // Create the decoder and start doing stuff | 101 | // Create the decoder and start doing stuff |
102 | decoder_ = new KRFBDecoder( this ); | 102 | decoder_ = new KRFBDecoder( this ); |
103 | CHECK_PTR( decoder_ ); | 103 | CHECK_PTR( decoder_ ); |
104 | 104 | ||
105 | buffer_ = new KRFBBuffer( decoder_, this, "RFB Buffer" ); | 105 | buffer_ = new KRFBBuffer( decoder_, this, "RFB Buffer" ); |
106 | CHECK_PTR( buffer_ ); | 106 | CHECK_PTR( buffer_ ); |
107 | decoder_->setBuffer( buffer_ ); | 107 | decoder_->setBuffer( buffer_ ); |
108 | 108 | ||
109 | connect( decoder_, SIGNAL( status( const QString & ) ), | 109 | connect( decoder_, SIGNAL( status(const QString&) ), |
110 | this, SIGNAL( statusChanged( const QString & ) ) ); | 110 | this, SIGNAL( statusChanged(const QString&) ) ); |
111 | emit loggedIn(); | 111 | emit loggedIn(); |
112 | 112 | ||
113 | decoder_->start(); | 113 | decoder_->start(); |
114 | 114 | ||
115 | updater = new QTimer; | 115 | updater = new QTimer; |
116 | connect( updater, SIGNAL( timeout() ), SLOT( updateTimer() ) ); | 116 | connect( updater, SIGNAL( timeout() ), SLOT( updateTimer() ) ); |
117 | updater->start( options_->updateRate ); | 117 | updater->start( options_->updateRate ); |
118 | } | 118 | } |
119 | 119 | ||
120 | void KRFBConnection::gotSocketError( int err ) | 120 | void KRFBConnection::gotSocketError( int err ) |
121 | { | 121 | { |
122 | currentState_ = Error; | 122 | currentState_ = Error; |
123 | 123 | ||
124 | // Do some error handling stuff | 124 | // Do some error handling stuff |
125 | qWarning( "KRFBConnection: Socket error %d", err ); | 125 | qWarning( "KRFBConnection: Socket error %d", err ); |
126 | 126 | ||
127 | static QString refused = tr( "Connection Refused" ); | 127 | static QString refused = tr( "Connection Refused" ); |
128 | static QString host = tr( "Host not found" ); | 128 | static QString host = tr( "Host not found" ); |
129 | static QString read = tr( "Read Error: QSocket reported an error reading\n" | 129 | static QString read = tr( "Read Error: QSocket reported an error reading\n" |
130 | "data, the remote host has probably dropped the\n" | 130 | "data, the remote host has probably dropped the\n" |
131 | "connection." ); | 131 | "connection." ); |
132 | static QString confused = tr( "QSocket reported an invalid error code" ); | 132 | static QString confused = tr( "QSocket reported an invalid error code" ); |
133 | 133 | ||
134 | QString msg; | 134 | QString msg; |