summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-09-12 20:36:48 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-09-12 20:36:48 (GMT)
commit0da93507bea788cf6bd8f327478caddf3ea679e5 (patch)
tree1e0e0609eea3a594b78fdad401282354db640fa6 /Swift/Controllers
parent536df08ad0646a95ab1352fb9e2b49b00aaaaf2b (diff)
downloadswift-contrib-0da93507bea788cf6bd8f327478caddf3ea679e5.zip
swift-contrib-0da93507bea788cf6bd8f327478caddf3ea679e5.tar.bz2
Block MUC bookmarks until the server has responded.
Else there could be bookmarks overwritten in an infeasibly unlikely race condition. Resolves: #340
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp10
-rw-r--r--Swift/Controllers/Chat/ChatsManager.h1
-rw-r--r--Swift/Controllers/UIInterfaces/ChatListWindow.h1
3 files changed, 12 insertions, 0 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index acc5e1d..e1a53b4 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -39,11 +39,15 @@ ChatsManager::ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRo
presenceSender_ = presenceSender;
uiEventStream_ = uiEventStream;
mucBookmarkManager_ = new MUCBookmarkManager(iqRouter);
+ mucBookmarkManager_->onBookmarksReady.connect(boost::bind(&ChatsManager::handleBookmarksReady, this));
mucBookmarkManager_->onBookmarkAdded.connect(boost::bind(&ChatsManager::handleMUCBookmarkAdded, this, _1));
mucBookmarkManager_->onBookmarkRemoved.connect(boost::bind(&ChatsManager::handleMUCBookmarkRemoved, this, _1));
presenceOracle_->onPresenceChange.connect(boost::bind(&ChatsManager::handlePresenceChange, this, _1, _2));
uiEventConnection_ = uiEventStream_->onUIEvent.connect(boost::bind(&ChatsManager::handleUIEvent, this, _1));
chatListWindow_ = chatListWindowFactory->createWindow(uiEventStream_);
+ if (chatListWindow_) {
+ chatListWindow_->setBookmarksEnabled(false);
+ }
}
ChatsManager::~ChatsManager() {
@@ -56,6 +60,12 @@ ChatsManager::~ChatsManager() {
delete mucBookmarkManager_;
}
+void ChatsManager::handleBookmarksReady() {
+ if (chatListWindow_) {
+ chatListWindow_->setBookmarksEnabled(true);
+ }
+}
+
void ChatsManager::handleMUCBookmarkAdded(const MUCBookmark& bookmark) {
std::map<JID, MUCController*>::iterator it = mucControllers_.find(bookmark.getRoom());
if (it == mucControllers_.end() && bookmark.getAutojoin()) {
diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h
index 3efd507..752acff 100644
--- a/Swift/Controllers/Chat/ChatsManager.h
+++ b/Swift/Controllers/Chat/ChatsManager.h
@@ -52,6 +52,7 @@ namespace Swift {
void handleMUCBookmarkAdded(const MUCBookmark& bookmark);
void handleMUCBookmarkRemoved(const MUCBookmark& bookmark);
void handleUserLeftMUC(MUCController* mucController);
+ void handleBookmarksReady();
ChatController* getChatControllerOrFindAnother(const JID &contact);
ChatController* createNewChatController(const JID &contact);
ChatController* getChatControllerOrCreate(const JID &contact);
diff --git a/Swift/Controllers/UIInterfaces/ChatListWindow.h b/Swift/Controllers/UIInterfaces/ChatListWindow.h
index fd176a6..3a7c30e 100644
--- a/Swift/Controllers/UIInterfaces/ChatListWindow.h
+++ b/Swift/Controllers/UIInterfaces/ChatListWindow.h
@@ -15,6 +15,7 @@ namespace Swift {
public:
virtual ~ChatListWindow();
+ virtual void setBookmarksEnabled(bool enabled) = 0;
virtual void addMUCBookmark(const MUCBookmark& bookmark) = 0;
virtual void removeMUCBookmark(const MUCBookmark& bookmark) = 0;
};