summaryrefslogtreecommitdiff
path: root/noncore/comm/keypebble/krfbconnection.cpp
Unidiff
Diffstat (limited to 'noncore/comm/keypebble/krfbconnection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/krfbconnection.cpp6
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
24KRFBConnection::~KRFBConnection() 24KRFBConnection::~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
32void KRFBConnection::connectTo( KRFBServer server) 32void 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
52void KRFBConnection::disconnect() 52void 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
94void KRFBConnection::gotRFBConnection() 94void 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
120void KRFBConnection::gotSocketError( int err ) 120void 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;