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
74
75 bool set(const QString &aProfName, int seconds);
76
81 bool remove(const QString &aProfName);
82
85 void removeAll();
86
87 // Sync switch
88
96 bool setSwitch(const QString &aProfName, const QDateTime &aSwitchTime);
97
102 bool removeSwitch(const QString &aProfName);
103
104signals:
105
110 void onBackgroundSyncRunning(QString aProfName);
111
116 void onBackgroundSwitchRunning(const QString &aProfName);
117
118public slots:
123 void onBackgroundSyncCompleted(QString aProfName);
124
125private slots:
128 void onBackgroundSyncStarted();
129
132 void onBackgroundSwitchStarted();
133
134private:
140 QString getProfNameFromId(const QString activityId) const;
141
147
148 BackgroundActivity::Frequency frequencyFromSeconds(int seconds);
149
150 // Sync switch
151
154 void removeAllSwitches();
155
161 QString getProfNameFromSwitchId(const QString activityId) const;
162
163private:
165 QMap<QString, BActivityStruct> iScheduledSyncs;
166
169};
170
171#endif // BACKGROUNDSYNC_H
void onBackgroundSyncCompleted(QString aProfName)
Called when background sync is completed.
Definition BackgroundSync.cpp:155
BackgroundSync(QObject *aParent)
Constructor.
Definition BackgroundSync.cpp:34
virtual ~BackgroundSync()
Destructor.
Definition BackgroundSync.cpp:40
void onBackgroundSwitchRunning(const QString &aProfName)
This signal will be emitted when a switch timer for particular profile is triggered.
bool set(const QString &aProfName, int seconds)
Schedules a background sync for this profile.
Definition BackgroundSync.cpp:84
void removeAll()
Removes all background syncs for all profiles.
Definition BackgroundSync.cpp:47
bool removeSwitch(const QString &aProfName)
Removes a switch(rush/off-rush) for a profile.
Definition BackgroundSync.cpp:228
void onBackgroundSyncRunning(QString aProfName)
This signal will be emitted when a background sync timer for particular profile is triggered.
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:244
bool remove(const QString &aProfName)
Removes background sync for a profile.
Definition BackgroundSync.cpp:66
Definition SyncBackupAdaptor.h:41