File indexing completed on 2025-04-13 07:38:14
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2009 Lukas Appelhans <l.appelhans@gmx.de> 0004 Copyright (C) 2009 Matthias Fuchs <mat69@gmx.net> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 */ 0011 #ifndef DBUSTRANSFERWRAPPER_H 0012 #define DBUSTRANSFERWRAPPER_H 0013 0014 #include "core/transferhandler.h" 0015 0016 #include <QDBusVariant> 0017 0018 class TransferHandler; 0019 0020 class DBusTransferWrapper : public QObject 0021 { 0022 Q_OBJECT 0023 public: 0024 explicit DBusTransferWrapper(TransferHandler *parent); 0025 ~DBusTransferWrapper() override; 0026 0027 public Q_SLOTS: 0028 int capabilities() const; 0029 void start(); 0030 void stop(); 0031 int status() const; 0032 int elapsedTime() const; 0033 int remainingTime() const; 0034 0035 /** 0036 * @return the transfer's group's name 0037 */ 0038 QString groupName() const; 0039 0040 /** 0041 * @return the source url 0042 */ 0043 QString source() const; 0044 0045 /** 0046 * @return the dest url 0047 */ 0048 QString dest() const; 0049 0050 /** 0051 * Move the download to the new destination 0052 * @param directory a directory where the download should be stored 0053 * @returns true if newDestination can be used 0054 */ 0055 bool setDirectory(const QString &directory); 0056 0057 /** 0058 * @return the total size of the transfer in bytes 0059 */ 0060 qulonglong totalSize() const; 0061 0062 /** 0063 * @return the downloaded size of the transfer in bytes 0064 */ 0065 qulonglong downloadedSize() const; 0066 0067 /** 0068 * @return the uploaded size of the transfer in bytes 0069 */ 0070 qulonglong uploadedSize() const; 0071 0072 /** 0073 * @return the progress percentage of the transfer 0074 */ 0075 int percent() const; 0076 0077 /** 0078 * @return the download speed of the transfer in bytes/sec 0079 */ 0080 int downloadSpeed() const; 0081 0082 /** 0083 * @return the upload speed of the transfer in bytes/sec 0084 */ 0085 int uploadSpeed() const; 0086 0087 /** 0088 * Set an UploadLimit for the transfer 0089 * @note this UploadLimit is not visible in the GUI 0090 * @param ulLimit upload Limit 0091 * @param limit the type of the upload limit 0092 */ 0093 void setUploadLimit(int ulLimit, int limit); 0094 0095 /** 0096 * Set a DownloadLimit for the transfer 0097 * @note this DownloadLimit is not visible in the GUI 0098 * @param dlLimit download Limit 0099 * @param limit the type of the download limit 0100 */ 0101 void setDownloadLimit(int dlLimit, int limit); 0102 0103 /** 0104 * @return the upload Limit of the transfer in KiB 0105 */ 0106 int uploadLimit(int limit) const; 0107 0108 /** 0109 * @return the download Limit of the transfer in KiB 0110 */ 0111 int downloadLimit(int limit) const; 0112 0113 /** 0114 * Set the maximum share-ratio 0115 * @param ratio the new maximum share-ratio 0116 */ 0117 void setMaximumShareRatio(double ratio); 0118 0119 /** 0120 * @return the maximum share-ratio 0121 */ 0122 double maximumShareRatio(); 0123 0124 /** 0125 * @return a string describing the current transfer status 0126 */ 0127 QString statusText() const; 0128 0129 /** 0130 * @return a pixmap associated with the current transfer status 0131 */ 0132 QDBusVariant statusPixmap() const; 0133 0134 /** 0135 * Returns the dBusObjectPath to the verifier 0136 * @param file for which to return the verifier 0137 */ 0138 QString verifier(const QString &file); 0139 0140 /** 0141 * Tries to repair file 0142 * @param file the file of a download that should be repaired, 0143 * if not defined all files of a download are going to be repaired 0144 * @return true if a repair started, false if it was not necessary 0145 */ 0146 bool repair(const QString &file); 0147 0148 Q_SIGNALS: 0149 /** 0150 * Emitted when the transfer changes 0151 */ 0152 void transferChangedEvent(int transferChange); 0153 0154 /** 0155 * Emitted whe the capabilities of the transfer changes 0156 */ 0157 void capabilitiesChanged(); 0158 0159 private Q_SLOTS: 0160 void slotTransferChanged(TransferHandler *transfer, TransferHandler::ChangesFlags changeflags); 0161 0162 private: 0163 TransferHandler *m_transfer; 0164 }; 0165 0166 #endif