TimerPool fixoutManipulator

git-svn-id: svn://db.shs.com.ru/pip@80 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-04-09 08:26:58 +00:00
parent 54d6d16464
commit 42afbb11b7
6 changed files with 69 additions and 78 deletions

View File

@@ -1,6 +1,6 @@
project(pip)
cmake_minimum_required(VERSION 2.6)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
include(CheckFunctionExists)

View File

@@ -21,9 +21,8 @@ PIBaseTransfer::PIBaseTransfer(): crc(standardCRC_16()), diag(false) {
PIBaseTransfer::~PIBaseTransfer() {
diag.stop();
break_ = true;
session.clear();
replies.clear();
}

View File

@@ -52,6 +52,11 @@ public:
const llong * bytesCur_ptr() const {return &bytes_cur;}
const PIDiagnostics &diagnostic() {return diag;}
EVENT_HANDLER1(void, received, PIByteArray, data);
EVENT_HANDLER(void, stop) {stopSend(); stopReceive();}
EVENT_HANDLER(void, pause) {setPause(true);}
EVENT_HANDLER(void, resume) {setPause(false);}
EVENT(receiveStarted)
EVENT(paused)
EVENT(resumed)
@@ -59,9 +64,6 @@ public:
EVENT(sendStarted)
EVENT1(sendFinished, bool, ok)
EVENT1(sendRequest, PIByteArray &, data)
EVENT_HANDLER1(void, received, PIByteArray, data);
EVENT_HANDLER(void, pause) {setPause(true);}
EVENT_HANDLER(void, resume) {setPause(false);}
protected:
uint packet_header_size, part_header_size;

View File

@@ -19,8 +19,7 @@ PIFileTransfer::PIFileTransfer() {
PIFileTransfer::~PIFileTransfer() {
break_ = true;
files_.clear();
stop();
work_file.close();
}
@@ -85,7 +84,10 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
pftheader.step = pft_Description;
buildSession(PIVector<Part>() << Part(0, desc.size()));
cur_file_string = "";
if (!send_process()) return false;
if (!send_process()) {
sendFilesFinished(false);
return false;
}
pftheader.step = pft_Data;
PIVector<Part> pts;
for (int i=0; i<files_.size_s(); i++) {
@@ -93,6 +95,7 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
}
buildSession(pts);
bool ok = send_process();
sendFilesFinished(ok);
return ok;
}
@@ -290,7 +293,4 @@ void PIFileTransfer::receive_finished(bool ok) {
void PIFileTransfer::send_finished(bool ok) {
work_file.close();
started_ = false;
sendFilesFinished(ok);
}

View File

@@ -42,8 +42,8 @@ Daemon::TileFileProgress::TileFileProgress(): PIScreenTile() {
label_speed = new TileSimple("");
prog_file = new TileProgress();
prog_all = new TileProgress();
buttons = new TileButtons();
buttons->content << TileButtons::Button("Ok", CellFormat());
buttons = new TileButtons("fd_buttons");
buttons->content << TileButtons::Button("Pause", CellFormat());
buttons->content << TileButtons::Button("Cancel", CellFormat());
buttons->back_format.color_back = label_file->back_format.color_back = label_speed->back_format.color_back = Yellow;
label_file->back_format.color_char = label_speed->back_format.color_char = Black;
@@ -55,6 +55,7 @@ Daemon::TileFileProgress::TileFileProgress(): PIScreenTile() {
addTile(prog_file);
addTile(prog_all);
addTile(buttons);
CONNECTU(&(::screen), tileEvent, this, tileEvent)
}
@@ -72,6 +73,7 @@ void Daemon::TileFileProgress::sizeHint(int & w, int & h) const {
void Daemon::TileFileProgress::drawEvent(PIScreenDrawer * d) {
if (ft) {
label_file->content[0].first = ft->stateString() + ft->curFile();
PIString spd;
@@ -87,6 +89,41 @@ void Daemon::TileFileProgress::drawEvent(PIScreenDrawer * d) {
}
void Daemon::TileFileProgress::show(PIFileTransfer * f) {
ft = f;
if (ft) {
conn_name = ft->name();
::screen.setDialogTile(this);
buttons->setFocus();
}
}
void Daemon::TileFileProgress::close() {
ft = 0;
::screen.setDialogTile(0);
}
void Daemon::TileFileProgress::tileEvent(PIScreenTile * t, TileEvent e) {
if (t->name() == "fd_buttons") {
if (e.type != TileButtons::ButtonSelected || !ft) return;
switch (e.data.toInt()) {
case 0:
if (buttons->content[0].first == "Pause") {
buttons->content[0].first = "Resume";
ft->pause();
} else {
buttons->content[0].first = "Pause";
ft->resume();
}
break;
case 1: ft->stop(); close(); break;
};
}
}
Daemon::Daemon(): PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_" + PIString(rand() % 100)), fm(this) {
@@ -273,8 +310,7 @@ void Daemon::fmActionRequest(bool remote_tile, FileManager::Action type, PIVaria
Remote * r = remotes.value(conn_name, 0);
if (!r) return;
r->sendFiles(fm.localDir() + PIDir::separator, data.toStringList());
tile_file_progress->ft = &(r->ft);
screen.setDialogTile(tile_file_progress);
tile_file_progress->show(&(r->ft));
}
break;
default: break;
@@ -338,6 +374,8 @@ void Daemon::peerConnected(const PIString & name) {
Remote * r = new Remote(name);
CONNECTU(r, sendRequest, this, sendRequest)
CONNECTU(r, receiveFinished, this, filesReceived)
CONNECTU(r, receiveFinished, this, closeFileDialog)
CONNECTU(r, sendFinished, this, closeFileDialog)
remotes.insert(name, r);
}
@@ -358,6 +396,14 @@ void Daemon::filesReceived(const PIString & name, bool ok) {
}
void Daemon::closeFileDialog(const PIString & name, bool ok) {
piCout << "CLOSE" << name << ok;
if (tile_file_progress->conn_name != name) return;
if (ok)
tile_file_progress->close();
}
void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
//if (conn_name != from) return;
if (data.size() < 4) return;
@@ -444,63 +490,6 @@ void Daemon::makeOtherHostInfo() {
}
void Daemon::updateConsole() {
switch (mode) {
case 0: tabConnect(); break;
case 1: tabFeature(); break;
case RequestHostInfo: tabInfo(); break;
}
}
void Daemon::tabConnectedHeader(int cols) {
/*console.addString("Connected to: " + connectedDaemon(), 1, PIConsole::BackGreen | PIConsole::Bold);
for (int i = 2; i <= cols; ++i)
console.addString(" ", i, PIConsole::Green | PIConsole::Inverse);*/
}
void Daemon::tabConnect() {
/*startTab();
console.addString("Available daemons:");
int num = 0;
dnames.clear();
PIStringList adl = availableDaemons();
piForeachC (PIString & p, adl) {
dnames[num] = p;
console.addString(" " + PIString(num++) + " - " + p);
}
finishTab();*/
}
void Daemon::tabFeature() {
/*startTab();
tabConnectedHeader();
console.addString("What do you wish to do with this daemon?");
console.addString(" 0 - show host info");
console.addString(" 1 - file manager");
console.addString(" 2 - execute command");
finishTab();*/
}
void Daemon::tabInfo() {
/*startTab(2);
tabConnectedHeader(2);
console.addString("Exec command: " + info_other.execCommand);
console.addString(" Executed on " + info_other.execDateTime.toString());
console.addString(" Hostname: " + info_other.hostname);
console.addString(" Username: " + info_other.user);
console.addString(" OS name: " + info_other.OS_name);
console.addString(" OS version: " + info_other.OS_version);
console.addString("Architecture: " + info_other.architecture);
console.addString(" CPU count: " + PIString::fromNumber(info_other.processorsCount));
console.addVariable("of this process", &sys_mon_other, 2);
finishTab();*/
}
void Daemon::requestChDir(const PIString & d) {
if (d.isEmpty()) return;
fm.remoteSaveDir();

View File

@@ -86,8 +86,11 @@ private:
};
class TileFileProgress: public PIScreenTile {
PIOBJECT_SUBCLASS(TileFileProgress, PIScreenTile)
public:
TileFileProgress();
void show(PIFileTransfer * f);
void close();
TileSimple * label_file, * label_speed;
TileProgress * prog_file, * prog_all;
TileButtons * buttons;
@@ -95,6 +98,8 @@ private:
void resizeEvent(int w, int h);
void sizeHint(int & w, int & h) const;
void drawEvent(PIScreenDrawer * d);
PIString conn_name;
EVENT_HANDLER2(void, tileEvent, PIScreenTile *, t, PIScreenTypes::TileEvent, e);
};
EVENT_HANDLER2(void, tileEvent, PIScreenTile *, t, PIScreenTypes::TileEvent, e);
@@ -104,6 +109,7 @@ private:
EVENT_HANDLER3(void, fmActionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data);
EVENT_HANDLER2(void, timerEvent, void * , _d, int, delim);
EVENT_HANDLER2(void, filesReceived, const PIString & , name, bool, ok);
EVENT_HANDLER2(void, closeFileDialog, const PIString & , name, bool, ok);
EVENT(menuRequest);
void hideAll();
void showTile(PIScreenTile * t, const PIString & header = PIString());
@@ -113,11 +119,6 @@ private:
void dataReceived(const PIString & from, const PIByteArray & data);
void makeMyHostInfo();
void makeOtherHostInfo();
void updateConsole();
void tabConnectedHeader(int cols = 1);
void tabConnect();
void tabFeature();
void tabInfo();
void requestChDir(const PIString & d);