summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SwifTools/Application/ApplicationPathProvider.cpp4
-rw-r--r--SwifTools/Application/ApplicationPathProvider.h1
-rw-r--r--Swift/Controllers/FileStoragesFactory.h24
-rw-r--r--Swift/Controllers/MainController.cpp46
-rw-r--r--Swift/Controllers/MainController.h22
-rw-r--r--Swift/Controllers/StoragesFactory.h (renamed from Swiften/VCards/VCardStorageFactory.h)9
-rw-r--r--Swift/QtUI/QtSwift.cpp14
-rw-r--r--Swift/QtUI/QtSwift.h11
-rw-r--r--Swiften/Client/Client.cpp20
-rw-r--r--Swiften/Client/Client.h18
-rw-r--r--Swiften/Client/FileStorages.cpp39
-rw-r--r--Swiften/Client/FileStorages.h33
-rw-r--r--Swiften/Client/MemoryStorages.cpp38
-rw-r--r--Swiften/Client/MemoryStorages.h28
-rw-r--r--Swiften/Client/Storages.h22
-rw-r--r--Swiften/SConscript2
-rw-r--r--Swiften/VCards/SConscript1
-rw-r--r--Swiften/VCards/VCardFileStorageFactory.h27
-rw-r--r--Swiften/VCards/VCardMemoryStorageFactory.h24
-rw-r--r--Swiften/VCards/VCardStorageFactory.cpp14
20 files changed, 252 insertions, 145 deletions
diff --git a/SwifTools/Application/ApplicationPathProvider.cpp b/SwifTools/Application/ApplicationPathProvider.cpp
index bf0a19e..2c5db7e 100644
--- a/SwifTools/Application/ApplicationPathProvider.cpp
+++ b/SwifTools/Application/ApplicationPathProvider.cpp
@@ -18,10 +18,6 @@ ApplicationPathProvider::ApplicationPathProvider(const String& applicationName)
ApplicationPathProvider::~ApplicationPathProvider() {
}
-boost::filesystem::path ApplicationPathProvider::getAvatarDir() const {
- return getDataDir() / "avatars";
-}
-
boost::filesystem::path ApplicationPathProvider::getProfileDir(const String& profile) const {
boost::filesystem::path result(getHomeDir() / profile.getUTF8String());
try {
diff --git a/SwifTools/Application/ApplicationPathProvider.h b/SwifTools/Application/ApplicationPathProvider.h
index 7bd2630..0c2d302 100644
--- a/SwifTools/Application/ApplicationPathProvider.h
+++ b/SwifTools/Application/ApplicationPathProvider.h
@@ -17,7 +17,6 @@ namespace Swift {
ApplicationPathProvider(const String& applicationName);
virtual ~ApplicationPathProvider();
- boost::filesystem::path getAvatarDir() const;
virtual boost::filesystem::path getHomeDir() const = 0;
virtual boost::filesystem::path getDataDir() const = 0;
virtual boost::filesystem::path getExecutableDir() const = 0;
diff --git a/Swift/Controllers/FileStoragesFactory.h b/Swift/Controllers/FileStoragesFactory.h
new file mode 100644
index 0000000..bd7cdfb
--- /dev/null
+++ b/Swift/Controllers/FileStoragesFactory.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swift/Controllers/StoragesFactory.h"
+#include "Swiften/Client/FileStorages.h"
+
+namespace Swift {
+ class FileStoragesFactory : public StoragesFactory {
+ public:
+ FileStoragesFactory(const boost::filesystem::path& basePath) : basePath(basePath) {}
+
+ virtual Storages* createStorages(const JID& profile) const {
+ return new FileStorages(basePath, profile);
+ }
+
+ private:
+ boost::filesystem::path basePath;
+ };
+}
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index c5b55bf..a2d8331 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -16,9 +16,9 @@
#include "Swiften/Network/BoostIOServiceThread.h"
#include "Swiften/Network/MainBoostIOServiceThread.h"
#include "Swift/Controllers/BuildVersion.h"
-#include "Swiften/VCards/VCardStorageFactory.h"
+#include "Swift/Controllers/StoragesFactory.h"
+#include "Swiften/Client/Storages.h"
#include "Swiften/VCards/VCardManager.h"
-#include "Swiften/VCards/VCardStorage.h"
#include "Swift/Controllers/Chat/MUCSearchController.h"
#include "Swift/Controllers/Chat/ChatsManager.h"
#include "Swift/Controllers/XMPPEvents/EventController.h"
@@ -53,9 +53,7 @@
#include "Swiften/Disco/CapsInfoGenerator.h"
#include "Swiften/Disco/GetDiscoInfoRequest.h"
#include "Swiften/VCards/GetVCardRequest.h"
-#include "Swiften/Avatars/AvatarStorage.h"
#include "Swiften/Avatars/AvatarManagerImpl.h"
-#include "Swiften/Disco/CapsFileStorage.h"
#include "Swiften/Disco/CapsManager.h"
#include "Swiften/Disco/EntityCapsManager.h"
#include "Swiften/StringCodecs/SHA1.h"
@@ -83,25 +81,23 @@ MainController::MainController(
XMLConsoleWidgetFactory* xmlConsoleWidgetFactory,
ChatListWindowFactory* chatListWindowFactory,
MUCSearchWindowFactory* mucSearchWindowFactory,
- AvatarStorage* avatarStorage,
- CapsStorage* capsStorage,
- VCardStorageFactory* vcardStorageFactory,
+ StoragesFactory* storagesFactory,
Dock* dock,
Notifier* notifier,
bool useDelayForLatency) :
timerFactory_(&boostIOServiceThread_.getIOService()),
idleDetector_(&idleQuerier_, &timerFactory_, 100),
+ storagesFactory_(storagesFactory),
chatWindowFactory_(chatWindowFactory),
mainWindowFactory_(mainWindowFactory),
loginWindowFactory_(loginWindowFactory),
settings_(settings),
- vcardStorageFactory_(vcardStorageFactory),
loginWindow_(NULL) ,
useDelayForLatency_(useDelayForLatency) {
+ storages_ = NULL;
statusTracker_ = NULL;
client_ = NULL;
- vcardManager_ = NULL;
avatarManager_ = NULL;
capsManager_ = NULL;
entityCapsManager_ = NULL;
@@ -122,8 +118,6 @@ MainController::MainController(
chatListWindowFactory_ = chatListWindowFactory;
uiEventStream_ = new UIEventStream();
- avatarStorage_ = avatarStorage;
- capsStorage_ = capsStorage;
notifier_ = new TogglableNotifier(notifier);
eventController_ = new EventController();
eventController_->onEventQueueLengthChange.connect(boost::bind(&MainController::handleEventQueueLengthChange, this, _1));
@@ -180,9 +174,6 @@ MainController::~MainController() {
resetClient();
delete eventController_;
delete notifier_;
- for(VCardStorageMap::iterator i = vcardStorages_.begin(); i != vcardStorages_.end(); ++i) {
- delete i->second;
- }
}
void MainController::resetClient() {
@@ -213,10 +204,10 @@ void MainController::resetClient() {
avatarManager_ = NULL;
delete nickResolver_;
nickResolver_ = NULL;
- delete vcardManager_;
- vcardManager_ = NULL;
delete client_;
client_ = NULL;
+ delete storages_;
+ storages_ = NULL;
delete statusTracker_;
statusTracker_ = NULL;
delete profileSettings_;
@@ -288,7 +279,7 @@ void MainController::handleConnected() {
discoInfoRequest->onResponse.connect(boost::bind(&MainController::handleServerDiscoInfoResponse, this, _1, _2));
discoInfoRequest->send();
- vcardManager_->requestOwnVCard();
+ client_->getVCardManager()->requestOwnVCard();
rosterController_->setEnabled(true);
/* Send presence later to catch all the incoming presences. */
@@ -390,7 +381,8 @@ void MainController::performLoginFromCachedCredentials() {
statusTracker_ = new StatusTracker();
}
if (!client_) {
- client_ = new Swift::Client(jid_, password_);
+ storages_ = storagesFactory_->createStorages(jid_);
+ client_ = new Swift::Client(jid_, password_, storages_);
client_->onDataRead.connect(boost::bind(&XMLConsoleController::handleDataRead, xmlConsoleController_, _1));
client_->onDataWritten.connect(boost::bind(&XMLConsoleController::handleDataWritten, xmlConsoleController_, _1));
client_->onError.connect(boost::bind(&MainController::handleError, this, _1));
@@ -398,11 +390,10 @@ void MainController::performLoginFromCachedCredentials() {
client_->setSoftwareVersion(CLIENT_NAME, buildVersion);
- vcardManager_ = new VCardManager(jid_, client_->getIQRouter(), getVCardStorageForProfile(jid_));
- vcardManager_->onVCardChanged.connect(boost::bind(&MainController::handleVCardReceived, this, _1, _2));
- nickResolver_ = new NickResolver(this->jid_.toBare(), client_->getRoster(), vcardManager_, client_->getMUCRegistry());
- avatarManager_ = new AvatarManagerImpl(vcardManager_, client_->getStanzaChannel(), avatarStorage_, client_->getMUCRegistry());
- capsManager_ = new CapsManager(capsStorage_, client_->getStanzaChannel(), client_->getIQRouter());
+ client_->getVCardManager()->onVCardChanged.connect(boost::bind(&MainController::handleVCardReceived, this, _1, _2));
+ nickResolver_ = new NickResolver(this->jid_.toBare(), client_->getRoster(), client_->getVCardManager(), client_->getMUCRegistry());
+ avatarManager_ = new AvatarManagerImpl(client_->getVCardManager(), client_->getStanzaChannel(), storages_->getAvatarStorage(), client_->getMUCRegistry());
+ capsManager_ = new CapsManager(storages_->getCapsStorage(), client_->getStanzaChannel(), client_->getIQRouter());
entityCapsManager_ = new EntityCapsManager(capsManager_, client_->getStanzaChannel());
presenceNotifier_ = new PresenceNotifier(client_->getStanzaChannel(), notifier_, client_->getMUCRegistry(), avatarManager_, nickResolver_, client_->getPresenceOracle(), &timerFactory_);
presenceNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1));
@@ -541,14 +532,5 @@ void MainController::handleNotificationClicked(const JID& jid) {
uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(jid)));
}
-VCardStorage* MainController::getVCardStorageForProfile(const JID& jid) {
- String profile = jid.toBare().toString();
- std::pair<VCardStorageMap::iterator, bool> r = vcardStorages_.insert(std::make_pair<String, VCardStorage*>(profile, NULL));
- if (r.second) {
- r.first->second = vcardStorageFactory_->createVCardStorage(profile);
- }
- return r.first->second;
-}
-
}
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index e04123c..0a14993 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -28,10 +28,6 @@
#include "Swift/Controllers/UIEvents/UIEvent.h"
namespace Swift {
- class AvatarStorage;
- class CapsStorage;
- class VCardStorage;
- class VCardManager;
class Application;
class Client;
class ChatWindowFactory;
@@ -67,8 +63,9 @@ namespace Swift {
class MUCSearchController;
class MUCSearchWindowFactory;
class StatusTracker;
- class VCardStorageFactory;
class Dock;
+ class Storages;
+ class StoragesFactory;
class MainController {
public:
@@ -83,9 +80,7 @@ namespace Swift {
XMLConsoleWidgetFactory* xmlConsoleWidgetFactory,
ChatListWindowFactory* chatListWindowFactory_,
MUCSearchWindowFactory* mucSearchWindowFactory,
- AvatarStorage* avatarStorage,
- CapsStorage* capsStorage,
- VCardStorageFactory* vcardStorageFactory,
+ StoragesFactory* storagesFactory,
Dock* dock,
Notifier* notifier,
bool useDelayForLatency);
@@ -116,13 +111,13 @@ namespace Swift {
void setManagersOffline();
void handleNotificationClicked(const JID& jid);
- VCardStorage* getVCardStorageForProfile(const JID& jid);
-
private:
BoostIOServiceThread boostIOServiceThread_;
BoostTimerFactory timerFactory_;
PlatformIdleQuerier idleQuerier_;
ActualIdleDetector idleDetector_;
+ StoragesFactory* storagesFactory_;
+ Storages* storages_;
Client* client_;
ChatWindowFactory* chatWindowFactory_;
MainWindowFactory* mainWindowFactory_;
@@ -130,10 +125,6 @@ namespace Swift {
EventWindowFactory* eventWindowFactory_;
SettingsProvider *settings_;
ProfileSettingsProvider* profileSettings_;
- AvatarStorage* avatarStorage_;
- CapsStorage* capsStorage_;
- VCardStorageFactory* vcardStorageFactory_;
- VCardManager* vcardManager_;
Dock* dock_;
TogglableNotifier* notifier_;
PresenceNotifier* presenceNotifier_;
@@ -167,8 +158,5 @@ namespace Swift {
Timer::ref reconnectTimer_;
StatusTracker* statusTracker_;
bool myStatusLooksOnline_;
-
- typedef std::map<String, VCardStorage*> VCardStorageMap;
- VCardStorageMap vcardStorages_;
};
}
diff --git a/Swiften/VCards/VCardStorageFactory.h b/Swift/Controllers/StoragesFactory.h
index 7bef87b..441a4e9 100644
--- a/Swiften/VCards/VCardStorageFactory.h
+++ b/Swift/Controllers/StoragesFactory.h
@@ -7,13 +7,12 @@
#pragma once
namespace Swift {
- class VCardStorage;
- class String;
+ class Storages;
- class VCardStorageFactory {
+ class StoragesFactory {
public:
- virtual ~VCardStorageFactory();
+ virtual ~StoragesFactory() {}
- virtual VCardStorage* createVCardStorage(const String& profile) = 0;
+ virtual Storages* createStorages(const JID& profile) const = 0;
};
}
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index d9879a2..d61f94c 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -26,9 +26,9 @@
#include "SwifTools/Application/PlatformApplicationPathProvider.h"
#include "Swiften/Avatars/AvatarFileStorage.h"
#include "Swiften/Disco/CapsFileStorage.h"
-#include "Swiften/VCards/VCardFileStorageFactory.h"
#include "Swiften/Base/String.h"
#include "Swiften/Base/Platform.h"
+#include "Swift/Controllers/FileStoragesFactory.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/Client/Client.h"
#include "Swift/Controllers/MainController.h"
@@ -95,9 +95,7 @@ QtSwift::QtSwift(po::variables_map options) : autoUpdater_(NULL) {
tabs_ = options.count("no-tabs") && !(splitter_ > 0) ? NULL : new QtChatTabs();
settings_ = new QtSettingsProvider();
applicationPathProvider_ = new PlatformApplicationPathProvider(SWIFT_APPLICATION_NAME);
- avatarStorage_ = new AvatarFileStorage(applicationPathProvider_->getAvatarDir());
- vcardStorageFactory_ = new VCardFileStorageFactory(applicationPathProvider_->getDataDir());
- capsStorage_ = new CapsFileStorage(applicationPathProvider_->getDataDir() / "caps");
+ storagesFactory_ = new FileStoragesFactory(applicationPathProvider_->getDataDir());
chatWindowFactory_ = new QtChatWindowFactory(splitter_, settings_, tabs_, "");
soundPlayer_ = new QtSoundPlayer(applicationPathProvider_);
#if defined(HAVE_GROWL)
@@ -147,9 +145,7 @@ QtSwift::QtSwift(po::variables_map options) : autoUpdater_(NULL) {
xmlConsoleWidgetFactory,
chatListWindowFactory,
mucSearchWindowFactory,
- avatarStorage_,
- capsStorage_,
- vcardStorageFactory_,
+ storagesFactory_,
dock_,
notifier_,
options.count("latency-debug") > 0);
@@ -197,9 +193,7 @@ QtSwift::~QtSwift() {
foreach (QtChatListWindowFactory* factory, chatListWindowFactories_) {
delete factory;
}
- delete capsStorage_;
- delete avatarStorage_;
- delete vcardStorageFactory_;
+ delete storagesFactory_;
}
}
diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h
index d72faaa..59fa746 100644
--- a/Swift/QtUI/QtSwift.h
+++ b/Swift/QtUI/QtSwift.h
@@ -4,8 +4,7 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFT_QtSwift_H
-#define SWIFT_QtSwift_H
+#pragma once
#include <boost/program_options/variables_map.hpp>
#include <boost/program_options/options_description.hpp>
@@ -31,7 +30,7 @@ class QSplitter;
namespace Swift {
class Dock;
class Notifier;
- class VCardStorageFactory;
+ class StoragesFactory;
class AutoUpdater;
class ApplicationPathProvider;
class AvatarStorage;
@@ -70,9 +69,7 @@ namespace Swift {
Dock* dock_;
QtChatTabs* tabs_;
ApplicationPathProvider* applicationPathProvider_;
- AvatarStorage* avatarStorage_;
- CapsStorage* capsStorage_;
- VCardStorageFactory* vcardStorageFactory_;
+ StoragesFactory* storagesFactory_;
AutoUpdater* autoUpdater_;
Notifier* notifier_;
#if defined(SWIFTEN_PLATFORM_MACOSX)
@@ -83,5 +80,3 @@ namespace Swift {
#endif
};
}
-
-#endif
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index 63cd89f..7363c3f 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -12,10 +12,14 @@
#include "Swiften/Presence/PresenceOracle.h"
#include "Swiften/Presence/PresenceSender.h"
#include "Swiften/MUC/MUCRegistry.h"
+#include "Swiften/Client/MemoryStorages.h"
+#include "Swiften/VCards/VCardManager.h"
namespace Swift {
-Client::Client(const JID& jid, const String& password) : CoreClient(jid, password) {
+Client::Client(const JID& jid, const String& password, Storages* storages) : CoreClient(jid, password), storages(storages) {
+ memoryStorages = new MemoryStorages();
+
softwareVersionResponder = new SoftwareVersionResponder(getIQRouter());
softwareVersionResponder->start();
@@ -29,9 +33,13 @@ Client::Client(const JID& jid, const String& password) : CoreClient(jid, passwor
presenceSender = new PresenceSender(getStanzaChannel());
mucRegistry = new MUCRegistry();
+
+ vcardManager = new VCardManager(jid, getIQRouter(), getStorages()->getVCardStorage());
}
Client::~Client() {
+ delete vcardManager;
+
delete mucRegistry;
delete presenceSender;
@@ -42,6 +50,8 @@ Client::~Client() {
softwareVersionResponder->stop();
delete softwareVersionResponder;
+
+ delete memoryStorages;
}
XMPPRoster* Client::getRoster() const {
@@ -65,4 +75,12 @@ Presence::ref Client::getHighestPriorityPresence(const JID& bareJID) const {
return presenceOracle->getHighestPriorityPresence(bareJID);
}
+Storages* Client::getStorages() const {
+ if (storages) {
+ return storages;
+ }
+ return memoryStorages;
+}
+
+
}
diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h
index 2b4aa45..22fc636 100644
--- a/Swiften/Client/Client.h
+++ b/Swiften/Client/Client.h
@@ -16,16 +16,22 @@ namespace Swift {
class PresenceOracle;
class PresenceSender;
class MUCRegistry;
+ class Storages;
+ class MemoryStorages;
+ class VCardManager;
/**
* Provides the core functionality for writing XMPP client software.
*
* Besides connecting to an XMPP server, this class also provides interfaces for
* performing most tasks on the XMPP network.
+ *
+ * \param storages The interfaces for storing cache information etc. If this is NULL,
+ * all data will be stored in memory (and be lost on shutdown)
*/
class Client : public CoreClient {
public:
- Client(const JID& jid, const String& password);
+ Client(const JID& jid, const String& password, Storages* storages = NULL);
~Client();
@@ -80,6 +86,10 @@ namespace Swift {
return mucRegistry;
}
+ VCardManager* getVCardManager() const {
+ return vcardManager;
+ }
+
public:
/**
* This signal is emitted when a JID changes presence.
@@ -92,11 +102,17 @@ namespace Swift {
boost::signal<void (const JID&, const String&)> onPresenceSubscriptionRequest;
private:
+ Storages* getStorages() const;
+
+ private:
+ Storages* storages;
+ MemoryStorages* memoryStorages;
SoftwareVersionResponder* softwareVersionResponder;
XMPPRosterImpl* roster;
XMPPRosterController* rosterController;
PresenceOracle* presenceOracle;
PresenceSender* presenceSender;
MUCRegistry* mucRegistry;
+ VCardManager* vcardManager;
};
}
diff --git a/Swiften/Client/FileStorages.cpp b/Swiften/Client/FileStorages.cpp
new file mode 100644
index 0000000..9f2dda0
--- /dev/null
+++ b/Swiften/Client/FileStorages.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Client/FileStorages.h"
+#include "Swiften/VCards/VCardFileStorage.h"
+#include "Swiften/Avatars/AvatarFileStorage.h"
+#include "Swiften/Disco/CapsFileStorage.h"
+
+namespace Swift {
+
+FileStorages::FileStorages(const boost::filesystem::path& baseDir, const JID& jid) {
+ String profile = jid.toBare();
+ vcardStorage = new VCardFileStorage(baseDir / profile.getUTF8String() / "vcards");
+ capsStorage = new CapsFileStorage(baseDir / "caps");
+ avatarStorage = new AvatarFileStorage(baseDir / "avatars");
+}
+
+FileStorages::~FileStorages() {
+ delete avatarStorage;
+ delete capsStorage;
+ delete vcardStorage;
+}
+
+VCardStorage* FileStorages::getVCardStorage() const {
+ return vcardStorage;
+}
+
+CapsStorage* FileStorages::getCapsStorage() const {
+ return capsStorage;
+}
+
+AvatarStorage* FileStorages::getAvatarStorage() const {
+ return avatarStorage;
+}
+
+}
diff --git a/Swiften/Client/FileStorages.h b/Swiften/Client/FileStorages.h
new file mode 100644
index 0000000..f8c3162
--- /dev/null
+++ b/Swiften/Client/FileStorages.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <boost/filesystem.hpp>
+
+#include "Swiften/Client/Storages.h"
+
+namespace Swift {
+ class VCardFileStorage;
+ class AvatarFileStorage;
+ class CapsFileStorage;
+ class JID;
+
+ class FileStorages : public Storages {
+ public:
+ FileStorages(const boost::filesystem::path& baseDir, const JID& jid);
+ ~FileStorages();
+
+ virtual VCardStorage* getVCardStorage() const;
+ virtual AvatarStorage* getAvatarStorage() const;
+ virtual CapsStorage* getCapsStorage() const;
+
+ private:
+ VCardFileStorage* vcardStorage;
+ AvatarFileStorage* avatarStorage;
+ CapsFileStorage* capsStorage;
+ };
+}
diff --git a/Swiften/Client/MemoryStorages.cpp b/Swiften/Client/MemoryStorages.cpp
new file mode 100644
index 0000000..5f6371b
--- /dev/null
+++ b/Swiften/Client/MemoryStorages.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Client/MemoryStorages.h"
+#include "Swiften/VCards/VCardMemoryStorage.h"
+#include "Swiften/Avatars/AvatarMemoryStorage.h"
+#include "Swiften/Disco/CapsMemoryStorage.h"
+
+namespace Swift {
+
+MemoryStorages::MemoryStorages() {
+ vcardStorage = new VCardMemoryStorage();
+ capsStorage = new CapsMemoryStorage();
+ avatarStorage = new AvatarMemoryStorage();
+}
+
+MemoryStorages::~MemoryStorages() {
+ delete avatarStorage;
+ delete capsStorage;
+ delete vcardStorage;
+}
+
+VCardStorage* MemoryStorages::getVCardStorage() const {
+ return vcardStorage;
+}
+
+CapsStorage* MemoryStorages::getCapsStorage() const {
+ return capsStorage;
+}
+
+AvatarStorage* MemoryStorages::getAvatarStorage() const {
+ return avatarStorage;
+}
+
+}
diff --git a/Swiften/Client/MemoryStorages.h b/Swiften/Client/MemoryStorages.h
new file mode 100644
index 0000000..13f41d1
--- /dev/null
+++ b/Swiften/Client/MemoryStorages.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swiften/Client/Storages.h"
+
+namespace Swift {
+ class VCardMemoryStorage;
+
+ class MemoryStorages : public Storages {
+ public:
+ MemoryStorages();
+ ~MemoryStorages();
+
+ virtual VCardStorage* getVCardStorage() const;
+ virtual AvatarStorage* getAvatarStorage() const;
+ virtual CapsStorage* getCapsStorage() const;
+
+ private:
+ VCardMemoryStorage* vcardStorage;
+ AvatarStorage* avatarStorage;
+ CapsStorage* capsStorage;
+ };
+}
diff --git a/Swiften/Client/Storages.h b/Swiften/Client/Storages.h
new file mode 100644
index 0000000..6f286ca
--- /dev/null
+++ b/Swiften/Client/Storages.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+namespace Swift {
+ class VCardStorage;
+ class AvatarStorage;
+ class CapsStorage;
+
+ class Storages {
+ public:
+ virtual ~Storages() {}
+
+ virtual VCardStorage* getVCardStorage() const = 0;
+ virtual AvatarStorage* getAvatarStorage() const = 0;
+ virtual CapsStorage* getCapsStorage() const = 0;
+ };
+}
diff --git a/Swiften/SConscript b/Swiften/SConscript
index 12703fc..543029d 100644
--- a/Swiften/SConscript
+++ b/Swiften/SConscript
@@ -33,6 +33,8 @@ if env["SCONS_STAGE"] == "build" :
"Client/CoreClient.cpp",
"Client/Client.cpp",
"Client/ClientSession.cpp",
+ "Client/MemoryStorages.cpp",
+ "Client/FileStorages.cpp",
"Compress/ZLibCodecompressor.cpp",
"Compress/ZLibDecompressor.cpp",
"Compress/ZLibCompressor.cpp",
diff --git a/Swiften/VCards/SConscript b/Swiften/VCards/SConscript
index e83e633..13be7d3 100644
--- a/Swiften/VCards/SConscript
+++ b/Swiften/VCards/SConscript
@@ -4,6 +4,5 @@ objects = swiften_env.StaticObject([
"VCardManager.cpp",
"VCardStorage.cpp",
"VCardFileStorage.cpp",
- "VCardStorageFactory.cpp",
])
swiften_env.Append(SWIFTEN_OBJECTS = [objects])
diff --git a/Swiften/VCards/VCardFileStorageFactory.h b/Swiften/VCards/VCardFileStorageFactory.h
deleted file mode 100644
index 27e50af..0000000
--- a/Swiften/VCards/VCardFileStorageFactory.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include <boost/filesystem.hpp>
-
-#include "Swiften/VCards/VCardStorageFactory.h"
-#include "Swiften/VCards/VCardFileStorage.h"
-
-namespace Swift {
- class VCardFileStorageFactory : public VCardStorageFactory {
- public:
- VCardFileStorageFactory(boost::filesystem::path base) : base(base) {
- }
-
- virtual VCardStorage* createVCardStorage(const String& profile) {
- return new VCardFileStorage(base / profile.getUTF8String() / "vcards");
- }
-
- private:
- boost::filesystem::path base;
- };
-}
diff --git a/Swiften/VCards/VCardMemoryStorageFactory.h b/Swiften/VCards/VCardMemoryStorageFactory.h
deleted file mode 100644
index d48794d..0000000
--- a/Swiften/VCards/VCardMemoryStorageFactory.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include <boost/filesystem.hpp>
-
-#include "Swiften/VCards/VCardStorageFactory.h"
-#include "Swiften/VCards/VCardMemoryStorage.h"
-
-namespace Swift {
- class VCardMemoryStorageFactory : public VCardStorageFactory {
- public:
- VCardMemoryStorageFactory() {
- }
-
- virtual VCardStorage* createVCardStorage(const String& profile) {
- return new VCardMemoryStorage();
- }
- };
-}
diff --git a/Swiften/VCards/VCardStorageFactory.cpp b/Swiften/VCards/VCardStorageFactory.cpp
deleted file mode 100644
index 64a3e88..0000000
--- a/Swiften/VCards/VCardStorageFactory.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swiften/VCards/VCardStorageFactory.h"
-
-namespace Swift {
-
-VCardStorageFactory::~VCardStorageFactory() {
-}
-
-}