[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi-next/feature/new_cli] akonadish: sync command
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2015-12-23 22:43:57
Message-ID: E1aBs8T-0000ri-Ur () scm ! kde ! org
[Download RAW message or body]

Git commit 17ea319fa8cbdf36396a4a5a68853857ca6ac51f by Aaron Seigo.
Committed on 23/12/2015 at 22:39.
Pushed by aseigo into branch 'feature/new_cli'.

sync command

M  +1    -0    akonadish/CMakeLists.txt
A  +67   -0    akonadish/syntax_modules/akonadi_sync.cpp     [License: GPL (v2+)]
A  +29   -0    akonadish/syntax_modules/akonadi_sync.h     [License: GPL (v2+)]
M  +2    -0    akonadish/syntaxtree.cpp

http://commits.kde.org/akonadi-next/17ea319fa8cbdf36396a4a5a68853857ca6ac51f

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
     syntax_modules/core_syntax.cpp
     syntax_modules/akonadi_list.cpp
     syntax_modules/akonadi_count.cpp
+    syntax_modules/akonadi_sync.cpp
     akonadish_utils.cpp
     repl/repl.cpp
     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 @@
+/*
+ * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   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.
+ */
+
+#include "akonadi_sync.h"
+
+#include <QDebug>
+#include <QObject> // tr()
+#include <QTimer>
+
+#include "common/resource.h"
+#include "common/storage.h"
+#include "common/domain/event.h"
+#include "common/domain/folder.h"
+#include "common/resourceconfig.h"
+#include "common/log.h"
+#include "common/storage.h"
+#include "common/definitions.h"
+
+#include "akonadish_utils.h"
+
+namespace AkonadiSync
+{
+
+Syntax::List syntax()
+{
+    Syntax::List syntax;
+    syntax << Syntax("sync", QObject::tr("Syncronizes all resources that are listed; \
and empty list triggers a syncronizaton on all resources"), &AkonadiSync::sync, \
Syntax::EventDriven ); +
+    return syntax;
+}
+
+bool sync(const QStringList &args, State &state)
+{
+    Akonadi2::Query query;
+    for (const auto &res : args) {
+        query.resources << res.toLatin1();
+    }
+    query.syncOnDemand = true;
+    query.processAll = true;
+
+    QTimer::singleShot(0, [query, state]() {
+    Akonadi2::Store::synchronize(query).then<void>([state]() {
+            state.printLine("Synchronization complete!");
+            state.commandFinished();
+            }).exec();
+    });
+
+    return true;
+}
+
+}
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 @@
+/*
+ * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   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 "syntaxtree.h"
+
+namespace AkonadiSync
+{
+    Syntax::List syntax();
+    bool sync(const QStringList &commands, State &state);
+}
+
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 @@
 #include "syntax_modules/core_syntax.h"
 #include "syntax_modules/akonadi_list.h"
 #include "syntax_modules/akonadi_count.h"
+#include "syntax_modules/akonadi_sync.h"
 
 SyntaxTree *SyntaxTree::s_module = 0;
 
@@ -48,6 +49,7 @@ SyntaxTree::SyntaxTree()
     syntaxSyntaxTrees << &CoreSyntax::syntax
                       << &AkonadiList::syntax
                       << &AkonadiCount::syntax
+                      << &AkonadiSync::syntax
                       ;
     for (auto syntaxSyntaxTree: syntaxSyntaxTrees) {
         m_syntax += syntaxSyntaxTree();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic