serializer.cpp revision 12107abbb78a8201106786c55ec2dda6b2cdab2d
/**
* Inkboard message -> XML::Event* serializer
*
* Authors:
* David Yip <yipdw@rose-hulman.edu>
*
* Copyright (c) 2005 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "xml/attribute-record.h"
#include "jabber_whiteboard/serializer.h"
#include "jabber_whiteboard/message-utilities.h"
#include "jabber_whiteboard/message-tags.h"
#include "jabber_whiteboard/typedefs.h"
#include "jabber_whiteboard/node-tracker.h"
#include "jabber_whiteboard/node-utilities.h"
#include "jabber_whiteboard/node-tracker-observer.h"
namespace Inkscape {
namespace Whiteboard {
void
{
// do not recurse upon initial notification
}
void
{
// 1. Check if we are tracking the parent node,
// and issue it an ID if we are not.
// 2. Check if the child node is a special node.
// Special nodes are nodes that should appear only once in a document.
// If it is, we do not want to generate a new ID for the child; we will use
// the existing ID. Otherwise, we will generate a new ID for it, since we
// have not yet seen it.
} else {
// If the child id already exists in the new node buffer, then we've already seen it.
return;
} else {
// childid = this->_findOrGenerateNodeID(child);
}
}
// 3. Find this node's previous node, and, if it has one, retrieve its ID.
if (prev) {
}
// 4. Serialize.
Glib::ustring nodetype = MessageUtilities::makeTagWithContent(MESSAGE_NODETYPE, NodeUtilities::nodeTypeToString(child));
}
Glib::ustring buf = MessageUtilities::makeTagWithContent(MESSAGE_NEWOBJ, childmsg + parentmsg + prevmsg + namemsg + nodetype);
// 5. Add the child node to the new nodes buffers.
// 6. Scan attributes and content.
}
}
// 7. Repeat this process for each child of this child.
// No prev node in this case.
} else {
}
}
}
return;
}
void
{
// 1. Get the ID of the child.
// Don't look in local! Go for the tracker.
} else if (i == this->_parent_child_map.end()) {
this->_parent_child_map.erase(i);
} else {
}
// 2. Double-deletes don't make any sense. If we've seen this node already and if it's
// marked for deletion, return.
return;
} else {
// 2a. Although we do not have to remove all child nodes of this subtree,
// we _do_ have to mark each child node as deleted.
this->_recursiveMarkAsRemoved(child);
}
// 2. Mark this node as deleted. We don't want to be faced with the possibility of
// generating a new key for this deleted node, so insert it into both maps.
// 4. Serialize the event.
this->_events.push_back(MessageUtilities::makeTagWithContent(MESSAGE_DELETE, childidmsg + parentidmsg));
}
void
Serializer::notifyChildOrderChanged(XML::Node& node, XML::Node& child, XML::Node* old_prev, XML::Node* new_prev)
{
// 1. Find the ID of the node, or generate it if it does not exist.
// 2. Find the ID of the parent of this node, or generate it if it does not exist.
// 3. Get the ID for the new child reference node, or generate it if it does not exist.
// 4. Get the ID for the old child reference node, or generate it if it does not exist.
// 5. Serialize the event.
this->_events.push_back(MessageUtilities::makeTagWithContent(MESSAGE_ORDERCHANGE, nodeidmsg + parentidmsg + oldprevidmsg + newprevidmsg));
}
void
Serializer::notifyContentChanged(XML::Node& node, Util::shared_ptr<char> old_content, Util::shared_ptr<char> new_content)
{
// 1. Find the ID of the node, or generate it if it does not exist.
// 2. If the old and new content are identical, don't send out this change.
// (identical meaning "same string" or "same string content")
if (old_content == new_content) {
return;
}
return;
}
}
// 3. Serialize the event.
}
}
this->_events.push_back(MessageUtilities::makeTagWithContent(MESSAGE_NODECONTENT, nodeidmsg + oldvalmsg + newvalmsg));
}
void
Serializer::notifyAttributeChanged(XML::Node& node, GQuark name, Util::shared_ptr<char> old_value, Util::shared_ptr<char> new_value)
{
// 1. Find the ID of the node that has had an attribute modified, or generate it if it
// does not exist.
// Proceed with 2-4 if the node has not already been scanned by notifyChildAdded.
// 2. Convert the key to a string.
// 3. If oldval == newval, don't echo this change.
return;
}
}
// 4. Serialize the event.
}
}
this->_events.push_back(MessageUtilities::makeTagWithContent(MESSAGE_CHANGE, nodeidmsg + keymsg + oldvalmsg + newvalmsg));
}
}
void
{
// The root of the subtree defined by parent has already been considered; now,
// recursively look at the rest of the tree.
} else {
}
}
}
}
void
{
this->_recursiveMarkAsRemoved(*ch);
}
}
}
}
/*
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 :