File: icalimporter.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 (107 lines) | stat: -rw-r--r-- 3,538 bytes parent folder | download
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
103
104
105
106
107
/**
  This file is part of the akonadi-calendar library.

  Copyright (C) 2013 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 ICALIMPORTER_H
#define ICALIMPORTER_H

#include "akonadi-calendar_export.h"

#include <collection.h>

#include <QObject>
#include <QString>

/**
 * A class to import ical calendar files into akonadi.
 *
 * @since 4.12
 */
namespace Akonadi
{

class IncidenceChanger;

class AKONADI_CALENDAR_EXPORT ICalImporter : public QObject
{
    Q_OBJECT
public:

    /**
     * Constructs a new ICalImporter object. Use a different ICalImporter instance for each file you want to import.
     *
     * @param changer An existing IncidenceChanger, if 0, an internal one will be created.
     *                If you pass an existing one, you will be able to undo/redo import operations.
     * @param parent  Parent QObject.
     */
    explicit ICalImporter(Akonadi::IncidenceChanger *changer = nullptr, QObject *parent = nullptr);

    /**
     * Translated error message.
     * This is set when either importIntoExistingFinished() or importIntoNewResource() return false
     * or when the corresponding signals are have success=false.
     */
    Q_REQUIRED_RESULT QString errorMessage() const;

Q_SIGNALS:
    /**
     * Emitted after calling importIntoExistingResource()
     * @param success Success of the operation.
     * @param total Number of incidences included in the ical file.
     *
     * @see importIntoExistingResource(), errorMessage().
     */
    void importIntoExistingFinished(bool success, int total);

    /**
     * Emitted after calling importIntoNewResource().
     * If success is false, check errorMessage().
     */
    void importIntoNewFinished(bool success);

public Q_SLOTS:

    /**
     * Creates a new akonadi_ical_resource and configures it to use @p filename.
     * @param filename ical absolute file path
     * @return True if the job was started, in this case you should wait for the corresponding signal.
     */
    bool importIntoNewResource(const QString &filename);

    /**
     * Imports an ical file into an existing resource.
     * @param url Path of a local or remote file to import.
     * @param collectionId The destination collection. If null, the user will be prompted for a destination.
     *
     * @return false if some basic validation happened, like insufficient permissions. Use errorMessage() to see
     *         what happened. The importIntoExistingFinished() signal won't be emitted in this case.
     *
     *         true if the import job was started. importIntoExistingFinished() signal will be emitted in this case.
     */
    bool importIntoExistingResource(const QUrl &url, Collection collection);

private:
    class Private;
    Private *const d;
};

}

#endif // ICALIMPORTER_H