File indexing completed on 2024-04-28 09:46:12

0001 /***************************************************************************
0002  *   Copyright (C) 2016 by Arnav Dhamija <arnav.dhamija@gmail.com>         *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
0018  ***************************************************************************/
0019 
0020 #ifndef STASHNOTIFIER_H
0021 #define STASHNOTIFIER_H
0022 
0023 #include "fs.h"
0024 
0025 #include <QStringList>
0026 #include <QVariant>
0027 
0028 #include <KDEDModule>
0029 
0030 class KDirWatch;
0031 
0032 class StashNotifier : public KDEDModule
0033 {
0034     Q_OBJECT
0035     Q_CLASSINFO("D-Bus Interface", "org.kde.kio.StashNotifier")
0036 
0037 private:
0038     KDirWatch *dirWatch;
0039     StashFileSystem *fileSystem;
0040     const QString m_daemonService;
0041     const QString m_daemonPath;
0042     QString processString(const QString &path);
0043     QString encodeString(StashFileSystem::StashNode::iterator node, const QString &path);
0044     QString encodeString(StashFileSystem::StashNodeData nodeData, const QString &path);
0045 
0046 public:
0047     StashNotifier(QObject *parent,
0048                   const QList<QVariant> &,
0049                   const QString &daemonService = "org.kde.kio.StashNotifier",
0050                   const QString &daemonPath = "/StashNotifier");
0051     ~StashNotifier();
0052 
0053 Q_SIGNALS:
0054     Q_SCRIPTABLE void listChanged();
0055 
0056 public Q_SLOTS:
0057     Q_SCRIPTABLE void addPath(const QString &source, const QString &stashPath, int fileType);
0058     Q_SCRIPTABLE void removePath(const QString &path);
0059     Q_SCRIPTABLE void nukeStash();
0060     Q_SCRIPTABLE void pingDaemon();
0061     Q_SCRIPTABLE bool copyWithStash(const QString &src, const QString &dest);
0062     Q_SCRIPTABLE QStringList fileList(const QString &path);
0063     Q_SCRIPTABLE QString fileInfo(const QString &path);
0064 
0065 private Q_SLOTS:
0066     void dirty(const QString &path);
0067     void created(const QString &path);
0068     void removeWatchedPath(const QString &filePath);
0069     void displayRoot() // function to the contents of the SFS for testing
0070     {
0071         // fileSystem->displayRoot();
0072     }
0073 };
0074 
0075 #endif