From 032f6b43efd27585c30de7dfd48ad15247ed6a03 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 17 Feb 2013 02:46:00 +0000 Subject: Bu::ProtocolTelnet can now disable echoing if echoing is being controlled by the server anyway. It needs a bunch more work to handle things like special characters better, but overall it's really pretty good. --- src/stable/protocoltelnet.cpp | 15 +++++++++++++-- src/stable/protocoltelnet.h | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/stable/protocoltelnet.cpp b/src/stable/protocoltelnet.cpp index 4259fc7..f8a3906 100644 --- a/src/stable/protocoltelnet.cpp +++ b/src/stable/protocoltelnet.cpp @@ -70,6 +70,7 @@ Bu::ProtocolTelnet::ProtocolTelnet() : oNAWS( *this, OPT_NAWS ), oSuppressGA(*this, OPT_SUPGA ), bCanonical( true ), + bEcho( true ), bSubOpt( false ) { } @@ -230,7 +231,7 @@ void Bu::ProtocolTelnet::onNewData( Bu::Client *pClient ) else { sDataBuf += bc; - if( oEcho.isLocalSet() ) + if( oEcho.isLocalSet() && bEcho ) { pClient->write( &bc, 1 ); #ifdef __TELNET_DEBUG @@ -243,7 +244,7 @@ void Bu::ProtocolTelnet::onNewData( Bu::Client *pClient ) else { sDataBuf += bc; - if( oEcho.isLocalSet() ) + if( oEcho.isLocalSet() && bEcho ) { pClient->write( &bc, 1 ); } @@ -273,6 +274,16 @@ bool Bu::ProtocolTelnet::isCanonical() return bCanonical; } +void Bu::ProtocolTelnet::setEcho( bool bOpt ) +{ + bEcho = bOpt; +} + +bool Bu::ProtocolTelnet::isEchoEnabled() +{ + return bEcho; +} + void Bu::ProtocolTelnet::write( const Bu::String &sData ) { write( sData.getStr(), sData.getSize() ); diff --git a/src/stable/protocoltelnet.h b/src/stable/protocoltelnet.h index 9686974..a620a02 100644 --- a/src/stable/protocoltelnet.h +++ b/src/stable/protocoltelnet.h @@ -117,6 +117,9 @@ namespace Bu void setCanonical( bool bCon=true ); bool isCanonical(); + void setEcho( bool bOpt=true ); + bool isEchoEnabled(); + void write( const Bu::String &sData ); void write( const char *pData, int iSize ); void write( char cData ); @@ -213,6 +216,7 @@ namespace Bu char cSubOpt; /**< Which suboption are we processing. */ bool bCanonical; /**< Are we canonicalizing incoming data? */ + bool bEcho; /**< Should chars be echoed? */ bool bSubOpt; /**< Are we processing a suboption right now? */ }; } -- cgit v1.2.3