diff options
author | Aaron Seigo <aseigo@kde.org> | 2015-12-23 23:39:14 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2015-12-23 23:39:14 +0100 |
commit | 17ea319fa8cbdf36396a4a5a68853857ca6ac51f (patch) | |
tree | c08927957643c140ecfffa438c4693066abb2d9a /akonadish/syntax_modules | |
parent | 0efcf4febf4d6d6cdb3218674999b6de1155a4d9 (diff) | |
download | sink-17ea319fa8cbdf36396a4a5a68853857ca6ac51f.tar.gz sink-17ea319fa8cbdf36396a4a5a68853857ca6ac51f.zip |
sync command
Diffstat (limited to 'akonadish/syntax_modules')
-rw-r--r-- | akonadish/syntax_modules/akonadi_sync.cpp | 67 | ||||
-rw-r--r-- | akonadish/syntax_modules/akonadi_sync.h | 29 |
2 files changed, 96 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 | |||
37 | namespace AkonadiSync | ||
38 | { | ||
39 | |||
40 | Syntax::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 | |||
48 | bool 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 | } | ||
diff --git a/akonadish/syntax_modules/akonadi_sync.h b/akonadish/syntax_modules/akonadi_sync.h new file mode 100644 index 0000000..62f7424 --- /dev/null +++ b/akonadish/syntax_modules/akonadi_sync.h | |||
@@ -0,0 +1,29 @@ | |||
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 | #pragma once | ||
21 | |||
22 | #include "syntaxtree.h" | ||
23 | |||
24 | namespace AkonadiSync | ||
25 | { | ||
26 | Syntax::List syntax(); | ||
27 | bool sync(const QStringList &commands, State &state); | ||
28 | } | ||
29 | |||