summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40ab2e9)
raw | patch | inline | side by side (parent: 40ab2e9)
author | daleharvey <daleharvey@users.sourceforge.net> | |
Tue, 15 Aug 2006 14:00:14 +0000 (14:00 +0000) | ||
committer | daleharvey <daleharvey@users.sourceforge.net> | |
Tue, 15 Aug 2006 14:00:14 +0000 (14:00 +0000) |
index e5470c045657e622f05e206372bd2e73ccee810a..b4ac480dede3bd224635bb6447063df4c5b135fc 100644 (file)
jabber_whiteboard/message-utilities.cpp \
jabber_whiteboard/message-utilities.h \
jabber_whiteboard/inkboard-node.cpp \
- jabber_whiteboard/inkboard-node.h \
jabber_whiteboard/inkboard-session.cpp \
jabber_whiteboard/inkboard-session.h \
jabber_whiteboard/inkboard-document.cpp \
index 8d9559c570fce36522fac98c155ce99b406ac4d9..a8843b9e758f40331275480cbb49d45e66652b67 100644 (file)
"<wb xmlns='%4' session='%5'>%6</wb>"
"</message>");
- const std::string PROTOCOL_MESSAGE("<%1><%2 /></%1>");
- const std::string NEW_MESSAGE("<new parent=\"%1\" id=\"%2\" target=\"%3\">%4</new>");
+ const std::string PROTOCOL_MESSAGE(
+ "<%1><%2 /></%1>");
+
+ const std::string NEW_MESSAGE(
+ "<new parent=\"%1\" id=\"%2\" target=\"%3\">%4</new>");
+
+ const std::string CONFIGURE_MESSAGE(
+ "<configure target=\"%1\" version=\"%2\" attribute=\"%3\" value=\"%4\" />");
+
+ const std::string CONFIGURE_TEXT_MESSAGE(
+ "<configure target=\"%1\" version=\"%2\"><text>%3</text></configure>");
+
+ const std::string MOVE_MESSAGE(
+ "<move target=\"%1\" n=\"%2\" />");
+
+ const std::string REMOVE_MESSAGE(
+ "<remove target=\"%1\" />");
}
namespace State {
index cff54916c38bbc735b8a0f392dbf2490cf2a0851..675e1313615ad24158dbf5258e79c029560e0694 100644 (file)
namespace Vars {
extern const std::string DOCUMENT_ROOT_NODE;
+
extern const std::string INKBOARD_XMLNS;
+
extern const std::string WHITEBOARD_MESSAGE;
extern const std::string PROTOCOL_MESSAGE;
extern const std::string NEW_MESSAGE;
+ extern const std::string CONFIGURE_MESSAGE;
+ extern const std::string CONFIGURE_TEXT_MESSAGE;
+ extern const std::string MOVE_MESSAGE;
+ extern const std::string REMOVE_MESSAGE;
+
+
+
}
diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp
index 521e8d1b4b897de157c15ad7e9374fc1a450f7ca..60d4cdd27e15c532339fe084d7f006b38bfbab0d 100644 (file)
#include "jabber_whiteboard/inkboard-document.h"
-
#include "util/ucompose.hpp"
#include "xml/simple-session.h"
@@ -243,36 +242,6 @@ InkboardDocument::handleState(State::SessionState expectedState, State::SessionS
return false;
}
-Glib::ustring
-InkboardDocument::addNodeToTracker(Inkscape::XML::Node *node)
-{
- Glib::ustring key = this->tracker->generateKey(this->getRecipient());
- this->tracker->put(key,node);
- return key;
-}
-
-Message::Message
-InkboardDocument::composeNewMessage(Inkscape::XML::Node *node)
-{
- Glib::ustring parentKey;
- Glib::ustring key = this->tracker->get(node);
- Inkscape::XML::Node *parent = node->parent();
-
- Glib::ustring tempParentKey = this->tracker->get(node->parent());
- if(tempParentKey.size() < 1)
- parentKey = Vars::DOCUMENT_ROOT_NODE;
- else
- parentKey = tempParentKey;
-
- unsigned int index = parent->_childPosition(*node);
-
- Message::Message nodeMessage = MessageUtilities::objectToString(node);
- Message::Message message = String::ucompose(Vars::NEW_MESSAGE,parentKey,key,index,nodeMessage);
-
- return message;
-}
-
-
} // namespace Whiteboard
} // namespace Inkscape
index c7d325ab99bb468fc3b73df6eb5a6d2e5bc9b0ee..c463e461a2013b5206aa1596e3c0da66208bf4fd 100644 (file)
#include <glib.h>
#include <glibmm.h>
-#include "jabber_whiteboard/inkboard-node.h"
+#include "util/ucompose.hpp"
+
+#include "jabber_whiteboard/message-utilities.h"
+#include "jabber_whiteboard/defines.h"
+#include "jabber_whiteboard/inkboard-document.h"
namespace Inkscape {
namespace Whiteboard {
-InkboardNode::InkboardNode(int code, Inkscape::XML::NodeType type) :
- XML::SimpleNode(code), version(0), nodetype(type)
+Glib::ustring
+InkboardDocument::addNodeToTracker(Inkscape::XML::Node *node)
+{
+ Glib::ustring key = this->tracker->generateKey(this->getRecipient());
+ this->tracker->put(key,node);
+ return key;
+}
+
+Message::Message
+InkboardDocument::composeNewMessage(Inkscape::XML::Node *node)
{
+ Glib::ustring parentKey;
+ Glib::ustring key = this->tracker->get(node);
+ Inkscape::XML::Node *parent = node->parent();
+
+ Glib::ustring tempParentKey = this->tracker->get(node->parent());
+ if(tempParentKey.size() < 1)
+ parentKey = Vars::DOCUMENT_ROOT_NODE;
+ else
+ parentKey = tempParentKey;
+
+ unsigned int index = parent->_childPosition(*node);
+
+ Message::Message nodeMessage = MessageUtilities::objectToString(node);
+ Message::Message message = String::ucompose(Vars::NEW_MESSAGE,parentKey,key,index,nodeMessage);
+ return message;
}
} // namespace Whiteboard
diff --git a/src/jabber_whiteboard/inkboard-node.h b/src/jabber_whiteboard/inkboard-node.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation
- *
- * Authors:
- * Dale Harvey <harveyd@gmail.com>
- *
- * Copyright (c) 2005 Authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#ifndef __INKSCAPE_WHITEBOARD_INKBOARDNODE_H__
-#define __INKSCAPE_WHITEBOARD_INKBOARDNODE_H__
-
-#include <glibmm.h>
-
-#include "document.h"
-#include "xml/document.h"
-#include "xml/simple-node.h"
-
-namespace Inkscape {
-
-namespace Whiteboard {
-
-class InkboardNode : public XML::SimpleNode {
-public:
-
- explicit InkboardNode(int code, Inkscape::XML::NodeType type);
-
- XML::NodeType type() const
- {
- return this->nodetype;
- }
-
-protected:
-
- /**
- * Copy constructor.
- *
- * \param orig Instance to copy.
- */
- InkboardNode(InkboardNode const& orig, Inkscape::XML::NodeType type) :
- XML::Node(), XML::SimpleNode(orig), version(0), nodetype(type) {}
-
- XML::SimpleNode* _duplicate() const
- {
- return new InkboardNode(*this,this->nodetype);
- }
-
-private:
-
- unsigned int version;
- Inkscape::XML::NodeType nodetype;
-};
-
-}
-
-}
-
-#endif
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/jabber_whiteboard/inkboard-session.cpp b/src/jabber_whiteboard/inkboard-session.cpp
index ea63c5f31e4c2e02b45b8f1225b431de91e71f22..6601d5d879b43ffe762eb346e79bbc8907f7d852 100644 (file)
#include "jabber_whiteboard/inkboard-session.h"
#include "jabber_whiteboard/inkboard-document.h"
-#include "jabber_whiteboard/inkboard-node.h"
#include "jabber_whiteboard/defines.h"
#include "xml/node.h"
#include "xml/comment-node.h"
#include "util/share.h"
+#include "util/ucompose.hpp"
namespace Inkscape {
XML::Node*
InkboardSession::createElementNode(char const* name)
{
- g_log(NULL, G_LOG_LEVEL_DEBUG, "InkboardSession::createElementNode");
- return new InkboardNode(g_quark_from_string(name),Inkscape::XML::ELEMENT_NODE);
+ return new XML::ElementNode(g_quark_from_string(name));
}
XML::Node*
InkboardSession::createTextNode(char const* content)
{
- g_log(NULL, G_LOG_LEVEL_DEBUG, "InkboardSession::createTextNode");
return new XML::TextNode(Util::share_string(content));
}
XML::Node*
InkboardSession::createCommentNode(char const* content)
{
- g_log(NULL, G_LOG_LEVEL_DEBUG, "InkboardSession::createCommentNode");
return new XML::CommentNode(Util::share_string(content));
}
{
if (_in_transaction && doc->state == State::IN_WHITEBOARD) {
- InkboardNode *node = dynamic_cast< InkboardNode* >((XML::Node *)&child);
- if(node == NULL)
- {
- g_warning("non inkboard node");
- return;
- }
+ XML::Node *node = (XML::Node *)&child;
this->doc->addNodeToTracker(node);
Message::Message message = this->doc->composeNewMessage(node);
Node &child,
Node *prev)
{
- if (_in_transaction && doc->state == State::IN_WHITEBOARD) {
- g_warning("child removed");
+ if (_in_transaction && doc->state == State::IN_WHITEBOARD)
+ {
+ XML::Node *element = (XML::Node *)&child;
+
+ Message::Message message = String::ucompose(Vars::REMOVE_MESSAGE,
+ this->doc->tracker->get(element));
+
+ this->doc->send(this->doc->getRecipient(),Message::REMOVE,message);
}
}
Node *old_prev,
Node *new_prev)
{
- if (_in_transaction && doc->state == State::IN_WHITEBOARD) {
- g_warning("child reordered");
+ if (_in_transaction && doc->state == State::IN_WHITEBOARD)
+ {
+ XML::Node *element = (XML::Node *)&child;
+ XML::Node *parentElement = (XML::Node *)&parent;
+
+ unsigned int index = parentElement->_childPosition(*element);
+
+ Message::Message message = String::ucompose(Vars::MOVE_MESSAGE,
+ this->doc->tracker->get(element),index);
+
+ this->doc->send(this->doc->getRecipient(),Message::MOVE,message);
}
}
Util::ptr_shared<char> old_content,
Util::ptr_shared<char> new_content)
{
- if (_in_transaction && doc->state == State::IN_WHITEBOARD) {
- g_warning("content changed");
+ if (_in_transaction && doc->state == State::IN_WHITEBOARD)
+ {
+ XML::Node *element = (XML::Node *)&node;
+
+ if(new_content.pointer())
+ {
+ Message::Message message = String::ucompose(Vars::CONFIGURE_TEXT_MESSAGE,
+ this->doc->tracker->get(element),"0",new_content.pointer());
+
+ this->doc->send(this->doc->getRecipient(),Message::CONFIGURE,message);
+ }
}
}
Util::ptr_shared<char> old_value,
Util::ptr_shared<char> new_value)
{
- if (_in_transaction && doc->state == State::IN_WHITEBOARD) {
+ if (_in_transaction && doc->state == State::IN_WHITEBOARD)
+ {
+ XML::Node *element = (XML::Node *)&node;
+
+ if(name && new_value.pointer())
+ {
+ Message::Message message = String::ucompose(Vars::CONFIGURE_MESSAGE,
+ this->doc->tracker->get(element),"0",g_quark_to_string(name),new_value.pointer());
+ this->doc->send(this->doc->getRecipient(),Message::CONFIGURE,message);
+ }
}
}
index 4ade2ca32d3a37322ba60cf611d690deab9efcf2..10eeb63223674e24591eaf1fa438b313f403284f 100644 (file)
#include "pedro/pedroxmpp.h"
#include "jabber_whiteboard/inkboard-document.h"
-#include "jabber_whiteboard/inkboard-node.h"
-
#include "jabber_whiteboard/defines.h"
#include "util/share.h"