Buteo Synchronization Framework
BackgroundSync.h
1/*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2014 Jolla Ltd.
5 *
6 * Contact: Valerio Valerio <valerio.valerio@jolla.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef BACKGROUNDSYNC_H
25#define BACKGROUNDSYNC_H
26
27#include <QObject>
28#include <QMap>
29#include <QDateTime>
30
31#include <keepalive/backgroundactivity.h>
32
33class BackgroundActivity;
34
38class BackgroundSync : public QObject
39{
40 Q_OBJECT
41
43 struct BActivityStruct {
44 QString id;
45 BackgroundActivity *backgroundActivity;
46 BackgroundActivity::Frequency frequency;
47 };
48
50 struct BActivitySwitchStruct {
51 QString id;
52 BackgroundActivity *backgroundActivity;
53 QDateTime nextSwitch;
54 };
55
56public:
60 BackgroundSync(QObject *aParent);
61
65 virtual ~BackgroundSync();
66
82 bool set(const QString &aProfName, int seconds, bool aExactTime = false);
83
88 bool remove(const QString &aProfName);
89
92 void removeAll();
93
94 // Sync switch
95
103 bool setSwitch(const QString &aProfName, const QDateTime &aSwitchTime);
104
109 bool removeSwitch(const QString &aProfName);
110
111signals:
116 void backgroundSyncRunning(QString aProfName);
117
122 void backgroundSwitchRunning(const QString &aProfName);
123
124public slots:
129 void onBackgroundSyncCompleted(QString aProfName);
130
131private slots:
134 void onBackgroundSyncStarted();
135
138 void onBackgroundSwitchStarted();
139
140private:
146 QString getProfNameFromId(const QString activityId) const;
147
153
154 BackgroundActivity::Frequency frequencyFromSeconds(int seconds);
155
156 // Sync switch
157
160 void removeAllSwitches();
161
167 QString getProfNameFromSwitchId(const QString activityId) const;
168
169private:
171 QMap<QString, BActivityStruct> iScheduledSyncs;
172
175};
176
177#endif // BACKGROUNDSYNC_H
bool set(const QString &aProfName, int seconds, bool aExactTime=false)
Schedules a background sync for this profile.
Definition BackgroundSync.cpp:91
void backgroundSyncRunning(QString aProfName)
This signal will be emitted when a background sync timer for particular profile is triggered.
void onBackgroundSyncCompleted(QString aProfName)
Called when background sync is completed.
Definition BackgroundSync.cpp:170
BackgroundSync(QObject *aParent)
Constructor.
Definition BackgroundSync.cpp:41
virtual ~BackgroundSync()
Destructor.
Definition BackgroundSync.cpp:47
void backgroundSwitchRunning(const QString &aProfName)
This signal will be emitted when a switch timer for particular profile is triggered.
void removeAll()
Removes all background syncs for all profiles.
Definition BackgroundSync.cpp:54
bool removeSwitch(const QString &aProfName)
Removes a switch(rush/off-rush) for a profile.
Definition BackgroundSync.cpp:243
bool setSwitch(const QString &aProfName, const QDateTime &aSwitchTime)
Schedules a switch(rush/off-rush) for a background sync running for this profile, the switch should b...
Definition BackgroundSync.cpp:259
bool remove(const QString &aProfName)
Removes background sync for a profile.
Definition BackgroundSync.cpp:73
Definition SyncBackupAdaptor.h:41