blob: c406f7969ad4322f53beb4c40ba682cea889695d (
plain)
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
|
/*
* qtmaildir - a Qt6 mail client for notmuch-indexed Maildirs
* Copyright (C) 2026 Danilo M. <danix@danix.xyz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include <QObject>
#include <QProcess>
#include <QTimer>
/// Runs calendar_sync_command a short delay after the last write.
///
/// The calendar's counterpart to MailSync, and deliberately smaller: no lock
/// monitoring and no status file, because the command itself takes the
/// flock that cron shares. A write arriving while a run is in progress is not
/// dropped: it queues exactly one more run for when this one finishes, since
/// the running sync may have listed the vdir before the write landed.
class CalendarSync : public QObject
{
Q_OBJECT
public:
CalendarSync(const QString &command, int delayMs, QObject *parent = nullptr);
void schedule();
bool isRunning() const;
signals:
void started();
void finished(bool ok, const QString &output);
private:
void run();
QString m_command;
QTimer m_timer;
QProcess m_process;
QByteArray m_output;
bool m_again = false;
};
|