133 Q_ASSERT(m_thread.hasFunction() &&
"Call setWorkerFunction() before run()");
138 static_assert(std::tuple_size<T_result>::value > 2,
139 "Result tuple too small");
140 static_assert(std::is_same <
141 typename std::tuple_element <
142 std::tuple_size<T_result>::value - 2,
147 "Second to last result type not a QString");
148 static_assert(std::is_same <
149 typename std::tuple_element <
150 std::tuple_size<T_result>::value - 1,
155 "Last result type not a GpgME::Error");
159 std::enable_if_t<!std::is_void_v<T_private_>,
bool> =
true>
161 : T_base(std::make_unique<T_private>(),
nullptr), m_ctx(
ctx), m_thread(), m_auditLog(), m_auditLogError()
167 std::enable_if_t<std::is_void_v<T_private_>,
bool> =
true>
169 : T_base(
nullptr), m_ctx(
ctx), m_thread(), m_auditLog(), m_auditLogError()
173 void lateInitialization()
176 QObject::connect(&m_thread, &QThread::finished,
this,
177 &mixin_type::slotFinished);
178 m_ctx->setProgressProvider(
this);
179 QGpgME::g_context_map.insert(
this, m_ctx.get());
184 QGpgME::g_context_map.remove(
this);
187 template <
typename T_binder>
190 m_thread.setFunction([
this,
func]() {
return func(this->context()); });
194 template <
typename T_binder>
197 m_thread.setFunction(std::bind(
func, this->context()));
200 template <
typename T_binder>
201 void run(
const T_binder &
func,
const std::shared_ptr<QIODevice> &
io)
204 io->moveToThread(&m_thread);
210 m_thread.setFunction(std::bind(
func, this->context(), this->
thread(), std::weak_ptr<QIODevice>(
io)));
213 template <
typename T_binder>
214 void run(
const T_binder &
func,
const std::shared_ptr<QIODevice> &
io1,
const std::shared_ptr<QIODevice> &
io2)
217 io1->moveToThread(&m_thread);
220 io2->moveToThread(&m_thread);
226 m_thread.setFunction(std::bind(
func, this->context(), this->
thread(), std::weak_ptr<QIODevice>(
io1), std::weak_ptr<QIODevice>(
io2)));
231 GpgME::Context *context()
const
241 m_auditLog = std::get < std::tuple_size<T_result>::value - 2 > (
r);
242 m_auditLogError = std::get < std::tuple_size<T_result>::value - 1 > (
r);
248 void slotCancel()
override {
251 m_ctx->cancelPendingOperation();
254 QString auditLogAsHtml()
const override
258 GpgME::Error auditLogError()
const override
260 return m_auditLogError;
262 void showProgress(
const char *
what,
264 QMetaObject::invokeMethod(
this, [
this,
current,
total]() {
266 }, Qt::QueuedConnection);
270 }, Qt::QueuedConnection);
276 }, Qt::QueuedConnection);
279 template <
typename T1,
typename T2>
280 void doEmitResult(
const std::tuple<T1, T2> &
tuple)
285 template <
typename T1,
typename T2,
typename T3>
286 void doEmitResult(
const std::tuple<T1, T2, T3> &
tuple)
291 template <
typename T1,
typename T2,
typename T3,
typename T4>
292 void doEmitResult(
const std::tuple<T1, T2, T3, T4> &
tuple)
297 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
298 void doEmitResult(
const std::tuple<T1, T2, T3, T4, T5> &
tuple)
304 std::shared_ptr<GpgME::Context> m_ctx;
307 GpgME::Error m_auditLogError;