/* * Copyright (c) 2012 Mateusz Piękos * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include #include "Swift/Controllers/WhiteboardController.h" #include #include #include #include namespace Swift { WhiteboardController::WhiteboardController(StanzaChannel* stanzaChannel, const JID& toJID, WhiteboardWindowFactory* whiteboardWindowFactory) : stanzaChannel_(stanzaChannel), toJID_(toJID) { whiteboardWindow_ = whiteboardWindowFactory->createWhiteboardWindow(); whiteboardWindow_->show(); whiteboardWindow_->onItemAdd.connect(boost::bind(&WhiteboardController::handleItemChange, this, _1)); } WhiteboardController::~WhiteboardController() { delete whiteboardWindow_; } void WhiteboardController::handleIncomingMessage(boost::shared_ptr message) { boost::shared_ptr wb = message->getStanza()->getPayload(); if(wb) { whiteboardWindow_->addItem(wb->getData()); } } void WhiteboardController::handleItemChange(std::string item) { boost::shared_ptr mes(new Message()); mes->setTo(toJID_); boost::shared_ptr wbPayload(new WhiteboardPayload); wbPayload->setData(item); // mes->setType(Swift::Message::Chat); mes->addPayload(wbPayload); stanzaChannel_->sendMessage(mes); } }