← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~nik90/ubuntu-clock-app/add-utility-backend into lp:ubuntu-clock-app

 

Nekhelesh Ramananthan has proposed merging lp:~nik90/ubuntu-clock-app/add-utility-backend into lp:ubuntu-clock-app.

Commit message:
Added a Clock Utility c++ plugin housing filemanagement and standardpath types.

Requested reviews:
  Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot): continuous-integration
  Ubuntu Clock Developers (ubuntu-clock-dev)

For more details, see:
https://code.launchpad.net/~nik90/ubuntu-clock-app/add-utility-backend/+merge/268490

Added a c++ backend plugin for 
a) deleting files 
b) returning the QStandardPath /home/phablet/.local/share/com.ubuntu.clock 

This is necessary for the upcoming custom-alarm-sound feature implementation which requires the above mentioned functionalities.
-- 
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~nik90/ubuntu-clock-app/add-utility-backend into lp:ubuntu-clock-app.
=== modified file 'app/ubuntu-clock-app.qml'
--- app/ubuntu-clock-app.qml	2015-07-15 22:31:52 +0000
+++ app/ubuntu-clock-app.qml	2015-08-19 14:33:24 +0000
@@ -20,6 +20,7 @@
 import DateTime 1.0
 import U1db 1.0 as U1db
 import Ubuntu.Components 1.2
+import Clock.Utility 1.0
 import "clock"
 import "components"
 

=== modified file 'backend/CMakeLists.txt'
--- backend/CMakeLists.txt	2015-07-16 21:02:18 +0000
+++ backend/CMakeLists.txt	2015-08-19 14:33:24 +0000
@@ -34,6 +34,13 @@
     modules/GeoLocation/geolocation.cpp
 )
 
+set(
+    clockutility_SRCS
+    modules/Clock/Utility/backend.cpp
+    modules/Clock/Utility/standardpath.cpp
+    modules/Clock/Utility/filemanagement.cpp
+)
+
 add_library(timezone MODULE
     ${timezone_SRCS}
 )
@@ -50,6 +57,10 @@
     ${geolocation_SRCS}
 )
 
+add_library(clockutility MODULE
+    ${clockutility_SRCS}
+)
+
 set_target_properties(timezone PROPERTIES
     LIBRARY_OUTPUT_DIRECTORY Timezone
 )
@@ -66,10 +77,15 @@
     LIBRARY_OUTPUT_DIRECTORY GeoLocation
 )
 
+set_target_properties(clockutility PROPERTIES
+    LIBRARY_OUTPUT_DIRECTORY Clock/Utility
+)
+
 qt5_use_modules(datetime Gui Qml Quick)
 qt5_use_modules(timezone Gui Qml Quick)
 qt5_use_modules(alarmsettings Gui Qml Quick DBus)
 qt5_use_modules(geolocation Gui Qml Quick)
+qt5_use_modules(clockutility Gui Qml Quick)
 
 # Copy qmldir file to build dir for running in QtCreator
 add_custom_target(timezone-qmldir ALL
@@ -92,6 +108,11 @@
     DEPENDS ${QMLFILES}
 )
 
+add_custom_target(clockutility-qmldir ALL
+    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/modules/Clock/Utility/qmldir ${CMAKE_CURRENT_BINARY_DIR}/Clock/Utility
+    DEPENDS ${QMLFILES}
+)
+
 # Install plugin file
 install(TARGETS timezone DESTINATION ${MODULE_PATH}/Timezone/)
 install(FILES   modules/Timezone/qmldir DESTINATION ${MODULE_PATH}/Timezone/)
@@ -104,3 +125,6 @@
 
 install(TARGETS geolocation DESTINATION ${MODULE_PATH}/GeoLocation/)
 install(FILES   modules/GeoLocation/qmldir DESTINATION ${MODULE_PATH}/GeoLocation/)
+
+install(TARGETS clockutility DESTINATION ${MODULE_PATH}/Clock/Utility/)
+install(FILES   modules/Clock/Utility/qmldir DESTINATION ${MODULE_PATH}/Clock/Utility/)

=== added directory 'backend/modules/Clock'
=== added directory 'backend/modules/Clock/Utility'
=== added file 'backend/modules/Clock/Utility/backend.cpp'
--- backend/modules/Clock/Utility/backend.cpp	1970-01-01 00:00:00 +0000
+++ backend/modules/Clock/Utility/backend.cpp	2015-08-19 14:33:24 +0000
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Clock App
+ *
+ * Ubuntu Clock App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Clock App 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QtQml>
+#include <QtQml/QQmlContext>
+#include "backend.h"
+#include "standardpath.h"
+#include "filemanagement.h"
+
+void BackendPlugin::registerTypes(const char *uri)
+{
+    Q_ASSERT(uri == QLatin1String("Clock.Utility"));
+
+    qmlRegisterType<StandardPath>(uri, 1, 0, "StandardPath");
+    qmlRegisterType<FileManagement>(uri, 1, 0, "FileManagement");
+}
+
+void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
+{
+    QQmlExtensionPlugin::initializeEngine(engine, uri);
+}

=== added file 'backend/modules/Clock/Utility/backend.h'
--- backend/modules/Clock/Utility/backend.h	1970-01-01 00:00:00 +0000
+++ backend/modules/Clock/Utility/backend.h	2015-08-19 14:33:24 +0000
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2014-2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Clock App
+ *
+ * Ubuntu Clock App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Clock App 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BACKEND_PLUGIN_H
+#define BACKEND_PLUGIN_H
+
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlExtensionPlugin>
+
+class BackendPlugin : public QQmlExtensionPlugin
+{
+    Q_OBJECT
+    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+
+public:
+    void registerTypes(const char *uri);
+    void initializeEngine(QQmlEngine *engine, const char *uri);
+};
+#endif // BACKEND_PLUGIN_H
+

=== added file 'backend/modules/Clock/Utility/filemanagement.cpp'
--- backend/modules/Clock/Utility/filemanagement.cpp	1970-01-01 00:00:00 +0000
+++ backend/modules/Clock/Utility/filemanagement.cpp	2015-08-19 14:33:24 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Clock App
+ *
+ * Ubuntu Clock App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Clock App 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QDir>
+#include <QDebug>
+
+#include "filemanagement.h"
+
+FileManagement::FileManagement(QObject *parent):
+    QObject(parent)
+{
+}
+
+void FileManagement::deleteFile(const QString &dirName, const QString &fileName)
+{
+    QDir dir(dirName);
+
+    // If directory doesn't exist, return
+    if (!dir.exists())
+    {
+        qCritical("Directory %s doesn't exist", dirName);
+        return;
+    }
+
+    dir.remove(fileName);
+}

=== added file 'backend/modules/Clock/Utility/filemanagement.h'
--- backend/modules/Clock/Utility/filemanagement.h	1970-01-01 00:00:00 +0000
+++ backend/modules/Clock/Utility/filemanagement.h	2015-08-19 14:33:24 +0000
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Clock App
+ *
+ * Ubuntu Clock App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Clock App 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FILEMANAGEMENT_H
+#define FILEMANAGEMENT_H
+
+#include <QObject>
+
+class FileManagement: public QObject
+{
+    Q_OBJECT
+
+public:
+    FileManagement(QObject *parent = 0);
+
+public slots:
+    void deleteFile(const QString &dirName, const QString &fileName);
+};
+
+#endif

=== added file 'backend/modules/Clock/Utility/qmldir'
--- backend/modules/Clock/Utility/qmldir	1970-01-01 00:00:00 +0000
+++ backend/modules/Clock/Utility/qmldir	2015-08-19 14:33:24 +0000
@@ -0,0 +1,2 @@
+module Clock.Utility
+plugin clockutility

=== added file 'backend/modules/Clock/Utility/standardpath.cpp'
--- backend/modules/Clock/Utility/standardpath.cpp	1970-01-01 00:00:00 +0000
+++ backend/modules/Clock/Utility/standardpath.cpp	2015-08-19 14:33:24 +0000
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Clock App
+ *
+ * Ubuntu Clock App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Clock App 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QStandardPaths>
+
+#include "standardpath.h"
+
+StandardPath::StandardPath(QObject *parent):
+    QObject(parent)
+{
+}
+
+QString StandardPath::appDirectory() const
+{
+    return QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first();
+}

=== added file 'backend/modules/Clock/Utility/standardpath.h'
--- backend/modules/Clock/Utility/standardpath.h	1970-01-01 00:00:00 +0000
+++ backend/modules/Clock/Utility/standardpath.h	2015-08-19 14:33:24 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This file is part of Ubuntu Clock App
+ *
+ * Ubuntu Clock App is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Ubuntu Clock App 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef STANDARDPATH_H
+#define STANDARDPATH_H
+
+#include <QObject>
+
+class StandardPath: public QObject
+{
+    Q_OBJECT
+
+    // READONLY Property to return the app data directory path
+    Q_PROPERTY( QString appDirectory
+                READ appDirectory)
+
+public:
+    StandardPath(QObject *parent = 0);
+
+    // Function to return the app data directory path
+    QString appDirectory() const;
+};
+
+#endif

=== modified file 'debian/changelog'
--- debian/changelog	2015-08-16 20:53:03 +0000
+++ debian/changelog	2015-08-19 14:33:24 +0000
@@ -14,6 +14,7 @@
   * Added README.mergeproposal checklist to help with the review process.
   * Fix alarm interval information being inconsistent (LP: #1466000)
   * Changed default alarm sound (LP: #1354370)
+  * Added Clock Utility C++ plugin housing filemanagement and standardpath.
 
   [Victor Thompson]
   * Show all README files in QtCreator