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