summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8013164)
raw | patch | inline | side by side (parent: 8013164)
author | daleharvey <daleharvey@users.sourceforge.net> | |
Sun, 6 Aug 2006 21:48:20 +0000 (21:48 +0000) | ||
committer | daleharvey <daleharvey@users.sourceforge.net> | |
Sun, 6 Aug 2006 21:48:20 +0000 (21:48 +0000) |
index ca2bbab0e73277271744ee6b6652483a38ef5cd6..725391deb8ab810ec7f525cdc6a2002b0a568f60 100644 (file)
const std::string INKBOARD_XMLNS("http://inkscape.org/inkboard");
+ const std::string WHITEBOARD_MESSAGE(
+ "<message type='%1' from='%2' to='%3'>"
+ "<wb xmlns='%4' session='%5'>%6</wb>"
+ "</message>");
+
+ const std::string PROTOCOL_MESSAGE("<%1><%2 /></%1>");
+
}
namespace State {
index 19b87624b527b1aa1d297ba3de79a59ea697f14e..ade33cc786ce77235d9617a58202ab697c3b5b23 100644 (file)
namespace Message {
typedef const std::string Wrapper;
- typedef const std::string Message;
+ typedef std::string Message;
extern Wrapper PROTOCOL;
extern Wrapper NEW;
namespace Vars {
extern const std::string INKBOARD_XMLNS;
+ extern const std::string WHITEBOARD_MESSAGE;
+ extern const std::string PROTOCOL_MESSAGE;
+ extern const std::string NEW_MESSAGE;
}
diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp
index e9363ecd95c02a2728ce54627e9f7e71b21bda9f..644db8e2a3b1ca7d7f63a48e7cabbdee0b16eff6 100644 (file)
#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();
}
void
InkboardDocument::_initBindings()
{
- this->_sm = &SessionManager::instance();
+ this->sm = &SessionManager::instance();
this->state = State::INITIAL;
_bindDocument(*this);
_bindLogger(*(new XML::SimpleSession()));
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
}
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=
- "<message type='%s' from='%s' to='%s'>"
- "<wb xmlns='%s' session='%s'>"
- "<%s>"
- "<%s />"
- "</%s>"
- "</wb>"
- "</message>";
-
- 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<char* >(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)
{
index 9eff38003494f159d959e9401a0443b436a745f7..dfe001842d10959fcdc4d1ca83cc7c893d4721ec 100644 (file)
class InkboardDocument : public XML::SimpleNode, public XML::Document {
public:
- explicit InkboardDocument(int code, State::SessionType type, Glib::ustring const& to);
+ explicit InkboardDocument(int code, State::SessionType sessionType, Glib::ustring const& to);
XML::NodeType type() const
{
void startSessionNegotiation();
void terminateSession();
- void processInkboardEvent(Message::Wrapper &wrapper, Pedro::Element* data);
- bool sendProtocol(const Glib::ustring &destJid, Message::Wrapper &mwrapper, Message::Message &message);
+ void recieve(Message::Wrapper &wrapper, Pedro::Element* data);
+ bool send(const Glib::ustring &destJid, Message::Wrapper &mwrapper, Message::Message &message);
+
+ void sendDocument();
bool handleOutgoingState(Message::Wrapper &wrapper,Glib::ustring const& message);
bool handleIncomingState(Message::Wrapper &wrapper,Pedro::Element* data);
* \param orig Instance to copy.
*/
InkboardDocument(InkboardDocument const& orig) :
- XML::Node(), XML::SimpleNode(orig), XML::Document(), _recipient(orig._recipient)
+ XML::Node(), XML::SimpleNode(orig), XML::Document(), recipient(orig.recipient)
{
_initBindings();
}
void _initBindings();
- SessionManager *_sm;
- SPDocument *_doc;
- State::SessionType _type;
+ SessionManager *sm;
+
+ State::SessionType sessionType;
State::SessionState state;
- Glib::ustring _session;
- Glib::ustring _recipient;
+ Glib::ustring sessionId;
+ Glib::ustring recipient;
- KeyNodeTable _tracker;
+ KeyNodeTable *tracker;
};
}
index d9af43f637244fc704ec6b4afe90d1b7059ab0a2..b338a91fe31dec552a4c07d7d93cc438592ad9b9 100644 (file)
* Copyright (c) 2005 Authors
*/
#include "keynode.h"
-
+#include "util/ucompose.hpp"
namespace Inkscape
{
return items[index];
}
+Glib::ustring
+KeyNodeTable::generateKey(Glib::ustring jid)
+{
+ return String::ucompose("%1/%2",this->counter++,jid);
+}
} // namespace Whiteboard
index a224b7c53a2323614cc3b34c33d6c7bf89bb11b1..eb68f40b6af2b3771b28944fb391e50cda5edf59 100644 (file)
KeyNodeTable()
{}
-
+
KeyNodeTable(const KeyNodeTable &other)
{
items = other.items;
}
-
+
virtual ~KeyNodeTable()
{}
-
+
virtual void clear();
-
+
virtual void append(const KeyNodeTable &other);
virtual void put(const KeyNodePair &pair);
-
+
virtual void put(const Glib::ustring &key, const XML::Node *node);
-
+
virtual XML::Node * get(const Glib::ustring &key) const;
-
+
virtual void remove(const Glib::ustring &key);
virtual Glib::ustring get(XML::Node *node) const;
-
+
virtual void remove(XML::Node *node);
virtual unsigned int size() const;
-
+
virtual KeyNodePair item(unsigned int index) const;
+ virtual Glib::ustring generateKey(Glib::ustring);
+
private:
std::vector<KeyNodePair> items;
+ unsigned int counter;
+
};
index 3e8ee72a19e95b2951c2ef1b65c7c583000a543d..cd5bf681438c9b671ceea58d9c0c8ecd18aeddbc 100644 (file)
bool PedroGui::chatMessage(const DOMString &from, const DOMString &data)
{
- if(data.size() < 1)
+ if(data.size() > 0)
{
std::vector<ChatWindow *>::iterator iter;
for (iter=chats.begin() ; iter != chats.end() ; iter++)
index 3dcb8e217bdf08a9aef87406f18e25d4df1ba8bf..35d87b4b5e3bc79719412aab17b2b2be3f054970 100644 (file)
}
Pedro::DOMString session = root->getTagAttribute("wb", "session");
- Pedro::DOMString type = root->getTagAttribute("session", "type");
+ Pedro::DOMString type = root->getTagAttribute("message", "type");
Pedro::DOMString domwrapper = root->getFirstChild()->getFirstChild()->getFirstChild()->getName();
if (session.empty()) {
{
Message::Wrapper wrapper = static_cast< Message::Wrapper >(domwrapper);
InkboardDocument* doc = getInkboardSession(session);
- doc->processInkboardEvent(wrapper, root->getFirstChild());
- }
+ if(doc != NULL)
+ doc->recieve(wrapper, root->getFirstChild());
+ }
}
char*
switch (reply) {
case Dialog::ACCEPT_INVITATION:{
- inkdoc->sendProtocol(from, Message::PROTOCOL,Message::ACCEPT_INVITATION);
+ inkdoc->send(from, Message::PROTOCOL,Message::ACCEPT_INVITATION);
makeInkboardDesktop(doc);
break; }
case Dialog::DECLINE_INVITATION: default: {
- inkdoc->sendProtocol(from, Message::PROTOCOL,Message::DECLINE_INVITATION);
+ inkdoc->send(from, Message::PROTOCOL,Message::DECLINE_INVITATION);
terminateSession(sessionId);
break; }
}