aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-08-20 18:10:46 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-08-20 18:10:46 +0900
commit92614294a89c1f450b82c2b6e35614cf124dc344 (patch)
treee7dc69dc683e6139d7a15fa383d1948ff2332c85 /lib/connection.h
parent8629748c5c609882486d25d989becfe0ae2352ed (diff)
downloadlibquotient-92614294a89c1f450b82c2b6e35614cf124dc344.tar.gz
libquotient-92614294a89c1f450b82c2b6e35614cf124dc344.zip
Connection::run()
Finally, clients can pre-create job objects and then separately submit them for execution on a given connection - previously such separation was a privilege of Connection (others had to use Connection::callApi<>, which invoked jobs right away).
Diffstat (limited to 'lib/connection.h')
-rw-r--r--lib/connection.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/connection.h b/lib/connection.h
index c807b827..7e32e5c9 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -37,6 +37,8 @@ class Account;
}
namespace Quotient {
+Q_NAMESPACE
+
class Room;
class User;
class ConnectionData;
@@ -89,10 +91,12 @@ static inline user_factory_t defaultUserFactory()
/** Enumeration with flags defining the network job running policy
* So far only background/foreground flags are available.
*
- * \sa Connection::callApi
+ * \sa Connection::callApi, Connection::run
*/
enum RunningPolicy { ForegroundRequest = 0x0, BackgroundRequest = 0x1 };
+Q_ENUM_NS(RunningPolicy)
+
class Connection : public QObject {
Q_OBJECT
@@ -352,9 +356,12 @@ public:
bool lazyLoading() const;
void setLazyLoading(bool newValue);
- /** Start a job of a specified type with specified arguments and policy
+ /*! Start a pre-created job object on this connection */
+ void run(BaseJob* job, RunningPolicy runningPolicy = ForegroundRequest) const;
+
+ /*! Start a job of a specified type with specified arguments and policy
*
- * This is a universal method to start a job of a type passed
+ * This is a universal method to create and start a job of a type passed
* as a template parameter. The policy allows to fine-tune the way
* the job is executed - as of this writing it means a choice
* between "foreground" and "background".
@@ -368,14 +375,13 @@ public:
JobT* callApi(RunningPolicy runningPolicy, JobArgTs&&... jobArgs) const
{
auto job = new JobT(std::forward<JobArgTs>(jobArgs)...);
- connect(job, &BaseJob::failure, this, &Connection::requestFailed);
- job->start(connectionData(), runningPolicy & BackgroundRequest);
+ run(job, runningPolicy);
return job;
}
- /** Start a job of a specified type with specified arguments
+ /*! Start a job of a specified type with specified arguments
*
- * This is an overload that calls the job with "foreground" policy.
+ * This is an overload that runs the job with "foreground" policy.
*/
template <typename JobT, typename... JobArgTs>
JobT* callApi(JobArgTs&&... jobArgs) const