808 lines
24 KiB
Plaintext
808 lines
24 KiB
Plaintext
// if(getDocumentClass(String(STRING_PROCESSVIEWCLASSNAME),mdiWindow))
|
|
// {
|
|
// mdiWindow->top();
|
|
// return;
|
|
// }
|
|
|
|
|
|
|
|
// if(strText.isNull())strText="None";
|
|
// strCaption=strCaption.betweenString(0,'-');
|
|
// strCaption.trimRight();
|
|
// FrameWindow::setCaption(strCaption+String(" - [")+strText+String("]"));
|
|
|
|
|
|
// FolderTree(GUIWindow &parentWindow,const Rect &winRect=Rect(1,1,320,200),int controlID=101,RGBColor bkColor=RGBColor(::GetSysColor(COLOR_WINDOW)));
|
|
|
|
|
|
//inline
|
|
//LPARAM SectionDialog::makeItemID(NodeType nodeType,WORD itemID)const
|
|
//{
|
|
// return MAKELPARAM(itemID,nodeType);
|
|
//}
|
|
// enum {RootID=0};
|
|
// enum{EditOffsetTop=170,EditOffsetBottom=45};
|
|
// enum{FolderOffsetTop=5,FolderOffsetBottom=155};/
|
|
// enum {CodeMenuSave=101,CodeMenuDisplayHex=102,CodeMenuSearchInstruction=103,
|
|
// CodeMenuNextFrame=104,DataMenuSave=105,DataMenuDisplayCode=106,
|
|
// DataMenuSearchString=107};
|
|
// enum NodeType{NullNode=0x0000,ImportTerminalNode=0x0001,ExportTerminalNode=0x0002,
|
|
// CodeTerminalNode=0x0003,DataTerminalNode=0x0004,
|
|
// ResourceTerminalNode=0x0005};
|
|
|
|
|
|
|
|
|
|
void ProcessView::serverConnect(const String &strServerName)
|
|
{
|
|
ComObj comObj;
|
|
ComResult comResult;
|
|
ServerInfo serverInfo(strServerName);
|
|
BString string;
|
|
MultiQuery multiQuery;
|
|
Variant variant;
|
|
|
|
multiQuery.size(1);
|
|
multiQuery[0].pIID=&IID_IRemoteProcess;
|
|
mStatusBar->setText(String("Connecting to '")+strServerName+String("'"));
|
|
comResult=comObj.createInstance(CLSID_CoRemoteProcess,0,ClassContext(LocalServer|RemoteServer),serverInfo,multiQuery);
|
|
if(!comResult.success())
|
|
{
|
|
ComResult::Facility facility=comResult.facility();
|
|
WORD comError(comResult.error());
|
|
mStatusBar->setText(String("Connection to '")+strServerName+String("' failed."));
|
|
return;
|
|
}
|
|
mStatusBar->setText(String("Connected to '")+strServerName+String("'"));
|
|
if(!ComResult(multiQuery[0].hr).success())
|
|
{
|
|
mStatusBar->setText("Failed to acquire interface.");
|
|
return;
|
|
}
|
|
mStatusBar->setText("Interface acquired, retrieving process list.");
|
|
IRemoteProcess *pIRemoteProcess=(IRemoteProcess*)multiQuery[0].pItf;
|
|
getListItems(pIRemoteProcess);
|
|
mStatusBar->setText("Process list retrieved, updating display...");
|
|
showListItems();
|
|
pIRemoteProcess->Release();
|
|
mStatusBar->setText("Ready.");
|
|
}
|
|
|
|
void ProcessView::getListItems(IRemoteProcess *pIRemoteProcess)
|
|
{
|
|
Variant variant;
|
|
Variant varProcessID;
|
|
String ansiString;
|
|
String strParent;
|
|
DWORD processID;
|
|
|
|
if(!pIRemoteProcess)return;
|
|
setCaption(mServerName);
|
|
mProcessList.remove();
|
|
mProcessList.computerName(mServerName);
|
|
try{pIRemoteProcess->Snapshot(&variant.getVARIANT());}
|
|
catch(...)
|
|
{
|
|
mStatusBar->setText("Fatal error communicating with server.");
|
|
::MessageBeep(0);
|
|
return;
|
|
}
|
|
int processCount(0);
|
|
variant.getData(VTInt4,(void*)&processCount);
|
|
variant.clear();
|
|
if(!processCount)
|
|
{
|
|
mStatusBar->setText("Error retrieving remote process list.");
|
|
::MessageBeep(0);
|
|
return;
|
|
}
|
|
pIRemoteProcess->GetProcessFirst(&variant.getVARIANT());
|
|
variant.getData(VTInt4,&processID);
|
|
varProcessID.setData(processID);
|
|
|
|
|
|
// DATE kernelTime;
|
|
// SystemTime sysKernelTime;
|
|
// pIRemoteProcess->GetProcessKernelTime(&variant.getVARIANT(),&kernelTime);
|
|
// VariantTime variantTime(kernelTime);
|
|
// variantTime.getTime(sysKernelTime);
|
|
|
|
|
|
|
|
variant.clear();
|
|
for(int index=0;index<processCount;index++)
|
|
{
|
|
pIRemoteProcess->GetModuleFirst(&variant.getVARIANT());
|
|
if(VTInt4==variant.getType())variant.clear();
|
|
else
|
|
{
|
|
BString string;
|
|
variant.getData(string);
|
|
ansiString=string.toString();
|
|
ansiString.upper();
|
|
strParent=ansiString;
|
|
mProcessList.insert(&ProcessItem());
|
|
ProcessItem &processItem=mProcessList[mProcessList.size()-1];
|
|
processItem.processName(ansiString);
|
|
processItem.processID(processID);
|
|
variant.clear();
|
|
|
|
DATE kernelTime;
|
|
SystemTime sysKernelTime;
|
|
pIRemoteProcess->GetProcessKernelTime(&varProcessID.getVARIANT(),&kernelTime);
|
|
VariantTime variantTime(kernelTime);
|
|
variantTime.getTime(sysKernelTime);
|
|
::OutputDebugString(ansiString+String(" ")+sysKernelTime.toString()+String("\n"));
|
|
|
|
while(true)
|
|
{
|
|
pIRemoteProcess->GetModuleNext(&variant.getVARIANT());
|
|
if(VTInt4==variant.getType())
|
|
{
|
|
variant.clear();
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
BString string;
|
|
variant.getData(string);
|
|
ansiString=string.toString();
|
|
ansiString.upper();
|
|
processItem.insert(&ansiString);
|
|
variant.clear();
|
|
}
|
|
}
|
|
}
|
|
pIRemoteProcess->GetProcessNext(&variant.getVARIANT());
|
|
variant.getData(VTInt4,&processID);
|
|
varProcessID.setData(processID);
|
|
variant.clear();
|
|
|
|
// {
|
|
// DATE kernelTime;
|
|
// SystemTime sysKernelTime;
|
|
// pIRemoteProcess->GetProcessKernelTime(&variant.getVARIANT(),&kernelTime);
|
|
// VariantTime variantTime(kernelTime);
|
|
// variantTime.getTime(sysKernelTime);
|
|
// ::OutputDebugString(ansiString+String(" ")+sysKernelTime.toString()+String("\n"));
|
|
//
|
|
//}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
VariantTime creationTime;
|
|
VariantTime exitTime;
|
|
VariantTime kernelTime;
|
|
VariantTime userTime;
|
|
SystemTime sysCreationTime;
|
|
SystemTime sysExitTime;
|
|
SystemTime sysKernelTime;
|
|
SystemTime sysUserTime;
|
|
processVariant.changeType(VTInt4);
|
|
processVariant.setData(processID);
|
|
pIRemoteProcess->GetProcessTimes(&processVariant.getVARIANT(),&creationTime.getDATE(),&exitTime.getDATE(),&kernelTime.getDATE(),&userTime.getDATE());
|
|
processVariant.clear();
|
|
creationTime.getTime(sysCreationTime);
|
|
exitTime.getTime(sysExitTime);
|
|
kernelTime.getTime(sysKernelTime);
|
|
userTime.getTime(sysUserTime);
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#include <common/windows.hpp>
|
|
#include <com/bstring.hpp>
|
|
#include <com/variant.hpp>
|
|
#include <com/sarray.hpp>
|
|
#include <com/com.hpp>
|
|
#include <remoteps/remoteps_i.c>
|
|
#include <remoteps/remoteps.h>
|
|
|
|
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
|
{
|
|
ComObj comObj;
|
|
ComResult comResult;
|
|
ServerInfo serverInfo(String("rocinante"));
|
|
BString string;
|
|
MultiQuery multiQuery;
|
|
Variant variant;
|
|
|
|
multiQuery.size(1);
|
|
multiQuery[0].pIID=&IID_IRemoteProcess;
|
|
comResult=comObj.createInstance(CLSID_CoRemoteProcess,0,ClassContext(LocalServer|RemoteServer),serverInfo,multiQuery);
|
|
if(!comResult.success())
|
|
{
|
|
ComResult::Facility facility=comResult.facility();
|
|
WORD comError(comResult.error());
|
|
return 0;
|
|
}
|
|
if(!ComResult(multiQuery[0].hr).success())return 0;
|
|
IRemoteProcess *pIRemoteProcess=(IRemoteProcess*)multiQuery[0].pItf;
|
|
|
|
// pIRemoteProcess->GetRemoteProcesses(&variant.getVARIANT());
|
|
pIRemoteProcess->Snapshot(&variant.getVARIANT());
|
|
int processCount(0);
|
|
variant.getData(VTInt4,(void*)&processCount);
|
|
variant.clear();
|
|
pIRemoteProcess->GetProcessFirst(&variant.getVARIANT());
|
|
variant.clear();
|
|
for(int index=0;index<processCount;index++)
|
|
{
|
|
pIRemoteProcess->GetModuleFirst(&variant.getVARIANT());
|
|
if(VTInt4==variant.getType())variant.clear();
|
|
else
|
|
{
|
|
BString string;
|
|
variant.getData(string);
|
|
::OutputDebugString(string.toString()+String("\n"));
|
|
variant.clear();
|
|
while(true)
|
|
{
|
|
pIRemoteProcess->GetModuleNext(&variant.getVARIANT());
|
|
if(VTInt4==variant.getType())
|
|
{
|
|
variant.clear();
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
BString string;
|
|
variant.getData(string);
|
|
::OutputDebugString(string.toString()+String("\n"));
|
|
variant.clear();
|
|
}
|
|
}
|
|
}
|
|
pIRemoteProcess->GetProcessNext(&variant.getVARIANT());
|
|
variant.clear();
|
|
}
|
|
|
|
pIRemoteProcess->Release();
|
|
|
|
|
|
// pIRemoteProcess->GetRemoteProcesses(&variant.getVARIANT());
|
|
// variant.getData(string);
|
|
// ::OutputDebugString(string.toString()+String("\n"));
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
bool PureImage::decode(const String &strPathFileName,PureDevice &pureDevice)
|
|
{
|
|
JSAMPARRAY buffer;
|
|
int row_stride;
|
|
int row_elements;
|
|
int row(0);
|
|
jpeg_decompress_struct cinfo;
|
|
FILE *fp;
|
|
|
|
destroy();
|
|
if((fp=::fopen((char*)(String&)strPathFileName,"rb"))==NULL)return FALSE;
|
|
::jpeg_create_decompress(&cinfo);
|
|
::jpeg_stdio_src(&cinfo,fp);
|
|
try{::jpeg_read_header(&cinfo,TRUE);}
|
|
catch(JPGError){return FALSE;}
|
|
try{::jpeg_start_decompress(&cinfo);}
|
|
catch(JPGError){return FALSE;}
|
|
row_stride=cinfo.output_width*cinfo.output_components;
|
|
buffer=(*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo,JPOOL_IMAGE,row_stride,cinfo.output_height);
|
|
while(cinfo.output_scanline<cinfo.output_height)::jpeg_read_scanlines(&cinfo,&buffer[row++],1);
|
|
getBitmapInfo().rgbColors(0);
|
|
getBitmapInfo().bitCount(BitmapInfo::Bit24);
|
|
getBitmapInfo().width(cinfo.output_width);
|
|
getBitmapInfo().height(-cinfo.output_height);
|
|
getBitmapInfo().planes(1);
|
|
getBitmapInfo().compression(BI_RGB);
|
|
getBitmapInfo().sizeImage(0);
|
|
getBitmapInfo().colorUsed(0);
|
|
getBitmapInfo().colorImportant(0);
|
|
getBitmapInfo().verifyDimensions();
|
|
getRGBArray().size(getBitmapInfo().width()*(-getBitmapInfo().height()));
|
|
row_elements=row_stride/cinfo.output_components;
|
|
for(int scanline=0;scanline<cinfo.output_height;scanline++)
|
|
{
|
|
copyBGRRGB(&getRGBArray()[scanline*getBitmapInfo().width()],(char*)buffer[scanline],row_elements,cinfo.output_components);
|
|
}
|
|
mhBitmap=::CreateDIBitmap((HDC)pureDevice,(BITMAPINFOHEADER*)getBitmapInfo(),CBM_INIT,&getRGBArray()[0],(BITMAPINFO*)getBitmapInfo(),DIB_RGB_COLORS);
|
|
try{::jpeg_finish_decompress(&cinfo);}
|
|
catch(JPGError){;}
|
|
::jpeg_destroy_decompress(&cinfo);
|
|
::fclose(fp);
|
|
return TRUE;
|
|
}
|
|
|
|
bool JPGImage::decode(const String &strPathFileName)
|
|
{
|
|
JSAMPARRAY buffer;
|
|
int row_stride;
|
|
int row_elements;
|
|
int row(0);
|
|
jpeg_decompress_struct cinfo;
|
|
FILE *fp;
|
|
|
|
destroy();
|
|
if((fp=::fopen((char*)(String&)strPathFileName,"rb"))==NULL)return FALSE;
|
|
::jpeg_create_decompress(&cinfo);
|
|
::jpeg_stdio_src(&cinfo,fp);
|
|
try{::jpeg_read_header(&cinfo,TRUE);}
|
|
catch(JPGError){return FALSE;}
|
|
try{::jpeg_start_decompress(&cinfo);}
|
|
catch(JPGError){return FALSE;}
|
|
row_stride=cinfo.output_width*cinfo.output_components;
|
|
buffer=(*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo,JPOOL_IMAGE,row_stride,cinfo.output_height);
|
|
while(cinfo.output_scanline<cinfo.output_height)::jpeg_read_scanlines(&cinfo,&buffer[row++],1);
|
|
getBitmapInfo().rgbColors(0);
|
|
getBitmapInfo().bitCount(BitmapInfo::Bit24);
|
|
getBitmapInfo().width(cinfo.output_width);
|
|
getBitmapInfo().height(-cinfo.output_height);
|
|
getBitmapInfo().planes(1);
|
|
getBitmapInfo().compression(BI_RGB);
|
|
getBitmapInfo().sizeImage(0);
|
|
getBitmapInfo().colorUsed(0);
|
|
getBitmapInfo().colorImportant(0);
|
|
getBitmapInfo().verifyDimensions();
|
|
getRGBArray().size(getBitmapInfo().width()*(-getBitmapInfo().height()));
|
|
row_elements=row_stride/cinfo.output_components;
|
|
for(int scanline=0;scanline<cinfo.output_height;scanline++)
|
|
{
|
|
copyBGRRGB(&getRGBArray()[scanline*getBitmapInfo().width()],(char*)buffer[scanline],row_elements,cinfo.output_components);
|
|
}
|
|
try{::jpeg_finish_decompress(&cinfo);}
|
|
catch(JPGError){;}
|
|
::jpeg_destroy_decompress(&cinfo);
|
|
::fclose(fp);
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
CallbackData::ReturnType ImageView::paintHandler(CallbackData &someCallbackData)
|
|
{
|
|
CursorControl cursorControl;
|
|
|
|
cursorControl.waitCursor(TRUE);
|
|
mMutex.requestMutex();
|
|
if(!mJPGImage.isOkay())
|
|
{
|
|
mMutex.releaseMutex();
|
|
cursorControl.waitCursor(FALSE);
|
|
return (CallbackData::ReturnType)FALSE;
|
|
}
|
|
PaintInformation &paintInfo=*((PaintInformation*)someCallbackData.lParam());
|
|
PureDevice &paintDevice=(PureDevice&)paintInfo;
|
|
if(mScrollInfo.sizeEvent())
|
|
{
|
|
mScrollInfo.sizeEvent(FALSE);
|
|
mJPGImage.draw(paintDevice,Rect(0,0,mJPGImage.width(),mJPGImage.height()),Point(mScrollInfo.currScrollx(),mScrollInfo.currScrolly()));
|
|
}
|
|
if(mScrollInfo.scrollEvent()||(!mScrollInfo.sizeEvent()&&!mScrollInfo.scrollEvent()))
|
|
{
|
|
Rect paintRect(paintInfo.paintRect());
|
|
mScrollInfo.scrollEvent(FALSE);
|
|
paintRect.right(paintRect.right()-paintRect.left());
|
|
paintRect.bottom(paintRect.bottom()-paintRect.top());
|
|
mJPGImage.draw(paintDevice,paintRect,Point(paintRect.left()+mScrollInfo.currScrollx(),paintRect.top()+mScrollInfo.currScrolly()));
|
|
}
|
|
mMutex.releaseMutex();
|
|
cursorControl.waitCursor(FALSE);
|
|
return (CallbackData::ReturnType)FALSE;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
bool RemoteProcessInfo::getDesktopWindow(IRemoteProcess *pIRemoteProcess,int &width,int &height,GlobalData<BYTE> &imageBytes)
|
|
{
|
|
Variant variant;
|
|
SafeArray safeArray;
|
|
int upperBound;
|
|
BYTE *pData;
|
|
|
|
pIRemoteProcess->GetDesktopWindow(&variant.getVARIANT());
|
|
if(VTArray!=variant.getType()){variant.clear();return false;}
|
|
if(!variant.getData(safeArray)){variant.clear();return false;}
|
|
upperBound=safeArray.getUpperBound();
|
|
safeArray.accessData((void**)&pData);
|
|
width=*((int*)pData);
|
|
height=(*(((int*)pData)+1));
|
|
imageBytes.size(*(((int*)pData)+4));
|
|
::memcpy(&imageBytes[0],pData+(sizeof(DWORD)*5),imageBytes.size());
|
|
safeArray.unaccessData();
|
|
safeArray.destroy();
|
|
variant.clear();
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
#include <remotepsapp/group.hpp>
|
|
#include <remotepsapp/optnsreg.hpp>
|
|
Group group;
|
|
OptionsReg optionsReg;
|
|
Block<String> strGroupNames;
|
|
|
|
group.groupName("J&R");
|
|
optionsReg.getGroup(group);
|
|
optionsReg.getGroupNames(strGroupNames);
|
|
|
|
group.groupName("GGG");
|
|
group.insert(&String("192.168.1.1"));
|
|
group.insert(&String("192.168.1.2"));
|
|
optionsReg.setGroup(group);
|
|
optionsReg.getGroup(group);
|
|
|
|
|
|
|
|
|
|
#include <remotepsapp/viewdialog.hpp>
|
|
#include <remotepsapp/remoteps.hpp>
|
|
#include <remotepsapp/windowview.hpp>
|
|
#include <common/stdio.hpp>
|
|
#include <common/mdifrm.hpp>
|
|
#include <com/cominit.hpp>
|
|
#include <statbar/statbarx.hpp>
|
|
#include <imagelst/ftree.hpp>
|
|
//#include <widget/tabhandler.hpp>
|
|
//#include <widget/tabitem.hpp>
|
|
|
|
ViewDialog::ViewDialog(void)
|
|
: mIsInConnect(false)
|
|
{
|
|
mInitHandler.setCallback(this,&ViewDialog::initHandler);
|
|
mDestroyHandler.setCallback(this,&ViewDialog::destroyHandler);
|
|
mCommandHandler.setCallback(this,&ViewDialog::commandHandler);
|
|
mCloseHandler.setCallback(this,&ViewDialog::closeHandler);
|
|
// mSelChangedHandler.setCallback(this,&ViewDialog::tvSelChangedHandler);
|
|
// mItemExpandedHandler.setCallback(this,&ViewDialog::tvItemExpandedHandler);
|
|
// mTabSelChangeHandler.setCallback(this,&ViewDialog::tabSelChangeHandler);
|
|
mThreadHandler.setCallback(this,&ViewDialog::threadHandler);
|
|
DWindow::insertHandler(VectorHandler::InitDialogHandler,&mInitHandler);
|
|
DWindow::insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
|
|
DWindow::insertHandler(VectorHandler::CommandHandler,&mCommandHandler);
|
|
DWindow::insertHandler(VectorHandler::CloseHandler,&mCloseHandler);
|
|
MessageThread::insertHandler(&mThreadHandler);
|
|
}
|
|
|
|
ViewDialog::ViewDialog(const ViewDialog &/*someViewDialog*/)
|
|
{ // private implementation
|
|
}
|
|
|
|
ViewDialog::~ViewDialog()
|
|
{
|
|
if(mIsInConnect){mIsInConnect=false;fatalThreadExit();}
|
|
DWindow::removeHandler(VectorHandler::InitDialogHandler,&mInitHandler);
|
|
DWindow::removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
|
|
DWindow::removeHandler(VectorHandler::CommandHandler,&mCommandHandler);
|
|
DWindow::removeHandler(VectorHandler::CloseHandler,&mCloseHandler);
|
|
MessageThread::removeHandler(&mThreadHandler);
|
|
}
|
|
|
|
ViewDialog &ViewDialog::operator=(const ViewDialog &/*someViewDialog*/)
|
|
{ // private implementation
|
|
return *this;
|
|
}
|
|
|
|
void ViewDialog::handleConnect(const String &serverName)
|
|
{
|
|
String *pComputerName=::new String(serverName);
|
|
ThreadMessage connectMessage(ThreadMessage::TM_USER,MsgConnect,(LONG)pComputerName);
|
|
mIsInConnect=true;
|
|
MessageThread::postMessage(connectMessage);
|
|
}
|
|
|
|
bool ViewDialog::perform(MDIWindow &parentWindow,SmartPointer<StatusBarEx> &statusBar)
|
|
{
|
|
mStatusBar=statusBar;
|
|
createDialogParam(*(parentWindow.getFrame()),parentWindow,String("VIEWDIALOG"),(LPARAM)(DWindow*)this);
|
|
return isValid();
|
|
}
|
|
|
|
CallbackData::ReturnType ViewDialog::initHandler(CallbackData &someCallbackData)
|
|
{
|
|
#if 0
|
|
mTabControl=::new TabControlHandler(*this,Rect(InitTreeLeft,InitTreeTop,width(),height()-(InitTreeTop-45)),TabControlID);
|
|
mTabControl.disposition(PointerDisposition::Delete);
|
|
mTabControl->insertHandler(TabControlHandler::SelChangeHandler,&mTabSelChangeHandler);
|
|
mTabControl->insertItem(TabControl::TabIndex(0),TabItem(TabItem::TabText,0,0,String("Process List"),0,0,0L));
|
|
mTabControl->insertItem(TabControl::TabIndex(1),TabItem(TabItem::TabText,0,0,String("Desktop Window"),0,0,0L));
|
|
|
|
// mFolderTree=::new FolderTree(*this,Rect(10,30,mTabControl->width()-20,mTabControl->height()-45),TreeViewControlID);
|
|
mFolderTree=::new FolderTree(*mTabControl,Rect(10,30,mTabControl->width()-20,mTabControl->height()-45),TreeViewControlID);
|
|
mFolderTree.disposition(PointerDisposition::Delete);
|
|
mFolderTree->insertHandler(FolderTree::SelChangedHandler,&mSelChangedHandler);
|
|
mFolderTree->insertHandler(FolderTree::ItemExpandedHandler,&mItemExpandedHandler);
|
|
#endif
|
|
|
|
// mWindowView=::new WindowView(*mTabControl,Rect(10,30,mTabControl->width()-20,mTabControl->height()-45),WindowViewControlID);
|
|
mWindowView=::new WindowView(*this,Rect(10,30,width()-20,height()-45),WindowViewControlID);
|
|
mWindowView.disposition(PointerDisposition::Delete);
|
|
if(!mWindowView->isValid())return false;
|
|
mWindowView->show(SW_SHOW);
|
|
return FALSE;
|
|
}
|
|
|
|
CallbackData::ReturnType ViewDialog::commandHandler(CallbackData &someCallbackData)
|
|
{
|
|
switch(someCallbackData.wmCommandID())
|
|
{
|
|
case IDOK :
|
|
if(mIsInConnect)break;
|
|
GUIWindow::postMessage(parent(),WM_CLOSE,0,0L);
|
|
endDialog(true);
|
|
break;
|
|
case IDCANCEL :
|
|
if(mIsInConnect)break;
|
|
GUIWindow::postMessage(parent(),WM_CLOSE,0,0L);
|
|
endDialog(false);
|
|
break;
|
|
case VIEWDIALOG_REFRESHNOW :
|
|
handleRefreshNow();
|
|
break;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
CallbackData::ReturnType ViewDialog::closeHandler(CallbackData &someCallbackData)
|
|
{
|
|
if(mIsInConnect)return TRUE;
|
|
return FALSE;
|
|
}
|
|
|
|
CallbackData::ReturnType ViewDialog::destroyHandler(CallbackData &someCallbackData)
|
|
{
|
|
// if(mFolderTree.isOkay())mFolderTree.destroy();
|
|
// if(mTabControl.isOkay())mTabControl.destroy();
|
|
return FALSE;
|
|
}
|
|
|
|
#if 0
|
|
CallbackData::ReturnType ViewDialog::tabSelChangeHandler(CallbackData &someCallbackData)
|
|
{
|
|
TabControl::TabIndex currentSelection(mTabControl->getCurrentSelection());
|
|
if(TabControlTreeViewIndex==int(currentSelection))
|
|
{
|
|
mWindowView->show(SW_HIDE);
|
|
mWindowView->update();
|
|
mFolderTree->show(SW_SHOW);
|
|
mFolderTree->update();
|
|
}
|
|
else if(TabControlDesktopWindowIndex==int(currentSelection))
|
|
{
|
|
mFolderTree->show(SW_HIDE);
|
|
mFolderTree->update();
|
|
mWindowView->show(SW_SHOW);
|
|
mWindowView->update();
|
|
}
|
|
return FALSE;
|
|
}
|
|
#endif
|
|
|
|
#if 0
|
|
CallbackData::ReturnType ViewDialog::tvSelChangedHandler(CallbackData &someCallbackData)
|
|
{
|
|
String strString;
|
|
WORD selector(someCallbackData.loWord());
|
|
WORD index(someCallbackData.hiWord());
|
|
|
|
if(65535==selector&&65535==index)return FALSE;
|
|
if(65535==selector)
|
|
{
|
|
::sprintf(strString,"selected process:%d\n",index);
|
|
}
|
|
else
|
|
{
|
|
::sprintf(strString,"index(%d,%d)\n",selector,index);
|
|
}
|
|
::OutputDebugString(strString);
|
|
return FALSE;
|
|
}
|
|
|
|
CallbackData::ReturnType ViewDialog::tvItemExpandedHandler(CallbackData &someCallbackData)
|
|
{
|
|
String strString;
|
|
::sprintf(strString,"ViewDialog::tvItemExpandedHandler(%d,%d)\n",someCallbackData.hiWord(),someCallbackData.loWord());
|
|
::OutputDebugString(strString);
|
|
return FALSE;
|
|
}
|
|
#endif
|
|
|
|
void ViewDialog::handleRefreshNow(void)
|
|
{
|
|
handleConnect(mStrServerName);
|
|
}
|
|
|
|
DWORD ViewDialog::threadHandler(ThreadMessage &threadMessage)
|
|
{
|
|
switch(threadMessage.message())
|
|
{
|
|
case ThreadMessage::TM_CREATE :
|
|
break;
|
|
case ThreadMessage::TM_DESTROY :
|
|
break;
|
|
case ThreadMessage::TM_USER :
|
|
if(MsgConnect==threadMessage.userDataOne())
|
|
{
|
|
HANDLE hCurrentThread(::GetCurrentThread());
|
|
DWORD currPriority(::GetThreadPriority(hCurrentThread));
|
|
::SetThreadPriority(hCurrentThread,THREAD_PRIORITY_HIGHEST);
|
|
thConnect(*((String*)threadMessage.userDataTwo()));
|
|
::SetThreadPriority(hCurrentThread,currPriority);
|
|
mIsInConnect=false;
|
|
::delete (String*)threadMessage.userDataTwo();
|
|
}
|
|
break;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void ViewDialog::thConnect(const String &serverName)
|
|
{
|
|
GlobalData<BYTE> imageBytes;
|
|
int width;
|
|
int height;
|
|
|
|
::OutputDebugString("ViewDialog::thConnect\n");
|
|
if(!mConnectionMutex.requestMutex(0))
|
|
{
|
|
mStatusBar->setText("Connection is already in progress.");
|
|
return;
|
|
}
|
|
ComInitializer comInitializer;
|
|
mStrServerName=serverName;
|
|
mStatusBar->setText(String("Connecting to ")+serverName+String("..."));
|
|
if(!mRemoteProcessInfo.connect(serverName))
|
|
{
|
|
mStatusBar->setText("Connection failed.");
|
|
mConnectionMutex.releaseMutex();
|
|
return;
|
|
}
|
|
// mStatusBar->setText("Retrieving list...");
|
|
// mRemoteProcessInfo.getListItems();
|
|
// mStatusBar->setText("Retrieving desktop image...");
|
|
mRemoteProcessInfo.getDesktopWindow(*mWindowView);
|
|
mRemoteProcessInfo.disconnect();
|
|
mStatusBar->setText("Updating desktop view...");
|
|
mWindowView->invalidate(false);
|
|
// mStatusBar->setText("Updating process list...");
|
|
// showListItems(mRemoteProcessInfo);
|
|
mConnectionMutex.releaseMutex();
|
|
mStatusBar->setText("Ready.");
|
|
return;
|
|
}
|
|
|
|
#if 0
|
|
void ViewDialog::showListItems(ProcessList &processList)
|
|
{
|
|
String strParent;
|
|
|
|
if(!processList.size())return;
|
|
mFolderTree->remove();
|
|
mFolderTree->addRootNode(FolderTree::FolderClosed,processList.computerName(),MAKELPARAM(-1,-1));
|
|
for(int pindex=0;pindex<processList.size();pindex++)
|
|
{
|
|
ProcessItem &processItem=processList[pindex];
|
|
String processName(processItem.processName());
|
|
TreeViewItem insertItem(0,0,0,0,(LPSTR)processName,processName.length(),FolderTree::FolderClosed,FolderTree::FolderOpen,0,MAKELPARAM(-1,pindex));
|
|
mFolderTree->addNode(TreeView::NodeChild,insertItem,processList.computerName());
|
|
strParent=processName;
|
|
for(int mindex=0;mindex<processItem.size();mindex++)
|
|
{
|
|
String &strModuleName=processItem[mindex];
|
|
if(!mindex)
|
|
{
|
|
TreeViewItem insertItem(0,0,0,0,(LPSTR)strModuleName,strModuleName.length(),FolderTree::FolderClosed,FolderTree::FolderOpen,0,MAKELPARAM(pindex,mindex));
|
|
mFolderTree->addNode(TreeView::NodeChild,insertItem,strParent,FALSE);
|
|
}
|
|
else mFolderTree->appendNode(TreeView::NodeSibling,FolderTree::FolderClosed,strModuleName,MAKELPARAM(pindex,mindex));
|
|
}
|
|
}
|
|
mFolderTree->selectRoot();
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _REMOTEPSAPP_VIEWDIALOG_HPP_
|
|
#define _REMOTEPSAPP_VIEWDIALOG_HPP_
|
|
#ifndef _COMMON_DWINDOW_HPP_
|
|
#include <common/dwindow.hpp>
|
|
#endif
|
|
#ifndef _COMMON_SMARTPOINTER_HPP_
|
|
#include <common/pointer.hpp>
|
|
#endif
|
|
#ifndef _COMMON_MDIWIN_HPP_
|
|
#include <common/mdiwin.hpp>
|
|
#endif
|
|
#ifndef _THREAD_MESSAGETHREAD_HPP_
|
|
#include <thread/mthread.hpp>
|
|
#endif
|
|
#ifndef _THREAD_MUTEX_HPP_
|
|
#include <thread/mutex.hpp>
|
|
#endif
|
|
//#ifndef _WIDGET_TABCONTROL_HPP
|
|
//#include <widget/tabctrl.hpp>
|
|
//#endif
|
|
#ifndef _REMOTEPSAPP_REMOTEPROCESSINFO_HPP_
|
|
#include <remotepsapp/remoteprocessinfo.hpp>
|
|
#endif
|
|
|
|
//class FolderTree;
|
|
class WindowView;
|
|
class StatusBarEx;
|
|
//class TabControlHandler;
|
|
|
|
class ViewDialog : public DWindow, public MessageThread
|
|
{
|
|
public:
|
|
ViewDialog(void);
|
|
virtual ~ViewDialog();
|
|
bool perform(MDIWindow &parentWindow,SmartPointer<StatusBarEx> &statusBar);
|
|
void handleConnect(const String &serverName);
|
|
private:
|
|
enum {MsgConnect};
|
|
enum{InitTreeLeft=5,InitTreeTop=125};
|
|
enum{TreeViewControlID=100,TabControlID=101,WindowViewControlID=102};
|
|
enum{TabControlTreeViewIndex=0,TabControlDesktopWindowIndex=1};
|
|
ViewDialog(const ViewDialog &someViewDialog);
|
|
ViewDialog &operator=(const ViewDialog &someViewDialog);
|
|
CallbackData::ReturnType initHandler(CallbackData &someCallbackData);
|
|
CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData);
|
|
CallbackData::ReturnType commandHandler(CallbackData &someCallbackData);
|
|
CallbackData::ReturnType closeHandler(CallbackData &someCallbackData);
|
|
// CallbackData::ReturnType tvSelChangedHandler(CallbackData &someCallbackData);
|
|
// CallbackData::ReturnType tvItemExpandedHandler(CallbackData &someCallbackData);
|
|
// CallbackData::ReturnType tabSelChangeHandler(CallbackData &someCallbackData);
|
|
DWORD threadHandler(ThreadMessage &threadMessage);
|
|
void thConnect(const String &strServerName);
|
|
void handleRefreshNow(void);
|
|
// void showListItems(ProcessList &processList);
|
|
|
|
Callback<ViewDialog> mInitHandler;
|
|
Callback<ViewDialog> mDestroyHandler;
|
|
Callback<ViewDialog> mCommandHandler;
|
|
Callback<ViewDialog> mCloseHandler;
|
|
// Callback<ViewDialog> mSelChangedHandler;
|
|
// Callback<ViewDialog> mItemExpandedHandler;
|
|
// Callback<ViewDialog> mTabSelChangeHandler;
|
|
ThreadCallback<ViewDialog> mThreadHandler;
|
|
// SmartPointer<FolderTree> mFolderTree;
|
|
SmartPointer<WindowView> mWindowView;
|
|
// SmartPointer<TabControlHandler> mTabControl;
|
|
SmartPointer<StatusBarEx> mStatusBar;
|
|
RemoteProcessInfo mRemoteProcessInfo;
|
|
String mStrServerName;
|
|
Mutex mConnectionMutex;
|
|
bool mIsInConnect;
|
|
};
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum{InitTreeLeft=5,InitTreeTop=125};
|
|
enum{TreeViewControlID=100,TabControlID=101,WindowViewControlID=102};
|
|
enum{TabControlTreeViewIndex=0,TabControlDesktopWindowIndex=1};
|