Buteo Synchronization Framework: ServerActivator.h Source File

Buteo Synchronization Framework

ServerActivator.h
1 /*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 *
6 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.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 SERVERACTIVATOR_H_
25 #define SERVERACTIVATOR_H_
26
27 #include "TransportTracker.h"
28 #include "ProfileManager.h"
29 #include <QObject>
30 #include <QMap>
31 #include <QString>
32
33 namespace Buteo {
34
47 class ServerActivator : public QObject
48 {
49 Q_OBJECT
50
51 public:
52
59 ServerActivator(ProfileManager &aProfileManager,
60 TransportTracker &aTransportTracker, QObject *aParent = 0);
61
63 virtual ~ServerActivator();
64
73 int addRef(const QString &aServerName, bool emitSignal = true);
74
83 int removeRef(const QString &aServerName, bool emitSignal = true);
84
89 QStringList enabledServers() const;
90
91 signals:
92
97 void serverEnabled(const QString &aServerName);
98
103 void serverDisabled(const QString &aServerName);
104
105 public slots:
106
112 void onConnectivityStateChanged(Sync::ConnectivityType aType, bool aState);
113
114 private:
115
116 QList<Sync::ConnectivityType> transportsFromProfile(const Profile *aProfile);
117
118 ProfileManager &iProfileManager;
119
120 TransportTracker &iTransportTracker;
121
122 struct ServerData {
123 ServerData() : iRefCount(0) { }
124 QList<Sync::ConnectivityType> iTransports;
125 int iRefCount;
126 };
127
128 QMap<QString, ServerData> iServers;
129
130 #ifdef SYNCFW_UNIT_TESTS
131 friend class ServerActivatorTest;
132 #endif
133
134 };
135
136 }
137
138 #endif /* SERVERACTIVATOR_H_ */
Buteo::ProfileManager
ProfileManager is responsible for storing and retrieving the profiles.
Definition: ProfileManager.h:46
Buteo::Profile
This class represents a single profile, a collection of settings or data releated to some entity.
Definition: Profile.h:53
Buteo::ServerActivator
Keeps track of which server plug-ins should be enabled.
Definition: ServerActivator.h:48
Buteo::ServerActivator::addRef
int addRef(const QString &aServerName, bool emitSignal=true)
Adds a reference to the given server.
Definition: ServerActivator.cpp:90
Buteo::ServerActivator::~ServerActivator
virtual ~ServerActivator()
Destructor.
Definition: ServerActivator.cpp:85
Buteo::ServerActivator::serverDisabled
void serverDisabled(const QString &aServerName)
Signal emitted when a server should be disabled.
Definition: moc_ServerActivator.cpp:172
Buteo::ServerActivator::enabledServers
QStringList enabledServers() const
Gets the list of enabled server.
Definition: ServerActivator.cpp:128
Buteo::ServerActivator::onConnectivityStateChanged
void onConnectivityStateChanged(Sync::ConnectivityType aType, bool aState)
Called when transport state changes.
Definition: ServerActivator.cpp:142
Buteo::ServerActivator::removeRef
int removeRef(const QString &aServerName, bool emitSignal=true)
Removes a reference from the given server.
Definition: ServerActivator.cpp:107
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.
Definition: moc_ServerActivator.cpp:165
Buteo::TransportTracker
Class for tracking transport states.
Definition: TransportTracker.h:50
QList< Sync::ConnectivityType >
QMap< QString, ServerData >