File: itiphandler_p.h

package info (click to toggle)
akonadi-calendar 4:18.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,808 kB
  • sloc: cpp: 14,079; xml: 36; makefile: 8; sh: 4
file content (102 lines) | stat: -rw-r--r-- 3,523 bytes parent folder | download | duplicates (2)
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
92
93
94
95
96
97
98
99
100
101
102
/*
  Copyright (C) 2012 Sérgio Martins <iamsergio@gmail.com>

  This library is free software; you can redistribute it and/or modify it
  under the terms of the GNU Library General Public License as published by
  the Free Software Foundation; either version 2 of the License, or (at your
  option) any later version.

  This library is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
  License for more details.

  You should have received a copy of the GNU Library General Public License
  along with this library; see the file COPYING.LIB.  If not, write to the
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  02110-1301, USA.
*/

#ifndef AKONADI_CALENDAR_ITIP_HANDLER_P_H
#define AKONADI_CALENDAR_ITIP_HANDLER_P_H

#include "calendarbase.h"
#include "mailscheduler_p.h"
#include "itiphandler.h"
#include "itiphandlerhelper_p.h"

#include <kcalcore/schedulemessage.h>

#include <QObject>
#include <QString>
#include <QPointer>

namespace Akonadi
{

struct Invitation {
    QString receiver;
    QString iCal;
    QString action;
    KCalCore::iTIPMethod method;
    KCalCore::Incidence::Ptr incidence;
};

/**
 * Our API has two methods, one to process received invitations and another one to send them.
 * These operations are async and we don't want them to be called before the other has finished.
 * This enum is just to Q_ASSERT that.
 */
enum Operation {
    OperationNone,
    OperationProcessiTIPMessage,
    OperationSendiTIPMessage,
    OperationPublishInformation,
    OperationSendAsICalendar
};

class Q_DECL_HIDDEN ITIPHandler::Private : public QObject
{
    Q_OBJECT
public:
    Private(ITIPHandlerComponentFactory *factory, ITIPHandler *q);

    void finishProcessiTIPMessage(Akonadi::MailScheduler::Result, const QString &errorMessage);
    void finishSendiTIPMessage(Akonadi::MailScheduler::Result, const QString &errorMessage);
    void finishPublishInformation(Akonadi::MailScheduler::Result, const QString &errorMessage);

    /**
     * Returns the calendar.
     * Creates a new one, if none is set.
     */
    CalendarBase::Ptr calendar();
    bool isLoaded(); // don't make const

    Invitation m_queuedInvitation;
    bool m_calendarLoadError = false;
    CalendarBase::Ptr m_calendar;
    ITIPHandlerComponentFactory *m_factory = nullptr;
    MailScheduler *m_scheduler = nullptr;
    KCalCore::Incidence::Ptr m_incidence;
    KCalCore::iTIPMethod m_method; // METHOD field of ical rfc of incoming invitation
    ITIPHandlerHelper *m_helper = nullptr;
    Operation m_currentOperation;
    QPointer<QWidget> m_parentWidget; // To be used for KMessageBoxes
    GroupwareUiDelegate *m_uiDelegate = nullptr;
    bool m_showDialogsOnError = true;
    ITIPHandler *const q;

    void finishSendAsICalendar(Akonadi::MailClient::Result, const QString &errorMessage);
private:
    void onLoadFinished(bool success, const QString &errorMessage);
    void onSchedulerFinished(Akonadi::Scheduler::Result, const QString &errorMessage);
    void onHelperFinished(Akonadi::ITIPHandlerHelper::SendResult result,
                          const QString &errorMessage);

    void onHelperModifyDialogClosed(ITIPHandlerHelper::SendResult result, KCalCore::iTIPMethod method, const KCalCore::Incidence::Ptr &incidence);

    void onCounterProposalDelegateFinished(bool success, const QString &errorMessage);
};

}
#endif