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 | |
parent | 0efcf4febf4d6d6cdb3218674999b6de1155a4d9 (diff) | |
download | sink-17ea319fa8cbdf36396a4a5a68853857ca6ac51f.tar.gz sink-17ea319fa8cbdf36396a4a5a68853857ca6ac51f.zip |
sync command
-rw-r--r-- | akonadish/CMakeLists.txt | 1 | ||||
-rw-r--r-- | akonadish/syntax_modules/akonadi_sync.cpp | 67 | ||||
-rw-r--r-- | akonadish/syntax_modules/akonadi_sync.h | 29 | ||||
-rw-r--r-- | akonadish/syntaxtree.cpp | 2 |
4 files changed, 99 insertions, 0 deletions
diff --git a/akonadish/CMakeLists.txt b/akonadish/CMakeLists.txt index 9d0e7a5..39a059f 100644 --- a/akonadish/CMakeLists.txt +++ b/akonadish/CMakeLists.txt | |||
@@ -9,6 +9,7 @@ set(akonadi2_cli_SRCS | |||
9 | syntax_modules/core_syntax.cpp | 9 | syntax_modules/core_syntax.cpp |
10 | syntax_modules/akonadi_list.cpp | 10 | syntax_modules/akonadi_list.cpp |
11 | syntax_modules/akonadi_count.cpp | 11 | syntax_modules/akonadi_count.cpp |
12 | syntax_modules/akonadi_sync.cpp | ||
12 | akonadish_utils.cpp | 13 | akonadish_utils.cpp |
13 | repl/repl.cpp | 14 | repl/repl.cpp |
14 | repl/replStates.cpp | 15 | repl/replStates.cpp |
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 | |||
diff --git a/akonadish/syntaxtree.cpp b/akonadish/syntaxtree.cpp index 0cd3e3f..2d7c127 100644 --- a/akonadish/syntaxtree.cpp +++ b/akonadish/syntaxtree.cpp | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "syntax_modules/core_syntax.h" | 27 | #include "syntax_modules/core_syntax.h" |
28 | #include "syntax_modules/akonadi_list.h" | 28 | #include "syntax_modules/akonadi_list.h" |
29 | #include "syntax_modules/akonadi_count.h" | 29 | #include "syntax_modules/akonadi_count.h" |
30 | #include "syntax_modules/akonadi_sync.h" | ||
30 | 31 | ||
31 | SyntaxTree *SyntaxTree::s_module = 0; | 32 | SyntaxTree *SyntaxTree::s_module = 0; |
32 | 33 | ||
@@ -48,6 +49,7 @@ SyntaxTree::SyntaxTree() | |||
48 | syntaxSyntaxTrees << &CoreSyntax::syntax | 49 | syntaxSyntaxTrees << &CoreSyntax::syntax |
49 | << &AkonadiList::syntax | 50 | << &AkonadiList::syntax |
50 | << &AkonadiCount::syntax | 51 | << &AkonadiCount::syntax |
52 | << &AkonadiSync::syntax | ||
51 | ; | 53 | ; |
52 | for (auto syntaxSyntaxTree: syntaxSyntaxTrees) { | 54 | for (auto syntaxSyntaxTree: syntaxSyntaxTrees) { |
53 | m_syntax += syntaxSyntaxTree(); | 55 | m_syntax += syntaxSyntaxTree(); |