summaryrefslogtreecommitdiff
authortreke <treke>2002-12-22 00:58:46 (UTC)
committer treke <treke>2002-12-22 00:58:46 (UTC)
commit17d7f11b16b650f6ee2b5c440506167ea41fbfe5 (patch) (side-by-side diff)
treecd5924c9e374a82c1cac6433dce098f3f45f4286
parent6853d02989fc01e5a65048aca9749c20e0f5d095 (diff)
downloadopie-17d7f11b16b650f6ee2b5c440506167ea41fbfe5.zip
opie-17d7f11b16b650f6ee2b5c440506167ea41fbfe5.tar.gz
opie-17d7f11b16b650f6ee2b5c440506167ea41fbfe5.tar.bz2
1) Fixed a bug where double clicking a blank spot on the bookmark list
caused a segfault. 2) Removed support for copying from the server. Trying to setText in the clipboard would segfault everytime from within the KRFBDecoder. Doesnt seem to like being called from within a slot.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/krfbcanvas.cpp4
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp5
-rw-r--r--noncore/comm/keypebble/kvnc.cpp3
3 files changed, 6 insertions, 6 deletions
diff --git a/noncore/comm/keypebble/krfbcanvas.cpp b/noncore/comm/keypebble/krfbcanvas.cpp
index 049bbd4..bc71c90 100644
--- a/noncore/comm/keypebble/krfbcanvas.cpp
+++ b/noncore/comm/keypebble/krfbcanvas.cpp
@@ -50,164 +50,160 @@ void KRFBCanvas::openConnection(KRFBServer server)
void KRFBCanvas::openURL( const QUrl &url )
{
if ( loggedIn_ ) {
qWarning( "openURL invoked when logged in\n" );
return;
}
QCString host = url.host().latin1();
int display = url.port();
// connection_->connectTo( host, display );
}
void KRFBCanvas::closeConnection()
{
loggedIn_ = false;
connection_->disconnect();
viewport()->setMouseTracking( false );
viewport()->setBackgroundMode( PaletteDark );
setBackgroundMode( PaletteDark );
update();
}
void KRFBCanvas::bell()
{
if ( connection_->options()->deIconify ) {
topLevelWidget()->raise();
topLevelWidget()->show();
}
}
void KRFBCanvas::loggedIn()
{
qWarning( "Ok, we're logged in" );
//
// Get ready for action
//
loggedIn_ = true;
viewport()->setMouseTracking( true );
viewport()->setBackgroundMode( NoBackground );
setBackgroundMode( NoBackground );
// Start using the buffer
connect( connection_->buffer(), SIGNAL( sizeChanged( int, int ) ),
this, SLOT( resizeContents(int,int) ) );
connect( connection_->buffer(), SIGNAL( updated( int, int, int, int ) ),
this, SLOT( viewportUpdate(int,int,int,int) ) );
connect( connection_->buffer(), SIGNAL( bell() ),
this, SLOT( bell() ) );
connect( qApp->clipboard(), SIGNAL( dataChanged() ),
this, SLOT( clipboardChanged() ) );
}
void KRFBCanvas::viewportPaintEvent( QPaintEvent *e )
{
QRect r = e->rect();
if ( loggedIn_ ) {
QPixmap p;
bitBlt( viewport(), r.x(), r.y(),
connection_->buffer()->pixmap(),
r.x() + contentsX(), r.y() + contentsY(),
r.width(), r.height() );
}
else {
QScrollView::viewportPaintEvent( e );
}
}
void KRFBCanvas::viewportUpdate( int x, int y, int w, int h )
{
updateContents( x, y, w, h );
}
void KRFBCanvas::contentsMousePressEvent( QMouseEvent *e )
{
if (nextDoubleClick) {
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),LeftButton,LeftButton));
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0));
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),LeftButton,0));
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton));
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0));
} if (nextRightClick) {
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),RightButton,RightButton));
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),RightButton,0));
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonPress, e->pos(),NoButton,NoButton));
connection_->buffer()->mouseEvent( &QMouseEvent(QEvent::MouseButtonRelease, e->pos(),NoButton,0));
} else if ( loggedIn_ )
connection_->buffer()->mouseEvent( e );
- qDebug("Press");
- qDebug(QString::number(e->type()==QEvent::MouseButtonPress));
}
void KRFBCanvas::contentsMouseReleaseEvent( QMouseEvent *e )
{
if ( loggedIn_ && !nextRightClick && !nextDoubleClick) {
connection_->buffer()->mouseEvent( e );
}
nextRightClick=0;
nextDoubleClick=0;
- qDebug("Release");
- qDebug(QString::number(e->button()));
}
void KRFBCanvas::contentsMouseMoveEvent( QMouseEvent *e )
{
if ( loggedIn_ )
connection_->buffer()->mouseEvent( e );
}
void KRFBCanvas::keyPressEvent( QKeyEvent *e )
{
if ( loggedIn_ )
connection_->buffer()->keyPressEvent( e );
}
void KRFBCanvas::keyReleaseEvent( QKeyEvent *e )
{
if ( loggedIn_ )
connection_->buffer()->keyReleaseEvent( e );
}
void KRFBCanvas::refresh()
{
if ( loggedIn_ )
connection_->refresh();
}
void KRFBCanvas::clipboardChanged()
{
if ( loggedIn_ ) {
connection_->sendCutText( qApp->clipboard()->text() );
}
}
void KRFBCanvas::sendCtlAltDel( void)
{
if ( loggedIn_ ) {
connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Control, 0,0));
connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Alt, 0,0));
connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyPress,Qt::Key_Delete, 0,0));
connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Control, 0,0));
connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Alt, 0,0));
connection_->buffer()->keyPressEvent( &QKeyEvent(QEvent::KeyRelease,Qt::Key_Delete, 0,0));
}
}
void KRFBCanvas::markDoubleClick( void)
{
nextRightClick=1;
}
void KRFBCanvas::markRightClick( void)
{
nextRightClick=1;
}
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
index 94e3b79..33418ae 100644
--- a/noncore/comm/keypebble/krfbdecoder.cpp
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -614,213 +614,216 @@ void KRFBDecoder::handleCoRRERect()
qWarning( "CoRRE not implemented" );
}
void KRFBDecoder::handleHexTileRect()
{
qWarning( "HexTile not implemented" );
}
void KRFBDecoder::sendMouseEvent( QMouseEvent *e )
{
// Deal with the buttons
if ( e->type() != QEvent::MouseMove ) {
buttonMask = 0;
if ( e->type() == QEvent::MouseButtonPress ) {
if ( e->button() & LeftButton )
buttonMask |= 0x01;
if ( e->button() & MidButton )
buttonMask |= 0x04;
if ( e->button() & RightButton )
buttonMask |= 0x02;
}
else if ( e->type() == QEvent::MouseButtonRelease ) {
if ( e->button() & LeftButton )
buttonMask &= 0x06;
if ( e->button() & MidButton )
buttonMask |= 0x03;
if ( e->button() & RightButton )
buttonMask |= 0x05;
}
}
// HACK: Scaling
CARD16 x = Swap16IfLE( e->x() * con->options()->scaleFactor );
CARD16 y = Swap16IfLE( e->y() * con->options()->scaleFactor );
con->write( &PointerEventId, 1 );
con->write( &buttonMask, 1 );
con->write( &x, 2 );
con->write( &y, 2 );
}
void KRFBDecoder::sendCutEvent( const QString &unicode )
{
//
// Warning: There is a bug in the RFB protocol because there is no way to find
// out the codepage in use on the remote machine. This could be fixed by requiring
// the remote server to use utf8 etc. but for now we have to assume they're the
// same. I've reported this problem to the ORL guys, but they apparantly have no
// immediate plans to fix the issue. :-( (rich)
//
CARD8 padding[3];
QCString text = unicode.local8Bit();
CARD32 length = text.length();
length = Swap32IfLE( length );
con->write( &ClientCutTextId, 1 );
con->write( &padding, 3 );
con->write( &length, 4 );
con->write( text.data(), length );
}
void KRFBDecoder::gotServerCut()
{
qWarning( "Got server cut" );
currentState = AwaitingServerCutLength;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) );
con->waitForData( ServerCutLenLength );
}
void KRFBDecoder::gotServerCutLength()
{
assert( currentState = AwaitingServerCutLength );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotServerCutLength() ) );
CARD8 padding[3];
con->read( padding, 3 );
con->read( &serverCutTextLen, 4 );
serverCutTextLen = Swap32IfLE( serverCutTextLen );
currentState = AwaitingServerCutText;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutText() ) );
con->waitForData( serverCutTextLen );
}
void KRFBDecoder::gotServerCutText()
{
assert( currentState = AwaitingServerCutText );
disconnect( con, SIGNAL( gotEnoughData() ),
this, SLOT( gotServerCutText() ) );
+
//
// Warning: There is a bug in the RFB protocol because there is no way to find
// out the codepage in use on the remote machine. This could be fixed by requiring
// the remote server to use utf8 etc. but for now we have to assume they're the
// same. I've reported this problem to the ORL guys, but they apparantly have no
// immediate plans to fix the issue. :-( (rich)
//
char *cutbuf = new char[ serverCutTextLen + 1 ];
CHECK_PTR( cutbuf );
con->read( cutbuf, serverCutTextLen );
cutbuf[ serverCutTextLen ] = '\0';
+ /* For some reason QApplication::clipboard()->setText() segfaults when called
+ * from within keypebble's mass of signals and slots
qWarning( "Server cut: %s", cutbuf );
QString cutText( cutbuf ); // DANGER!!
qApp->clipboard()->setText( cutText );
+ */
delete cutbuf;
-
// Now wait for the update (again)
if ( oldState == AwaitingUpdate ) {
currentState = AwaitingUpdate;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
con->waitForData( UpdateHeaderLength );
}
else if ( oldState == Idle ) {
currentState = Idle;
}
else {
qWarning( "Async handled in weird state" );
currentState = oldState;
};
}
void KRFBDecoder::gotBell()
{
qWarning( "Got server bell" );
buf->soundBell();
// Now wait for the update (again)
if ( oldState == AwaitingUpdate ) {
currentState = AwaitingUpdate;
connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
con->waitForData( UpdateHeaderLength );
}
else if ( oldState == Idle ) {
currentState = Idle;
}
else {
qWarning( "Async handled in weird state" );
currentState = oldState;
};
}
void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event )
{
int key;
key = toKeySym( event );
if ( key ) {
key = Swap32IfLE( key );
CARD8 mask = true;
CARD16 padding = 0;
con->write( &KeyEventId, 1 );
con->write( &mask, 1 );
con->write( &padding, 2 );
con->write( &key, 4 );
}
}
void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event )
{
int key;
key = toKeySym( event );
if ( key ) {
key = Swap32IfLE( key );
CARD8 mask = false;
CARD16 padding = 0;
con->write( &KeyEventId, 1 );
con->write( &mask, 1 );
con->write( &padding, 2 );
con->write( &key, 4 );
}
}
int KRFBDecoder::toKeySym( QKeyEvent *k )
{
int ke = 0;
ke = k->ascii();
// Markus: Crappy hack. I dont know why lower case letters are
// not defined in qkeydefs.h. The key() for e.g. 'l' == 'L'.
// This sucks. :-(
if ( (ke == 'a') || (ke == 'b') || (ke == 'c') || (ke == 'd')
|| (ke == 'e') || (ke == 'f') || (ke == 'g') || (ke == 'h')
|| (ke == 'i') || (ke == 'j') || (ke == 'k') || (ke == 'l')
|| (ke == 'm') || (ke == 'n') || (ke == 'o') || (ke == 'p')
|| (ke == 'q') || (ke == 'r') || (ke == 's') || (ke == 't')
|| (ke == 'u') || (ke == 'v') ||( ke == 'w') || (ke == 'x')
|| (ke == 'y') || (ke == 'z') ) {
ke = k->key();
ke = ke + 0x20;
return ke;
}
// qkeydefs = xkeydefs! :-)
if ( ( k->key() >= 0x0a0 ) && k->key() <= 0x0ff )
return k->key();
if ( ( k->key() >= 0x20 ) && ( k->key() <= 0x7e ) )
diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp
index 5b1dc9f..48a442c 100644
--- a/noncore/comm/keypebble/kvnc.cpp
+++ b/noncore/comm/keypebble/kvnc.cpp
@@ -66,193 +66,194 @@ KVNC::KVNC( const char *name ) : QMainWindow( 0, name ,WStyle_ContextHelp)
bookmarkSelector=new KVNCBookmarkDlg();
stack->addWidget(bookmarkSelector,get_unique_id());
stack->raiseWidget( bookmarkSelector );
canvas = new KRFBCanvas( stack, "canvas" );
stack->addWidget(canvas,get_unique_id());
setCentralWidget( stack );
connect( bookmarkSelector->bookmarkList, SIGNAL(clicked(QListBoxItem *)),
this, SLOT(openConnection(QListBoxItem *)) );
connect( canvas->connection(), SIGNAL(statusChanged(const QString &)),
this, SLOT(statusMessage(const QString &)) );
connect( canvas->connection(), SIGNAL(error(const QString &)),
this, SLOT(error(const QString &)) );
connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) );
connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) );
connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) );
setupActions();
cornerButton = new QPushButton( this );
cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) );
canvas->setCornerWidget( cornerButton );
stack->raiseWidget( bookmarkSelector );
bar= new QToolBar( this );
setToolBarsMovable( false );
setRightJustification(false);
QAction *n = new QAction( tr( "New Connection" ), Resource::loadPixmap( "new" ),
QString::null, 0, this, 0 );
connect( n, SIGNAL( activated() ),
this, SLOT( newConnection() ) );
n->addTo( bar );
QAction *o = new QAction( tr( "Open Bookmark" ), Resource::loadPixmap( "fileopen" ),
QString::null, 0, this, 0 );
connect( o, SIGNAL( activated() ),
this, SLOT( openConnection() ) );
o->addTo( bar );
QAction *d = new QAction( tr( "Delete Bookmark" ), Resource::loadPixmap( "trash" ),
QString::null, 0, this, 0 );
connect( d, SIGNAL( activated() ),
this, SLOT( deleteBookmark() ) );
d->addTo( bar );
}
KVNC::~KVNC()
{
}
void KVNC::newConnection()
{
curServer=new KRFBServer;
KVNCConnDlg dlg( curServer,this);
dlg.showMaximized();
if ( dlg.exec()) {
if (!curServer->name.isEmpty())
bookmarkSelector->addBookmark(curServer);
canvas->openConnection(*curServer);
} else
curServer=0;
}
void KVNC::openConnection( QString name)
{
curServer=bookmarkSelector->getServer(name);
if (curServer) {
KVNCConnDlg dlg( curServer,this);
dlg.showMaximized();
if ( dlg.exec() ) {
canvas->openConnection(*curServer);
bookmarkSelector->writeBookmarks();
} else
curServer=0;
}
}
void KVNC::openConnection( void )
{
openConnection( bookmarkSelector->selectedBookmark());
}
void KVNC::openConnection( QListBoxItem * item)
{
- openConnection(item->text());
+ if (item)
+ openConnection(item->text());
}
void KVNC::setupActions()
{
cornerMenu = new QPopupMenu( this );
fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 );
connect( fullScreenAction, SIGNAL(activated()),
this, SLOT( toggleFullScreen() ) );
fullScreenAction->addTo( cornerMenu );
fullScreenAction->setEnabled( false );
ctlAltDelAction = new QAction( tr("Send Contrl-Alt-Delete"), QString::null, 0, 0 );
connect( ctlAltDelAction, SIGNAL(activated()),
canvas, SLOT( sendCtlAltDel() ) );
ctlAltDelAction->addTo( cornerMenu );
ctlAltDelAction->setEnabled( false );
disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 );
connect( disconnectAction, SIGNAL(activated()),
this, SLOT( closeConnection() ) );
disconnectAction->addTo( cornerMenu );
disconnectAction->setEnabled( false );
doubleClickAction = new QAction( tr("Next Click is Double Click"), QString::null, 0, 0 );
connect( doubleClickAction, SIGNAL(activated()),
canvas, SLOT( markDoubleClick() ) );
doubleClickAction->addTo( cornerMenu );
doubleClickAction->setEnabled( false );
rightClickAction = new QAction( tr("Next Click is Right Click"), QString::null, 0, 0 );
connect( rightClickAction, SIGNAL(activated()),
canvas, SLOT( markRightClick() ) );
rightClickAction->addTo( cornerMenu );
rightClickAction->setEnabled( false );
}
void KVNC::toggleFullScreen()
{
if ( fullscreen ) {
canvas->releaseKeyboard();
canvas->reparent( stack, 0, QPoint(0,0), false );
canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken );
setCentralWidget( stack );
stack->addWidget(canvas,get_unique_id());
stack->raiseWidget(canvas);
canvas->show();
stack->show();
fullScreenAction->setText( tr("Full Screen") );
} else {
canvas->setFrameStyle( QFrame::NoFrame );
stack->removeWidget(canvas);
canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
QPoint(0,0),false);
canvas->resize(qApp->desktop()->width(), qApp->desktop()->height());
canvas->raise();
canvas->setFocus();
canvas->grabKeyboard();
canvas->show();
fullScreenAction->setText( tr("Stop Full Screen") );
}
fullscreen = !fullscreen;
}
void KVNC::closeConnection()
{
if ( fullscreen )
toggleFullScreen();
canvas->closeConnection();
}
void KVNC::showMenu()
{
QPoint pt = mapToGlobal(cornerButton->pos());
QSize s = cornerMenu->sizeHint();
pt.ry() -= s.height();
pt.rx() -= s.width();
cornerMenu->popup( pt );
}
void KVNC::connected()
{
static QString msg = tr( "Connected to remote host" );
statusMessage( msg );
ctlAltDelAction->setEnabled(true);
disconnectAction->setEnabled( true );
fullScreenAction->setEnabled( true );
doubleClickAction->setEnabled( false );
rightClickAction->setEnabled( true );
stack->raiseWidget(canvas);
bar->hide();
}