git-svn-id: svn://db.shs.com.ru/pip@236 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "daemon.h"
|
||||
#include "shared.h"
|
||||
#include "pisysteminfo.h"
|
||||
#include "picrypt.h"
|
||||
|
||||
const char self_name[] = "__self__";
|
||||
extern PIScreen screen;
|
||||
@@ -43,7 +44,7 @@ void Daemon::Remote::run() {
|
||||
case RemoveFiles:
|
||||
::removeFiles(d, _fl);
|
||||
updateDirEntries();
|
||||
removeFinished(name(), d.absolutePath());
|
||||
changeDirFinished(name(), d.absolutePath());
|
||||
break;
|
||||
case RequestChangeDir:
|
||||
updateDirEntries();
|
||||
@@ -54,6 +55,15 @@ void Daemon::Remote::run() {
|
||||
updateDirEntries();
|
||||
changeDirFinished(name(), d.absolutePath());
|
||||
break;
|
||||
case CryptFiles:
|
||||
piCoutObj << "CryptFiles";
|
||||
if (!_fl.isEmpty()) {
|
||||
PIString p = askUserInput("Password:");
|
||||
::cryptFiles(d, _fl, PICrypt::hash(p));
|
||||
}
|
||||
updateDirEntries();
|
||||
changeDirFinished(name(), d.absolutePath());
|
||||
break;
|
||||
default: break;
|
||||
};
|
||||
}
|
||||
@@ -208,6 +218,7 @@ Daemon::Daemon(): inited__(false), PIPeer(pisd_prefix + PISystemInfo::instance()
|
||||
CONNECTU(_self, sendRequest, this, localSend)
|
||||
CONNECTU(_self, receiveFinished, this, closeFileDialog)
|
||||
CONNECTU(_self, sendFinished, this, closeFileDialog)
|
||||
CONNECTU(_self, changeDirFinished, this, dirChanged)
|
||||
localft.setName(self_name);
|
||||
CONNECTU(&localft, sendRequest, _self, received)
|
||||
dtimer.addDelimiter(5);
|
||||
@@ -393,7 +404,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 && type != FileManager::LocalCopy) return;
|
||||
if (!r && type != FileManager::LocalCopy && type != FileManager::LocalCrypt) return;
|
||||
switch (type) {
|
||||
case FileManager::Copy:
|
||||
if (remote_tile) {
|
||||
@@ -435,6 +446,25 @@ void Daemon::fmActionRequest(bool remote_tile, FileManager::Action type, PIVaria
|
||||
}
|
||||
tile_file_progress->rec = false;
|
||||
tile_file_progress->show(&(_self->ft));
|
||||
case FileManager::Crypt:
|
||||
if (remote_tile) {
|
||||
PIByteArray ba;
|
||||
ba << int(CryptFiles) << fm.selectedRemote();
|
||||
send(conn_name, ba);
|
||||
} else {
|
||||
_self->dir_my.setDir(fm.localDir());
|
||||
_self->cryptFiles(data.toStringList());
|
||||
}
|
||||
break;
|
||||
case FileManager::LocalCrypt:
|
||||
piCoutObj << "LocalCrypt";
|
||||
if (remote_tile) {
|
||||
_self->dir_my.setDir(fm.remoteDir());
|
||||
} else {
|
||||
_self->dir_my.setDir(fm.localDir());
|
||||
}
|
||||
_self->cryptFiles(data.toStringList());
|
||||
break;
|
||||
default: break;
|
||||
};
|
||||
//piCout << remote_tile << type << data;
|
||||
@@ -502,7 +532,6 @@ void Daemon::peerConnected(const PIString & p_name) {
|
||||
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 ml2(remote_mutex);
|
||||
remotes.insert(p_name, r);
|
||||
@@ -535,15 +564,13 @@ void Daemon::filesReceived(const PIString & p_name, bool ok) {
|
||||
|
||||
|
||||
void Daemon::dirChanged(const PIString & p_name, const PIString & dir) {
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
Remote * r = remotes.value(p_name, 0);
|
||||
if (!r) return;
|
||||
if (r->dir_my.absolutePath() != dir) return;
|
||||
sendDirToRemote(r);
|
||||
}
|
||||
|
||||
|
||||
void Daemon::filesRemoved(const PIString & p_name, const PIString & dir) {
|
||||
if (p_name == self_name) {
|
||||
fm.clearSelectionLocal();
|
||||
fm.clearSelectionRemote();
|
||||
fm.updateLocalDir();
|
||||
fm.updateRemoteDir();
|
||||
return;
|
||||
}
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
Remote * r = remotes.value(p_name, 0);
|
||||
if (!r) return;
|
||||
@@ -652,6 +679,15 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
||||
case FileTransfer:
|
||||
if (r) r->received(ba);
|
||||
break;
|
||||
case CryptFiles:
|
||||
if (!r) return;
|
||||
if (r->isRunning()) return;
|
||||
{
|
||||
PIStringList files;
|
||||
ba >> files;
|
||||
r->cryptFiles(files);
|
||||
}
|
||||
break;
|
||||
};
|
||||
if (!rba.isEmpty()) send(from, rba);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user