ServerActivator.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.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 SERVERACTIVATOR_H_
#define SERVERACTIVATOR_H_
#include "TransportTracker.h"
#include "ProfileManager.h"
#include <QObject>
#include <QMap>
#include <QString>
namespace Buteo {
class ServerActivator : public QObject
{
Q_OBJECT
public:
ServerActivator(ProfileManager &aProfileManager,
TransportTracker &aTransportTracker, QObject *aParent = 0);
virtual ~ServerActivator();
int addRef(const QString &aServerName, bool emitSignal = true);
int removeRef(const QString &aServerName, bool emitSignal = true);
QStringList enabledServers() const;
signals:
void serverEnabled(const QString &aServerName);
void serverDisabled(const QString &aServerName);
public slots:
void onConnectivityStateChanged(Sync::ConnectivityType aType, bool aState);
private:
QList<Sync::ConnectivityType> transportsFromProfile(const Profile *aProfile);
ProfileManager &iProfileManager;
TransportTracker &iTransportTracker;
struct ServerData {
ServerData() : iRefCount(0) { }
QList<Sync::ConnectivityType> iTransports;
int iRefCount;
};
QMap<QString, ServerData> iServers;
#ifdef SYNCFW_UNIT_TESTS
friend class ServerActivatorTest;
#endif
};
}
#endif /* SERVERACTIVATOR_H_ */
Buteo::ProfileManager
ProfileManager is responsible for storing and retrieving the profiles.
Definition ProfileManager.h:47
Buteo::Profile
This class represents a single profile, a collection of settings or data releated to some entity.
Definition Profile.h:53
Buteo::ServerActivator::addRef
int addRef(const QString &aServerName, bool emitSignal=true)
Adds a reference to the given server.
Definition ServerActivator.cpp:91
Buteo::ServerActivator::~ServerActivator
virtual ~ServerActivator()
Destructor.
Definition ServerActivator.cpp:86
Buteo::ServerActivator::serverDisabled
void serverDisabled(const QString &aServerName)
Signal emitted when a server should be disabled.
Buteo::ServerActivator::enabledServers
QStringList enabledServers() const
Gets the list of enabled server.
Definition ServerActivator.cpp:129
Buteo::ServerActivator::onConnectivityStateChanged
void onConnectivityStateChanged(Sync::ConnectivityType aType, bool aState)
Called when transport state changes.
Definition ServerActivator.cpp:143
Buteo::ServerActivator::removeRef
int removeRef(const QString &aServerName, bool emitSignal=true)
Removes a reference from the given server.
Definition ServerActivator.cpp:108
Buteo::ServerActivator::ServerActivator
ServerActivator(ProfileManager &aProfileManager, TransportTracker &aTransportTracker, QObject *aParent=0)
Constructor.
Definition ServerActivator.cpp:30
Buteo::ServerActivator::serverEnabled
void serverEnabled(const QString &aServerName)
Signal emitted when a server should be enabled.
Buteo::TransportTracker
Class for tracking transport states.
Definition TransportTracker.h:49
QList
Definition SyncBackupAdaptor.h:40
QMap
Definition SyncBackupAdaptor.h:41