Commit 59eebabd authored by Stas Korobeynikov's avatar Stas Korobeynikov

add special assync process

parent b22eb710
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "asyncprocess.h"
#endif
#include "wx/wxprec.h"
#include "stdio.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "asyncprocess.h"
IMPLEMENT_DYNAMIC_CLASS(AsyncProcess, wxProcess)
AsyncProcess::AsyncProcess() : wxProcess(), wxThreadHelper() {
Redirect();
}
void AsyncProcess::start() {
int pid;
const char* cmd = "nxssh -nx -x -2 -p 2222 -o 'RhostsAuthentication no' -o 'PasswordAuthentication no' -o 'RSAAuthentication no' -o 'RhostsRSAAuthentication no' -o 'PubkeyAuthentication yes' -i /usr/lib64/opennx/share/keys/server.id_dsa.key -B -E nx@192.168.4.58";
pid = wxExecute(cmd, wxEXEC_ASYNC, this);
printf("pid: %d\n",pid);
}
wxThread::ExitCode AsyncProcess::Entry() {
while (!m_thread->TestDestroy()) {
while (IsInputAvailable()) {
char c = GetInputStream()->GetC();
printf("%c", c);
}
}
}
AsyncProcess::~AsyncProcess() {
}
void AsyncProcess::OnTerminate(int pid, int status) {
}
#ifndef _ASYNCPROCESS_H_
#define _ASYNCPROCESS_H_
#include <wx/event.h>
#include <wx/process.h>
#include <wx/thread.h>
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "AsyncProcess.cpp"
#endif
class AsyncProcess : public wxProcess, public wxThreadHelper {
DECLARE_DYNAMIC_CLASS(AsyncProcess)
public:
AsyncProcess();
void start();
virtual ~AsyncProcess();
virtual wxThread::ExitCode Entry();
virtual void OnTerminate(int pid, int status);
};
#endif
\ No newline at end of file
......@@ -5,16 +5,25 @@
#endif
#include "opennxtestevent.h"
#include "asyncprocess.h"
IMPLEMENT_APP(OpennxTestEvent)
BEGIN_EVENT_TABLE(OpennxTestEvent, wxEvtHandler)
END_EVENT_TABLE();
// This is executed upon startup, like 'main()' in non-wxWidgets programs.
bool OpennxTestEvent::OnInit()
{
AsyncProcess* ap = new AsyncProcess();
wxFrame *frame = new wxFrame((wxFrame*) NULL, -1, _T("Test opennx event"));
frame->CreateStatusBar();
frame->SetStatusText(_T("Test opennx event"));
frame->Show(true);
SetTopWindow(frame);
ap->start();
return true;
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
class OpennxTestEvent : public wxApp
{
DECLARE_EVENT_TABLE();
public:
virtual bool OnInit();
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment