1 /*
2   This file is part of kdepim.
3 
4   SPDX-FileCopyrightText: 2013 Sérgio Martins <iamsergio@gmail.com>
5 
6   SPDX-License-Identifier: GPL-2.0-or-later
7 */
8 
9 #include "syncitiphandler.h"
10 #include "text_calendar_debug.h"
11 #include <CalendarSupport/CalendarSingleton>
12 
13 using namespace Akonadi;
14 
SyncItipHandler(const QString & receiver,const QString & iCal,const QString & type,const Akonadi::CalendarBase::Ptr & calendar,QObject * parent)15 SyncItipHandler::SyncItipHandler(const QString &receiver, const QString &iCal, const QString &type, const Akonadi::CalendarBase::Ptr &calendar, QObject *parent)
16     : QObject(parent)
17     , m_counterProposalEditorDelegate(new IncidenceEditorNG::GroupwareUiDelegate())
18 {
19     Q_ASSERT(calendar);
20     qCDebug(TEXT_CALENDAR_LOG) << "SyncItipHandler::SyncItipHandler: " << this;
21     auto handler = new Akonadi::ITIPHandler(this);
22     QObject::connect(handler, &Akonadi::ITIPHandler::iTipMessageProcessed, this, &SyncItipHandler::onITipMessageProcessed, Qt::QueuedConnection);
23 
24     handler->setGroupwareUiDelegate(m_counterProposalEditorDelegate);
25     handler->setCalendar(calendar);
26 
27     handler->processiTIPMessage(receiver, iCal, type);
28 
29     m_eventLoop.exec();
30 }
31 
~SyncItipHandler()32 SyncItipHandler::~SyncItipHandler()
33 {
34     qCDebug(TEXT_CALENDAR_LOG) << "SyncItipHandler::~SyncItipHandler: " << this;
35 }
36 
onITipMessageProcessed(Akonadi::ITIPHandler::Result result,const QString & errorMessage)37 void SyncItipHandler::onITipMessageProcessed(Akonadi::ITIPHandler::Result result, const QString &errorMessage)
38 {
39     m_result = result;
40     m_errorMessage = errorMessage;
41     m_eventLoop.exit();
42     deleteLater();
43     delete m_counterProposalEditorDelegate;
44 }
45 
errorMessage() const46 QString SyncItipHandler::errorMessage() const
47 {
48     return m_errorMessage;
49 }
50 
result() const51 Akonadi::ITIPHandler::Result SyncItipHandler::result() const
52 {
53     return m_result;
54 }
55