/usr/include/qt5qevercloud/AsyncResult.h is in qt5qevercloud-dev 3.0.3+ds-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /**
* Original work: Copyright (c) 2014 Sergey Skoblikov
* Modified work: Copyright (c) 2015-2016 Dmitry Ivanov
*
* This file is a part of QEverCloud project and is distributed under the terms of MIT license:
* https://opensource.org/licenses/MIT
*/
#ifndef QEVERCLOUD_ASYNC_RESULT_H
#define QEVERCLOUD_ASYNC_RESULT_H
#include "qt4helpers.h"
#include "export.h"
#include "EverCloudException.h"
#include <QObject>
#include <QNetworkRequest>
namespace qevercloud {
QT_FORWARD_DECLARE_CLASS(AsyncResultPrivate)
/**
* @brief Returned by asynchonous versions of functions.
*
* Wait for AsyncResult::finished signal.
*
* Intended usage is something like this:
*
* @code
NoteStore* ns;
Note note;
...
QObject::connect(ns->createNoteAsync(note), &AsyncResult::finished, [ns](QVariant result, QSharedPointer<EverCloudExceptionData> error) {
if(!error.isNull()) {
// do something in case of an error
} else {
Note note = result.value<Note>();
// process returned result
}
});
@endcode
*/
class QEVERCLOUD_EXPORT AsyncResult: public QObject
{
Q_OBJECT
Q_DISABLE_COPY(AsyncResult)
private:
static QVariant asIs(QByteArray replyData);
public:
typedef QVariant (*ReadFunctionType)(QByteArray replyData);
AsyncResult(QString url, QByteArray postData, ReadFunctionType readFunction = AsyncResult::asIs,
bool autoDelete = true, QObject * parent = Q_NULLPTR);
AsyncResult(QNetworkRequest request, QByteArray postData, ReadFunctionType readFunction = AsyncResult::asIs,
bool autoDelete = true, QObject * parent = Q_NULLPTR);
~AsyncResult();
/**
* @brief Wait for asyncronous operation to complete.
* @param timeout
* Maximum time to wait in milliseconds. Forever if < 0.
* @return true if finished succesfully, flase in case of the timeout
*/
bool waitForFinished(int timeout = -1);
Q_SIGNALS:
/**
* @brief Emitted upon asyncronous call completition.
* @param result
* @param error
* error.isNull() != true in case of an error. See EverCloudExceptionData for more details.
*
* AsyncResult deletes itself after emitting this signal. You don't have to manage it's lifetime explicitly.
*/
void finished(QVariant result, QSharedPointer<EverCloudExceptionData> error);
private Q_SLOTS:
void onReplyFetched(QObject * rp);
void start();
private:
AsyncResultPrivate * const d_ptr;
Q_DECLARE_PRIVATE(AsyncResult)
};
} // namespace qevercloud
#endif // QEVERCLOUD_ASYNC_RESULT_H
|