Merge lp:~renatofilho/buteo-syncfw-qml/initial-code into lp:~renatofilho/buteo-syncfw-qml/trunk

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: no longer in the source branch.
Merged at revision: 2
Proposed branch: lp:~renatofilho/buteo-syncfw-qml/initial-code
Merge into: lp:~renatofilho/buteo-syncfw-qml/trunk
Diff against target: 1073 lines (+979/-0)
18 files modified
.bzr-builddeb/default.conf (+2/-0)
Buteo/CMakeLists.txt (+39/-0)
Buteo/buteo-sync-qml.cpp (+204/-0)
Buteo/buteo-sync-qml.h (+181/-0)
Buteo/plugin.cpp (+27/-0)
Buteo/plugin.h (+31/-0)
Buteo/qmldir (+2/-0)
CMakeLists.txt (+30/-0)
cmake_uninstall.cmake.in (+21/-0)
debian/changelog (+5/-0)
debian/compat (+1/-0)
debian/control (+34/-0)
debian/copyright (+19/-0)
debian/rules (+9/-0)
tests/CMakeLists.txt (+1/-0)
tests/qml/CMakeLists.txt (+36/-0)
tests/qml/buteo-syncfw.py (+163/-0)
tests/qml/tst_ButeoSyncFW.qml (+174/-0)
To merge this branch: bzr merge lp:~renatofilho/buteo-syncfw-qml/initial-code
Reviewer Review Type Date Requested Status
Michael Sheldon (community) Approve
Ken VanDine (community) Needs Fixing
Renato Araujo Oliveira Filho Pending
Review via email: mp+264160@code.launchpad.net

Commit message

Implemented QML bindings for buteo syncfw DBUS service.

Description of the change

Server implementation can be found here: https://github.com/nemomobile/buteo-syncfw

To post a comment you must log in.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Not sure if "gnome" is the best section for the package?

review: Needs Information
Revision history for this message
Ken VanDine (ken-vandine) wrote :

I pushed a few packaging fixes to lp:~ken-vandine/buteo-syncfw-qml/packaging_tweaks

review: Needs Fixing
Revision history for this message
Ken VanDine (ken-vandine) wrote :

> Not sure if "gnome" is the best section for the package?

Agreed, but those sections aren't really all that useful these days. It seems all the apps with a GUI tend to go in "gnome", not opposed to changing that but also not really concerned.

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

I'm not sure the reinitialization that's done after an owner change will work, see the diff comment for details

review: Needs Fixing
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Ah, no my mistake; presumably a call to deinitialize() will happen when the original owner is lost, which then calls reset on m_iface, so when the new owner appears it is null again.

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

One small in-line comment added about one of the copyright statements, but otherwise the code for this all looks good to me.

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Looks good :)

review: Approve
2. By Renato Araujo Oliveira Filho

Implemented QML bindings for buteo syncfw DBUS service.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory '.bzr-builddeb'
=== added file '.bzr-builddeb/default.conf'
--- .bzr-builddeb/default.conf 1970-01-01 00:00:00 +0000
+++ .bzr-builddeb/default.conf 2015-07-09 14:03:36 +0000
@@ -0,0 +1,2 @@
1[BUILDDEB]
2split = True
03
=== added directory 'Buteo'
=== added file 'Buteo/CMakeLists.txt'
--- Buteo/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ Buteo/CMakeLists.txt 2015-07-09 14:03:36 +0000
@@ -0,0 +1,39 @@
1set(BUTEO_SYNC_QML_PLUGIN "buteo-syncfw-qml")
2
3set(BUTEO_SYNC_QML_PLUGIN_SRCS
4 buteo-sync-qml.cpp
5 buteo-sync-qml.h
6 plugin.h
7 plugin.cpp
8)
9
10set(BUTEO_SYNC_QML_PLUGIN_FILES
11 qmldir
12)
13
14add_library(${BUTEO_SYNC_QML_PLUGIN} MODULE
15 ${BUTEO_SYNC_QML_PLUGIN_SRCS}
16)
17
18target_link_libraries(${BUTEO_SYNC_QML_PLUGIN}
19 Qt5::Core
20 Qt5::Qml
21 Qt5::DBus
22 Qt5::Xml
23)
24
25#copy qml files to build dir to make it possible to run without install
26add_custom_target(buteo_components_QmlFiles ALL SOURCES ${BUTEO_SYNC_QML_PLUGIN_FILES})
27if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
28 add_custom_command(TARGET buteo_components_QmlFiles PRE_BUILD
29 COMMAND ${CMAKE_COMMAND} -E
30 copy ${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${CMAKE_CURRENT_BINARY_DIR}/)
31endif()
32
33execute_process(
34 COMMAND qmake -query QT_INSTALL_QML
35 OUTPUT_VARIABLE QT_IMPORTS_DIR
36 OUTPUT_STRIP_TRAILING_WHITESPACE
37)
38install(TARGETS ${BUTEO_SYNC_QML_PLUGIN} DESTINATION ${QT_IMPORTS_DIR}/Buteo/)
39install(FILES ${BUTEO_SYNC_QML_PLUGIN_FILES} DESTINATION ${QT_IMPORTS_DIR}/Buteo/)
040
=== added file 'Buteo/buteo-sync-qml.cpp'
--- Buteo/buteo-sync-qml.cpp 1970-01-01 00:00:00 +0000
+++ Buteo/buteo-sync-qml.cpp 2015-07-09 14:03:36 +0000
@@ -0,0 +1,204 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
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; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "buteo-sync-qml.h"
18
19#include <QtCore/QDebug>
20#include <QtDBus/QDBusInterface>
21#include <QtDBus/QDBusReply>
22#include <QtXml/QDomDocument>
23
24#define BUTEO_DBUS_SERVICE_NAME "com.meego.msyncd"
25#define BUTEO_DBUS_OBJECT_PATH "/synchronizer"
26#define BUTEO_DBUS_INTERFACE "com.meego.msyncd"
27
28ButeoSyncFW::ButeoSyncFW(QObject *parent)
29 : QObject(parent)
30{
31}
32
33bool ButeoSyncFW::syncing() const
34{
35 return !(getRunningSyncList().isEmpty());
36}
37
38QStringList ButeoSyncFW::visibleSyncProfiles() const
39{
40 if (m_iface) {
41 QDBusReply<QStringList> result = m_iface->call("allVisibleSyncProfiles");
42 return result.value();
43 }
44 return QStringList();
45}
46
47void ButeoSyncFW::classBegin()
48{
49}
50
51void ButeoSyncFW::componentComplete()
52{
53 m_serviceWatcher.reset(new QDBusServiceWatcher(BUTEO_DBUS_SERVICE_NAME,
54 QDBusConnection::sessionBus(),
55 QDBusServiceWatcher::WatchForOwnerChange,
56 this));
57 connect(m_serviceWatcher.data(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
58 this, SLOT(serviceOwnerChanged(QString,QString,QString)));
59
60 initialize();
61}
62
63void ButeoSyncFW::initialize()
64{
65 if (!m_iface.isNull()) {
66 return;
67 }
68
69 m_iface.reset(new QDBusInterface(BUTEO_DBUS_SERVICE_NAME,
70 BUTEO_DBUS_OBJECT_PATH,
71 BUTEO_DBUS_INTERFACE));
72
73 if (!m_iface->isValid()) {
74 m_iface.reset();
75 qWarning() << "Fail to connect with syncfw";
76 return;
77 }
78
79 connect(m_iface.data(),
80 SIGNAL(syncStatus(QString, int, QString, int)),
81 SIGNAL(syncStatus(QString, int, QString, int)), Qt::QueuedConnection);
82 connect(m_iface.data(),
83 SIGNAL(signalProfileChanged(QString, int, QString)),
84 SIGNAL(profileChanged(QString, int, QString)), Qt::QueuedConnection);
85
86 // notify changes on properties
87 emit syncStatus("", 0, "", 0);
88 emit profileChanged("", 0, "");
89}
90
91bool ButeoSyncFW::startSync(const QString &aProfileId) const
92{
93 if (m_iface) {
94 QDBusReply<bool> result = m_iface->call("startSync", aProfileId);
95 return result.value();
96 }
97 return false;
98}
99
100bool ButeoSyncFW::startSyncByCategory(const QString &category) const
101{
102 foreach(const QString &profile, syncProfilesByCategory(category)) {
103 if (!startSync(profile)) {
104 return false;
105 }
106 }
107 return true;
108}
109
110void ButeoSyncFW::abortSync(const QString &aProfileId) const
111{
112 if (m_iface) {
113 m_iface->call("abortSync", aProfileId);
114 }
115}
116
117QStringList ButeoSyncFW::getRunningSyncList() const
118{
119 if (m_iface) {
120 QDBusReply<QStringList> syncList = m_iface->call("runningSyncs");
121 return syncList;
122 }
123 return QStringList();
124}
125
126QStringList ButeoSyncFW::syncProfilesByCategory(const QString &category) const
127{
128 if (m_iface) {
129 QDBusReply<QStringList> profiles = m_iface->call("syncProfilesByKey", "category", category);
130 // extract ids
131 QStringList ids;
132 foreach(const QString &profile, profiles.value()) {
133 QDomDocument doc;
134 QString errorMsg;
135 int errorLine;
136 int errorColumn;
137 if (doc.setContent(profile, &errorMsg, &errorLine, &errorColumn)) {
138 QDomNodeList profileElements = doc.elementsByTagName("profile");
139 if (!profileElements.isEmpty()) {
140 //check if is enabled
141 QDomElement e = profileElements.item(0).toElement();
142 QDomNodeList values = e.elementsByTagName("key");
143 bool enabled = true;
144 for(int i = 0; i < values.count(); i++) {
145 QDomElement v = values.at(i).toElement();
146 if ((v.attribute("name") == "enabled") &&
147 (v.attribute("value") == "false")) {
148 enabled = false;
149 continue;
150 }
151 }
152 if (!enabled) {
153 continue;
154 }
155 QString profileName = e.attribute("name", "");
156 if (!profileName.isEmpty()) {
157 ids << profileName;
158 } else {
159 qWarning() << "Profile name is empty in:" << profile;
160 }
161 } else {
162 qWarning() << "Profile not found in:" << profile;
163 }
164 } else {
165 qWarning() << "Fail to parse profile:" << profile;
166 qWarning() << "Error:" << errorMsg << errorLine << errorColumn;
167 }
168 }
169 return ids;
170 }
171 return QStringList();
172}
173
174bool ButeoSyncFW::removeProfile(const QString &profileId) const
175{
176 if (m_iface) {
177 QDBusReply<bool> result = m_iface->call("removeProfile", profileId);
178 return result;
179 }
180 return false;
181}
182
183void ButeoSyncFW::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner)
184{
185 Q_UNUSED(oldOwner);
186
187 if (name == BUTEO_DBUS_SERVICE_NAME) {
188 if (!newOwner.isEmpty()) {
189 // service appear
190 initialize();
191 } else if (!m_iface.isNull()) {
192 // lost service
193 deinitialize();
194 }
195 }
196}
197
198void ButeoSyncFW::deinitialize()
199{
200 m_iface.reset();
201 // notify changes on properties
202 emit syncStatus("", 0, "", 0);
203 emit profileChanged("", 0, "");
204}
0205
=== added file 'Buteo/buteo-sync-qml.h'
--- Buteo/buteo-sync-qml.h 1970-01-01 00:00:00 +0000
+++ Buteo/buteo-sync-qml.h 2015-07-09 14:03:36 +0000
@@ -0,0 +1,181 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
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; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <QtCore/QObject>
18#include <QtQml/QQmlParserStatus>
19#include <QtDBus/QDBusInterface>
20#include <QtDBus/QDBusServiceWatcher>
21
22class ButeoSyncFW : public QObject, public QQmlParserStatus
23{
24 Q_OBJECT
25 Q_INTERFACES(QQmlParserStatus)
26
27 Q_PROPERTY(bool syncing READ syncing NOTIFY syncStatus)
28 Q_PROPERTY(QStringList visibleSyncProfiles READ visibleSyncProfiles NOTIFY profileChanged)
29
30public:
31 ButeoSyncFW(QObject *parent = 0);
32
33 bool syncing() const;
34 QStringList visibleSyncProfiles() const;
35
36 // QQmlParserStatus
37 void classBegin();
38 void componentComplete();
39
40 //! \brief Enum to indicate the change type of the Profile Operation
41 enum ProfileChangeType
42 {
43 //! a New Profile has been added
44 ProfileAdded = 0,
45 //! a Existing Profile has been modified
46 ProfileModified,
47 //! Profile has been Removed
48 ProfileRemoved,
49 //! Profile log file Modified.
50 ProfileLogsModified
51 };
52 Q_ENUMS(ProfileChangeType)
53
54 //! \brief Enum to indicate the change type of the Profile Operation
55 enum SyncStatus
56 {
57 //! Sync request has been queued
58 SyncQueued = 0,
59 //! Sync session has been started
60 SyncStarted,
61 //! Sync session is progressing
62 SyncProgress,
63 //! Sync session has encountered an error
64 SyncError,
65 //! Sync session was successfully completed
66 SyncDone,
67 //! Sync session was aborted
68 SyncAborted
69 };
70 Q_ENUMS(SyncStatus)
71
72signals:
73 /*! \brief Notifies about a change in profile.
74 *
75 * This signal is sent when the profile data is modified or when a profile
76 * is added or deleted in msyncd.
77 * \param aProfileId Id of the changed profile.
78 * \param aChangeType
79 * 0 (ADDITION): Profile was added.
80 * 1 (MODIFICATION): Profile was modified.
81 * 2 (DELETION): Profile was deleted.
82 * \param aChangedProfile changed sync profie as XMl string.
83 *
84 */
85 void profileChanged(QString aProfileId,int aChangeType, QString aChangedProfile);
86
87 /*!
88 * \brief Notifies about a change in synchronization status.
89 *
90 * \param aProfileId Id of the profile used in the sync session whose
91 * status has changed.
92 * \param aStatus The new status. One of the following:
93 * 0 (QUEUED): Sync request has been queued or was already in the
94 * queue when sync start was requested.
95 * 1 (STARTED): Sync session has been started.
96 * 2 (PROGRESS): Sync session is progressing.
97 * 3 (ERROR): Sync session has encountered an error and has been stopped,
98 * or the session could not be started at all.
99 * 4 (DONE): Sync session was successfully completed.
100 * 5 (ABORTED): Sync session was aborted.
101 * Statuses 3-5 are final, no more status changes will be sent from the
102 * same sync session.
103 * \param aMessage A message describing the status change in detail. This
104 * can for example be shown to the user or written to a log
105 * \param aStatusDetails
106 * When aStatus is ERROR, this parameter contains a specific error code.
107 * When aStatus is PROGRESS, this parameter contains more details about the progress
108 * \see SyncCommonDefs::SyncProgressDetails
109 */
110 void syncStatus(QString aProfileId, int aStatus,
111 QString aMessage, int aStatusDetails);
112
113public slots:
114 /*!
115 * \brief Requests to starts synchronizing using a profile Id
116 *
117 * A status change signal (QUEUED, STARTED or ERROR) will be sent by the
118 * daemon when the request is processed. If there is a sync already in
119 * progress using the same resources that are needed by the given profile,
120 * adds the sync request to a sync queue. Otherwise a sync session is
121 * started immediately.
122 *
123 * \param aProfileId Id of the profile to use in sync.
124 * \return True if a profile with the Id was found. Otherwise
125 * false and no status change signals will follow from this request.
126 */
127 bool startSync(const QString &aProfileId) const;
128
129 /*!
130 * \brief Requests to starts synchronizing using a profile category
131 *
132 * \param category Category name of the profile.
133 * \return True if a profile with the Id was found. Otherwise
134 * false and no status change signals will follow from this request.
135 *
136 * \see ButeoSyncFW::startSync
137 */
138 bool startSyncByCategory(const QString &category) const;
139
140 /*!
141 * \brief Stops synchronizing the profile with the given Id.
142 *
143 * If the sync request is still in queue and not yet started, the queue
144 * entry is removed.
145 *
146 * \param aProfileId Id of the profile to stop syncing.
147 */
148 void abortSync(const QString &aProfileId) const;
149
150 /*!
151 * \brief Gets the list of profile names of currently running syncs.
152 *
153 * \return Profile name list.
154 */
155 QStringList getRunningSyncList() const;
156
157 /*! \brief Gets enabled profiles matching the profile category.
158 *
159 * \param category Category name of the profile.
160 * \return The sync profile ids as string list.
161 */
162 QStringList syncProfilesByCategory(const QString &category) const;
163
164 /*!
165 * \brief This function should be called when sync profile has to be deleted
166 *
167 * \param aProfileId Id of the profile to be deleted.
168 * \return status of the remove operation
169 */
170 bool removeProfile(const QString &profileId) const;
171
172private slots:
173 void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
174
175private:
176 QScopedPointer<QDBusInterface> m_iface;
177 QScopedPointer<QDBusServiceWatcher> m_serviceWatcher;
178
179 void initialize();
180 void deinitialize();
181};
0182
=== added file 'Buteo/plugin.cpp'
--- Buteo/plugin.cpp 1970-01-01 00:00:00 +0000
+++ Buteo/plugin.cpp 2015-07-09 14:03:36 +0000
@@ -0,0 +1,27 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
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; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "plugin.h"
18#include "buteo-sync-qml.h"
19
20#include <QtQml/qqml.h>
21
22
23void ButeoSyncQmlPlugin::registerTypes(const char *uri)
24{
25 // @uri Buteo.ButeoSync
26 qmlRegisterType<ButeoSyncFW>(uri, 0, 1, "ButeoSync");
27}
028
=== added file 'Buteo/plugin.h'
--- Buteo/plugin.h 1970-01-01 00:00:00 +0000
+++ Buteo/plugin.h 2015-07-09 14:03:36 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
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; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef BUTE_SYNC_FW_QML_PLUGIN_H
18#define BUTE_SYNC_FW_QML_PLUGIN_H
19
20#include <QQmlExtensionPlugin>
21
22class ButeoSyncQmlPlugin : public QQmlExtensionPlugin
23{
24 Q_OBJECT
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26
27public:
28 void registerTypes(const char *uri);
29};
30
31#endif //BUTE_SYNC_FW_QML_PLUGIN_H
032
=== added file 'Buteo/qmldir'
--- Buteo/qmldir 1970-01-01 00:00:00 +0000
+++ Buteo/qmldir 2015-07-09 14:03:36 +0000
@@ -0,0 +1,2 @@
1module Buteo
2plugin buteo-syncfw-qml
03
=== added file 'CMakeLists.txt'
--- CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ CMakeLists.txt 2015-07-09 14:03:36 +0000
@@ -0,0 +1,30 @@
1project(buteo-sync-qml)
2
3cmake_minimum_required(VERSION 2.8.9)
4
5# Find includes in corresponding build directories
6set(CMAKE_INCLUDE_CURRENT_DIR ON)
7
8# Instruct CMake to run moc automatically when needed.
9set(CMAKE_AUTOMOC ON)
10set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG")
11
12# Standard install paths
13include(GNUInstallDirs)
14
15find_package(PkgConfig REQUIRED)
16find_package(Qt5Core REQUIRED)
17find_package(Qt5Qml REQUIRED)
18find_package(Qt5DBus REQUIRED)
19find_package(Qt5Xml REQUIRED)
20
21enable_testing()
22add_subdirectory(Buteo)
23add_subdirectory(tests)
24
25# uninstall target
26configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
27 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
28 IMMEDIATE @ONLY)
29add_custom_target(uninstall "${CMAKE_COMMAND}"
30 -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
031
=== added file 'cmake_uninstall.cmake.in'
--- cmake_uninstall.cmake.in 1970-01-01 00:00:00 +0000
+++ cmake_uninstall.cmake.in 2015-07-09 14:03:36 +0000
@@ -0,0 +1,21 @@
1IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
2 MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
3ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
4
5FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
6STRING(REGEX REPLACE "\n" ";" files "${files}")
7FOREACH(file ${files})
8 MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
9 IF(EXISTS "$ENV{DESTDIR}${file}")
10 EXEC_PROGRAM(
11 "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
12 OUTPUT_VARIABLE rm_out
13 RETURN_VALUE rm_retval
14 )
15 IF(NOT "${rm_retval}" STREQUAL 0)
16 MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
17 ENDIF(NOT "${rm_retval}" STREQUAL 0)
18 ELSE(EXISTS "$ENV{DESTDIR}${file}")
19 MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
20 ENDIF(EXISTS "$ENV{DESTDIR}${file}")
21ENDFOREACH(file)
022
=== added directory 'debian'
=== added file 'debian/changelog'
--- debian/changelog 1970-01-01 00:00:00 +0000
+++ debian/changelog 2015-07-09 14:03:36 +0000
@@ -0,0 +1,5 @@
1buteo-syncfw-qml (0.1-0ubuntu1) vivid; urgency=medium
2
3 * New package
4
5 -- Renato Araujo Oliveira Filho <renato.filho@canonical.com> Wed, 08 Jul 2015 12:01:34 -0300
06
=== added file 'debian/compat'
--- debian/compat 1970-01-01 00:00:00 +0000
+++ debian/compat 2015-07-09 14:03:36 +0000
@@ -0,0 +1,1 @@
19
02
=== added file 'debian/control'
--- debian/control 1970-01-01 00:00:00 +0000
+++ debian/control 2015-07-09 14:03:36 +0000
@@ -0,0 +1,34 @@
1Source: buteo-syncfw-qml
2Section: libs
3Priority: optional
4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
5Build-Depends: cmake,
6 dbus-test-runner,
7 debhelper (>= 9),
8 pkg-config,
9 qml-module-qttest,
10 qtchooser,
11 qt5-default,
12 qtbase5-dev,
13 qtdeclarative5-dev,
14Standards-Version: 3.9.5
15Homepage: https://launchpad.net/buteo-syncfw-qml
16# if you don't have have commit access to this branch but would like to upload
17# directly to Ubuntu, don't worry: your changes will be merged back into the
18# upstream branch
19Vcs-Bzr: lp:buteo-syncfw-qml
20X-Ubuntu-Use-Langpack: yes
21
22Package: qtdeclarative5-buteo-syncfw0.1
23Architecture: any
24Multi-Arch: same
25Pre-Depends: ${misc:Pre-Depends}
26Depends: ${misc:Depends},
27 ${shlibs:Depends},
28 buteo-syncfw-qt5,
29Description: Buteo sync framework client - QML bindings
30 buteo-syncfw manages data synchronization
31 .
32 This package contains the QML plugin providing the features from the buteo
33 to applications.
34
035
=== added file 'debian/copyright'
--- debian/copyright 1970-01-01 00:00:00 +0000
+++ debian/copyright 2015-07-09 14:03:36 +0000
@@ -0,0 +1,19 @@
1Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2Source: https://launchpad.net/buteo-syncfw-qml
3Upstream-Name: buteo-syncfw-qml
4
5Files: *
6Copyright: 2015 Canonical Ltd.
7License: GPL-3
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 3 as
10 published by the Free Software Foundation.
11 .
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 .
17 On Debian systems, the full text of the GNU General Public
18 License version 3 can be found in the file
19 `/usr/share/common-licenses/GPL-3'.
020
=== added file 'debian/rules'
--- debian/rules 1970-01-01 00:00:00 +0000
+++ debian/rules 2015-07-09 14:03:36 +0000
@@ -0,0 +1,9 @@
1#!/usr/bin/make -f
2# -*- makefile -*-
3export DPKG_GENSYMBOLS_CHECK_LEVEL=4
4
5# Uncomment this to turn on verbose mode.
6#export DH_VERBOSE=1
7
8%:
9 dh $@ --parallel --fail-missing
010
=== added directory 'tests'
=== added file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/CMakeLists.txt 2015-07-09 14:03:36 +0000
@@ -0,0 +1,1 @@
1add_subdirectory(qml)
02
=== added directory 'tests/qml'
=== added file 'tests/qml/CMakeLists.txt'
--- tests/qml/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/qml/CMakeLists.txt 2015-07-09 14:03:36 +0000
@@ -0,0 +1,36 @@
1find_program(QMLTESTRUNNER_BIN
2 NAMES qmltestrunner
3 PATHS /usr/lib/*/qt5/bin
4 NO_DEFAULT_PATH
5)
6
7find_program(DBUS_RUNNER_BIN dbus-test-runner)
8macro(DECLARE_QML_TEST TST_NAME TST_QML_FILE)
9 set(TEST_COMMAND "")
10 add_test(NAME ${TST_NAME}
11 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
12 COMMAND ${DBUS_RUNNER_BIN}
13 --task ${CMAKE_CURRENT_SOURCE_DIR}/buteo-syncfw.py -r -n buteo-syncfw
14 --task ${QMLTESTRUNNER_BIN}
15 -p -input -p ${CMAKE_CURRENT_SOURCE_DIR}/${TST_QML_FILE}
16 -p -import -p ${CMAKE_BINARY_DIR}
17 -p -platform -p offscreen
18 --wait-for=com.meego.msyncd
19 -n ${TST_NAME}
20 )
21endmacro()
22
23if(QMLTESTRUNNER_BIN AND DBUS_RUNNER_BIN)
24 declare_qml_test("buteo_syncfw_component" tst_ButeoSyncFW.qml)
25else()
26 if (NOT QMLTESTRUNNER_BIN)
27 message(WARNING "Qml tests disabled: qmltestrunner not found")
28 else()
29 message(WARNING "Qml tests disabled: dbus-test-runner not found")
30 endif()
31endif()
32
33set(QML_TST_FILES
34 tst_ButeoSyncFW.qml
35)
36add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})
037
=== added file 'tests/qml/buteo-syncfw.py'
--- tests/qml/buteo-syncfw.py 1970-01-01 00:00:00 +0000
+++ tests/qml/buteo-syncfw.py 2015-07-09 14:03:36 +0000
@@ -0,0 +1,163 @@
1#!/usr/bin/python3
2
3'''buteo syncfw mock template
4
5This creates the expected methods and properties of the main
6com.meego.msyncd object. You can specify D-BUS property values
7'''
8
9# This program is free software; you can redistribute it and/or modify it under
10# the terms of the GNU Lesser General Public License as published by the Free
11# Software Foundation; either version 3 of the License, or (at your option) any
12# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
13# of the license.
14
15__author__ = 'Renato Araujo Oliveira Filho'
16__email__ = 'renatofilho@canonical.com'
17__copyright__ = '(c) 2015 Canonical Ltd.'
18__license__ = 'LGPL 3+'
19
20import dbus
21from gi.repository import GObject
22
23import dbus
24import dbus.service
25import dbus.mainloop.glib
26
27BUS_NAME = 'com.meego.msyncd'
28MAIN_OBJ = '/synchronizer'
29MAIN_IFACE = 'com.meego.msyncd'
30SYSTEM_BUS = False
31
32class ButeoSyncFw(dbus.service.Object):
33 PROFILES = [
34"""<?xml version=\"1.0\" encoding=\"UTF-8\"?>
35<profile type=\"sync\" name=\"test-profile\">
36 <key value=\"45\" name=\"accountid\"/>
37 <key value=\"contacts\" name=\"category\"/>
38 <key value=\"google.Contacts-\" name=\"displayname\"/>
39 <key value=\"true\" name=\"enabled\"/>
40 <key value=\"true\" name=\"hidden\"/>
41 <key value=\"30\" name=\"sync_since_days_past\"/>
42 <key value=\"true\" name=\"use_accounts\"/>
43 <profile type=\"client\" name=\"googlecontacts\">
44 <key value=\"two-way\" name=\"Sync Direction\"/>
45 </profile>
46 <schedule time=\"05:00:00\" days=\"4,5,2,3,1,6,7\" syncconfiguredtime=\"\" interval=\"0\" enabled=\"true\">
47 <rush end=\"\" externalsync=\"false\" days=\"\" interval=\"15\" begin=\"\" enabled=\"false\"/>
48 </schedule>
49</profile>""",
50"""<?xml version=\"1.0\" encoding=\"UTF-8\"?>
51<profile type=\"sync\" name=\"testsync-ovi\">
52 <key value=\"calendar\" name=\"category\"/>
53 <schedule syncconfiguredtime=\"\" interval=\"0\" days=\"\" externalsync=\"true\" time=\"\" enabled=\"false\">
54 <rush interval=\"0\" days=\"\" externalsync=\"false\" begin=\"\" enabled=\"false\" end=\"\"/>
55 </schedule>
56</profile>""",
57"""<?xml version=\"1.0\" encoding=\"UTF-8\"?>
58<profile name=\"63807467\" type=\"sync\">
59 <key value=\"110\" name=\"accountid\"/>
60 <key value=\"contacts\" name=\"category\"/>
61 <key value=\"online\" name=\"destinationtype\"/>
62 <key value=\"google-contacts-renato.teste2@gmail.com\" name=\"displayname\"/>
63 <key value=\"true\" name=\"enabled\"/>
64 <key value=\"true\" name=\"hidden\"/>
65 <key value=\"false\" name=\"scheduled\"/>
66 <key value=\"true\" name=\"sync_always_up_to_date\"/>
67 <key value=\"true\" name=\"sync_on_change\"/>
68 <key value=\"30\" name=\"sync_since_days_past\"/>
69 <key value=\"true\" name=\"use_accounts\"/>
70 <profile name=\"googlecontacts\" type=\"client\">
71 <key value=\"two-way\" name=\"Sync Direction\"/>
72 <key value=\"gdata\" name=\"Sync Protocol\"/>
73 <key value=\"HTTP\" name=\"Sync Transport\"/>
74 <key value=\"prefer remote\" name=\"conflictpolicy\"/>
75 <key value=\"true\" name=\"sync_on_change\"/>
76 </profile>
77 <schedule syncconfiguredtime=\"\" days=\"5,4,7,6,1,3,2\" interval=\"60\" enabled=\"false\" time=\"\">
78 <rush begin=\"00:00:00\" end=\"00:00:00\" days=\"\" interval=\"60\" enabled=\"false\" externalsync=\"false\"/>
79 </schedule>
80</profile>""",
81"""<?xml version=\"1.0\" encoding=\"UTF-8\"?>
82<profile type=\"sync\" name=\"template-profile\">
83 <key value=\"contacts\" name=\"category\"/>
84 <key value=\"false\" name=\"enabled\"/>
85 <schedule syncconfiguredtime=\"\" interval=\"0\" days=\"\" externalsync=\"true\" time=\"\" enabled=\"false\">
86 <rush interval=\"0\" days=\"\" externalsync=\"false\" begin=\"\" enabled=\"false\" end=\"\"/>
87 </schedule>
88</profile>"""
89 ]
90
91 def __init__(self, object_path):
92 dbus.service.Object.__init__(self, dbus.SessionBus(), object_path)
93 self._activeSync = []
94 self._profiles = ButeoSyncFw.PROFILES
95
96 @dbus.service.method(dbus_interface=MAIN_IFACE,
97 in_signature='', out_signature='as')
98 def allVisibleSyncProfiles(self):
99 return self._profiles
100
101 @dbus.service.method(dbus_interface=MAIN_IFACE,
102 in_signature='ss', out_signature='as')
103 def syncProfilesByKey(self, key, value):
104 print ("syncProfilesByKey:", key, value)
105 if key == 'category':
106 if value == 'contacts':
107 return [ButeoSyncFw.PROFILES[0], ButeoSyncFw.PROFILES[2], ButeoSyncFw.PROFILES[3]]
108 if value == 'calendar':
109 return [ButeoSyncFw.PROFILES[1]]
110 return []
111
112 @dbus.service.method(dbus_interface=MAIN_IFACE,
113 in_signature='s', out_signature='')
114 def abortSync(self, profileId):
115 if profileId in self._activeSync:
116 self._activeSync.remove(profileId)
117 self.syncStatus(profileId, 5, 'aborted by the user', 0)
118 return
119
120 @dbus.service.method(dbus_interface=MAIN_IFACE,
121 in_signature='s', out_signature='b')
122 def startSync(self, profileId):
123 if profileId in ['63807467', 'testsync-ovi', 'test-profile']:
124 self._activeSync.append(profileId)
125 self.syncStatus(profileId, 1, '', 0)
126 return True
127 return False
128
129 @dbus.service.method(dbus_interface=MAIN_IFACE,
130 in_signature='', out_signature='as')
131 def runningSyncs(self):
132 return self._activeSync
133
134 @dbus.service.signal(dbus_interface=MAIN_IFACE,
135 signature='sisi')
136 def syncStatus(self, profileId, status, message, statusDetails):
137 print("SyncStatus called")
138
139 @dbus.service.signal(dbus_interface=MAIN_IFACE,
140 signature='sis')
141 def signalProfileChanged(self, profileId, status, changedProfile):
142 print("profileChanged called")
143
144 @dbus.service.method(dbus_interface=MAIN_IFACE,
145 in_signature='s', out_signature='b')
146 def removeProfile(self, profileId):
147 if int(profileId) < len(self._profiles):
148 self._profiles.remove(self._profiles[int(profileId)])
149 self.signalProfileChanged(profileId, 2, 'deleted')
150 return True
151 else:
152 return False
153
154
155
156if __name__ == '__main__':
157 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
158
159 name = dbus.service.BusName(BUS_NAME)
160 mainloop = GObject.MainLoop()
161 buteo = ButeoSyncFw(MAIN_OBJ)
162 mainloop.run()
163
0164
=== added file 'tests/qml/tst_ButeoSyncFW.qml'
--- tests/qml/tst_ButeoSyncFW.qml 1970-01-01 00:00:00 +0000
+++ tests/qml/tst_ButeoSyncFW.qml 2015-07-09 14:03:36 +0000
@@ -0,0 +1,174 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
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; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18import Buteo 0.1
19import QtTest 1.0
20
21Item {
22 id: root
23
24 property var buteoComponent
25
26 TestCase {
27 id: vcardParser
28 name: 'ButeoSyncFWTestCase'
29
30 function init()
31 {
32 buteoComponent = Qt.createQmlObject('import Buteo 0.1; ButeoSync{ }', root);
33 }
34
35 function cleanup()
36 {
37 if (buteoComponent) {
38 var activeProfiles = buteoComponent.getRunningSyncList()
39 for (var i in activeProfiles) {
40 buteoComponent.abortSync(activeProfiles[i])
41 }
42 activeProfiles = buteoComponent.getRunningSyncList()
43 compare(activeProfiles.length, 0)
44
45 buteoComponent.destroy()
46 buteoComponent = null
47 }
48 }
49
50 function test_start_sync()
51 {
52 var spy = Qt.createQmlObject('import QtTest 1.0; SignalSpy{ }', root);
53 spy.target = buteoComponent
54 spy.signalName = "syncStatus"
55
56 compare(buteoComponent.startSync('1234'), false)
57 compare(buteoComponent.startSync('63807467'), true)
58
59 tryCompare(spy, "count", 1)
60 compare(spy.signalArguments[0][0], '63807467')
61 compare(spy.signalArguments[0][1], ButeoSync.SyncStarted)
62 compare(spy.signalArguments[0][2], '')
63 }
64
65 function test_abort_sync()
66 {
67 var spy = Qt.createQmlObject('import QtTest 1.0; SignalSpy{ }', root);
68 spy.target = buteoComponent
69 spy.signalName = "syncStatus"
70
71 compare(buteoComponent.startSync('63807467'), true)
72 tryCompare(spy, "count", 1)
73
74 var spy2 = Qt.createQmlObject('import QtTest 1.0; SignalSpy{ }', root);
75 spy2.target = buteoComponent
76 spy2.signalName = "syncStatus"
77
78 buteoComponent.abortSync('63807467')
79
80 tryCompare(spy2, "count", 1)
81 compare(spy2.signalArguments[0][0], '63807467')
82 compare(spy2.signalArguments[0][1], ButeoSync.SyncAborted)
83 compare(spy2.signalArguments[0][2], 'aborted by the user')
84 }
85
86 function test_syncing_property()
87 {
88 // check if no sync is running
89 compare(buteoComponent.syncing, false)
90
91 // start a new sync and check if the property changed to true
92 buteoComponent.startSync('63807467')
93 tryCompare(buteoComponent, 'syncing', true)
94
95 // abort current sync and check if sync property changed to false
96 buteoComponent.abortSync('63807467')
97 tryCompare(buteoComponent, 'syncing', false)
98 }
99
100 function test_visibleSyncProfiles_property()
101 {
102 compare(buteoComponent.visibleSyncProfiles.length, 4)
103 var spy = Qt.createQmlObject('import QtTest 1.0; SignalSpy{ }', root);
104 spy.target = buteoComponent
105 spy.signalName = "profileChanged"
106
107 buteoComponent.removeProfile('3')
108 tryCompare(spy, "count", 1)
109 compare(spy.signalArguments[0][0], '3')
110 compare(spy.signalArguments[0][1], ButeoSync.ProfileRemoved)
111 compare(spy.signalArguments[0][2], 'deleted')
112 compare(buteoComponent.visibleSyncProfiles.length, 3)
113 spy.clear()
114
115 buteoComponent.removeProfile('2')
116 tryCompare(spy, "count", 1)
117 compare(spy.signalArguments[0][0], '2')
118 compare(spy.signalArguments[0][1], ButeoSync.ProfileRemoved)
119 compare(spy.signalArguments[0][2], 'deleted')
120 compare(buteoComponent.visibleSyncProfiles.length, 2)
121 spy.clear()
122
123 buteoComponent.removeProfile('1')
124 tryCompare(spy, "count", 1)
125 compare(spy.signalArguments[0][0], '1')
126 compare(spy.signalArguments[0][1], ButeoSync.ProfileRemoved)
127 compare(spy.signalArguments[0][2], 'deleted')
128 compare(buteoComponent.visibleSyncProfiles.length, 1)
129 spy.clear()
130
131 buteoComponent.removeProfile('0')
132 tryCompare(spy, "count", 1)
133 compare(spy.signalArguments[0][0], '0')
134 compare(spy.signalArguments[0][1], ButeoSync.ProfileRemoved)
135 compare(spy.signalArguments[0][2], 'deleted')
136 compare(buteoComponent.visibleSyncProfiles.length, 0)
137 spy.clear()
138 }
139
140 function test_sync_by_profile_by_category()
141 {
142 var profiles = buteoComponent.syncProfilesByCategory('contacts')
143 compare(profiles.length, 2)
144 compare(profiles[0], 'test-profile')
145 compare(profiles[1], '63807467')
146 }
147
148 function test_sync_by_category()
149 {
150 var spy = Qt.createQmlObject('import QtTest 1.0; SignalSpy{ }', root);
151 spy.target = buteoComponent
152 spy.signalName = "syncStatus"
153
154 compare(buteoComponent.startSyncByCategory('contacts'), true)
155
156 // wait for two signals (since we have two contacts profiles)
157 tryCompare(spy, "count", 2)
158 // first profile
159 compare(spy.signalArguments[0][0], 'test-profile')
160 compare(spy.signalArguments[0][1], ButeoSync.SyncStarted)
161 compare(spy.signalArguments[0][2], '')
162
163 // secound profile
164 compare(spy.signalArguments[1][0], '63807467')
165 compare(spy.signalArguments[1][1], ButeoSync.SyncStarted)
166 compare(spy.signalArguments[1][2], '')
167
168 var activeProfiles = buteoComponent.getRunningSyncList()
169 compare(activeProfiles.length, 2)
170 compare(activeProfiles[0], 'test-profile')
171 compare(activeProfiles[1], '63807467')
172 }
173 }
174}

Subscribers

People subscribed via source and target branches