📄 conn.cpp
字号:
// Empty?
}
void CConn::FramebufferUpdateEnd()
{
if(iAutoSelect)
AutoSelectFormatAndEncoding();
iCallback->GetDesktopWindow()->DrawNow();
RequestNewUpdate();
}
void CConn::SetColourMapEntries(TInt aFirstColour,TInt aNColours,RArray<TInt>& aRgbs)
{
iCallback->GetDesktopWindow()->SetColourMapEntries(aFirstColour,aNColours,aRgbs);
}
void CConn::Bell()
{
CEikonEnv::Beep();
}
void CConn::ServerCutText(TDes& aString)
{
//if (viewer.acceptClipboard.getValue())
// clipboardDialog.serverCutText(str);
}
void CConn::BeginRect(TInt aX,TInt aY,TInt aW,TInt aH,TEncodings aEncoding)
{
iVIS->StartTiming();
iCallback->GetDesktopWindow()->BeginRect(aX,aY,aW,aH,aEncoding);
}
void CConn::EndRect(TInt aX,TInt aY,TInt aW,TInt aH,TEncodings aEncoding)
{
iCallback->GetDesktopWindow()->EndRect(aX,aY,aW,aH,aEncoding);
iVIS->StopTiming();
if(aEncoding<=EEncodingMax)
iLastUsedEncoding=aEncoding;
}
void CConn::FillRect(TInt aX,TInt aY,TInt aW,TInt aH,TInt aP)
{
iCallback->GetDesktopWindow()->FillRect(aX,aY,aW,aH,aP);
}
void CConn::ImageRect(TInt aX,TInt aY,TInt aW,TInt aH,TDes8& aP,TInt aOffset)
{
iCallback->GetDesktopWindow()->ImageRect(aX,aY,aW,aH,aP,aOffset);
}
void CConn::CopyRect(TInt aX,TInt aY,TInt aW,TInt aH,TInt aSx,TInt aSy)
{
iCallback->GetDesktopWindow()->CopyRect(aX,aY,aW,aH,aSx,aSy);
}
void CConn::SetCursor(TInt aHotspotX,TInt aHotspotY,TInt aW,TInt aH,RBuf8& aData,RBuf8& aMask)
{
iCallback->GetDesktopWindow()->SetCursor(aHotspotX,aHotspotY,aW,aH,aData,aMask);
}
void CConn::RecreateViewport()
{
ReconfigureViewport();
iCallback->GetDesktopWindow()->InitGraphics();
}
void CConn::ReconfigureViewport()
{
//viewport->setMaxSize(cp.width, cp.height);
/*TInt w=iCP->GetWidth()+4; // 4 is due to bizarre ScrollPane border
TInt h=iCP->GetHeight()+4;
TRect dpySize=iCallback->iViewportView->ClientRect();
TInt wmDecorationWidth=6;
TInt wmDecorationHeight=24;
if(w+wmDecorationWidth>=dpySize.Width())
w=dpySize.Width()-wmDecorationWidth;
if(h+wmDecorationHeight>=dpySize.Height())
h=dpySize.Height()-wmDecorationHeight;
TInt x=(dpySize.Width()-w-wmDecorationWidth)/2;
TInt y=(dpySize.Height()-h-wmDecorationHeight)/2;
TRect dpySize=iCallback->iViewportView->ClientRect();
dpySize.Resize(-iCallback->iViewportView->iContainer->GetScrollBarBreadth(),-iCallback->iViewportView->iContainer->GetScrollBarBreadth());
iCallback->iViewportView->iContainer->SetRect(dpySize);*/
}
void CConn::AutoSelectFormatAndEncoding()
{
TInt64 kbitsPerSecond=iVIS->KBitsPerSecond();
TEncodings newEncoding=iCurrentEncoding;
if(kbitsPerSecond>3000)
{
newEncoding=EEncodingHextile;
}
else if(kbitsPerSecond<1500)
{
newEncoding=EEncodingZRLE;
}
if(newEncoding!=iCurrentEncoding)
{
iCurrentEncoding=newEncoding;
iEncodingChange=ETrue;
}
// if (kbitsPerSecond > 1000) {
// if (!fullColour) {
// vlog.info("Throughput "+kbitsPerSecond+
// " kbit/s - changing to full colour");
// fullColour = true;
// formatChange = true;
// }
// }
}
void CConn::RequestNewUpdate()
{
if(iFormatChange)
{
if(iFullColour)
{
//desktop.setPF(fullColourPF);
}
else
{
//desktop.setPF(rfb.PixelFormat(8,6,0,1,3,3,3,4,2,0));
}
iCP->SetPF(iCallback->GetDesktopWindow()->GetPF());
GetWriter()->WriteSetPixelFormat(iCP->GetPF());
}
CheckEncodings();
GetWriter()->WriteFramebufferUpdateRequest(0,0,iCP->GetWidth(),iCP->GetHeight(),
!iFormatChange);
iFormatChange=EFalse;
}
void CConn::Close()
{
iShuttingDown=ETrue;
iSock.Close();
}
void CConn::Refresh()
{
GetWriter()->WriteFramebufferUpdateRequest(0,0,iCP->GetWidth(),iCP->GetHeight(),EFalse);
}
void CConn::WriteClientCutText(TDesC& aStr)
{
if(GetState()!=ERfbStateNormal) return;
GetWriter()->WriteClientCutText(aStr);
}
void CConn::WriteKeyEvent(TInt aKeysym,TBool aDown)
{
if(GetState()!=ERfbStateNormal) return;
GetWriter()->WriteKeyEvent(aKeysym,aDown);
}
void CConn::WritePointerEvent(TPointerEvent aEv)
{
if(GetState()!=ERfbStateNormal) return;
switch(aEv.iType)
{
case TPointerEvent::EButton1Down:
{
iButtonMask=1;
}
break;
case TPointerEvent::EButton2Down:
{
iButtonMask=2;
}
break;
case TPointerEvent::EButton3Down:
{
iButtonMask=4;
}
break;
case TPointerEvent::EButton1Up:
case TPointerEvent::EButton2Up:
case TPointerEvent::EButton3Up:
{
iButtonMask=0;
}
break;
}
WriteModifiers(GetModifiers() & !EModifierAlt & !EModifierFunc);
if(aEv.iPosition.iX<0) aEv.iPosition.iX=0;
if(aEv.iPosition.iX>iCP->GetWidth()-1) aEv.iPosition.iX=iCP->GetWidth()-1;
if(aEv.iPosition.iY<0) aEv.iPosition.iY=0;
if(aEv.iPosition.iY>iCP->GetHeight()-1) aEv.iPosition.iY=iCP->GetHeight()-1;
GetWriter()->WritePointerEvent(aEv.iPosition.iX,aEv.iPosition.iY,iButtonMask);
if(iButtonMask==0) WriteModifiers(0);
}
void CConn::WriteModifiers(TInt aM)
{
if((aM & EModifierShift)!=(iPressedModifiers & EModifierShift))
WriteKeyEvent(Keysyms::KKeysymShift_L,(aM & EModifierShift)!=0);
if((aM & EModifierCtrl)!=(iPressedModifiers & EModifierCtrl))
WriteKeyEvent(Keysyms::KKeysymControl_L,(aM & EModifierCtrl)!=0);
if((aM & EModifierAlt)!=(iPressedModifiers & EModifierAlt))
WriteKeyEvent(Keysyms::KKeysymAlt_L,(aM & EModifierAlt)!=0);
if((aM & EModifierFunc)!=(iPressedModifiers & EModifierFunc))
WriteKeyEvent(Keysyms::KKeysymMeta_L,(aM & EModifierFunc)!=0);
iPressedModifiers=aM;
}
void CConn::CheckEncodings()
{
if(iEncodingChange && GetState()==ERfbStateNormal)
{
TBuf<100> temp;
temp.Copy(_L("Using "));
temp.AppendNum(iCurrentEncoding);
temp.Append(_L(" encoding"));
CLogWriter::InstanceL()->LogTrace(temp);
GetWriter()->WriteSetEncodings(iCurrentEncoding,ETrue);
iEncodingChange=EFalse;
}
}
// FROM TStreamBuf
void CConn::DoRelease()
{
}
void CConn::DoSynchL()
{
}
TInt CConn::DoReadL(TAny* aPtr,TInt aMaxLength)
{
}
TInt CConn::DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
{
while(!iMutex->IsEmpty())
{
CActiveSchedulerWait* temp=new (ELeave) CActiveSchedulerWait;
iMutex->PushL(temp);
temp->Start();
}
iSockState=ESockReading;
iRecvBuf->Des().SetMax();
iRecvBufPtr.Set(iRecvBuf->Des().LeftTPtr(aMaxLength));;
iSock.RecvOneOrMore(iRecvBufPtr,0,iStatus,iRecvLength);
SetActive();
CActiveSchedulerWait* temp=new (ELeave) CActiveSchedulerWait;
iMutex->PushL(temp);
temp->Start();
aStatus=iStatus;
aDes.Copy(iRecvBufPtr);
return iRecvLength();
}
TStreamTransfer CConn::DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer)
{
}
void CConn::DoWriteL(const TAny* aPtr,TInt aLength)
{
}
TInt CConn::DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
{
while(!iMutex->IsEmpty())
{
CActiveSchedulerWait* temp=new (ELeave) CActiveSchedulerWait;
iMutex->PushL(temp);
temp->Start();
}
iSockState=ESockWriting;
iSendBufPtr.Copy(aDes.Left(aMaxLength));
iSock.Send(iSendBufPtr,0,iStatus,iSendLength);
SetActive();
CActiveSchedulerWait* temp=new (ELeave) CActiveSchedulerWait;
iMutex->PushL(temp);
temp->Start();
aStatus=iStatus;
return iSendLength();
}
TStreamTransfer CConn::DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer)
{
}
TStreamPos CConn::DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset)
{
}
HBufC* CConn::SetConnectionInfo(TDesC& aInfoFormat)
{
HBufC* info=HBufC::NewL(1000);
TBuf<100> serverHost;
iInetAddr.Output(serverHost);
serverHost.Append(':');
serverHost.AppendNum(iInetAddr.Port());
TBuf<100> desktopSize;
desktopSize.Num(iCP->GetWidth());
desktopSize.Append('x');
desktopSize.AppendNum(iCP->GetHeight());
TBuf<500> pixelFormat;
iCP->GetPF()->Print(pixelFormat);
TBuf<500> serverDefault;
iServerPF->Print(serverDefault);
TBuf<100> lineSpeed;
lineSpeed.Num(iVIS->KBitsPerSecond());
lineSpeed.Append(_L(" kbits/s"));
TBuf<100> protocol;
protocol.Num(iCP->GetMajorVersion());
protocol.Append('.');
protocol.AppendNum(iCP->GetMinorVersion());
info->Des().Format(aInfoFormat,&(iCP->GetName()),&serverHost,&desktopSize,
&pixelFormat,&serverDefault,
&(CConnParams::EncodingName(iCurrentEncoding)),
&(CConnParams::EncodingName(iLastUsedEncoding)),
&lineSpeed,
&protocol,
&(MSecurity::SecurityName(GetCurrentSecurity()->GetType())),
&(GetCurrentSecurity()->Description()));
return info;
}
TInt CConn::GetModifiers()
{
TInt res=0;
for(TInt i=0;i<iModifiersArray->Count();i++)
{
switch(iModifiersArray->At(i))
{
case 0: res|=EModifierShift; break;
case 1: res|=EModifierCtrl; break;
case 2: res|=EModifierAlt; break;
case 3: res|=EModifierFunc; break;
}
}
return res;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -