2 Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 This file is part of the API for handling calendar data and provides
22 static functions for dealing with calendar incidence attachments.
24 @author Allen Winter \<winter@kde.org\>
26 #ifndef CALENDARSUPPORT_ATTACHMENTHANDLER_H
27 #define CALENDARSUPPORT_ATTACHMENTHANDLER_H
29 #include <KCalCore/Attachment>
30 #include <KCalCore/Incidence>
31 #include <KCalCore/ScheduleMessage>
40 namespace CalendarSupport
{
44 Provides methods to handle incidence attachments.
46 Includes functions to view and save attachments.
48 class AttachmentHandler
: public QObject
54 * Constructs an AttachmentHandler.
55 * @param parent is the parent widget for the dialogs used by this class.
57 explicit AttachmentHandler( QWidget
*parent
);
61 * Finds the attachment in the user's calendar, by @p attachmentName and @p incidence.
63 * @param attachmentName is the name of the attachment
64 * @param incidence is a pointer to a valid Incidence object containing the attachment.
65 * @return a pointer to the Attachment object located; 0 if no such attachment could be found.
67 KCalCore::Attachment::Ptr
find( const QString
&attachmentName
,
68 const KCalCore::Incidence::Ptr
&incidence
);
71 * Finds the attachment in the user's calendar, by @p attachmentName and a scheduler message;
72 * in other words, this function is intended to retrieve attachments from calendar invitations.
74 * @param attachmentName is the name of the attachment
75 * @param message is a pointer to a valid ScheduleMessage object containing the attachment.
76 * @return a pointer to the Attachment object located; 0 if no such attachment could be found.
78 KCalCore::Attachment::Ptr
find( const QString
&attachmentName
,
79 const KCalCore::ScheduleMessage::Ptr
&message
);
82 * Launches a viewer on the specified attachment.
84 * @param attachment is a pointer to a valid Attachment object.
85 * @return true if the viewer program successfully launched; false otherwise.
87 bool view( const KCalCore::Attachment::Ptr
&attachment
);
90 * Launches a viewer on the specified attachment.
92 * @param attachmentName is the name of the attachment
93 * @param incidence is a pointer to a valid Incidence object containing the attachment.
94 * @return true if the attachment could be found and the viewer program successfully launched;
97 bool view( const QString
&attachmentName
,
98 const KCalCore::Incidence::Ptr
&incidence
);
101 Launches a viewer on the specified attachment.
103 @param attachmentName is the name of the attachment
104 @param uid is a QString containing a UID of the incidence containing the attachment.
106 This function is async and will return immediately. Listen to signal viewFinished()
107 if you're interested on the success of this operation.
110 void view( const QString
&attachmentName
, const QString
&uid
);
113 Launches a viewer on the specified attachment.
115 @param attachmentName is the name of the attachment
116 @param message is a pointer to a valid ScheduleMessage object containing the attachment.
118 @return true if the attachment could be found and the viewer program successfully launched;
121 bool view( const QString
&attachmentName
,
122 const KCalCore::ScheduleMessage::Ptr
&message
);
125 Saves the specified attachment to a file of the user's choice.
127 @param attachment is a pointer to a valid Attachment object.
129 @return true if the save operation was successful; false otherwise.
131 bool saveAs( const KCalCore::Attachment::Ptr
&attachment
);
134 Saves the specified attachment to a file of the user's choice.
136 @param attachmentName is the name of the attachment
137 @param incidence is a pointer to a valid Incidence object containing the attachment.
139 @return true if the attachment could be found and the save operation was successful;
142 bool saveAs( const QString
&attachmentName
,
143 const KCalCore::Incidence::Ptr
&incidence
);
146 Saves the specified attachment to a file of the user's choice.
148 @param attachmentName is the name of the attachment
149 @param uid is a QString containing a UID of the incidence containing the attachment.
151 This function is async, it will return immediately. Listen to signal saveAsFinished()
152 if you're interested on the success of this operation.
154 void saveAs( const QString
&attachmentName
, const QString
&uid
);
157 Saves the specified attachment to a file of the user's choice.
159 @param attachmentName is the name of the attachment
160 @param message is a pointer to a valid ScheduleMessage object containing the attachment.
162 @return true if the attachment could be found and the save operation was successful;
165 bool saveAs( const QString
&attachmentName
,
166 const KCalCore::ScheduleMessage::Ptr
&message
);
169 void viewFinished( const QString
&uid
, const QString
&attachmentName
, bool success
);
170 void saveAsFinished( const QString
&uid
, const QString
&attachmentName
, bool success
);
173 void slotFinishView( KJob
*job
);
174 void slotFinishSaveAs( KJob
*job
);
182 }; // class AttachmentHandler
184 } // namespace CalendarSupport