From 4e40ccca5c3ebae1987c80f2f294dea54398a8e4 Mon Sep 17 00:00:00 2001 From: daleharvey Date: Sun, 6 Aug 2006 21:48:20 +0000 Subject: initial keynodetable work (bzr r1570) --- src/jabber_whiteboard/inkboard-document.cpp | 71 ++++++++++++++++------------- 1 file changed, 40 insertions(+), 31 deletions(-) (limited to 'src/jabber_whiteboard/inkboard-document.cpp') diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp index e9363ecd9..644db8e2a 100644 --- a/src/jabber_whiteboard/inkboard-document.cpp +++ b/src/jabber_whiteboard/inkboard-document.cpp @@ -14,17 +14,21 @@ #include "jabber_whiteboard/inkboard-document.h" + +#include "util/ucompose.hpp" + #include "xml/simple-session.h" #include "jabber_whiteboard/inkboard-session.h" #include "jabber_whiteboard/defines.h" #include "jabber_whiteboard/session-manager.h" +#include "jabber_whiteboard/node-tracker.h" namespace Inkscape { namespace Whiteboard { -InkboardDocument::InkboardDocument(int code, State::SessionType type, Glib::ustring const& to) : - XML::SimpleNode(code), _type(type), _recipient(to) +InkboardDocument::InkboardDocument(int code, State::SessionType sessionType, Glib::ustring const& to) : + XML::SimpleNode(code), sessionType(sessionType), recipient(to) { _initBindings(); } @@ -32,7 +36,7 @@ InkboardDocument::InkboardDocument(int code, State::SessionType type, Glib::ustr void InkboardDocument::_initBindings() { - this->_sm = &SessionManager::instance(); + this->sm = &SessionManager::instance(); this->state = State::INITIAL; _bindDocument(*this); _bindLogger(*(new XML::SimpleSession())); @@ -41,34 +45,34 @@ InkboardDocument::_initBindings() void InkboardDocument::setRecipient(Glib::ustring const& val) { - this->_recipient = val; + this->recipient = val; } Glib::ustring InkboardDocument::getRecipient() const { - return this->_recipient; + return this->recipient; } void InkboardDocument::setSessionId(Glib::ustring const& val) { - this->_session = val; + this->sessionId = val; } Glib::ustring InkboardDocument::getSessionId() const { - return this->_session; + return this->sessionId; } void InkboardDocument::startSessionNegotiation() { - if(_type == State::WHITEBOARD_PEER) - sendProtocol(_recipient, Message::PROTOCOL,Message::CONNECT_REQUEST); + if(this->sessionType == State::WHITEBOARD_PEER) + this->send(recipient, Message::PROTOCOL,Message::CONNECT_REQUEST); - else if(_type == State::WHITEBOARD_MUC) + else if(this->sessionType == State::WHITEBOARD_MUC) { // Check that the MUC room is whiteboard enabled, if not no need to send // anything, just set the room to be whiteboard enabled @@ -82,7 +86,7 @@ InkboardDocument::terminateSession() } void -InkboardDocument::processInkboardEvent(Message::Wrapper &wrapper, Pedro::Element* data) +InkboardDocument::recieve(Message::Wrapper &wrapper, Pedro::Element* data) { if(this->handleIncomingState(wrapper,data)) { @@ -98,16 +102,18 @@ InkboardDocument::processInkboardEvent(Message::Wrapper &wrapper, Pedro::Element { // TODO : Would be nice to create the desktop here - sendProtocol(getRecipient(),Message::PROTOCOL, Message::CONNECTED); - sendProtocol(getRecipient(),Message::PROTOCOL, Message::DOCUMENT_BEGIN); + this->send(getRecipient(),Message::PROTOCOL, Message::CONNECTED); + this->send(getRecipient(),Message::PROTOCOL, Message::DOCUMENT_BEGIN); - // Send the Document + // Send Document + this->tracker = new KeyNodeTable(); + this->sendDocument(); - sendProtocol(getRecipient(),Message::PROTOCOL, Message::DOCUMENT_END); + this->send(getRecipient(),Message::PROTOCOL, Message::DOCUMENT_END); }else if(message == Message::DECLINE_INVITATION) { - this->_sm->terminateSession(this->getSessionId()); + this->sm->terminateSession(this->getSessionId()); } } }else{ @@ -117,25 +123,22 @@ InkboardDocument::processInkboardEvent(Message::Wrapper &wrapper, Pedro::Element } bool -InkboardDocument::sendProtocol(const Glib::ustring &destJid, Message::Wrapper &wrapper, - Message::Message &message) +InkboardDocument::send(const Glib::ustring &destJid, Message::Wrapper &wrapper, Message::Message &message) { if(this->handleOutgoingState(wrapper,message)) { - char *fmt= - "" - "" - "<%s>" - "<%s />" - "" - "" - ""; - - if (!_sm->getClient().write(fmt, - _type.c_str(),_sm->getClient().getJid().c_str(),destJid.c_str(),Vars::INKBOARD_XMLNS.c_str(), - this->getSessionId().c_str(),wrapper.c_str(),message.c_str(),wrapper.c_str())) - { return false; } + Glib::ustring mes; + if(wrapper == Message::PROTOCOL) + mes = String::ucompose(Vars::PROTOCOL_MESSAGE,wrapper,message); + else + mes = message; + + char *finalmessage = const_cast(String::ucompose(Vars::WHITEBOARD_MESSAGE, + this->sessionType,this->sm->getClient().getJid(),destJid, + Vars::INKBOARD_XMLNS,this->getSessionId(),mes).c_str()); + if (!this->sm->getClient().write(finalmessage)) + { return false; } else { return true; } @@ -146,6 +149,12 @@ InkboardDocument::sendProtocol(const Glib::ustring &destJid, Message::Wrapper &w } } +void +InkboardDocument::sendDocument() +{ + +} + bool InkboardDocument::handleOutgoingState(Message::Wrapper &wrapper, Glib::ustring const& message) { -- cgit v1.2.3