KIO

storedtransferjob.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org>
4 SPDX-FileCopyrightText: 2000-2009 David Faure <faure@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KIO_STOREDTRANSFERJOB
10#define KIO_STOREDTRANSFERJOB
11
12#include "transferjob.h"
13
14namespace KIO
15{
16class StoredTransferJobPrivate;
17/**
18 * @class KIO::StoredTransferJob storedtransferjob.h <KIO/StoredTransferJob>
19 *
20 * StoredTransferJob is a TransferJob (for downloading or uploading data) that
21 * also stores a QByteArray with the data, making it simpler to use than the
22 * standard TransferJob.
23 *
24 * For KIO::storedGet it puts the data into the member QByteArray, so the user
25 * of this class can get hold of the whole data at once by calling data()
26 * when the result signal is emitted.
27 * You should only use StoredTransferJob to download data if you cannot
28 * process the data by chunks while it's being downloaded, since storing
29 * everything in a QByteArray can potentially require a lot of memory.
30 *
31 * For KIO::storedPut the user of this class simply provides the bytearray from
32 * the start, and the job takes care of uploading it.
33 * You should only use StoredTransferJob to upload data if you cannot
34 * provide the in chunks while it's being uploaded, since storing
35 * everything in a QByteArray can potentially require a lot of memory.
36 */
37class KIOCORE_EXPORT StoredTransferJob : public KIO::TransferJob
38{
39 Q_OBJECT
40
41public:
42 ~StoredTransferJob() override;
43
44 /**
45 * Set data to be uploaded. This is for put jobs.
46 * Automatically called by KIO::storedPut(const QByteArray &, ...),
47 * do not call this yourself.
48 */
49 void setData(const QByteArray &arr);
50
51 /**
52 * Get hold of the downloaded data. This is for get jobs.
53 * You're supposed to call this only from the slot connected to the result() signal.
54 */
55 QByteArray data() const;
56
57protected:
58 KIOCORE_NO_EXPORT explicit StoredTransferJob(StoredTransferJobPrivate &dd);
59
60private:
61 Q_DECLARE_PRIVATE(StoredTransferJob)
62};
63
64/**
65 * Get (means: read), into a single QByteArray.
66 * @see StoredTransferJob
67 *
68 * @param url the URL of the file
69 * @param reload Reload to reload the file, NoReload if it can be taken from the cache
70 * @param flags Can be HideProgressInfo here
71 * @return the job handling the operation.
72 */
73KIOCORE_EXPORT StoredTransferJob *storedGet(const QUrl &url, LoadType reload = NoReload, JobFlags flags = DefaultFlags);
74
75/**
76 * Put (means: write) data from a QIODevice.
77 * @see StoredTransferJob
78 *
79 * @param input The data to write, a device to read from. Must be open for reading (data will be read from the current position).
80 * @param url Where to write data.
81 * @param permissions May be -1. In this case no special permission mode is set.
82 * @param flags Can be HideProgressInfo, Overwrite and Resume here. WARNING:
83 * Setting Resume means that the data will be appended to @p dest if @p dest exists.
84 * @return the job handling the operation.
85 *
86 * @since 5.10
87 */
88KIOCORE_EXPORT StoredTransferJob *storedPut(QIODevice *input, const QUrl &url, int permissions, JobFlags flags = DefaultFlags);
89
90/**
91 * Put (means: write) data from a single QByteArray.
92 * @see StoredTransferJob
93 *
94 * @param arr The data to write
95 * @param url Where to write data.
96 * @param permissions May be -1. In this case no special permission mode is set.
97 * @param flags Can be HideProgressInfo, Overwrite and Resume here. WARNING:
98 * Setting Resume means that the data will be appended to @p dest if @p dest exists.
99 * @return the job handling the operation.
100 */
101KIOCORE_EXPORT StoredTransferJob *storedPut(const QByteArray &arr, const QUrl &url, int permissions, JobFlags flags = DefaultFlags);
102
103/**
104 * HTTP POST (means: write) data from a single QByteArray.
105 * @see StoredTransferJob
106 *
107 * @param arr The data to write
108 * @param url Where to write data.
109 * @param flags Can be HideProgressInfo here.
110 * @return the job handling the operation.
111 */
112KIOCORE_EXPORT StoredTransferJob *storedHttpPost(const QByteArray &arr, const QUrl &url, JobFlags flags = DefaultFlags);
113/**
114 * HTTP POST (means: write) data from the given IO device.
115 * @see StoredTransferJob
116 *
117 * @param device Device from which the encoded data to be posted is read. Must be open for reading.
118 * @param url Where to write data.
119 * @param size Size of the encoded data to be posted.
120 * @param flags Can be HideProgressInfo here.
121 * @return the job handling the operation.
122 *
123 */
124KIOCORE_EXPORT StoredTransferJob *storedHttpPost(QIODevice *device, const QUrl &url, qint64 size = -1, JobFlags flags = DefaultFlags);
125
126}
127
128#endif
StoredTransferJob is a TransferJob (for downloading or uploading data) that also stores a QByteArray ...
The transfer job pumps data into and/or out of a KIO worker.
A namespace for KIO globals.
KIOCORE_EXPORT StoredTransferJob * storedGet(const QUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
Get (means: read), into a single QByteArray.
KIOCORE_EXPORT StoredTransferJob * storedHttpPost(const QByteArray &arr, const QUrl &url, JobFlags flags=DefaultFlags)
HTTP POST (means: write) data from a single QByteArray.
KIOCORE_EXPORT StoredTransferJob * storedPut(QIODevice *input, const QUrl &url, int permissions, JobFlags flags=DefaultFlags)
Put (means: write) data from a QIODevice.
@ DefaultFlags
Show the progress info GUI, no Resume and no Overwrite.
Definition job_base.h:246
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.