mirror of
https://github.com/uroni/urbackup_frontend_wx.git
synced 2025-10-26 11:19:28 +00:00
Add function to retrieve CBT status
This commit is contained in:
parent
b916fa8918
commit
107c8474ce
81
CbtStatus.cpp
Normal file
81
CbtStatus.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include "CbtStatus.h"
|
||||
#include <wx/process.h>
|
||||
|
||||
extern wxString res_path;
|
||||
extern wxString ico_ext;
|
||||
extern wxBitmapType ico_type;
|
||||
|
||||
CbtStatus::CbtStatus(wxWindow* parent)
|
||||
: GUICbtStatus(parent), wxProcess(wxPROCESS_REDIRECT), first_val(true)
|
||||
{
|
||||
SetIcon(wxIcon(res_path + wxT("backup-ok.") + ico_ext, ico_type));
|
||||
|
||||
long pid = wxExecute("urbctctl.exe status all", wxEXEC_ASYNC, this);
|
||||
if (pid != 0)
|
||||
{
|
||||
Redirect();
|
||||
CloseOutput();
|
||||
}
|
||||
|
||||
Start(100);
|
||||
|
||||
m_textCtrl3->SetValue("Retrieving CBT status...");
|
||||
|
||||
Show(true);
|
||||
}
|
||||
|
||||
CbtStatus::~CbtStatus()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
void CbtStatus::OnExitClick(wxCommandEvent & event)
|
||||
{
|
||||
Stop();
|
||||
Close();
|
||||
}
|
||||
|
||||
void CbtStatus::Notify(void)
|
||||
{
|
||||
if (first_val)
|
||||
{
|
||||
first_val = false;
|
||||
m_textCtrl3->SetValue("");
|
||||
}
|
||||
|
||||
addStream(GetInputStream());
|
||||
addStream(GetErrorStream());
|
||||
|
||||
if ((GetErrorStream() == NULL || GetErrorStream()->Eof())
|
||||
&& (GetInputStream()==NULL || GetInputStream()->Eof()) )
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CbtStatus::OnTerminate(int pid, int status)
|
||||
{
|
||||
Notify();
|
||||
Stop();
|
||||
}
|
||||
|
||||
void CbtStatus::addStream(wxInputStream * input_stream)
|
||||
{
|
||||
if (input_stream == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (input_stream->CanRead())
|
||||
{
|
||||
char buffer[1024];
|
||||
input_stream->Read(buffer, 1024);
|
||||
size_t read = input_stream->LastRead();
|
||||
|
||||
if (read > 0)
|
||||
{
|
||||
wxString read_str = wxString::FromUTF8(buffer, read);
|
||||
m_textCtrl3->AppendText(read_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
CbtStatus.h
Normal file
22
CbtStatus.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "gui/GUI.h"
|
||||
#include <wx/process.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
class CbtStatus : public GUICbtStatus, wxTimer, wxProcess
|
||||
{
|
||||
public:
|
||||
CbtStatus(wxWindow* parent);
|
||||
~CbtStatus();
|
||||
protected:
|
||||
virtual void OnExitClick(wxCommandEvent& event);
|
||||
|
||||
virtual void Notify(void);
|
||||
|
||||
virtual void OnTerminate(int pid, int status);
|
||||
|
||||
void addStream(wxInputStream* input_stream);
|
||||
|
||||
bool first_val;
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user