summaryrefslogtreecommitdiff
path: root/noncore/comm/keypebble/krfblogin.cpp
authoralwin <alwin>2004-03-02 12:21:11 (UTC)
committer alwin <alwin>2004-03-02 12:21:11 (UTC)
commitb6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff)
treed3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/comm/keypebble/krfblogin.cpp
parent0d59c780513da78033f4d9040475dee9db0256d4 (diff)
downloadopie-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/krfblogin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/krfblogin.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/comm/keypebble/krfblogin.cpp b/noncore/comm/keypebble/krfblogin.cpp
index 0b4a757..2bbd110 100644
--- a/noncore/comm/keypebble/krfblogin.cpp
+++ b/noncore/comm/keypebble/krfblogin.cpp
@@ -3,98 +3,98 @@
3 3
4extern "C" { 4extern "C" {
5#include "vncauth.h" 5#include "vncauth.h"
6} 6}
7 7
8#include "krfblogin.h" 8#include "krfblogin.h"
9#include "krfbconnection.h" 9#include "krfbconnection.h"
10#include <qtimer.h> 10#include <qtimer.h>
11 11
12// The length of the various messages (used to decide how many bytes to 12// The length of the various messages (used to decide how many bytes to
13// wait for). 13// wait for).
14const int ServerVersionLength = 12; 14const int ServerVersionLength = 12;
15const int ClientVersionLength = 12; 15const int ClientVersionLength = 12;
16const int AuthSchemeLength = 4; 16const int AuthSchemeLength = 4;
17const int FailureReasonSizeLength = 4; 17const int FailureReasonSizeLength = 4;
18const int ChallengeLength = 16; 18const int ChallengeLength = 16;
19const int AuthResultLength = 4; 19const int AuthResultLength = 4;
20 20
21// Authentication results 21// Authentication results
22enum AuthResult { 22enum AuthResult {
23 AuthOk, 23 AuthOk,
24 AuthFailed, 24 AuthFailed,
25 AuthTooMany 25 AuthTooMany
26}; 26};
27 27
28typedef unsigned char CARD8; 28typedef unsigned char CARD8;
29typedef unsigned short CARD16; 29typedef unsigned short CARD16;
30typedef unsigned long CARD32; 30typedef unsigned long CARD32;
31 31
32const int endianTest = 1; 32const int endianTest = 1;
33 33
34// Endian stuff 34// Endian stuff
35#define Swap16IfLE(s) \ 35#define Swap16IfLE(s) \
36 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) 36 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
37 37
38#define Swap32IfLE(l) \ 38#define Swap32IfLE(l) \
39 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ 39 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \
40 (((l) & 0x00ff0000) >> 8) | \ 40 (((l) & 0x00ff0000) >> 8) | \
41 (((l) & 0x0000ff00) << 8) | \ 41 (((l) & 0x0000ff00) << 8) | \
42 (((l) & 0x000000ff) << 24)) : (l)) 42 (((l) & 0x000000ff) << 24)) : (l))
43 43
44KRFBLogin::KRFBLogin( KRFBConnection *con ) 44KRFBLogin::KRFBLogin( KRFBConnection *con )
45 : QObject( con, "RFB login manager" ) 45 : QObject( con, "RFB login manager" )
46{ 46{
47 assert( con ); 47 assert( con );
48 this->con = con; 48 this->con = con;
49 currentState = AwaitingServerVersion; 49 currentState = AwaitingServerVersion;
50 50
51 connect( this, SIGNAL( error( const QString & ) ), 51 connect( this, SIGNAL( error(const QString&) ),
52 con, SIGNAL( error( const QString & ) ) ); 52 con, SIGNAL( error(const QString&) ) );
53 53
54 54
55 qWarning( "Waiting for server version..." ); 55 qWarning( "Waiting for server version..." );
56 56
57 static QString statusMsg = tr( "Waiting for server version..." ); 57 static QString statusMsg = tr( "Waiting for server version..." );
58 emit status( statusMsg ); 58 emit status( statusMsg );
59 59
60 // Kick off the state machine 60 // Kick off the state machine
61 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerVersion() ) ); 61 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerVersion() ) );
62 con->waitForData( ServerVersionLength ); 62 con->waitForData( ServerVersionLength );
63} 63}
64 64
65KRFBLogin::~KRFBLogin() 65KRFBLogin::~KRFBLogin()
66{ 66{
67 67
68} 68}
69 69
70KRFBLogin::State KRFBLogin::state() const 70KRFBLogin::State KRFBLogin::state() const
71{ 71{
72 return currentState; 72 return currentState;
73} 73}
74 74
75void KRFBLogin::gotServerVersion() 75void KRFBLogin::gotServerVersion()
76{ 76{
77 qWarning( "Got server version" ); 77 qWarning( "Got server version" );
78 78
79 disconnect( con, SIGNAL( gotEnoughData() ), 79 disconnect( con, SIGNAL( gotEnoughData() ),
80 this, SLOT( gotServerVersion() ) ); 80 this, SLOT( gotServerVersion() ) );
81 81
82 // Read the server's version message 82 // Read the server's version message
83 char serverVersion[ ServerVersionLength + 1 ]; 83 char serverVersion[ ServerVersionLength + 1 ];
84 con->read( serverVersion, ServerVersionLength ); 84 con->read( serverVersion, ServerVersionLength );
85 serverVersion[ ServerVersionLength ] = '\0'; 85 serverVersion[ ServerVersionLength ] = '\0';
86 86
87 QCString rfbString( serverVersion, ServerVersionLength + 1 ); 87 QCString rfbString( serverVersion, ServerVersionLength + 1 );
88 versionString = rfbString; 88 versionString = rfbString;
89 89
90 QRegExp regexp( "RFB [0-9][0-9][0-9]\\.[0-9][0-9][0-9]\n" ); 90 QRegExp regexp( "RFB [0-9][0-9][0-9]\\.[0-9][0-9][0-9]\n" );
91 91
92 if ( rfbString.find( regexp ) == -1 ) { 92 if ( rfbString.find( regexp ) == -1 ) {
93 static QString msg = tr( "Error: Invalid server version, %1" ).arg( rfbString ); 93 static QString msg = tr( "Error: Invalid server version, %1" ).arg( rfbString );
94 94
95 qWarning( msg ); 95 qWarning( msg );
96 emit error( msg ); 96 emit error( msg );
97 currentState = Error; 97 currentState = Error;
98 return; 98 return;
99 } 99 }
100 100