📄 msgwriter.cpp
字号:
/* Copyright (C) 2006 Lucas Gomez All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
// INCLUDE FILES
#include "MsgWriter.h"
#include "Decoder.h"
#include "LogWriter.h"
//LITERALS
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CMsgWriter::CMsgWriter()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CMsgWriter::CMsgWriter(CConnParams* aCP,OutStream* aOS)
{
iCP=aCP;
iOS=aOS;
}
// ---------------------------------------------------------------------------
// CMsgWriter::~CMsgWriter()
// Destructor.
// ---------------------------------------------------------------------------
//
CMsgWriter::~CMsgWriter()
{
}
void CMsgWriter::WriteSetPixelFormat(CPixelFormat* aPF)
{
StartMsg(MsgType::KSetPixelFormat);
iOS->Pad(3);
aPF->Write(iOS);
EndMsg();
}
void CMsgWriter::WriteSetEncodings(TInt aNEncodings,RArray<TEncodings>& aEncodings)
{
StartMsg(MsgType::KSetEncodings);
iOS->Skip(1);
iOS->WriteU16(aNEncodings);
for(TInt i=0;i<aNEncodings;i++)
iOS->WriteU32(aEncodings[i]);
EndMsg();
}
void CMsgWriter::WriteSetEncodings(TEncodings aPreferredEncoding,TBool aUseCopyRect)
{
TInt nEncodings=0;
RArray<TEncodings> encodings;
if(iCP->GetSupportsLocalCursor())
{
encodings.AppendL(EEncodingPseudoEncodingCursor);
nEncodings++;
}
if(iCP->GetSupportsDesktopResize())
{
encodings.AppendL(EEncodingPseudoEncodingDesktopSize);
nEncodings++;
}
if(MDecoder::Supported(aPreferredEncoding))
{
encodings.AppendL(aPreferredEncoding);
nEncodings++;
}
if(aUseCopyRect)
{
encodings.AppendL(EEncodingCopyRect);
nEncodings++;
}
for(TInt i=EEncodingMax;i>=0;i--)
{
if(i!=static_cast<TInt>(aPreferredEncoding) && MDecoder::Supported(static_cast<TEncodings>(i)))
{
encodings.AppendL(static_cast<TEncodings>(i));
nEncodings++;
}
}
WriteSetEncodings(nEncodings, encodings);
encodings.Close();
}
void CMsgWriter::WriteFramebufferUpdateRequest(TInt aX,TInt aY,TInt aW,TInt aH,TBool aIncremental)
{
StartMsg(MsgType::KFramebufferUpdateRequest);
iOS->WriteU8(aIncremental?1:0);
iOS->WriteU16(aX);
iOS->WriteU16(aY);
iOS->WriteU16(aW);
iOS->WriteU16(aH);
EndMsg();
}
void CMsgWriter::WriteKeyEvent(TInt aKey,TBool aDown)
{
StartMsg(MsgType::KKeyEvent);
iOS->WriteU8(aDown?1:0);
iOS->Pad(2);
iOS->WriteU32(aKey);
EndMsg();
}
void CMsgWriter::WritePointerEvent(TInt aX,TInt aY,TInt aButtonMask)
{
if(aX<0) aX=0;
if(aY<0) aY=0;
if(aX>=iCP->GetWidth()) aX=iCP->GetWidth()-1;
if(aY>=iCP->GetHeight()) aY=iCP->GetHeight()-1;
StartMsg(MsgType::KPointerEvent);
iOS->WriteU8(aButtonMask);
iOS->WriteU16(aX);
iOS->WriteU16(aY);
EndMsg();
}
void CMsgWriter::WriteClientCutText(TDesC& aText)
{
StartMsg(MsgType::KClientCutText);
iOS->Pad(3);
HBufC8* str=HBufC8::NewLC(aText.Length());
str->Des().Copy(aText);
iOS->WriteString(*str);
CleanupStack::PopAndDestroy(str);
EndMsg();
}
void CMsgWriter::SetOutStream(OutStream* aOS)
{
iOS=aOS;
}
CConnParams* CMsgWriter::GetConnParams()
{
return iCP;
}
OutStream* CMsgWriter::GetOutStream()
{
return iOS;
}
CMsgWriterV3::~CMsgWriterV3()
{
}
CMsgWriterV3::CMsgWriterV3(CConnParams* aCP,OutStream* aOS) : CMsgWriter(aCP,aOS)
{
}
void CMsgWriterV3::WriteClientInit(TBool aShared)
{
iOS->WriteU8(aShared?1:0);
EndMsg();
}
void CMsgWriterV3::StartMsg(TInt aType)
{
iOS->WriteU8(aType);
}
void CMsgWriterV3::EndMsg()
{
iOS->Flush();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -