summaryrefslogtreecommitdiff
authordwmw2 <dwmw2>2002-05-09 17:31:30 (UTC)
committer dwmw2 <dwmw2>2002-05-09 17:31:30 (UTC)
commite7b6e8c14e2c7ed7fe440d018a28ea1b5d3020e5 (patch) (side-by-side diff)
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 @@
#include <assert.h>
extern "C" {
#include "vncauth.h"
}
#include "krfblogin.h"
#include "krfbconnection.h"
#include <qtimer.h>
+#include <qregexp.h>
// The length of the various messages (used to decide how many bytes to
// wait for).
const int ServerVersionLength = 12;
const int ClientVersionLength = 12;
const int AuthSchemeLength = 4;
const int FailureReasonSizeLength = 4;
const int ChallengeLength = 16;
const int AuthResultLength = 4;
// Authentication results
enum AuthResult {
AuthOk,
AuthFailed,
AuthTooMany
};
typedef unsigned char CARD8;
typedef unsigned short CARD16;
typedef unsigned long CARD32;
const int endianTest = 1;
// Endian stuff
#define Swap16IfLE(s) \
(*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
#define Swap32IfLE(l) \
(*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \
(((l) & 0x00ff0000) >> 8) | \
(((l) & 0x0000ff00) << 8) | \
(((l) & 0x000000ff) << 24)) : (l))
KRFBLogin::KRFBLogin( KRFBConnection *con )
: QObject( con, "RFB login manager" )
{
assert( con );
this->con = con;
currentState = AwaitingServerVersion;
connect( this, SIGNAL( error( const QString & ) ),
con, SIGNAL( error( const QString & ) ) );
connect( this, SIGNAL( passwordRequired( KRFBConnection * ) ),
con, SIGNAL( passwordRequired( KRFBConnection * ) ) );
qWarning( "Waiting for server version..." );
static QString statusMsg = tr( "Waiting for server version..." );
emit status( statusMsg );
// Kick off the state machine
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerVersion() ) );
con->waitForData( ServerVersionLength );
}
KRFBLogin::~KRFBLogin()
{
}
KRFBLogin::State KRFBLogin::state() const
{
return currentState;
}
void KRFBLogin::gotServerVersion()
{
qWarning( "Got server version" );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotServerVersion() ) );
// Read the server's version message
char serverVersion[ ServerVersionLength + 1 ];
con->read( serverVersion, ServerVersionLength );
serverVersion[ ServerVersionLength ] = '\0';
QCString rfbString( serverVersion, ServerVersionLength + 1 );
versionString = rfbString;
QRegExp regexp( "RFB [0-9][0-9][0-9]\\.[0-9][0-9][0-9]\n" );
if ( rfbString.find( regexp ) == -1 ) {
static QString msg = tr( "Error: Invalid server version, %1" ).arg( rfbString );
qWarning( msg );
emit error( msg );
currentState = Error;
return;
}
// Calculate the actual version number
serverMajor = (serverVersion[4] - '0') * 100
+ (serverVersion[5] - '0') * 10
+ (serverVersion[6] - '0');