File: sourcemanager.h

package info (click to toggle)
dde-store 1.2.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 724 kB
  • sloc: cpp: 2,048; makefile: 5
file content (81 lines) | stat: -rw-r--r-- 1,967 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
74
75
76
77
78
79
80
81
#ifndef SOURCE_H
#define SOURCE_H

#include <QObject>
#include <QIcon>

struct App;

class Source : public QObject
{
    Q_OBJECT

public:
    virtual QString name() = 0;
    virtual void getInstalled() = 0;
    virtual void getUpdates(bool refreshCache = false) = 0;
    virtual void getFullData(App *app) = 0;
    virtual void install(App *app) = 0;
    virtual void uninstall(App *app) = 0;
    virtual void launch(App *app) = 0;
    virtual void search(QString query) = 0;
    virtual void update() = 0;
    virtual QStringList urlSchemes() = 0;
    virtual App *appFromUrl(QUrl url) = 0;
    void error(QString text);
    bool preventingClose = false;

signals:
    void gotInstalled(QList<App*> installed);
    void gotUpdates(QList<App*> updates);
    void gotFullData(App *app);
    void percentageChanged(App *app, int percentage);
    void installFinished(App *app);
    void uninstallFinished(App *app);
    void searchFinished(QList<App*> results);
    void updateFinished();
    void stateChanged(App *app);

};

Q_DECLARE_INTERFACE(Source, "org.dekzi.dde-store.SourceInterface")

struct App
{
    Source *source;
    QString id;
    QString package;
    QString name;
    QIcon icon;
    QString description;
    QString developer;
    QList<QUrl> screenshots;
    int ratings;
    qulonglong downloadSize;
    bool fullData = false;
    bool hasMetadata;
    enum State { Installed, Installing, NotInstalled, Launchable } state;
    void install() { source->install(this); };
    void uninstall() { source->uninstall(this); };
    void launch() { source->launch(this); };
    void getFullData() { source->getFullData(this); };
};

class SourceManager : public QObject
{
    Q_OBJECT

public:
    static SourceManager *instance();
    QList<Source*> sources();
    Source *getSource(QString name);
    bool preventingClose();

private:
    SourceManager();
    static SourceManager *currentInstance;
    QList<Source*> m_sources;

};

#endif // SOURCE_H