back to polygonf
git-svn-id: svn://db.shs.com.ru/pip@105 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -19,7 +19,7 @@ Daemon::Remote::Remote(const PIString & n): PIThread() {
|
||||
|
||||
Daemon::Remote::~Remote() {
|
||||
ft.stop();
|
||||
waitForFinish(1000);
|
||||
stop(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -283,6 +283,7 @@ void Daemon::fillInfoTile(const Daemon::HostInfo & hi) {
|
||||
|
||||
|
||||
void Daemon::tileEvent(PIScreenTile * t, TileEvent e) {
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
if (t == list_daemons) {
|
||||
if (e.type == TileList::RowPressed) {
|
||||
connectToDaemon(list_daemons->content[e.data.toInt()].first);
|
||||
@@ -332,6 +333,7 @@ void Daemon::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
|
||||
void Daemon::fmKeyEvent(PIKbdListener::KeyEvent key) {
|
||||
PIByteArray ba;
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
//Remote * r = remotes.value(conn_name);
|
||||
//piCout << key.key << key.modifiers;
|
||||
switch (key.key) {
|
||||
@@ -448,6 +450,7 @@ void Daemon::peerConnected(const PIString & name) {
|
||||
CONNECTU(r, receiveFinished, this, closeFileDialog)
|
||||
CONNECTU(r, sendFinished, this, closeFileDialog)
|
||||
CONNECTU(r, removeFinished, this, filesRemoved)
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
remotes.insert(name, r);
|
||||
}
|
||||
|
||||
@@ -456,6 +459,7 @@ void Daemon::peerDisconnected(const PIString & name) {
|
||||
if (name == conn_name) {
|
||||
disconnect();
|
||||
}
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
Remote * dt = remotes.value(name, 0);
|
||||
if (!dt) return;
|
||||
if (tile_file_progress->ft == &(dt->ft)) {
|
||||
@@ -472,6 +476,7 @@ void Daemon::filesReceived(const PIString & name, bool ok) {
|
||||
|
||||
|
||||
void Daemon::filesRemoved(const PIString & name, const PIString & dir) {
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
Remote * r = remotes.value(name, 0);
|
||||
if (!r) return;
|
||||
if (r->dir_my.absolutePath() != dir) return;
|
||||
@@ -500,8 +505,9 @@ void Daemon::closeFileDialog(const PIString & name, bool ok) {
|
||||
void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
//if (conn_name != from) return;
|
||||
if (data.size() < 4) return;
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
PIByteArray ba(data), rba;
|
||||
Remote * r(0);
|
||||
Remote * r = remotes.value(from);
|
||||
PIString dir;
|
||||
int type; ba >> type;
|
||||
//piCout << "rec from " << from << type;
|
||||
@@ -511,7 +517,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
rba << int(ReplyHostInfo) << info_my;
|
||||
break;
|
||||
case RequestChangeDir:
|
||||
r = remotes.value(from);
|
||||
if (!r) break;
|
||||
ba >> dir;
|
||||
r->dir_my.cd(dir);
|
||||
@@ -526,7 +531,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
fillInfoTile(info_other);
|
||||
break;
|
||||
case ReplyChangeDir:
|
||||
r = remotes.value(from);
|
||||
if (!r) break;
|
||||
{
|
||||
PIVector<PIFile::FileInfo> fil;
|
||||
@@ -538,7 +542,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
}
|
||||
break;
|
||||
case CopyFiles:
|
||||
r = remotes.value(from);
|
||||
if (!r) return;
|
||||
if (r->isRunning()) return;
|
||||
{
|
||||
@@ -549,7 +552,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
}
|
||||
break;
|
||||
case RemoveFiles:
|
||||
r = remotes.value(from);
|
||||
if (!r) return;
|
||||
if (r->isRunning()) return;
|
||||
{
|
||||
@@ -561,7 +563,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
}
|
||||
break;
|
||||
case MkDir:
|
||||
r = remotes.value(from);
|
||||
if (!r) return;
|
||||
{
|
||||
PIString dn;
|
||||
@@ -572,7 +573,6 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
}
|
||||
break;
|
||||
case FileTransfer:
|
||||
r = remotes.value(from);
|
||||
if (r) r->received(ba);
|
||||
break;
|
||||
};
|
||||
@@ -625,6 +625,9 @@ void Daemon::makeOtherHostInfo() {
|
||||
|
||||
void Daemon::requestChDir(const PIString & d) {
|
||||
if (d.isEmpty()) return;
|
||||
Remote * r = remotes.value(conn_name, 0);
|
||||
if (d.isEmpty()) return;
|
||||
if (!r) return;
|
||||
fm.remoteSaveDir();
|
||||
fm.readingRemote();
|
||||
PIByteArray ba;
|
||||
|
||||
@@ -137,6 +137,7 @@ private:
|
||||
mutable PIStringList available_daemons;
|
||||
PITimer timer;
|
||||
PIString conn_name;
|
||||
PIMutex remote_mutex;
|
||||
PIMap<int, PIString> dnames;
|
||||
PIMap<PIString, Remote*> remotes;
|
||||
PISystemMonitor sys_mon_other;
|
||||
|
||||
@@ -15,6 +15,7 @@ FileManager::TileDir::TileDir(): TileList() {
|
||||
|
||||
PIStringList FileManager::TileDir::selectedNames() const {
|
||||
PIStringList ret;
|
||||
PIMutexLocker ml(e_mutex);
|
||||
PIVector<int> sind = selected.toVector();
|
||||
piForeachC (int i, sind)
|
||||
ret << entries[i].name();
|
||||
@@ -67,6 +68,9 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
pass = true;
|
||||
break;
|
||||
case PIKbdListener::Return:
|
||||
{
|
||||
e_mutex.lock();
|
||||
bool ud = false;
|
||||
if (cur < entries.size_s() && cur >= 0) {
|
||||
if (!remote) {
|
||||
//piCout << entries[cur];
|
||||
@@ -77,11 +81,14 @@ bool FileManager::TileDir::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
cur = cp.first;
|
||||
offset = cp.second;
|
||||
selected.clear();
|
||||
updateDir();
|
||||
ud = true;
|
||||
}
|
||||
}
|
||||
pass = true;
|
||||
}
|
||||
e_mutex.unlock();
|
||||
if (ud) updateDir();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (remote && pass) {
|
||||
@@ -103,6 +110,7 @@ void FileManager::TileDir::unlock() {
|
||||
|
||||
|
||||
void FileManager::TileDir::showReading() {
|
||||
PIMutexLocker ml(e_mutex);
|
||||
cur = -1;
|
||||
offset = 0;
|
||||
entries.clear();
|
||||
@@ -112,6 +120,7 @@ void FileManager::TileDir::showReading() {
|
||||
|
||||
|
||||
void FileManager::TileDir::setContent(const PIVector<PIFile::FileInfo> & l) {
|
||||
PIMutexLocker ml(e_mutex);
|
||||
PIVector<PIFile::FileInfo> el = dir.entries(), fl, dl;
|
||||
entries.clear();
|
||||
if (l.isEmpty()) {
|
||||
@@ -155,6 +164,7 @@ void FileManager::TileDir::updateDir() {
|
||||
void FileManager::TileDir::buildNames() {
|
||||
//if (!enabled) return;
|
||||
lock();
|
||||
PIMutexLocker ml(e_mutex);
|
||||
content.clear();
|
||||
PIChar t;
|
||||
CharFlags cf = 0;
|
||||
|
||||
@@ -54,6 +54,7 @@ private:
|
||||
PIVector<PIFile::FileInfo> entries;
|
||||
PIDir dir;
|
||||
PIMap<PIString, PIPair<int, int> > prev_pos;
|
||||
mutable PIMutex e_mutex;
|
||||
bool resized, remote, remote_mode;
|
||||
void * fm, * key_func;
|
||||
EVENT3(actionRequest, bool, remote_tile, FileManager::Action, type, PIVariant, data)
|
||||
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
ret->content << TileList::Row("Local file manager", CellFormat());
|
||||
ret->content << TileList::Row("Connect to another daemon", CellFormat());
|
||||
ret->content << TileList::Row("Peer info", CellFormat());
|
||||
ret->content << TileList::Row("Peer reinit", CellFormat());
|
||||
ret->content << TileList::Row("Exit", CellFormat());
|
||||
ret->selection_mode = TileList::NoSelection;
|
||||
return ret;
|
||||
@@ -136,21 +137,19 @@ public:
|
||||
", " + PIString::fromNumber(cur_peer)
|
||||
, CellFormat());
|
||||
piForeachC(PIPeer::PeerInfo &p , daemon_.allPeers())
|
||||
peers_tl->content << TileList::Row(p.name + " | " + PIString::fromNumber(p.dist) +
|
||||
" | " + PIString::fromNumber(p.ping()) +
|
||||
" | " + PIString::fromNumber(p.addresses.size_s()) +
|
||||
" | " + PIString::fromBool(p.isNeighbour())
|
||||
, CellFormat());
|
||||
peers_tl->content << TileList::Row(p.name + " | d = " + PIString::fromNumber(p.dist) +
|
||||
" | p = " + PIString::fromNumber(p.ping()) +
|
||||
" | n = " + PIString::fromBool(p.isNeighbour())
|
||||
, CellFormat());
|
||||
PIPeer::PeerInfo pi = daemon_.selfInfo();
|
||||
if (cur_peer >= 0 && cur_peer < daemon_.allPeers().size_s()) pi = daemon_.allPeers()[cur_peer];
|
||||
peerinfo_tl->content << TileSimple::Row("Name: " + pi.name, CellFormat());
|
||||
peerinfo_tl->content << TileSimple::Row("Addreses: " + PIString::fromNumber(pi.addresses.size()), CellFormat());
|
||||
peerinfo_tl->content << TileSimple::Row("Neighbours: " + pi.neighbours.join(", "), CellFormat());
|
||||
piForeachC(PIPeer::PeerInfo::Address &a , pi.addresses)
|
||||
addrs_tl->content << TileList::Row(a.address + " | " + a.netmask +
|
||||
" | " + PIString::fromNumber(a.ping) +
|
||||
" | " + PIString::fromNumber(a.last_ping.toSeconds()) +
|
||||
" | " + PIString::fromBool(a.isAvailable()), CellFormat());
|
||||
addrs_tl->content << TileList::Row(a.address +
|
||||
" | p = " + PIString::fromNumber(a.ping) +
|
||||
" | a = " + PIString::fromBool(a.isAvailable()), CellFormat());
|
||||
typedef PIPair<PIString, PIVector <PIPeer::PeerInfo* > > PeerPair;
|
||||
PIStringList peermap;
|
||||
piForeachC(PeerPair &p , daemon_._peerMap()) {
|
||||
@@ -182,7 +181,8 @@ public:
|
||||
case 1: tfm->show(); break;
|
||||
case 2: daemon_.showMainList(); tdaemon->show(); break;
|
||||
case 3: tpeer->show(); peers_tl->setFocus(); break;
|
||||
case 4: PIKbdListener::exiting = true; break;
|
||||
case 4: daemon_.reinit(); tmenu->show(); break;
|
||||
case 5: PIKbdListener::exiting = true; break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user