summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordaleharvey <daleharvey@users.sourceforge.net>2006-08-15 14:00:14 +0000
committerdaleharvey <daleharvey@users.sourceforge.net>2006-08-15 14:00:14 +0000
commit34ac74865f2ce8ab7bb103dd946ba0b42c0445c8 (patch)
tree337a19e2edad18ddebc4e28d37c1b67b0bb6cd7c /src
parentA guesstimate at what needs to be linked (diff)
downloadinkscape-34ac74865f2ce8ab7bb103dd946ba0b42c0445c8.tar.gz
inkscape-34ac74865f2ce8ab7bb103dd946ba0b42c0445c8.zip
inkboard-session now sends all changes to the document
(bzr r1602)
Diffstat (limited to 'src')
-rw-r--r--src/jabber_whiteboard/Makefile_insert1
-rw-r--r--src/jabber_whiteboard/defines.cpp19
-rw-r--r--src/jabber_whiteboard/defines.h9
-rw-r--r--src/jabber_whiteboard/inkboard-document.cpp31
-rw-r--r--src/jabber_whiteboard/inkboard-node.cpp33
-rw-r--r--src/jabber_whiteboard/inkboard-node.h71
-rw-r--r--src/jabber_whiteboard/inkboard-session.cpp61
-rw-r--r--src/jabber_whiteboard/inkboard-session.h2
8 files changed, 99 insertions, 128 deletions
diff --git a/src/jabber_whiteboard/Makefile_insert b/src/jabber_whiteboard/Makefile_insert
index e5470c045..b4ac480de 100644
--- a/src/jabber_whiteboard/Makefile_insert
+++ b/src/jabber_whiteboard/Makefile_insert
@@ -24,7 +24,6 @@ jabber_whiteboard_SOURCES = \
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 \
diff --git a/src/jabber_whiteboard/defines.cpp b/src/jabber_whiteboard/defines.cpp
index 8d9559c57..a8843b9e7 100644
--- a/src/jabber_whiteboard/defines.cpp
+++ b/src/jabber_whiteboard/defines.cpp
@@ -45,8 +45,23 @@ namespace Vars {
"<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 {
diff --git a/src/jabber_whiteboard/defines.h b/src/jabber_whiteboard/defines.h
index cff54916c..675e13136 100644
--- a/src/jabber_whiteboard/defines.h
+++ b/src/jabber_whiteboard/defines.h
@@ -88,10 +88,19 @@ namespace Message {
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 521e8d1b4..60d4cdd27 100644
--- a/src/jabber_whiteboard/inkboard-document.cpp
+++ b/src/jabber_whiteboard/inkboard-document.cpp
@@ -14,7 +14,6 @@
#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
diff --git a/src/jabber_whiteboard/inkboard-node.cpp b/src/jabber_whiteboard/inkboard-node.cpp
index c7d325ab9..c463e461a 100644
--- a/src/jabber_whiteboard/inkboard-node.cpp
+++ b/src/jabber_whiteboard/inkboard-node.cpp
@@ -12,17 +12,44 @@
#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
deleted file mode 100644
index 20787a597..000000000
--- a/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 ea63c5f31..6601d5d87 100644
--- a/src/jabber_whiteboard/inkboard-session.cpp
+++ b/src/jabber_whiteboard/inkboard-session.cpp
@@ -15,7 +15,6 @@
#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"
@@ -25,6 +24,7 @@
#include "xml/comment-node.h"
#include "util/share.h"
+#include "util/ucompose.hpp"
namespace Inkscape {
@@ -64,21 +64,18 @@ InkboardSession::commitUndoable()
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));
}
@@ -89,12 +86,7 @@ void InkboardSession::notifyChildAdded(Node &parent,
{
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);
@@ -107,8 +99,14 @@ void InkboardSession::notifyChildRemoved(Node &parent,
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);
}
}
@@ -117,8 +115,17 @@ void InkboardSession::notifyChildOrderChanged(Node &parent,
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);
}
}
@@ -126,8 +133,17 @@ void InkboardSession::notifyContentChanged(Node &node,
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);
+ }
}
}
@@ -136,8 +152,17 @@ void InkboardSession::notifyAttributeChanged(Node &node,
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);
+ }
}
}
diff --git a/src/jabber_whiteboard/inkboard-session.h b/src/jabber_whiteboard/inkboard-session.h
index 4ade2ca32..10eeb6322 100644
--- a/src/jabber_whiteboard/inkboard-session.h
+++ b/src/jabber_whiteboard/inkboard-session.h
@@ -26,8 +26,6 @@
#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"