Buteo Synchronization Framework
StorageBooker.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#ifndef STORAGEBOOKER_H
24#define STORAGEBOOKER_H
25
26#include <QString>
27#include <QStringList>
28#include <QMap>
29#include <QMutex>
30
31namespace Buteo {
32
37{
38public:
41
44
57 bool reserveStorage(const QString &aStorageName,
58 const QString &aClientId = "");
59
70 bool reserveStorages(const QStringList &aStorageNames,
71 const QString &aClientId = "");
72
79 unsigned releaseStorage(const QString &aStorageName);
80
85 void releaseStorages(const QStringList &aStorageNames);
86
96 bool isStorageAvailable(const QString &aStorageName,
97 const QString &aClientId = "") const;
98
105 bool storagesAvailable(const QStringList &aStorageNames,
106 const QString &aClientId = "") const;
107
108private:
109 struct StorageMapItem {
110 QString iClientId;
111 unsigned iRefCount;
112
113 StorageMapItem() : iRefCount(0) { };
114
115 StorageMapItem(const QString &aClientId) :
116 iClientId(aClientId), iRefCount(1) { };
117 };
118
120 mutable QMutex iMutex;
121};
122
123}
124
125#endif // STORAGEBOOKER_H
A helper class for managing storage reservations.
Definition StorageBooker.h:37
unsigned releaseStorage(const QString &aStorageName)
Releases the given storage.
Definition StorageBooker.cpp:94
void releaseStorages(const QStringList &aStorageNames)
Releases the given storages.
Definition StorageBooker.cpp:117
StorageBooker()
Constructor.
Definition StorageBooker.cpp:29
bool reserveStorages(const QStringList &aStorageNames, const QString &aClientId="")
Tries to reserve multiple storages for the given client.
Definition StorageBooker.cpp:74
bool isStorageAvailable(const QString &aStorageName, const QString &aClientId="") const
Checks if the given storage is available for the given client.
Definition StorageBooker.cpp:128
bool reserveStorage(const QString &aStorageName, const QString &aClientId="")
Tries to reserve one storage for the given client.
Definition StorageBooker.cpp:44
~StorageBooker()
Destructor.
Definition StorageBooker.cpp:39
bool storagesAvailable(const QStringList &aStorageNames, const QString &aClientId="") const
Checks if the given storages are available for the given client.
Definition StorageBooker.cpp:141
Definition SyncBackupAdaptor.h:41