Skip to content
Snippets Groups Projects
Commit 60160ae8 authored by rswindell's avatar rswindell
Browse files

SpyTerminal can now send keystrokes to node session.

parent 1af28b8b
No related branches found
No related tags found
No related merge requests found
......@@ -532,6 +532,7 @@ __fastcall TMainForm::TMainForm(TComponent* Owner)
SpyTerminalFont->Pitch=fpFixed;
SpyTerminalWidth=434;
SpyTerminalHeight=364;
SpyTerminalKeyboardActive=true;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FileExitMenuItemClick(TObject *Sender)
......@@ -576,6 +577,9 @@ void __fastcall TMainForm::FormCreate(TObject *Sender)
SpyTerminalFont->Name=Registry->ReadString("SpyTerminalFontName");
if(Registry->ValueExists("SpyTerminalFontSize"))
SpyTerminalFont->Size=Registry->ReadInteger("SpyTerminalFontSize");
if(Registry->ValueExists("SpyTerminalKeyboardActive"))
SpyTerminalKeyboardActive
=Registry->ReadBool("SpyTerminalKeyboardActive");
Registry->CloseKey();
delete Registry;
......@@ -734,11 +738,17 @@ void __fastcall TMainForm::SaveSettings(void)
,AnsiString(ftp_startup.index_file_name));
Registry->WriteInteger("FtpOptions",ftp_startup.options);
Registry->WriteInteger("SpyTerminalWidth",SpyTerminalWidth);
Registry->WriteInteger("SpyTerminalHeight",SpyTerminalHeight);
Registry->WriteString("SpyTerminalFontName",SpyTerminalFont->Name);
Registry->WriteInteger("SpyTerminalFontSize",SpyTerminalFont->Size);
Registry->WriteInteger( "SpyTerminalWidth"
,SpyTerminalWidth);
Registry->WriteInteger( "SpyTerminalHeight"
,SpyTerminalHeight);
Registry->WriteString( "SpyTerminalFontName"
,SpyTerminalFont->Name);
Registry->WriteInteger( "SpyTerminalFontSize"
,SpyTerminalFont->Size);
Registry->WriteBool( "SpyTerminalKeyboardActive"
,SpyTerminalKeyboardActive);
Registry->CloseKey();
delete Registry;
......
......@@ -239,6 +239,7 @@ public: // User declarations
int SpyTerminalWidth;
int SpyTerminalHeight;
TFont* SpyTerminalFont;
bool SpyTerminalKeyboardActive;
TPageControl* __fastcall PageControl(int num);
int __fastcall PageNum(TPageControl* obj);
void __fastcall SaveSettings(void);
......
......@@ -57,7 +57,7 @@ __fastcall TNodeForm::TNodeForm(TComponent* Owner)
{
// OutputDebugString("NodeForm constructor\n");
MainForm=(TMainForm*)Application->MainForm;
MainForm->bbs_startup.spybuf
MainForm->bbs_startup.node_spybuf
=(RingBuf**)calloc(1,sizeof(RingBuf*)*MAX_NODES);
}
//---------------------------------------------------------------------------
......@@ -470,8 +470,9 @@ void __fastcall TNodeForm::SpyButtonClick(TObject *Sender)
if(ListBox->Selected[i]==true) {
if(SpyForms[i]==NULL) {
Application->CreateForm(__classid(TSpyForm), &SpyForms[i]);
SpyForms[i]->spybuf=&MainForm->bbs_startup.spybuf[i];
SpyForms[i]->Caption="Spying on Node "+AnsiString(i+1);
SpyForms[i]->inbuf=&MainForm->bbs_startup.node_inbuf[i];
SpyForms[i]->outbuf=&MainForm->bbs_startup.node_spybuf[i];
SpyForms[i]->Caption="Node "+AnsiString(i+1);
}
SpyForms[i]->Show();
}
......
......@@ -19,9 +19,12 @@ __fastcall TSpyForm::TSpyForm(TComponent* Owner)
{
Width=MainForm->SpyTerminalWidth;
Height=MainForm->SpyTerminalHeight;
KeyboardActive->Checked=MainForm->SpyTerminalKeyboardActive;
Terminal = new TEmulVT(this);
Terminal->Parent=this;
Terminal->Align=alClient;
Terminal->OnKeyPress=FormKeyPress;
Terminal->OnMouseUp=FormMouseUp;
}
bool strip_ansi(char* str)
{
......@@ -83,10 +86,10 @@ void __fastcall TSpyForm::SpyTimerTick(TObject *Sender)
char buf[1024];
int rd;
if(*spybuf==NULL)
if(*outbuf==NULL)
return;
rd=RingBufRead(*spybuf,buf,sizeof(buf)-1);
rd=RingBufRead(*outbuf,buf,sizeof(buf)-1);
if(rd) {
#if 0
buf[rd]=0;
......@@ -105,13 +108,15 @@ void __fastcall TSpyForm::SpyTimerTick(TObject *Sender)
//---------------------------------------------------------------------------
void __fastcall TSpyForm::FormShow(TObject *Sender)
{
Terminal->Font=MainForm->SpyTerminalFont;
if((*spybuf=(RingBuf*)malloc(sizeof(RingBuf)))==NULL) {
if((*outbuf=(RingBuf*)malloc(sizeof(RingBuf)))==NULL) {
Terminal->WriteStr("Malloc failure!");
return;
}
RingBufInit(*spybuf,SPYBUF_LEN);
RingBufInit(*outbuf,SPYBUF_LEN);
Timer->Enabled=true;
Terminal->Font=MainForm->SpyTerminalFont;
Terminal->Clear();
Terminal->WriteStr("*** Synchronet Local Spy ***\r\n\r\n");
Terminal->WriteStr("ANSI Terminal Emulation:"+CopyRight+"\r\n\r\n");
......@@ -121,17 +126,18 @@ void __fastcall TSpyForm::FormShow(TObject *Sender)
void __fastcall TSpyForm::FormClose(TObject *Sender, TCloseAction &Action)
{
Timer->Enabled=false;
if(*spybuf!=NULL) {
RingBufDispose(*spybuf);
free(*spybuf);
*spybuf=NULL;
if(*outbuf!=NULL) {
RingBufDispose(*outbuf);
free(*outbuf);
*outbuf=NULL;
}
MainForm->SpyTerminalWidth=Width;
MainForm->SpyTerminalHeight=Height;
MainForm->SpyTerminalKeyboardActive=KeyboardActive->Checked;
}
//---------------------------------------------------------------------------
void __fastcall TSpyForm::FontMenuItemClick(TObject *Sender)
void __fastcall TSpyForm::ChangeFontClick(TObject *Sender)
{
TFontDialog *FontDialog=new TFontDialog(this);
......@@ -140,8 +146,29 @@ void __fastcall TSpyForm::FontMenuItemClick(TObject *Sender)
MainForm->SpyTerminalFont->Assign(FontDialog->Font);
Terminal->Font=MainForm->SpyTerminalFont;
delete FontDialog;
// Terminal->Clear();
Terminal->UpdateScreen();
}
//---------------------------------------------------------------------------
void __fastcall TSpyForm::FormKeyPress(TObject *Sender, char &Key)
{
if(KeyboardActive->Checked && inbuf!=NULL && *inbuf!=NULL)
RingBufWrite(*inbuf,&Key,1);
}
//---------------------------------------------------------------------------
void __fastcall TSpyForm::KeyboardActiveClick(TObject *Sender)
{
KeyboardActive->Checked=!KeyboardActive->Checked;
}
//---------------------------------------------------------------------------
void __fastcall TSpyForm::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if(Button==mbRight)
PopupMenu->Popup(ClientOrigin.x+X,ClientOrigin.y+Y);
}
//---------------------------------------------------------------------------
......@@ -41,6 +41,8 @@ object SpyForm: TSpyForm
OldCreateOrder = False
Position = poDefaultPosOnly
OnClose = FormClose
OnKeyPress = FormKeyPress
OnMouseUp = FormMouseUp
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
......@@ -197,9 +199,36 @@ object SpyForm: TSpyForm
object SpyMenu: TMainMenu
Left = 288
Top = 24
object FontMenuItem: TMenuItem
Caption = 'Font'
OnClick = FontMenuItemClick
object SettingsMenuItem: TMenuItem
Caption = 'Settings'
object KeyboardActiveMenuItem: TMenuItem
Action = KeyboardActive
end
object FontMenuItem: TMenuItem
Action = ChangeFont
end
end
end
object PopupMenu: TPopupMenu
Left = 80
Top = 104
object KeyboardActivePopupMenuItem: TMenuItem
Action = KeyboardActive
end
object FontPopupMenuItem: TMenuItem
Action = ChangeFont
end
end
object ActionList: TActionList
Left = 328
Top = 24
object KeyboardActive: TAction
Caption = 'Keyboard Active'
OnExecute = KeyboardActiveClick
end
object ChangeFont: TAction
Caption = 'Font...'
OnExecute = ChangeFontClick
end
end
end
......@@ -15,6 +15,7 @@
#include <ImgList.hpp>
#include <ToolWin.hpp>
#include <Menus.hpp>
#include <ActnList.hpp>
//---------------------------------------------------------------------------
class TSpyForm : public TForm
{
......@@ -22,15 +23,28 @@ __published: // IDE-managed Components
TTimer *Timer;
TImageList *ImageList;
TMainMenu *SpyMenu;
TMenuItem *SettingsMenuItem;
TMenuItem *KeyboardActiveMenuItem;
TMenuItem *FontMenuItem;
TPopupMenu *PopupMenu;
TMenuItem *KeyboardActivePopupMenuItem;
TActionList *ActionList;
TAction *KeyboardActive;
TAction *ChangeFont;
TMenuItem *FontPopupMenuItem;
void __fastcall SpyTimerTick(TObject *Sender);
void __fastcall FormShow(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall FontMenuItemClick(TObject *Sender);
void __fastcall ChangeFontClick(TObject *Sender);
void __fastcall FormKeyPress(TObject *Sender, char &Key);
void __fastcall KeyboardActiveClick(TObject *Sender);
void __fastcall FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
private: // User declarations
public: // User declarations
TEmulVT *Terminal;
RingBuf** spybuf;
TEmulVT* Terminal;
RingBuf** inbuf;
RingBuf** outbuf;
__fastcall TSpyForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment