~phablet-team/sync-monitor/trunk

« back to all changes in this revision

Viewing changes to Ubuntu/SyncMonitor/syncmonitor-qml.cpp

  • Committer: Bileto Bot
  • Author(s): Renato Araujo Oliveira Filho
  • Date: 2016-07-01 02:14:41 UTC
  • mfrom: (37.3.61 sync-individual-sources)
  • Revision ID: ci-train-bot@canonical.com-20160701021441-su9ubhybvttesfqt
Remove syncevolution account config files if the account get removed.
Avoid create extra sources for accounts on syncevolution config.
Create a config for each google calendar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 
49
49
SyncMonitorQml::SyncMonitorQml(QObject *parent)
50
50
    : QObject(parent),
51
 
      m_iface(0)
 
51
      m_iface(0),
 
52
      m_watcher(0)
52
53
{
53
54
}
54
55
 
55
56
SyncMonitorQml::~SyncMonitorQml()
56
57
{
 
58
    if (m_watcher) {
 
59
        delete m_watcher;
 
60
        m_watcher = 0;
 
61
    }
57
62
    if (m_iface) {
58
63
        m_iface->call("detach");
59
 
        delete m_iface;
60
 
        m_iface = 0;
 
64
        disconnectFromServer();
61
65
    }
62
66
}
63
67
 
64
 
 
65
 
 
66
68
/*!
67
69
  Specifies the current sync monitor state
68
70
 
102
104
 
103
105
void SyncMonitorQml::componentComplete()
104
106
{
 
107
    connectToServer();
 
108
    m_watcher = new QDBusServiceWatcher(QString(SYNCMONITOR_DBUS_SERVICE_NAME),
 
109
                                        QDBusConnection::sessionBus(),
 
110
                                        QDBusServiceWatcher::WatchForOwnerChange,
 
111
                                        this);
 
112
    connect(m_watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToServer()));
 
113
    connect(m_watcher, SIGNAL(serviceUnregistered(QString)), SLOT(disconnectFromServer()));
 
114
}
 
115
 
 
116
/*!
 
117
  Start a new sync for specified services
 
118
*/
 
119
void SyncMonitorQml::sync()
 
120
{
 
121
    if (m_iface) {
 
122
        m_iface->call("syncAll");
 
123
    }
 
124
}
 
125
 
 
126
/*!
 
127
  Cancel current sync for specified services
 
128
*/
 
129
void SyncMonitorQml::cancel()
 
130
{
 
131
    if (m_iface) {
 
132
        m_iface->call("cancelAll");
 
133
    }
 
134
}
 
135
 
 
136
/*!
 
137
  Chek if a specific service is enabled or not
 
138
*/
 
139
bool SyncMonitorQml::serviceIsEnabled(const QString &service)
 
140
{
 
141
    return enabledServices().contains(service);
 
142
}
 
143
 
 
144
void SyncMonitorQml::connectToServer()
 
145
{
 
146
    if (m_iface) {
 
147
        delete m_iface;
 
148
    }
 
149
 
105
150
    m_iface = new QDBusInterface(SYNCMONITOR_DBUS_SERVICE_NAME,
106
151
                                 SYNCMONITOR_DBUS_OBJECT_PATH,
107
152
                                 SYNCMONITOR_DBUS_INTERFACE);
108
153
    if (m_iface->lastError().isValid()) {
109
154
        qWarning() << "Fail to connect with sync monitor:" << m_iface->lastError();
110
 
        return;
 
155
        delete m_iface;
 
156
        m_iface = 0;
 
157
    } else {
 
158
        connect(m_iface, SIGNAL(stateChanged()), SIGNAL(stateChanged()));
 
159
        connect(m_iface, SIGNAL(enabledServicesChanged()), SIGNAL(enabledServicesChanged()));
 
160
        m_iface->call("attach");
 
161
        Q_EMIT enabledServicesChanged();
111
162
    }
 
163
    Q_EMIT stateChanged();
 
164
}
112
165
 
113
 
    connect(m_iface, SIGNAL(stateChanged()), SIGNAL(stateChanged()));
114
 
    connect(m_iface, SIGNAL(enabledServicesChanged()), SIGNAL(enabledServicesChanged()));
115
 
    m_iface->call("attach");
116
 
    Q_EMIT stateChanged();
 
166
void SyncMonitorQml::disconnectFromServer()
 
167
{
 
168
    if (m_iface) {
 
169
        delete m_iface;
 
170
        m_iface = 0;
 
171
    }
117
172
    Q_EMIT enabledServicesChanged();
118
 
}
119
 
 
120
 
/*!
121
 
  Start a new sync for specified services
122
 
*/
123
 
void SyncMonitorQml::sync(const QStringList &services)
124
 
{
125
 
    if (m_iface) {
126
 
        m_iface->call("sync", services);
127
 
    }
128
 
}
129
 
 
130
 
/*!
131
 
  Cancel current sync for specified services
132
 
*/
133
 
void SyncMonitorQml::cancel(const QStringList &services)
134
 
{
135
 
    if (m_iface) {
136
 
        m_iface->call("cancel", services);
137
 
    }
138
 
}
139
 
 
140
 
/*!
141
 
  Chek if a specific service is enabled or not
142
 
*/
143
 
bool SyncMonitorQml::serviceIsEnabled(const QString &service)
144
 
{
145
 
    return enabledServices().contains(service);
 
173
    Q_EMIT stateChanged();
146
174
}