BackgroundSync.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2014 Jolla Ltd.
*
* Contact: Valerio Valerio <valerio.valerio@jolla.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef BACKGROUNDSYNC_H
#define BACKGROUNDSYNC_H
#include <QObject>
#include <QMap>
#include <QDateTime>
#include <keepalive/backgroundactivity.h>
class BackgroundActivity;
class BackgroundSync : public QObject
{
Q_OBJECT
struct BActivityStruct {
QString id;
BackgroundActivity *backgroundActivity;
BackgroundActivity::Frequency frequency;
};
struct BActivitySwitchStruct {
QString id;
BackgroundActivity *backgroundActivity;
QDateTime nextSwitch;
};
public:
BackgroundSync(QObject *aParent);
virtual ~BackgroundSync();
bool set(const QString &aProfName, int seconds);
bool remove(const QString &aProfName);
void removeAll();
// Sync switch
bool setSwitch(const QString &aProfName, const QDateTime &aSwitchTime);
bool removeSwitch(const QString &aProfName);
signals:
void onBackgroundSyncRunning(QString aProfName);
void onBackgroundSwitchRunning(const QString &aProfName);
public slots:
void onBackgroundSyncCompleted(QString aProfName);
private slots:
void onBackgroundSyncStarted();
void onBackgroundSwitchStarted();
private:
QString getProfNameFromId(const QString activityId) const;
BackgroundActivity::Frequency frequencyFromSeconds(int seconds);
// Sync switch
void removeAllSwitches();
QString getProfNameFromSwitchId(const QString activityId) const;
private:
QMap<QString, BActivityStruct> iScheduledSyncs;
QMap<QString, BActivitySwitchStruct> iScheduledSwitch;
};
#endif // BACKGROUNDSYNC_H
BackgroundSync::onBackgroundSyncCompleted
void onBackgroundSyncCompleted(QString aProfName)
Called when background sync is completed.
Definition BackgroundSync.cpp:155
BackgroundSync::BackgroundSync
BackgroundSync(QObject *aParent)
Constructor.
Definition BackgroundSync.cpp:34
BackgroundSync::~BackgroundSync
virtual ~BackgroundSync()
Destructor.
Definition BackgroundSync.cpp:40
BackgroundSync::onBackgroundSwitchRunning
void onBackgroundSwitchRunning(const QString &aProfName)
This signal will be emitted when a switch timer for particular profile is triggered.
BackgroundSync::set
bool set(const QString &aProfName, int seconds)
Schedules a background sync for this profile.
Definition BackgroundSync.cpp:84
BackgroundSync::removeAll
void removeAll()
Removes all background syncs for all profiles.
Definition BackgroundSync.cpp:47
BackgroundSync::removeSwitch
bool removeSwitch(const QString &aProfName)
Removes a switch(rush/off-rush) for a profile.
Definition BackgroundSync.cpp:228
BackgroundSync::onBackgroundSyncRunning
void onBackgroundSyncRunning(QString aProfName)
This signal will be emitted when a background sync timer for particular profile is triggered.
BackgroundSync::setSwitch
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
BackgroundSync::remove
bool remove(const QString &aProfName)
Removes background sync for a profile.
Definition BackgroundSync.cpp:66
QMap
Definition SyncBackupAdaptor.h:41