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