File: fileviewdropboxplugin.h

package info (click to toggle)
dolphin-plugins 4%3A25.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,572 kB
  • sloc: cpp: 10,497; xml: 177; sh: 10; makefile: 3
file content (73 lines) | stat: -rw-r--r-- 2,239 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
    SPDX-FileCopyrightText: 2014 Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
    SPDX-FileCopyrightText: 2012 Sergei Stolyarov <sergei@regolit.com>
    SPDX-FileCopyrightText: 2010 Thomas Richard <thomas.richard@proan.be>
    SPDX-FileCopyrightText: 2009-2010 Peter Penz <peter.penz19@gmail.com>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef FILEVIEWDROPBOXPLUGIN_H
#define FILEVIEWDROPBOXPLUGIN_H

#include <Dolphin/KVersionControlPlugin>

#include <QMap>

class QLocalSocket;

// The dropbox protocol info can be found in the dropboxd-protocol file
// it can be found here https://build.opensuse.org/package/view_file/home:faco84/dolphin-box-plugin/dropboxd-protocol
// Thanks Steffen Schuldenzucker!

/**
 * @brief Dropbox implementation for the KVersionControlPlugin interface.
 */
class FileViewDropboxPlugin : public KVersionControlPlugin
{
    Q_OBJECT

private:
    enum SendCommandMode {
        WaitForReply,
        SendCommandOnly,
    };

    enum SendCommandTimeout {
        ShortTimeout,
        LongTimeout,
    };

public:
    FileViewDropboxPlugin(QObject *parent, const QVariantList &args);
    ~FileViewDropboxPlugin() override;

    QString fileName() const override;

    bool beginRetrieval(const QString &directory) override;
    KVersionControlPlugin::ItemVersion itemVersion(const KFileItem &item) const override;
    void endRetrieval() override;

    QList<QAction *> versionControlActions(const KFileItemList &items) const override;
    QList<QAction *> outOfVersionControlActions(const KFileItemList &items) const override;

private Q_SLOTS:
    void handleContextAction(QAction *action);

private:
    QStringList sendCommand(const QString &command,
                            const QStringList &paths,
                            const QPointer<QLocalSocket> &socket,
                            SendCommandMode mode = SendCommandOnly,
                            SendCommandTimeout timeout = ShortTimeout) const;

    bool connectWithDropbox(const QPointer<QLocalSocket> &socket, SendCommandTimeout timeout) const;

private:
    class Private;
    Private *const d;

    static QMap<QString, KVersionControlPlugin::ItemVersion> m_itemVersions;
};

#endif // FILEVIEWDROPBOXPLUGIN_H