summaryrefslogtreecommitdiffstats
path: root/akonadish/syntax_modules/akonadi_sync.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'akonadish/syntax_modules/akonadi_sync.cpp')
-rw-r--r--akonadish/syntax_modules/akonadi_sync.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/akonadish/syntax_modules/akonadi_sync.cpp b/akonadish/syntax_modules/akonadi_sync.cpp
new file mode 100644
index 0000000..990fdf6
--- /dev/null
+++ b/akonadish/syntax_modules/akonadi_sync.cpp
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#include "akonadi_sync.h"
21
22#include <QDebug>
23#include <QObject> // tr()
24#include <QTimer>
25
26#include "common/resource.h"
27#include "common/storage.h"
28#include "common/domain/event.h"
29#include "common/domain/folder.h"
30#include "common/resourceconfig.h"
31#include "common/log.h"
32#include "common/storage.h"
33#include "common/definitions.h"
34
35#include "akonadish_utils.h"
36
37namespace AkonadiSync
38{
39
40Syntax::List syntax()
41{
42 Syntax::List syntax;
43 syntax << Syntax("sync", QObject::tr("Syncronizes all resources that are listed; and empty list triggers a syncronizaton on all resources"), &AkonadiSync::sync, Syntax::EventDriven );
44
45 return syntax;
46}
47
48bool sync(const QStringList &args, State &state)
49{
50 Akonadi2::Query query;
51 for (const auto &res : args) {
52 query.resources << res.toLatin1();
53 }
54 query.syncOnDemand = true;
55 query.processAll = true;
56
57 QTimer::singleShot(0, [query, state]() {
58 Akonadi2::Store::synchronize(query).then<void>([state]() {
59 state.printLine("Synchronization complete!");
60 state.commandFinished();
61 }).exec();
62 });
63
64 return true;
65}
66
67}