MRCI/src/commands/fs.h
Maurice ONeal 72d57a0b10 Major upgrade and module interface changes
Made some major changes to the project to facilitate a lighter code base and the
must flexible module interface possible.

-the mutli-process architecture now operate at the command object level so each
 command now operate in it's own process instead of a single process handling
 multiple command objects.

-each module is now an independent application that will now tell the session
 object all of the commands it can run via named pipe. during command execution,
 it will run the requested command object also running io with the session object
 via named pipe.

 with this change, it is now possible for modules to be developed in different
 versions or QT or entirely different languages. the only requirement is the need
 to support named pipes. shared memory segments is also a nice to have but not
 needed.

-clients can now run multiple instances of the same command via changes to the
 protocol. mrci frames will now include a branch id along with the command id.
 the branch id can be used by clients to differentiate the io between instances
 of the same command.

-the command states are longer controlled by a single object. it will now be up
 to the command object (internal/exterenal) to send an IDLE frame to the client
 to notify it that the command has finished. the session object will still track
 if the command is in idle state or not but not directly control it.

-must async commands now use binary formatted data instead of TEXT as a way to
 reduce overhead.

-all command objects can now send async commands. it is no longer limited to just
 internal commands, however; the data of these async commands are verified by
 session in some way to prevent host crashing due to malformed data.

-changed up the database structure to rely more on user ids, channel ids and
 removed all foreign keys pointing to user names, channel names and sub-channel
 names. also removed the groups table altogether. instead, the host rank is now
 directly attached to the user data in the users table.

-changed the query object to now support the INNER JOIN SQL clause. this change
 was needed to support the new database structure.

-version negotiation is now one-way via tcp connection or module interface.
 the host will make it's own verion numner known to the client connected via
 tcp or the module connected via named pipe. it will now be entirely up to the
 client or module to decide if they support the host. another change in this
 regard is the removal of the import rev for the modules. compatibility for
 modules shall now use just the host verion.

-removed ls_cmds and cmd_info. the NEW_CMD frame now carries all information
 about the command (cmd_id, cmd_name, summery, io and full_description) so it
 is now possible for the clients to display the command documentation instead
 of the host.

Documentation for the internal commands were updated to reflect the changes but
all other documentation will need to be updated in the near future.
2019-11-08 22:06:09 -05:00

246 lines
4.5 KiB
C++

#ifndef FS_H
#define FS_H
// This file is part of MRCI.
// MRCI is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// MRCI is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with MRCI under the LICENSE.md file. If not, see
// <http://www.gnu.org/licenses/>.
#include "../common.h"
#include "../cmd_object.h"
QByteArray toFILE_INFO(const QString &path);
QByteArray toFILE_INFO(const QFileInfo &info);
void mkPathForFile(const QString &path);
class DownloadFile : public CmdObject
{
Q_OBJECT
private:
QFile *file;
qint64 buffSize;
qint64 len;
qint64 dataSent;
void sendChunk();
public:
static QString cmdName();
void clear();
void procIn(const QByteArray &binIn, quint8 dType);
explicit DownloadFile(QObject *parent = nullptr);
};
//-----------------------
class UploadFile : public CmdObject
{
Q_OBJECT
private:
QFile::OpenMode mode;
QFile *file;
qint64 len;
qint64 dataReceived;
bool ssMode;
bool confirm;
bool force;
void wrToFile(const QByteArray &data);
void run();
void ask();
public:
static QString cmdName();
void clear();
void procIn(const QByteArray &binIn, quint8 dType);
explicit UploadFile(QObject *parent = nullptr);
};
//-----------------------
class Delete : public CmdObject
{
Q_OBJECT
private:
void ask();
void run();
QString path;
public:
static QString cmdName();
void procIn(const QByteArray &binIn, uchar dType);
explicit Delete(QObject *parent = nullptr);
};
//------------------------
class Copy : public CmdObject
{
Q_OBJECT
protected:
void ask();
void run();
QFile *src;
QFile *dst;
bool procedAFile;
bool fromQueue;
bool yToAll;
bool nToAll;
QString dstPath;
QString srcPath;
QString oriSrcPath;
QList<QPair<QString,QString> > queue;
virtual bool matchingVolumeMatters();
virtual bool permissionsOk(bool dstExists);
virtual void runOnMatchingVolume() {}
virtual void postProcFile() {}
virtual void preFinish() {}
public:
static QString cmdName();
void clear();
void procIn(const QByteArray &binIn, quint8 dType);
explicit Copy(QObject *parent = nullptr);
};
//------------------------
class Move : public Copy
{
Q_OBJECT
private:
bool matchingVolumeMatters();
bool permissionsOk(bool dstExists);
void runOnMatchingVolume();
void postProcFile();
void preFinish();
public:
static QString cmdName();
explicit Move(QObject *parent = nullptr);
};
//-----------------------
class MakePath : public CmdObject
{
Q_OBJECT
public:
static QString cmdName();
void procIn(const QByteArray &binIn, quint8 dType);
explicit MakePath(QObject *parent = nullptr);
};
//-----------------------
class ListFiles : public CmdObject
{
Q_OBJECT
public:
static QString cmdName();
void procIn(const QByteArray &binIn, quint8 dType);
explicit ListFiles(QObject *parent = nullptr);
};
//-----------------------
class FileInfo : public CmdObject
{
Q_OBJECT
public:
static QString cmdName();
void procIn(const QByteArray &binIn, quint8 dType);
explicit FileInfo(QObject *parent = nullptr);
};
//-----------------------
class ChangeDir : public CmdObject
{
Q_OBJECT
public:
static QString cmdName();
void procIn(const QByteArray &binIn, quint8 dType);
explicit ChangeDir(QObject *parent = nullptr);
};
//--------------------------
class Tree : public CmdObject
{
Q_OBJECT
private:
QFileInfoList queue;
bool infoFrames;
bool noHidden;
void printList(const QString &path);
public:
static QString cmdName();
void clear();
void procIn(const QByteArray &binIn, quint8 dType);
explicit Tree(QObject *parent = nullptr);
};
#endif // FS_H