~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to calendarsupport/next/scheduler.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  This file is part of the calendarsupport library.
 
3
 
 
4
  Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
 
5
  Copyright (c) 2010 Sérgio Martins <iamsergio@gmail.com>
 
6
 
 
7
  This library is free software; you can redistribute it and/or
 
8
  modify it under the terms of the GNU Library General Public
 
9
  License as published by the Free Software Foundation; either
 
10
  version 2 of the License, or (at your option) any later version.
 
11
 
 
12
  This library is distributed in the hope that it will be useful,
 
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
  Library General Public License for more details.
 
16
 
 
17
  You should have received a copy of the GNU Library General Public License
 
18
  along with this library; see the file COPYING.LIB.  If not, write to
 
19
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
20
  Boston, MA 02110-1301, USA.
 
21
*/
 
22
#ifndef CALENDARSUPPORT_SCHEDULER_H
 
23
#define CALENDARSUPPORT_SCHEDULER_H
 
24
 
 
25
#include "calendarsupport_export.h"
 
26
#include "nepomukcalendar.h"
 
27
 
 
28
#include <KCalCore/ScheduleMessage>
 
29
#include <KCalCore/IncidenceBase>
 
30
#include <KCalCore/Calendar>
 
31
 
 
32
#include <QtCore/QString>
 
33
#include <QtCore/QList>
 
34
#include <QtCore/QObject>
 
35
 
 
36
/**
 
37
   Most scheduler methods are async. They return immediately a unique identifier (a CallId) and
 
38
   to the work in background.
 
39
   Use the CallId to match the call with the result signal( CallId, ResultCode );
 
40
*/
 
41
typedef int CallId;
 
42
 
 
43
 
 
44
namespace KCalCore {
 
45
  class ICalFormat;
 
46
  class FreeBusyCache;
 
47
}
 
48
 
 
49
namespace CalendarSupport {
 
50
  class IncidenceChanger2;
 
51
/**
 
52
  This class provides an encapsulation of iTIP transactions (RFC 2446).
 
53
  It is an abstract base class for inheritance by implementations of the
 
54
  iTIP scheme like iMIP or iRIP.
 
55
*/
 
56
class CALENDARSUPPORT_EXPORT Scheduler : public QObject
 
57
{
 
58
  Q_OBJECT
 
59
  public:
 
60
 
 
61
    enum ResultCode {
 
62
      ResultCodeSuccess,
 
63
      ResultCodeDifferentIncidenceTypes,
 
64
      ResultCodeNewIncidenceTooOld,
 
65
      ResultCodeUnknownStatus,
 
66
      ResultCodeInvalidIncidence,
 
67
      ResultCodeNotUpdate,
 
68
      ResultCodeSaveFreeBusyError,
 
69
      ResultCodeIncidenceOrAttendeeNotFound,
 
70
      ResultCodeIncidenceNotFound,
 
71
      ResultCodeErrorDeletingIncidence,
 
72
      ResultCodeErrorCreatingIncidence,
 
73
      ResultCodeErrorUpdatingIncidence,
 
74
      ResultCodeErrorSendingEmail
 
75
    };
 
76
 
 
77
    /**
 
78
      Creates a scheduler for calendar specified as argument.
 
79
    */
 
80
    Scheduler( const CalendarSupport::NepomukCalendar::Ptr &calendar,
 
81
               CalendarSupport::IncidenceChanger2 *changer );
 
82
 
 
83
    virtual ~Scheduler();
 
84
 
 
85
    /**
 
86
      iTIP publish action
 
87
    */
 
88
    virtual CallId publish( const KCalCore::IncidenceBase::Ptr &incidence,
 
89
                            const QString &recipients ) = 0;
 
90
    /**
 
91
      Performs iTIP transaction on incidence. The method is specified as the
 
92
      method argument and can be any valid iTIP method.
 
93
 
 
94
      @param incidence the incidence for the transaction.
 
95
      @param method the iTIP transaction method to use.
 
96
    */
 
97
    virtual CallId performTransaction( const KCalCore::IncidenceBase::Ptr &incidence,
 
98
                                       KCalCore::iTIPMethod method ) = 0;
 
99
 
 
100
    /**
 
101
      Performs iTIP transaction on incidence to specified recipient(s).
 
102
      The method is specified as the method argumanet and can be any valid iTIP method.
 
103
 
 
104
      @param incidence the incidence for the transaction.
 
105
      @param method the iTIP transaction method to use.
 
106
      @param recipients the receipients of the transaction.
 
107
    */
 
108
    virtual CallId performTransaction( const KCalCore::IncidenceBase::Ptr &incidence,
 
109
                                       KCalCore::iTIPMethod method, const QString &recipients ) = 0;
 
110
 
 
111
    /**
 
112
      Accepts the transaction. The incidence argument specifies the iCal
 
113
      component on which the transaction acts. The status is the result of
 
114
      processing a iTIP message with the current calendar and specifies the
 
115
      action to be taken for this incidence.
 
116
 
 
117
      @param incidence the incidence for the transaction.
 
118
      @param method iTIP transaction method to check.
 
119
      @param status scheduling status.
 
120
      @param email the email address of the person for whom this
 
121
      transaction is to be performed.
 
122
    */
 
123
    CallId acceptTransaction( const KCalCore::IncidenceBase::Ptr &incidence,
 
124
                              KCalCore::iTIPMethod method,
 
125
                              KCalCore::ScheduleMessage::Status status,
 
126
                              const QString &email = QString() );
 
127
 
 
128
    virtual bool deleteTransaction( const QString &uid );
 
129
 
 
130
    /**
 
131
      Returns the directory where the free-busy information is stored.
 
132
    */
 
133
    virtual QString freeBusyDir() const = 0;
 
134
 
 
135
    /**
 
136
      Sets the free/busy cache used to store free/busy information.
 
137
    */
 
138
    void setFreeBusyCache( KCalCore::FreeBusyCache * );
 
139
 
 
140
    /**
 
141
      Returns the free/busy cache.
 
142
    */
 
143
    KCalCore::FreeBusyCache *freeBusyCache() const;
 
144
 
 
145
  protected:
 
146
 
 
147
    // This signal sis delayed because it can't be emitted before "return callId",
 
148
    // otherwise the caller would not know the callId that was being sent in the signal
 
149
    void emitOperationFinished( CallId, ResultCode, const QString & );
 
150
 
 
151
    CallId acceptPublish( const KCalCore::IncidenceBase::Ptr &,
 
152
                          KCalCore::ScheduleMessage::Status status,
 
153
                          KCalCore::iTIPMethod method );
 
154
 
 
155
    CallId acceptRequest( const KCalCore::IncidenceBase::Ptr &,
 
156
                          KCalCore::ScheduleMessage::Status status,
 
157
                          const QString &email );
 
158
 
 
159
    CallId acceptAdd( const KCalCore::IncidenceBase::Ptr &,
 
160
                      KCalCore::ScheduleMessage::Status status );
 
161
 
 
162
    CallId acceptCancel( const KCalCore::IncidenceBase::Ptr &,
 
163
                         KCalCore::ScheduleMessage::Status status,
 
164
                         const QString &attendee );
 
165
 
 
166
    CallId acceptDeclineCounter( const KCalCore::IncidenceBase::Ptr &,
 
167
                                 KCalCore::ScheduleMessage::Status status );
 
168
 
 
169
    CallId acceptReply( const KCalCore::IncidenceBase::Ptr &,
 
170
                        KCalCore::ScheduleMessage::Status status,
 
171
                        KCalCore::iTIPMethod method );
 
172
 
 
173
    CallId acceptRefresh( const KCalCore::IncidenceBase::Ptr &,
 
174
                          KCalCore::ScheduleMessage::Status status );
 
175
 
 
176
    CallId acceptCounter( const KCalCore::IncidenceBase::Ptr &,
 
177
                          KCalCore::ScheduleMessage::Status status );
 
178
 
 
179
    CallId acceptFreeBusy( const KCalCore::IncidenceBase::Ptr &, KCalCore::iTIPMethod method );
 
180
 
 
181
    NepomukCalendar::Ptr calendar() const;
 
182
 
 
183
    IncidenceChanger2 * changer() const;
 
184
 
 
185
    CallId nextCallId();
 
186
 
 
187
  Q_SIGNALS:
 
188
    void acceptTransactionFinished( CallId callId, ResultCode code, const QString &errorMessage );
 
189
    void performTransactionFinished( CallId callId, ResultCode code, const QString &errorMessage );
 
190
    void publishFinished( CallId callId, ResultCode code, const QString &errorMessage );
 
191
 
 
192
  private:
 
193
    Q_DISABLE_COPY( Scheduler )
 
194
    class Private;
 
195
    Private *const d;
 
196
};
 
197
 
 
198
}
 
199
 
 
200
#endif