git-svn-id: svn://db.shs.com.ru/pip@231 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -329,15 +329,10 @@ PIScreen::PIScreen(bool startNow, PIKbdListener::KBFunc slot): PIThread(), drawe
|
|||||||
|
|
||||||
|
|
||||||
PIScreen::~PIScreen() {
|
PIScreen::~PIScreen() {
|
||||||
piCoutObj << "~PIScreen";
|
|
||||||
if (isRunning())
|
if (isRunning())
|
||||||
stop();
|
stop();
|
||||||
piCoutObj << "stop PIScreen .. ";
|
|
||||||
PIThread::waitForFinish(10);
|
PIThread::waitForFinish(10);
|
||||||
piCoutObj << "stop PIScreen ok";
|
|
||||||
piCoutObj << "stop listener .. ";
|
|
||||||
listener->waitForFinish(10);
|
listener->waitForFinish(10);
|
||||||
piCoutObj << "stop listener ok";
|
|
||||||
delete listener;
|
delete listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public:
|
|||||||
void show() {visible = true;}
|
void show() {visible = true;}
|
||||||
void hide() {visible = false;}
|
void hide() {visible = false;}
|
||||||
void setFocus();
|
void setFocus();
|
||||||
|
bool hasFocus() const {return has_focus;}
|
||||||
void setMargins(int m) {marginLeft = marginRight = marginTop = marginBottom = m;}
|
void setMargins(int m) {marginLeft = marginRight = marginTop = marginBottom = m;}
|
||||||
void setMargins(int l, int r, int t, int b) {marginLeft = l; marginRight = r; marginTop = t; marginBottom = b;}
|
void setMargins(int l, int r, int t, int b) {marginLeft = l; marginRight = r; marginTop = t; marginBottom = b;}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
|||||||
diag.received(data.size(), false);
|
diag.received(data.size(), false);
|
||||||
return;
|
return;
|
||||||
} else diag.received(data.size(), true);
|
} else diag.received(data.size(), true);
|
||||||
// piCoutObj << "receive" << h.session_id << h.type << h.id;
|
//piCoutObj << "receive" << h.session_id << h.type << h.id;
|
||||||
switch (pt) {
|
switch (pt) {
|
||||||
case pt_Unknown: break;
|
case pt_Unknown: break;
|
||||||
case pt_Data:
|
case pt_Data:
|
||||||
@@ -446,7 +446,7 @@ bool PIBaseTransfer::getStartRequest() {
|
|||||||
mutex_session.lock();
|
mutex_session.lock();
|
||||||
if (replies[0] == pt_ReplySuccess) {
|
if (replies[0] == pt_ReplySuccess) {
|
||||||
state_string = "send permited!";
|
state_string = "send permited!";
|
||||||
piCoutObj << "ping " << tm.elapsed_m();
|
//piCoutObj << "ping " << tm.elapsed_m();
|
||||||
mutex_session.unlock();
|
mutex_session.unlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
|
|||||||
srand(PISystemTime::current().toMilliseconds());
|
srand(PISystemTime::current().toMilliseconds());
|
||||||
pftheader.session_id = rand();
|
pftheader.session_id = rand();
|
||||||
sendFilesStarted();
|
sendFilesStarted();
|
||||||
cur_file_string = "buil session";
|
cur_file_string = "build session";
|
||||||
desc.clear();
|
desc.clear();
|
||||||
desc << files_;
|
desc << files_;
|
||||||
pftheader.step = pft_Description;
|
pftheader.step = pft_Description;
|
||||||
@@ -223,7 +223,7 @@ void PIFileTransfer::receivePart(PIBaseTransfer::Part fi, PIByteArray ba, PIByte
|
|||||||
StepType st = (StepType)h.step;
|
StepType st = (StepType)h.step;
|
||||||
pftheader.step = st;
|
pftheader.step = st;
|
||||||
if (!h.check_sig()) {
|
if (!h.check_sig()) {
|
||||||
cur_file_string = "ERROR File Transfer uncompatable! or invalid version";
|
cur_file_string = "ERROR check signature: File Transfer incompatable or invalid version!";
|
||||||
piCoutObj << cur_file_string;
|
piCoutObj << cur_file_string;
|
||||||
stopReceive();
|
stopReceive();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
|||||||
cnt++;
|
cnt++;
|
||||||
if (cnt > _PIPEER_MSG_TTL || from == dp->name) return true;
|
if (cnt > _PIPEER_MSG_TTL || from == dp->name) return true;
|
||||||
sba << type << from << to << cnt << pba;
|
sba << type << from << to << cnt << pba;
|
||||||
piCout << "translate packet" << from << "->" << to << ", ttl =" << cnt;
|
//piCout << "translate packet" << from << "->" << to << ", ttl =" << cnt;
|
||||||
sendToNeighbour(dp, sba);
|
sendToNeighbour(dp, sba);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
#include "pisysteminfo.h"
|
#include "pisysteminfo.h"
|
||||||
|
|
||||||
const char pisd_prefix[] = "_pisd_";
|
const char pisd_prefix[] = "_pisd_";
|
||||||
|
const char self_name[] = "__self__";
|
||||||
extern PIScreen screen;
|
extern PIScreen screen;
|
||||||
|
//bool Daemon::inited__ = false;
|
||||||
|
|
||||||
Daemon::Remote::Remote(const PIString & n): PIThread() {
|
Daemon::Remote::Remote(const PIString & n): PIThread() {
|
||||||
setName(n);
|
setName(n);
|
||||||
@@ -60,6 +61,8 @@ void Daemon::Remote::run() {
|
|||||||
|
|
||||||
|
|
||||||
void Daemon::Remote::updateDirEntries() {
|
void Daemon::Remote::updateDirEntries() {
|
||||||
|
//piCout << dir_my;
|
||||||
|
if (!dir_my.isExists()) dir_my = PIDir::current();
|
||||||
my_filelist = dir_my.entries();
|
my_filelist = dir_my.entries();
|
||||||
piForeach (PIFile::FileInfo & f, my_filelist) f.path = f.name();
|
piForeach (PIFile::FileInfo & f, my_filelist) f.path = f.name();
|
||||||
}
|
}
|
||||||
@@ -194,7 +197,7 @@ void Daemon::TileFileProgress::tileEvent(PIScreenTile * t, TileEvent e) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Daemon::Daemon(): PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_" + PIString(rand() % 100)), fm(this) {
|
Daemon::Daemon(): inited__(false), PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_" + PIString(rand() % 100)), fm(this) {
|
||||||
setName("Daemon");
|
setName("Daemon");
|
||||||
dtimer.setName("__S__Daemon_timer");
|
dtimer.setName("__S__Daemon_timer");
|
||||||
mode = offset = cur = height = 0;
|
mode = offset = cur = height = 0;
|
||||||
@@ -202,6 +205,12 @@ Daemon::Daemon(): PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_"
|
|||||||
CONNECTU(&dtimer, tickEvent, this, timerEvent)
|
CONNECTU(&dtimer, tickEvent, this, timerEvent)
|
||||||
CONNECTU(&fm, tileKey, this, fmKeyEvent)
|
CONNECTU(&fm, tileKey, this, fmKeyEvent)
|
||||||
CONNECTU(&fm, actionRequest, this, fmActionRequest)
|
CONNECTU(&fm, actionRequest, this, fmActionRequest)
|
||||||
|
_self = new Remote(self_name);
|
||||||
|
CONNECTU(_self, sendRequest, this, localSend)
|
||||||
|
CONNECTU(_self, receiveFinished, this, closeFileDialog)
|
||||||
|
CONNECTU(_self, sendFinished, this, closeFileDialog)
|
||||||
|
localft.setName(self_name);
|
||||||
|
CONNECTU(&localft, sendRequest, _self, received)
|
||||||
dtimer.addDelimiter(5);
|
dtimer.addDelimiter(5);
|
||||||
dtimer.start(200);
|
dtimer.start(200);
|
||||||
|
|
||||||
@@ -227,7 +236,7 @@ Daemon::Daemon(): PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_"
|
|||||||
tile_info = new TileSimple("daemon info");
|
tile_info = new TileSimple("daemon info");
|
||||||
tile_info->hide();
|
tile_info->hide();
|
||||||
|
|
||||||
fm.setRemote(true);
|
fm.setRemote();
|
||||||
tile_fm = fm.tile();
|
tile_fm = fm.tile();
|
||||||
tile_fm->hide();
|
tile_fm->hide();
|
||||||
|
|
||||||
@@ -241,7 +250,7 @@ Daemon::Daemon(): PIPeer(pisd_prefix + PISystemInfo::instance()->hostname + "_"
|
|||||||
tile_root->addTile(tile_fm);
|
tile_root->addTile(tile_fm);
|
||||||
|
|
||||||
CONNECTU(&screen, tileEvent, this, tileEvent)
|
CONNECTU(&screen, tileEvent, this, tileEvent)
|
||||||
|
inited__ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,6 +267,15 @@ PIScreenTile * Daemon::tile() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Daemon::localSend(const PIString & p_name, const PIByteArray & data) {
|
||||||
|
//piCoutObj << "localSend" << localft.stateString();
|
||||||
|
PIByteArray h; h << int(FileTransfer);
|
||||||
|
PIByteArray ba = data;
|
||||||
|
ba.remove(0, h.size());
|
||||||
|
localft.received(ba);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Daemon::hideAll() {
|
void Daemon::hideAll() {
|
||||||
list_actions->hide();
|
list_actions->hide();
|
||||||
tile_info->hide();
|
tile_info->hide();
|
||||||
@@ -355,7 +373,7 @@ void Daemon::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
void Daemon::fmKeyEvent(PIKbdListener::KeyEvent key) {
|
void Daemon::fmKeyEvent(PIKbdListener::KeyEvent key) {
|
||||||
PIMutexLocker ml(remote_mutex);
|
PIMutexLocker ml(remote_mutex);
|
||||||
//Remote * r = remotes.value(conn_name);
|
//Remote * r = remotes.value(conn_name);
|
||||||
//piCout << key.key << key.modifiers;
|
// piCoutObj << key.key << key.modifiers;
|
||||||
switch (key.key) {
|
switch (key.key) {
|
||||||
case PIKbdListener::Return:
|
case PIKbdListener::Return:
|
||||||
{
|
{
|
||||||
@@ -375,7 +393,7 @@ void Daemon::fmKeyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
void Daemon::fmActionRequest(bool remote_tile, FileManager::Action type, PIVariant data) {
|
void Daemon::fmActionRequest(bool remote_tile, FileManager::Action type, PIVariant data) {
|
||||||
Remote * r = 0;
|
Remote * r = 0;
|
||||||
r = remotes.value(conn_name, 0);
|
r = remotes.value(conn_name, 0);
|
||||||
if (!r) return;
|
if (!r && type != FileManager::LocalCopy) return;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FileManager::Copy:
|
case FileManager::Copy:
|
||||||
if (remote_tile) {
|
if (remote_tile) {
|
||||||
@@ -406,6 +424,17 @@ void Daemon::fmActionRequest(bool remote_tile, FileManager::Action type, PIVaria
|
|||||||
send(conn_name, ba);
|
send(conn_name, ba);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case FileManager::LocalCopy:
|
||||||
|
//piCoutObj << "localCopy";
|
||||||
|
if (remote_tile) {
|
||||||
|
localft.setDirectory(fm.localDir());
|
||||||
|
_self->sendFiles(fm.remoteDir() + PIDir::separator, data.toStringList());
|
||||||
|
} else {
|
||||||
|
localft.setDirectory(fm.remoteDir());
|
||||||
|
_self->sendFiles(fm.localDir() + PIDir::separator, data.toStringList());
|
||||||
|
}
|
||||||
|
tile_file_progress->rec = false;
|
||||||
|
tile_file_progress->show(&(_self->ft));
|
||||||
default: break;
|
default: break;
|
||||||
};
|
};
|
||||||
//piCout << remote_tile << type << data;
|
//piCout << remote_tile << type << data;
|
||||||
@@ -459,67 +488,82 @@ PIString Daemon::connectedDaemon() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Daemon::peerConnected(const PIString & name) {
|
void Daemon::peerConnected(const PIString & p_name) {
|
||||||
|
while (!inited__) piMSleep(5);
|
||||||
|
// PIMutexLocker ml(peers_mutex);
|
||||||
/*piCout << "connected" << name;
|
/*piCout << "connected" << name;
|
||||||
mode = 2;
|
mode = 2;
|
||||||
conn_name = name;*/
|
conn_name = name;*/
|
||||||
if (!name.startsWith(pisd_prefix)) return;
|
if (!p_name.startsWith(pisd_prefix)) return;
|
||||||
Remote * r = new Remote(name);
|
Remote * r = new Remote(p_name);
|
||||||
|
piCoutObj << "peer connected" << p_name;
|
||||||
|
// piCout << r->methodsEH() << this->methodsEH();
|
||||||
CONNECTU(r, sendRequest, this, sendRequest)
|
CONNECTU(r, sendRequest, this, sendRequest)
|
||||||
CONNECTU(r, receiveFinished, this, filesRreceived)
|
CONNECTU(r, receiveFinished, this, filesReceived)
|
||||||
CONNECTU(r, receiveFinished, this, closeFileDialog)
|
CONNECTU(r, receiveFinished, this, closeFileDialog)
|
||||||
CONNECTU(r, sendFinished, this, closeFileDialog)
|
CONNECTU(r, sendFinished, this, closeFileDialog)
|
||||||
CONNECTU(r, removeFinished, this, filesRemoved)
|
CONNECTU(r, removeFinished, this, filesRemoved)
|
||||||
CONNECTU(r, changeDirFinished, this, dirChanged)
|
CONNECTU(r, changeDirFinished, this, dirChanged)
|
||||||
PIMutexLocker ml(remote_mutex);
|
PIMutexLocker ml2(remote_mutex);
|
||||||
remotes.insert(name, r);
|
remotes.insert(p_name, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Daemon::peerDisconnected(const PIString & name) {
|
void Daemon::peerDisconnected(const PIString & p_name) {
|
||||||
if (name == conn_name) {
|
while (!inited__) piMSleep(5);
|
||||||
|
piCoutObj << "peer disconnect" << p_name;
|
||||||
|
if (p_name == conn_name) {
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
PIMutexLocker ml(remote_mutex);
|
PIMutexLocker ml(remote_mutex);
|
||||||
Remote * dt = remotes.value(name, 0);
|
Remote * dt = remotes.value(p_name, 0);
|
||||||
if (!dt) return;
|
if (!dt) return;
|
||||||
if (tile_file_progress->ft == &(dt->ft)) {
|
if (tile_file_progress->ft == &(dt->ft)) {
|
||||||
tile_file_progress->close(false);
|
tile_file_progress->close(false);
|
||||||
}
|
}
|
||||||
remotes.remove(name);
|
remotes.remove(p_name);
|
||||||
delete dt;
|
delete dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Daemon::filesReceived(const PIString & name, bool ok) {
|
void Daemon::filesReceived(const PIString & p_name, bool ok) {
|
||||||
PIMutexLocker ml(remote_mutex);
|
PIMutexLocker ml(remote_mutex);
|
||||||
Remote * r = remotes.value(name, 0);
|
Remote * r = remotes.value(p_name, 0);
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
r->updateDir();
|
r->updateDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Daemon::dirChanged(const PIString & name, const PIString & dir) {
|
void Daemon::dirChanged(const PIString & p_name, const PIString & dir) {
|
||||||
PIMutexLocker ml(remote_mutex);
|
PIMutexLocker ml(remote_mutex);
|
||||||
Remote * r = remotes.value(name, 0);
|
Remote * r = remotes.value(p_name, 0);
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
if (r->dir_my.absolutePath() != dir) return;
|
if (r->dir_my.absolutePath() != dir) return;
|
||||||
sendDirToRemote(r);
|
sendDirToRemote(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Daemon::filesRemoved(const PIString & name, const PIString & dir) {
|
void Daemon::filesRemoved(const PIString & p_name, const PIString & dir) {
|
||||||
PIMutexLocker ml(remote_mutex);
|
PIMutexLocker ml(remote_mutex);
|
||||||
Remote * r = remotes.value(name, 0);
|
Remote * r = remotes.value(p_name, 0);
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
if (r->dir_my.absolutePath() != dir) return;
|
if (r->dir_my.absolutePath() != dir) return;
|
||||||
sendDirToRemote(r);
|
sendDirToRemote(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Daemon::closeFileDialog(const PIString & name, bool ok) {
|
void Daemon::closeFileDialog(const PIString & p_name, bool ok) {
|
||||||
//piCout << "CLOSE" << tile_file_progress->conn_name << name << ok;
|
//piCout << "CLOSE" << tile_file_progress->conn_name << name << ok;
|
||||||
if (tile_file_progress->conn_name != name) return;
|
if (p_name == self_name) {
|
||||||
|
tile_file_progress->close(ok);
|
||||||
|
fm.clearSelectionLocal();
|
||||||
|
fm.clearSelectionRemote();
|
||||||
|
fm.updateLocalDir();
|
||||||
|
fm.updateRemoteDir();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
piCoutObj << "file transfer with" << p_name << (ok ? "success" : "failure");
|
||||||
|
if (tile_file_progress->conn_name != p_name) return;
|
||||||
tile_file_progress->close(ok);
|
tile_file_progress->close(ok);
|
||||||
// if (ok) {
|
// if (ok) {
|
||||||
if (tile_file_progress->rec) {
|
if (tile_file_progress->rec) {
|
||||||
@@ -543,7 +587,7 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
Remote * r = remotes.value(from);
|
Remote * r = remotes.value(from);
|
||||||
PIString dir;
|
PIString dir;
|
||||||
int type; ba >> type;
|
int type; ba >> type;
|
||||||
//piCout << "rec from " << from << type;
|
//piCout << "rec from " << from << type << r;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RequestHostInfo:
|
case RequestHostInfo:
|
||||||
makeMyHostInfo();
|
makeMyHostInfo();
|
||||||
@@ -555,7 +599,7 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
r->dir_my.cd(dir);
|
r->dir_my.cd(dir);
|
||||||
r->ft.setDirectory(r->dir_my);
|
r->ft.setDirectory(r->dir_my);
|
||||||
//piCout << "store to" << r->dir_my.absolutePath();
|
//piCout << "store to" << r->dir_my.absolutePath();
|
||||||
//piCout << "cd to" << dir << ", abs =" << r->dir_my.absolutePath();
|
piCout << "cd to" << r->dir_my.absolutePath();
|
||||||
r->updateDir();
|
r->updateDir();
|
||||||
// sendDirToRemote(r);
|
// sendDirToRemote(r);
|
||||||
break;
|
break;
|
||||||
@@ -657,6 +701,7 @@ void Daemon::makeOtherHostInfo() {
|
|||||||
void Daemon::requestChDir(const PIString & d) {
|
void Daemon::requestChDir(const PIString & d) {
|
||||||
if (d.isEmpty()) return;
|
if (d.isEmpty()) return;
|
||||||
Remote * r = remotes.value(conn_name, 0);
|
Remote * r = remotes.value(conn_name, 0);
|
||||||
|
//piCout << "request chdir" << d << conn_name << r;
|
||||||
if (d.isEmpty()) return;
|
if (d.isEmpty()) return;
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
fm.remoteSaveDir();
|
fm.remoteSaveDir();
|
||||||
@@ -664,5 +709,4 @@ void Daemon::requestChDir(const PIString & d) {
|
|||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba << int(RequestChangeDir) << d;
|
ba << int(RequestChangeDir) << d;
|
||||||
send(conn_name, ba);
|
send(conn_name, ba);
|
||||||
//piCout << "request chdir" << d;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
|
|
||||||
void showMainList() {showTile(list_daemons, "Select daemon");}
|
void showMainList() {showTile(list_daemons, "Select daemon");}
|
||||||
void showActionList() {showTile(list_actions, "Select action");}
|
void showActionList() {showTile(list_actions, "Select action");}
|
||||||
|
void showLocalFilemanager() {mode = 3; showTile(tile_fm, "File manager");}
|
||||||
|
|
||||||
PIStringList availableDaemons();
|
PIStringList availableDaemons();
|
||||||
void connectToDaemon(const PIString & dn);
|
void connectToDaemon(const PIString & dn);
|
||||||
@@ -58,6 +59,8 @@ public:
|
|||||||
bool lockedSends() const {return send_mutex.isLocked();}
|
bool lockedSends() const {return send_mutex.isLocked();}
|
||||||
bool lockedMCSends() const {return send_mc_mutex.isLocked();}
|
bool lockedMCSends() const {return send_mc_mutex.isLocked();}
|
||||||
|
|
||||||
|
FileManager fm;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum PacketType {
|
enum PacketType {
|
||||||
RequestHostInfo = 10,
|
RequestHostInfo = 10,
|
||||||
@@ -76,7 +79,7 @@ private:
|
|||||||
class Remote: public PIThread {
|
class Remote: public PIThread {
|
||||||
PIOBJECT_SUBCLASS(Remote, PIThread)
|
PIOBJECT_SUBCLASS(Remote, PIThread)
|
||||||
public:
|
public:
|
||||||
Remote(const PIString & n = PIString());
|
explicit Remote(const PIString & n = PIString());
|
||||||
~Remote();
|
~Remote();
|
||||||
void sendFiles(const PIString & dir, const PIStringList & fl) {startAction(Daemon::CopyFiles, dir, fl);}
|
void sendFiles(const PIString & dir, const PIStringList & fl) {startAction(Daemon::CopyFiles, dir, fl);}
|
||||||
void removeFiles(const PIStringList & fl) {startAction(Daemon::RemoveFiles, PIString(), fl);}
|
void removeFiles(const PIStringList & fl) {startAction(Daemon::RemoveFiles, PIString(), fl);}
|
||||||
@@ -86,12 +89,12 @@ private:
|
|||||||
EVENT_HANDLER1(void, ftReceived, bool, ok) {receiveFinished(name(), ok);}
|
EVENT_HANDLER1(void, ftReceived, bool, ok) {receiveFinished(name(), ok);}
|
||||||
EVENT_HANDLER1(void, ftSended, bool, ok) {sendFinished(name(), ok);}
|
EVENT_HANDLER1(void, ftSended, bool, ok) {sendFinished(name(), ok);}
|
||||||
|
|
||||||
EVENT2(sendRequest, const PIString & , name, const PIByteArray &, data)
|
EVENT2(sendRequest, const PIString &, p_name, const PIByteArray &, data)
|
||||||
EVENT2(receiveFinished, const PIString & , name, bool, ok)
|
EVENT2(receiveFinished, const PIString & , p_name, bool, ok)
|
||||||
EVENT2(sendFinished, const PIString & , name, bool, ok)
|
EVENT2(sendFinished, const PIString & , p_name, bool, ok)
|
||||||
EVENT2(removeFinished, const PIString & , name, const PIString & , dir)
|
EVENT2(removeFinished, const PIString & , p_name, const PIString & , dir)
|
||||||
EVENT2(changeDirFinished, const PIString & , name, const PIString & , dir)
|
EVENT2(changeDirFinished, const PIString & , p_name, const PIString & , dir)
|
||||||
EVENT_HANDLER1(void, received, const PIByteArray & , data) {ft.received(data);}
|
EVENT_HANDLER1(void, received, PIByteArray & , data) {ft.received(data);}
|
||||||
|
|
||||||
void startAction(PacketType a, const PIString & dir, const PIStringList & fl);
|
void startAction(PacketType a, const PIString & dir, const PIStringList & fl);
|
||||||
void run();
|
void run();
|
||||||
@@ -127,20 +130,21 @@ private:
|
|||||||
|
|
||||||
EVENT_HANDLER2(void, tileEvent, PIScreenTile *, t, PIScreenTypes::TileEvent, e);
|
EVENT_HANDLER2(void, tileEvent, PIScreenTile *, t, PIScreenTypes::TileEvent, e);
|
||||||
EVENT_HANDLER1(void, keyEvent, PIKbdListener::KeyEvent, key);
|
EVENT_HANDLER1(void, keyEvent, PIKbdListener::KeyEvent, key);
|
||||||
EVENT_HANDLER2(void, sendRequest, const PIString & , name, const PIByteArray & , data) {send(name, data);}
|
EVENT_HANDLER2(void, sendRequest, const PIString &, p_name, const PIByteArray &, data) {send(p_name, data);}
|
||||||
EVENT_HANDLER1(void, fmKeyEvent, PIKbdListener::KeyEvent, key);
|
EVENT_HANDLER1(void, fmKeyEvent, PIKbdListener::KeyEvent, key);
|
||||||
EVENT_HANDLER3(void, fmActionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data);
|
EVENT_HANDLER3(void, fmActionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data);
|
||||||
EVENT_HANDLER2(void, timerEvent, void * , _d, int, delim);
|
EVENT_HANDLER2(void, timerEvent, void * , _d, int, delim);
|
||||||
EVENT_HANDLER2(void, filesReceived, const PIString & , name, bool, ok);
|
EVENT_HANDLER2(void, filesReceived, const PIString & , p_name, bool, ok);
|
||||||
EVENT_HANDLER2(void, filesRemoved, const PIString & , name, const PIString & , dir);
|
EVENT_HANDLER2(void, filesRemoved, const PIString & , p_name, const PIString & , dir);
|
||||||
EVENT_HANDLER2(void, dirChanged, const PIString & , name, const PIString & , dir);
|
EVENT_HANDLER2(void, dirChanged, const PIString & , p_name, const PIString & , dir);
|
||||||
EVENT_HANDLER2(void, closeFileDialog, const PIString & , name, bool, ok);
|
EVENT_HANDLER2(void, closeFileDialog, const PIString & , p_name, bool, ok);
|
||||||
|
EVENT_HANDLER2(void, localSend, const PIString & , p_name, const PIByteArray &, data);
|
||||||
EVENT(menuRequest)
|
EVENT(menuRequest)
|
||||||
void hideAll();
|
void hideAll();
|
||||||
void showTile(PIScreenTile * t, const PIString & header = PIString());
|
void showTile(PIScreenTile * t, const PIString & header = PIString());
|
||||||
void fillInfoTile(const HostInfo & hi);
|
void fillInfoTile(const HostInfo & hi);
|
||||||
void peerConnected(const PIString & name);
|
void peerConnected(const PIString & p_name);
|
||||||
void peerDisconnected(const PIString & name);
|
void peerDisconnected(const PIString & p_name);
|
||||||
void dataReceived(const PIString & from, const PIByteArray & data);
|
void dataReceived(const PIString & from, const PIByteArray & data);
|
||||||
void makeMyHostInfo();
|
void makeMyHostInfo();
|
||||||
void makeOtherHostInfo();
|
void makeOtherHostInfo();
|
||||||
@@ -156,14 +160,14 @@ private:
|
|||||||
PIMap<PIString, Remote*> remotes;
|
PIMap<PIString, Remote*> remotes;
|
||||||
PISystemMonitor sys_mon_other;
|
PISystemMonitor sys_mon_other;
|
||||||
HostInfo info_my, info_other;
|
HostInfo info_my, info_other;
|
||||||
FileManager fm;
|
|
||||||
PIScreenTile * tile_root, * tile_fm;
|
PIScreenTile * tile_root, * tile_fm;
|
||||||
TileSimple * tile_info, * tile_header;
|
TileSimple * tile_info, * tile_header;
|
||||||
TileList * list_daemons, * list_actions;
|
TileList * list_daemons, * list_actions;
|
||||||
TileFileProgress * tile_file_progress;
|
TileFileProgress * tile_file_progress;
|
||||||
|
PIFileTransfer localft;
|
||||||
|
Remote * _self;
|
||||||
int mode, offset, cur, height;
|
int mode, offset, cur, height;
|
||||||
|
bool inited__;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline PIByteArray & operator <<(PIByteArray & b, const Daemon::HostInfo & v) {
|
inline PIByteArray & operator <<(PIByteArray & b, const Daemon::HostInfo & v) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ FileManager::TileDir::TileDir(): TileList() {
|
|||||||
label_path = 0;
|
label_path = 0;
|
||||||
selection_mode = TileList::MultiSelection;
|
selection_mode = TileList::MultiSelection;
|
||||||
dir = PIDir::current();
|
dir = PIDir::current();
|
||||||
resized = remote = remote_mode = false;
|
resized = is_right = remote_mode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -28,15 +28,15 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
bool pass = false;
|
bool pass = false;
|
||||||
PIString nd;
|
PIString nd;
|
||||||
switch (key.key) {
|
switch (key.key) {
|
||||||
case 'R': if (!remote) updateDir(); pass = true; break;
|
case 'R': if (!(is_right && remote_mode)) updateDir(); pass = true; break;
|
||||||
case PIKbdListener::F5:
|
case PIKbdListener::F5:
|
||||||
if (remote_mode) {
|
if (selected.isEmpty())
|
||||||
if (selected.isEmpty())
|
selected << cur;
|
||||||
selected << cur;
|
if (!askQuestion("Copy selected files?")) return true;
|
||||||
if (!askQuestion("Copy selected files?")) return true;
|
setFocus();
|
||||||
setFocus();
|
//piCoutObj << "remote" << remote_mode;
|
||||||
actionRequest(remote, Copy, selectedNames());
|
if (remote_mode) actionRequest(is_right, Copy, selectedNames());
|
||||||
}
|
else actionRequest(is_right, LocalCopy, selectedNames());
|
||||||
break;
|
break;
|
||||||
case PIKbdListener::F6:
|
case PIKbdListener::F6:
|
||||||
if (key.modifiers[PIKbdListener::Shift]) {
|
if (key.modifiers[PIKbdListener::Shift]) {
|
||||||
@@ -47,8 +47,8 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
nd = askNewDir();
|
nd = askNewDir();
|
||||||
setFocus();
|
setFocus();
|
||||||
if (nd.isEmpty()) return true;
|
if (nd.isEmpty()) return true;
|
||||||
if (remote)
|
if (is_right && remote_mode)
|
||||||
actionRequest(remote, MkDir, nd);
|
actionRequest(is_right, MkDir, nd);
|
||||||
else {
|
else {
|
||||||
PIDir::make(dir.absolutePath() + PIDir::separator + nd);
|
PIDir::make(dir.absolutePath() + PIDir::separator + nd);
|
||||||
updateDir();
|
updateDir();
|
||||||
@@ -63,8 +63,8 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setFocus();
|
setFocus();
|
||||||
if (remote) {
|
if (is_right && remote_mode) {
|
||||||
actionRequest(remote, Remove, selectedNames());
|
actionRequest(is_right, Remove, selectedNames());
|
||||||
} else {
|
} else {
|
||||||
removeFiles(dir, selectedNames());
|
removeFiles(dir, selectedNames());
|
||||||
selected.clear();
|
selected.clear();
|
||||||
@@ -77,7 +77,7 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
e_mutex.lock();
|
e_mutex.lock();
|
||||||
bool ud = false;
|
bool ud = false;
|
||||||
if (cur < entries.size_s() && cur >= 0) {
|
if (cur < entries.size_s() && cur >= 0) {
|
||||||
if (!remote) {
|
if (!(is_right && remote_mode)) {
|
||||||
//piCout << entries[cur];
|
//piCout << entries[cur];
|
||||||
if (entries[cur].isDir()) {
|
if (entries[cur].isDir()) {
|
||||||
prev_pos[dir.path()] = PIPair<int, int>(cur, offset);
|
prev_pos[dir.path()] = PIPair<int, int>(cur, offset);
|
||||||
@@ -96,7 +96,8 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (remote && pass) {
|
// piCout << is_right << remote_mode << pass;
|
||||||
|
if (is_right && remote_mode && pass) {
|
||||||
((void(*)(void*,PIKbdListener::KeyEvent))key_func)(fm, key);
|
((void(*)(void*,PIKbdListener::KeyEvent))key_func)(fm, key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -250,6 +251,7 @@ FileManager::FileManager(Daemon * d) {
|
|||||||
panels[i]->updateDir();
|
panels[i]->updateDir();
|
||||||
pt->addTile(panel);
|
pt->addTile(panel);
|
||||||
}
|
}
|
||||||
|
panels[1]->is_right = true;
|
||||||
tile_root->addTile(pt);
|
tile_root->addTile(pt);
|
||||||
|
|
||||||
PIScreenTile * labels = new PIScreenTile();
|
PIScreenTile * labels = new PIScreenTile();
|
||||||
@@ -275,6 +277,17 @@ PIScreenTile * FileManager::tile() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FileManager::setLocal() {
|
||||||
|
if (panels[1]->remote_mode) setRemoteDir(panels[0]->dir.absolutePath());
|
||||||
|
panels[0]->remote_mode = panels[1]->remote_mode = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FileManager::setRemote() {
|
||||||
|
panels[0]->remote_mode = panels[1]->remote_mode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FileManager::setRemoteDir(const PIString & d) {
|
void FileManager::setRemoteDir(const PIString & d) {
|
||||||
panels[1]->dir.setDir(d);
|
panels[1]->dir.setDir(d);
|
||||||
if (panels[1]->label_path) {
|
if (panels[1]->label_path) {
|
||||||
@@ -290,6 +303,13 @@ void FileManager::setRemoteContent(const PIVector< PIFile::FileInfo > & el) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int FileManager::selectedPanel() const {
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
if (panels[i]->hasFocus()) return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PIStringList FileManager::selectedRemote() const {
|
PIStringList FileManager::selectedRemote() const {
|
||||||
PIStringList ret;
|
PIStringList ret;
|
||||||
panels[1]->lock();
|
panels[1]->lock();
|
||||||
|
|||||||
@@ -15,13 +15,15 @@ public:
|
|||||||
PIScreenTile * localTile() const {return panels[0];}
|
PIScreenTile * localTile() const {return panels[0];}
|
||||||
PIScreenTile * remoteTile() const {return panels[1];}
|
PIScreenTile * remoteTile() const {return panels[1];}
|
||||||
|
|
||||||
enum Action {MkDir, Remove, Copy, Move};
|
enum Action {MkDir, Remove, Copy, Move, LocalCopy};
|
||||||
|
|
||||||
void setRemote(bool r) {panels[1]->remote = r; panels[0]->remote_mode = panels[1]->remote_mode = true;}
|
void setLocal();
|
||||||
|
void setRemote();
|
||||||
void setRemoteDir(const PIString & d);
|
void setRemoteDir(const PIString & d);
|
||||||
void setRemoteContent(const PIVector<PIFile::FileInfo> & el);
|
void setRemoteContent(const PIVector<PIFile::FileInfo> & el);
|
||||||
PIString remoteDir() const {return panels[1]->dir.absolutePath();}
|
PIString remoteDir() const {return panels[1]->dir.absolutePath();}
|
||||||
PIString localDir() const {return panels[0]->dir.absolutePath();}
|
PIString localDir() const {return panels[0]->dir.absolutePath();}
|
||||||
|
int selectedPanel() const;
|
||||||
PIStringList selectedRemote() const;
|
PIStringList selectedRemote() const;
|
||||||
PIFile::FileInfo currentRemoteEntry() const;
|
PIFile::FileInfo currentRemoteEntry() const;
|
||||||
PIFile::FileInfo selectedRemoteEntry(int index) const {return panels[1]->entries[index];}
|
PIFile::FileInfo selectedRemoteEntry(int index) const {return panels[1]->entries[index];}
|
||||||
@@ -29,6 +31,7 @@ public:
|
|||||||
void remoteRestoreDir();
|
void remoteRestoreDir();
|
||||||
void readingRemote() const {panels[1]->showReading();}
|
void readingRemote() const {panels[1]->showReading();}
|
||||||
void updateLocalDir() {panels[0]->updateDir();}
|
void updateLocalDir() {panels[0]->updateDir();}
|
||||||
|
void updateRemoteDir() {panels[1]->updateDir();}
|
||||||
void clearSelectionLocal() {panels[0]->selected.clear();}
|
void clearSelectionLocal() {panels[0]->selected.clear();}
|
||||||
void clearSelectionRemote() {panels[1]->selected.clear();}
|
void clearSelectionRemote() {panels[1]->selected.clear();}
|
||||||
|
|
||||||
@@ -55,7 +58,7 @@ private:
|
|||||||
PIDir dir;
|
PIDir dir;
|
||||||
PIMap<PIString, PIPair<int, int> > prev_pos;
|
PIMap<PIString, PIPair<int, int> > prev_pos;
|
||||||
mutable PIMutex e_mutex;
|
mutable PIMutex e_mutex;
|
||||||
bool resized, remote, remote_mode;
|
bool resized, is_right, remote_mode;
|
||||||
void * fm, * key_func;
|
void * fm, * key_func;
|
||||||
EVENT3(actionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data)
|
EVENT3(actionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ _Init _pisd_init;
|
|||||||
PIScreen screen(false);
|
PIScreen screen(false);
|
||||||
PISystemMonitor sys_mon;
|
PISystemMonitor sys_mon;
|
||||||
Daemon daemon_;
|
Daemon daemon_;
|
||||||
FileManager file_manager;
|
//FileManager file_manager;
|
||||||
|
|
||||||
|
|
||||||
class MainMenu: public PITimer {
|
class MainMenu: public PITimer {
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
mt->hide(); mt->name() = "local info";
|
mt->hide(); mt->name() = "local info";
|
||||||
center->addTile(mt); mtiles << mt;
|
center->addTile(mt); mtiles << mt;
|
||||||
|
|
||||||
mt = tfm = file_manager.tile();
|
//mt = tfm = daemon_.fm.tile();
|
||||||
mt->hide(); mt->name() = "file manager";
|
mt->hide(); mt->name() = "file manager";
|
||||||
center->addTile(mt); mtiles << mt;
|
center->addTile(mt); mtiles << mt;
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
|
|
||||||
CONNECTU(&screen, tileEvent, this, tileEvent)
|
CONNECTU(&screen, tileEvent, this, tileEvent)
|
||||||
CONNECTU(&screen, keyPressed, this, keyEvent)
|
CONNECTU(&screen, keyPressed, this, keyEvent)
|
||||||
CONNECTU(&file_manager, menuRequest, this, menuRequest)
|
CONNECTU(&daemon_.fm, menuRequest, this, menuRequest)
|
||||||
CONNECTU(&daemon_, menuRequest, this, menuRequest)
|
CONNECTU(&daemon_, menuRequest, this, menuRequest)
|
||||||
start(10);
|
start(10);
|
||||||
}
|
}
|
||||||
@@ -208,6 +208,7 @@ public:
|
|||||||
EVENT_HANDLER(void, menuRequest) {
|
EVENT_HANDLER(void, menuRequest) {
|
||||||
piForeach (PIScreenTile * t, mtiles)
|
piForeach (PIScreenTile * t, mtiles)
|
||||||
t->hide();
|
t->hide();
|
||||||
|
daemon_.disconnect();
|
||||||
tmenu->show();
|
tmenu->show();
|
||||||
tmenu->setFocus();
|
tmenu->setFocus();
|
||||||
}
|
}
|
||||||
@@ -218,8 +219,8 @@ public:
|
|||||||
t->hide();
|
t->hide();
|
||||||
switch (e.data.toInt()) {
|
switch (e.data.toInt()) {
|
||||||
case 0: tinfo->show(); break;
|
case 0: tinfo->show(); break;
|
||||||
case 1: tfm->show(); break;
|
case 1: daemon_.fm.setLocal(); daemon_.showLocalFilemanager(); tdaemon->show(); break;
|
||||||
case 2: daemon_.showMainList(); tdaemon->show(); break;
|
case 2: daemon_.fm.setRemote(); daemon_.showMainList(); tdaemon->show(); break;
|
||||||
case 3: tpeer->show(); peers_tl->setFocus(); break;
|
case 3: tpeer->show(); peers_tl->setFocus(); break;
|
||||||
case 4: daemon_.reinit(); tmenu->show(); break;
|
case 4: daemon_.reinit(); tmenu->show(); break;
|
||||||
case 5: tpeerdiag->show(); break;
|
case 5: tpeerdiag->show(); break;
|
||||||
|
|||||||
Reference in New Issue
Block a user