2
* Copyright 2014 Canonical Ltd.
4
* This file is part of sync-monitor.
6
* sync-monitor is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 3.
10
* contact-service-app is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#include "syncmonitor-qml.h"
23
#define SYNCMONITOR_DBUS_SERVICE_NAME "com.canonical.SyncMonitor"
24
#define SYNCMONITOR_DBUS_OBJECT_PATH "/com/canonical/SyncMonitor"
25
#define SYNCMONITOR_DBUS_INTERFACE "com.canonical.SyncMonitor"
30
\inqmlmodule Ubuntu.SyncMonitor 0.1
31
\brief The SyncMonitor is a helper class to get access to SyncMonitor Daemon
33
\b{This component is under heavy development.}
43
onClick: syncMonitor.sync(["calendar", ["contacts"])
49
SyncMonitorQml::SyncMonitorQml(QObject *parent)
55
SyncMonitorQml::~SyncMonitorQml()
66
Specifies the current sync monitor state
69
\li "idle" - Service is in idle state
70
\li "syncing" - Service is running a sync
73
\qmlproperty string state
75
QString SyncMonitorQml::state() const
78
return m_iface->property("state").toString();
85
Specifies the enabled services to sync
87
\qmlproperty list enabledServices
89
QStringList SyncMonitorQml::enabledServices() const
92
return m_iface->property("enabledServices").toStringList();
98
void SyncMonitorQml::classBegin()
102
void SyncMonitorQml::componentComplete()
104
m_iface = new QDBusInterface(SYNCMONITOR_DBUS_SERVICE_NAME,
105
SYNCMONITOR_DBUS_OBJECT_PATH,
106
SYNCMONITOR_DBUS_INTERFACE);
107
if (m_iface->lastError().isValid()) {
108
qWarning() << "Fail to connect with sync monitor:" << m_iface->lastError();
112
connect(m_iface, SIGNAL(stateChanged()), SIGNAL(stateChanged()));
113
connect(m_iface, SIGNAL(enabledServicesChanged()), SIGNAL(enabledServicesChanged()));
114
Q_EMIT stateChanged();
115
Q_EMIT enabledServicesChanged();
119
Start a new sync for specified services
121
void SyncMonitorQml::sync(const QStringList &services)
124
m_iface->call("sync", services);
129
Cancel current sync for specified services
131
void SyncMonitorQml::cancel(const QStringList &services)
134
m_iface->call("cancel", services);
139
Chek if a specific service is enabled or not
141
bool SyncMonitorQml::serviceIsEnabled(const QString &service)
143
return enabledServices().contains(service);