138 Q_ASSERT(m_thread.hasFunction() &&
"Call setWorkerFunction() before run()");
143 static_assert(std::tuple_size<T_result>::value > 2,
144 "Result tuple too small");
145 static_assert(std::is_same <
146 typename std::tuple_element <
147 std::tuple_size<T_result>::value - 2,
152 "Second to last result type not a QString");
153 static_assert(std::is_same <
154 typename std::tuple_element <
155 std::tuple_size<T_result>::value - 1,
160 "Last result type not a GpgME::Error");
163 : T_base(
nullptr), m_ctx(
ctx), m_thread(), m_auditLog(), m_auditLogError()
167 void lateInitialization()
170 QObject::connect(&m_thread, &QThread::finished,
this,
171 &mixin_type::slotFinished);
172 m_ctx->setProgressProvider(
this);
173 QGpgME::g_context_map.insert(
this, m_ctx.get());
178 QGpgME::g_context_map.remove(
this);
181 template <
typename T_binder>
184 m_thread.setFunction([
this,
func]() {
return func(this->context()); });
188 template <
typename T_binder>
191 m_thread.setFunction(std::bind(
func, this->context()));
194 template <
typename T_binder>
195 void run(
const T_binder &
func,
const std::shared_ptr<QIODevice> &
io)
198 io->moveToThread(&m_thread);
204 m_thread.setFunction(std::bind(
func, this->context(), this->
thread(), std::weak_ptr<QIODevice>(
io)));
207 template <
typename T_binder>
208 void run(
const T_binder &
func,
const std::shared_ptr<QIODevice> &
io1,
const std::shared_ptr<QIODevice> &
io2)
211 io1->moveToThread(&m_thread);
214 io2->moveToThread(&m_thread);
220 m_thread.setFunction(std::bind(
func, this->context(), this->
thread(), std::weak_ptr<QIODevice>(
io1), std::weak_ptr<QIODevice>(
io2)));
225 GpgME::Context *context()
const
235 m_auditLog = std::get < std::tuple_size<T_result>::value - 2 > (
r);
236 m_auditLogError = std::get < std::tuple_size<T_result>::value - 1 > (
r);
242 void slotCancel()
override {
245 m_ctx->cancelPendingOperation();
248 QString auditLogAsHtml()
const override
252 GpgME::Error auditLogError()
const override
254 return m_auditLogError;
256 void showProgress(
const char *
what,
258 QMetaObject::invokeMethod(
this, [
this,
current,
total]() {
260 }, Qt::QueuedConnection);
264 }, Qt::QueuedConnection);
270 }, Qt::QueuedConnection);
273 template <
typename T1,
typename T2>
274 void doEmitResult(
const std::tuple<T1, T2> &
tuple)
279 template <
typename T1,
typename T2,
typename T3>
280 void doEmitResult(
const std::tuple<T1, T2, T3> &
tuple)
285 template <
typename T1,
typename T2,
typename T3,
typename T4>
286 void doEmitResult(
const std::tuple<T1, T2, T3, T4> &
tuple)
291 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
292 void doEmitResult(
const std::tuple<T1, T2, T3, T4, T5> &
tuple)
298 std::shared_ptr<GpgME::Context> m_ctx;
301 GpgME::Error m_auditLogError;