~ubuntu-branches/ubuntu/saucy/kget/saucy

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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* This file is part of the KDE project

   Copyright (C) 2009 Lukas Appelhans <l.appelhans@gmx.de>
   Copyright (C) 2009 Matthias Fuchs <mat69@gmx.net>

   This program 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 2 of the License, or (at your option) any later version.
*/
#ifndef DBUSTRANSFERWRAPPER_H
#define DBUSTRANSFERWRAPPER_H

#include "core/transferhandler.h"

#include <QDBusVariant>

class TransferHandler;

class DBusTransferWrapper : public QObject
{
    Q_OBJECT
    public:
        DBusTransferWrapper(TransferHandler * parent);
        ~DBusTransferWrapper();

    public slots:
        int capabilities() const;
        void start();
        void stop();
        int status() const;
        int elapsedTime() const;
        int remainingTime() const;

        /**
         * @return the transfer's group's name
         */
        QString groupName() const;

        /**
         * @return the source url
         */
        QString source() const;

        /**
         * @return the dest url
         */
        QString dest() const;

        /**
         * Move the download to the new destination
         * @param newDirectory is a directory where the download should be stored
         * @returns true if newDestination can be used
         */
        bool setDirectory(const QString &directory);

        /**
         * @return the total size of the transfer in bytes
         */
        qulonglong totalSize() const;

        /**
         * @return the downloaded size of the transfer in bytes
         */
        qulonglong downloadedSize() const;

        /**
         * @return the uploaded size of the transfer in bytes
         */
        qulonglong uploadedSize() const;

        /**
         * @return the progress percentage of the transfer
         */
        int percent() const;

        /**
         * @return the download speed of the transfer in bytes/sec
         */
        int downloadSpeed() const;

        /**
         * @return the upload speed of the transfer in bytes/sec
         */
        int uploadSpeed() const;

        /**
         * Set an UploadLimit for the transfer
         * @note this UploadLimit is not visible in the GUI
         * @param ulLimit upload Limit
         */
        void setUploadLimit(int ulLimit, int limit);

        /**
         * Set a DownloadLimit for the transfer
         * @note this DownloadLimit is not visible in the GUI
         * @param dlLimit download Limit
         */
        void setDownloadLimit(int dlLimit, int limit);

        /**
         * @return the upload Limit of the transfer in KiB
         */
        int uploadLimit(int limit) const;

        /**
         * @return the download Limit of the transfer in KiB
         */
        int downloadLimit(int limit) const;

        /**
         * Set the maximum share-ratio
         * @param ratio the new maximum share-ratio
         */
        void setMaximumShareRatio(double ratio);

        /**
         * @return the maximum share-ratio
         */
        double maximumShareRatio();

        /**
         * @return a string describing the current transfer status
         */
        QString statusText() const;

        /**
         * @return a pixmap associated with the current transfer status
         */
        QDBusVariant statusPixmap() const;

        /**
         * Returns the dBusObjectPath to the verifier
         * @param file for wich to return the verifier
         */
        QString verifier(const QString &file);

        /**
         * Tries to repair file
         * @param file the file of a download that should be repaired,
         * if not defined all files of a download are going to be repaird
         * @return true if a repair started, false if it was not nescessary
         */
        bool repair(const QString &file);

    signals:
        /**
         * Emitted when the transfer changes
         */
        void transferChangedEvent(int transferChange);

        /**
         * Emitted whe the capabilities of the transfer changes
         */
        void capabilitiesChanged();

    private slots:
        void slotTransferChanged(TransferHandler *transfer, TransferHandler::ChangesFlags changeflags);

    private:
        TransferHandler *m_transfer;
};

#endif