summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordaleharvey <daleharvey@users.sourceforge.net>2006-07-29 23:29:11 +0000
committerdaleharvey <daleharvey@users.sourceforge.net>2006-07-29 23:29:11 +0000
commit906ecd69b79f5420f236e53be4649685cf046179 (patch)
treec2f73273e394b63961644bfa49bd36fe738218b1 /src
parentremove GObject signals from SPObject (diff)
downloadinkscape-906ecd69b79f5420f236e53be4649685cf046179.tar.gz
inkscape-906ecd69b79f5420f236e53be4649685cf046179.zip
update to whiteboard, merged typedefs / defines and constants
(bzr r1512)
Diffstat (limited to 'src')
-rw-r--r--src/jabber_whiteboard/Makefile_insert5
-rw-r--r--src/jabber_whiteboard/defines.cpp110
-rw-r--r--src/jabber_whiteboard/defines.h227
-rw-r--r--src/jabber_whiteboard/inkboard-document.cpp27
-rw-r--r--src/jabber_whiteboard/inkboard-document.h26
-rw-r--r--src/jabber_whiteboard/inkboard-session.h2
-rw-r--r--src/jabber_whiteboard/internal-constants.cpp76
-rw-r--r--src/jabber_whiteboard/internal-constants.h84
-rw-r--r--src/jabber_whiteboard/invitation-handlers.cpp6
-rw-r--r--src/jabber_whiteboard/message-utilities.cpp1
-rw-r--r--src/jabber_whiteboard/message-utilities.h2
-rw-r--r--src/jabber_whiteboard/node-tracker.h2
-rw-r--r--src/jabber_whiteboard/node-utilities.cpp1
-rw-r--r--src/jabber_whiteboard/node-utilities.h2
-rw-r--r--src/jabber_whiteboard/session-manager.cpp55
-rw-r--r--src/jabber_whiteboard/session-manager.h23
16 files changed, 325 insertions, 324 deletions
diff --git a/src/jabber_whiteboard/Makefile_insert b/src/jabber_whiteboard/Makefile_insert
index 252ec4980..1f2d26671 100644
--- a/src/jabber_whiteboard/Makefile_insert
+++ b/src/jabber_whiteboard/Makefile_insert
@@ -14,8 +14,6 @@ jabber_whiteboard_SOURCES = \
jabber_whiteboard/empty.cpp \
jabber_whiteboard/keynode.cpp \
jabber_whiteboard/keynode.h \
- jabber_whiteboard/internal-constants.cpp \
- jabber_whiteboard/internal-constants.h \
jabber_whiteboard/message-aggregator.cpp \
jabber_whiteboard/message-aggregator.h \
jabber_whiteboard/message-node.h \
@@ -40,8 +38,7 @@ jabber_whiteboard_SOURCES = \
jabber_whiteboard/session-manager.h \
jabber_whiteboard/tracker-node.h \
jabber_whiteboard/pedrogui.cpp \
- jabber_whiteboard/pedrogui.h \
- jabber_whiteboard/typedefs.h
+ jabber_whiteboard/pedrogui.h
if WITH_INKBOARD
diff --git a/src/jabber_whiteboard/defines.cpp b/src/jabber_whiteboard/defines.cpp
index 7e06cd625..d97520d55 100644
--- a/src/jabber_whiteboard/defines.cpp
+++ b/src/jabber_whiteboard/defines.cpp
@@ -19,43 +19,79 @@ namespace Inkscape {
namespace Whiteboard {
-char const * const MessageString[] = {
- // image and internal data
- "CHANGE_NOT_REPEATABLE",
- "CHANGE_REPEATABLE",
- "DUMMY_CHANGE",
- "CHANGE_COMMIT",
- "DOCUMENT_BEGIN",
- "DOCUMENT_END",
-
- // 1-1 connections
- "connect-request",
- "CONNECT_REQUEST_RESPONSE_USER",
- // chat connections
- "CONNECT_REQUEST_RESPONSE_CHAT",
-
- // chatroom document synchronization
- "CHATROOM_SYNCHRONIZE_REQUEST",
- "CHATROOM_SYNCHRONIZE_RESPONSE",
-
- // requests
- "DOCUMENT_SENDER_REQUEST",
- "DOCUMENT_SENDER_REQUEST_RESPONSE",
- "DOCUMENT_REQUEST",
-
- // notifications
- "CONNECTED_SIGNAL",
- "DISCONNECTED_FROM_USER_SIGNAL",
-
- // error responses
- "CONNECT_REQUEST_REFUSED_BY_PEER",
- "UNSUPPORTED_PROTOCOL_VERSION",
- "ALREADY_IN_SESSION",
-
- // error cases, i.e. garbled messages or bad clients. These should
- // never actually be transmitted
- "UNKNOWN"
-};
+namespace Message {
+
+ Wrapper PROTOCOL = 0;
+ Wrapper NEW = 1;
+ Wrapper REMOVE = 2;
+ Wrapper CONFIGURE = 3;
+ Wrapper MOVE = 4;
+
+ Message CONNECT_REQUEST = "connect-request";
+ Message CONNECTED = "connected";
+ Message ACCEPT_INVITATION = "accept-invitation";
+ Message DECLINE_INVITATION = "decline-invitation";
+ Message DOCUMENT_BEGIN = "document-begin";
+ Message DOCUMENT_END = "document-end";
+}
+
+namespace Vars {
+
+ char const* INKBOARD_XMLNS = "http://inkscape.org/inkboard";
+
+}
+
+namespace State {
+
+ SessionType WHITEBOARD_MUC = "groupchat";
+ SessionType WHITEBOARD_PEER = "chat";
+
+}
+
+// Protocol versions
+char const* MESSAGE_PROTOCOL_V1 = "1";
+char const* MESSAGE_PROTOCOL_V2 = "2";
+int const HIGHEST_SUPPORTED = 1;
+
+// Node types (as strings)
+char const* NODETYPE_DOCUMENT_STR = "document";
+char const* NODETYPE_ELEMENT_STR = "element";
+char const* NODETYPE_TEXT_STR = "text";
+char const* NODETYPE_COMMENT_STR = "comment";
+
+// Number of chars to allocate for type field (in SessionManager::sendMessage)
+int const TYPE_FIELD_SIZE = 5;
+
+// Number of chars to allocate for sequence number field (in SessionManager::sendMessage)
+int const SEQNUM_FIELD_SIZE = 70;
+
+// Designators for certain "special" nodes in the document
+// These nodes are "special" because they are generally present in all documents,
+// and we generally only want one copy of them
+char const* DOCUMENT_ROOT_NODE = "ROOT";
+char const* DOCUMENT_NAMEDVIEW_NODE = "NAMEDVIEW";
+
+// Names of these special nodes
+char const* DOCUMENT_ROOT_NAME = "svg:svg";
+char const* DOCUMENT_NAMEDVIEW_NAME = "sodipodi:namedview";
+
+// Inkboard client states
+int const IN_WHITEBOARD = 0;
+int const LOGGED_IN = 1;
+int const IN_CHATROOM = 2;
+int const WAITING_FOR_INVITE_RESPONSE = 3;
+int const CONNECTING_TO_CHAT = 4;
+int const WAITING_TO_SYNC_TO_CHAT = 5;
+int const SYNCHRONIZING_WITH_CHAT = 6;
+int const OPEN_FOR_DOC = 7;
+int const PLAYING_SESSION_FILE = 8;
+
+// TODO: make this user-configurable, within sane limits
+// ("sane" limits being roughly in the range (10, 100], from personal testing)
+// Based on discussions with Ted, it seems that we're going to make the Jabber guys
+// accomodate Inkscape, not the other way around...
+// Dispatch interval (in milliseconds)
+int const SEND_TIMEOUT = 35;
}
}
diff --git a/src/jabber_whiteboard/defines.h b/src/jabber_whiteboard/defines.h
index 587e29376..cef369056 100644
--- a/src/jabber_whiteboard/defines.h
+++ b/src/jabber_whiteboard/defines.h
@@ -14,53 +14,95 @@
#define __INKSCAPE_WHITEBOARD_DEFINES_H__
#include "jabber_whiteboard/message-tags.h"
-#include "jabber_whiteboard/internal-constants.h"
+
+#include <algorithm>
+#include <cstring>
+#include <string>
+#include <map>
+#include <set>
+#include <bitset>
+#include <vector>
+
+#include <glibmm.h>
+#include <sigc++/sigc++.h>
+
+#include "jabber_whiteboard/keynode.h"
+
+#include "gc-alloc.h"
+
+// Various specializations of std::less for XMLNodeTracker maps.
+namespace std {
+using Inkscape::XML::Node;
+
+/**
+ * Specialization of std::less<> for pointers to XML::Nodes.a
+ *
+ * \see Inkscape::XML::Node
+ */
+template<>
+struct less< Node* > : public binary_function < Node*, Node*, bool >
+{
+ bool operator()(Node* _x, Node* _y) const
+ {
+ return _x < _y;
+ }
+
+};
+
+}
namespace Inkscape {
+namespace XML {
+ class Node;
+}
+
+namespace Util {
+ template< typename T > class ListContainer;
+}
+
namespace Whiteboard {
+#define NUM_FLAGS 9
+
+namespace Message {
+
+ typedef int const Wrapper;
+ typedef char const* Message;
+
+ extern Wrapper PROTOCOL;
+ extern Wrapper NEW;
+ extern Wrapper REMOVE;
+ extern Wrapper CONFIGURE;
+ extern Wrapper MOVE;
+
+ extern Message CONNECT_REQUEST;
+ extern Message CONNECTED;
+ extern Message ACCEPT_INVITATION;
+ extern Message DECLINE_INVITATION;
+ extern Message DOCUMENT_BEGIN;
+ extern Message DOCUMENT_END;
+
+}
+
+namespace Vars {
+
+ extern char const* INKBOARD_XMLNS;
+
+}
+
+namespace State {
+
+ typedef char const* SessionType;
+
+ extern SessionType WHITEBOARD_MUC;
+ extern SessionType WHITEBOARD_PEER;
+
+}
+
// message types
// explicitly numbered to aid protocol description later on
-enum MessageType {
- // image and internal data
- CHANGE_NOT_REPEATABLE = 0,
- CHANGE_REPEATABLE = 1,
- DUMMY_CHANGE = 2,
- CHANGE_COMMIT = 3,
- DOCUMENT_BEGIN = 4,
- DOCUMENT_END = 5,
-
- // 1-1 connections
- CONNECT_REQUEST_USER = 6,
- CONNECT_REQUEST_RESPONSE_USER = 7,
- // chat connections
- CONNECT_REQUEST_RESPONSE_CHAT = 8,
-
- // chatroom document synchronization
- CHATROOM_SYNCHRONIZE_REQUEST = 9,
- CHATROOM_SYNCHRONIZE_RESPONSE = 10,
-
- // requests
- DOCUMENT_SENDER_REQUEST = 11,
- DOCUMENT_SENDER_REQUEST_RESPONSE = 12,
- DOCUMENT_REQUEST = 13,
-
- // notifications
- CONNECTED_SIGNAL = 14,
- DISCONNECTED_FROM_USER_SIGNAL = 15,
-
- // error responses
- CONNECT_REQUEST_REFUSED_BY_PEER = 16,
- UNSUPPORTED_PROTOCOL_VERSION = 17,
- ALREADY_IN_SESSION = 18,
-
- // error cases, i.e. garbled messages or bad clients. These should
- // never actually be transmitted
- UNKNOWN = 21
-};
-extern char const * const MessageString[];
// Responses to whiteboard invitations
enum InvitationResponses {
@@ -85,6 +127,113 @@ enum NodeTrackerAction {
NODE_UNKNOWN
};
+// I am assuming that std::string (which will not properly represent Unicode data) will
+// suffice for associating (integer, Jabber ID) identifiers with nodes.
+// We do not need to preserve all semantics handled by Unicode; we just need to have
+// the byte representation. std::string is good enough for that.
+//
+// The reason for this is that comparisons with std::string are much faster than
+// comparisons with Glib::ustring (simply because the latter is using significantly
+// more complex text-handling algorithms), and we need speed here. We _could_ use
+// Glib::ustring::collate_key() here and therefore get the best of both worlds,
+// but collation keys are rather big.
+//
+// XML node tracker maps
+
+/// Associates node keys to pointers to XML::Nodes.
+/// \see Inkscape::Whiteboard::XMLNodeTracker
+typedef std::map< std::string, XML::Node*, std::less< std::string >, GC::Alloc< std::pair< std::string, XML::Node* >, GC::MANUAL > > KeyToTrackerNodeMap;
+
+/// Associates pointers to XML::Nodes with node keys.
+/// \see Inkscape::Whiteboard::XMLNodeTracker
+typedef std::map< XML::Node*, std::string, std::less< XML::Node* >, GC::Alloc< std::pair< XML::Node*, std::string >, GC::MANUAL > > TrackerNodeToKeyMap;
+
+
+// TODO: Clean up these typedefs. I'm sure quite a few of these aren't used anymore; additionally,
+// it's probably possible to consolidate a few of these types into one.
+
+// Temporary storage of new object messages and new nodes in said messages
+typedef std::list< Glib::ustring > NewChildObjectMessageList;
+
+typedef std::pair< KeyNodePair, NodeTrackerAction > SerializedEventNodeAction;
+
+typedef std::list< SerializedEventNodeAction > KeyToNodeActionList;
+
+//typedef std::map< std::string, SerializedEventNodeAction > KeyToNodeActionMap;
+
+typedef std::set< std::string > AttributesScannedSet;
+typedef std::set< XML::Node* > AttributesUpdatedSet;
+
+typedef std::map< std::string, XML::Node const* > KeyToNodeMap;
+typedef std::map< XML::Node const*, std::string > NodeToKeyMap;
+
+
+// Message context verification and processing
+struct MessageProcessor;
+class ReceiveMessageQueue;
+
+typedef std::map< std::string, ReceiveMessageQueue*, std::less< std::string >, GC::Alloc< std::pair< std::string, ReceiveMessageQueue* >, GC::MANUAL > > RecipientToReceiveQueueMap;
+typedef std::map< std::string, unsigned int > ReceipientToLatestTransactionMap;
+
+typedef std::string ReceivedCommitEvent;
+typedef std::list< ReceivedCommitEvent > CommitsQueue;
+
+// Message serialization
+typedef std::list< Glib::ustring > SerializedEventList;
+
+// Error handling -- someday
+// TODO: finish and integrate this
+//typedef boost::function< LmHandlerResult (unsigned int code) > ErrorHandlerFunctor;
+//typedef std::map< unsigned int, ErrorHandlerFunctor > ErrorHandlerFunctorMap;
+
+// TODO: breaking these up into namespaces would be nice, but it's too much typing
+// for now
+
+// Protocol versions
+extern char const* MESSAGE_PROTOCOL_V1;
+extern int const HIGHEST_SUPPORTED;
+
+// Node types (as strings)
+extern char const* NODETYPE_DOCUMENT_STR;
+extern char const* NODETYPE_ELEMENT_STR;
+extern char const* NODETYPE_TEXT_STR;
+extern char const* NODETYPE_COMMENT_STR;
+
+// Number of chars to allocate for type field (in SessionManager::sendMessage)
+extern int const TYPE_FIELD_SIZE;
+
+// Number of chars to allocate for sequence number field (in SessionManager::sendMessage)
+extern int const SEQNUM_FIELD_SIZE;
+
+// Designators for certain "special" nodes in the document
+// These nodes are "special" because they are generally present in all documents
+extern char const* DOCUMENT_ROOT_NODE;
+extern char const* DOCUMENT_NAMEDVIEW_NODE;
+
+// Names of these special nodes
+extern char const* DOCUMENT_ROOT_NAME;
+extern char const* DOCUMENT_NAMEDVIEW_NAME;
+
+// Inkboard client states
+extern int const IN_WHITEBOARD;
+extern int const LOGGED_IN;
+extern int const IN_CHATROOM;
+extern int const WAITING_FOR_INVITE_RESPONSE;
+extern int const CONNECTING_TO_CHAT;
+extern int const WAITING_TO_SYNC_TO_CHAT;
+extern int const SYNCHRONIZING_WITH_CHAT;
+extern int const OPEN_FOR_DOC;
+extern int const PLAYING_SESSION_FILE;
+
+// update this if any other status flags are added
+
+// TODO: make this user-configurable, within sane limits
+// ("sane" limits being roughly in the range (10, 100], from personal testing)
+// Based on discussions with Ted, it seems that we're going to make the Jabber guys
+// accomodate Inkscape, not the other way around...
+// Dispatch interval (in milliseconds)
+extern int const SEND_TIMEOUT;
+
}
}
diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp
index c7e86a527..9477399e5 100644
--- a/src/jabber_whiteboard/inkboard-document.cpp
+++ b/src/jabber_whiteboard/inkboard-document.cpp
@@ -16,7 +16,7 @@
#include "xml/simple-session.h"
#include "jabber_whiteboard/inkboard-session.h"
-
+#include "jabber_whiteboard/defines.h"
#include "jabber_whiteboard/session-manager.h"
namespace Inkscape {
@@ -54,11 +54,11 @@ InkboardDocument::startSessionNegotiation()
SessionManager& sm = SessionManager::instance();
switch (_type) {
case INKBOARD_MUC:
- sm.sendGroup(_recipient, CHATROOM_SYNCHRONIZE_REQUEST, " ");
+ sm.sendGroup(_recipient, Message::PROTOCOL, " ");
break;
case INKBOARD_PRIVATE:
default:
- sm.sendProtocol(_recipient, CONNECT_REQUEST_USER);
+ sm.send(_recipient, Message::PROTOCOL," ");
break;
}
}
@@ -70,14 +70,31 @@ InkboardDocument::terminateSession()
}
void
-InkboardDocument::processInkboardEvent(MessageType mtype, unsigned int seqnum, Glib::ustring const& data)
+InkboardDocument::processInkboardEvent(Message::Wrapper mtype, unsigned int seqnum, Glib::ustring const& data)
{
g_log(NULL, G_LOG_LEVEL_DEBUG, "Processing Inkboard event: mtype=%d seqnum=%d data=%s\n", mtype, seqnum, data.c_str());
}
+bool
+InkboardDocument::send(const Glib::ustring &destJid, Message::Wrapper wrapper, Message::Message message)
+{
+ char *fmt=
+ "<message type='chat' from='%s' to='%s'>"
+ "<wb xmlns='%s'>"
+ "<protocol>"
+ "%s"
+ "</protocol>"
+ "</wb>"
+ "</message>";
+ //if (!getClient().write(fmt,getClient().getJid().c_str(),destJid.c_str(),Vars::INKBOARD_XMLNS,message))
+ // return false;
+
+ return true;
}
-}
+} // namespace Whiteboard
+} // namespace Inkscape
+
/*
Local Variables:
diff --git a/src/jabber_whiteboard/inkboard-document.h b/src/jabber_whiteboard/inkboard-document.h
index 0c147d35e..aa726b1f9 100644
--- a/src/jabber_whiteboard/inkboard-document.h
+++ b/src/jabber_whiteboard/inkboard-document.h
@@ -26,19 +26,24 @@ namespace Whiteboard {
class InkboardDocument : public XML::SimpleNode, public XML::Document {
public:
- explicit InkboardDocument(int code, SessionType type, Glib::ustring const& to);
+
+ explicit InkboardDocument(int code, SessionType type, Glib::ustring const& to);
- XML::NodeType type() const
- {
- return Inkscape::XML::DOCUMENT_NODE;
- }
+ XML::NodeType type() const
+ {
+ return Inkscape::XML::DOCUMENT_NODE;
+ }
- void setRecipient(Glib::ustring const& val);
- Glib::ustring getRecipient() const;
+ void setRecipient(Glib::ustring const& val);
+ Glib::ustring getRecipient() const;
void startSessionNegotiation();
void terminateSession();
- void processInkboardEvent(MessageType mtype, unsigned int seqnum, Glib::ustring const& data);
+ void processInkboardEvent(Message::Wrapper mtype, unsigned int seqnum, Glib::ustring const& data);
+
+ bool send(const Glib::ustring &destJid, Message::Wrapper mwrapper, Message::Message message);
+ bool send(const Glib::ustring &destJid, Message::Wrapper mwrapper, const Glib::ustring &data);
+
protected:
/**
@@ -58,10 +63,11 @@ protected:
}
private:
- void _initBindings();
+
+ void _initBindings();
SessionType _type;
- Glib::ustring _recipient;
+ Glib::ustring _recipient;
KeyNodeTable _tracker;
};
diff --git a/src/jabber_whiteboard/inkboard-session.h b/src/jabber_whiteboard/inkboard-session.h
index 7ac5e4a90..28e844f23 100644
--- a/src/jabber_whiteboard/inkboard-session.h
+++ b/src/jabber_whiteboard/inkboard-session.h
@@ -16,7 +16,7 @@
#include <bitset>
#include "pedro/pedroxmpp.h"
-#include "jabber_whiteboard/internal-constants.h"
+#include "jabber_whiteboard/defines.h"
#include "xml/simple-session.h"
#include "util/share.h"
diff --git a/src/jabber_whiteboard/internal-constants.cpp b/src/jabber_whiteboard/internal-constants.cpp
deleted file mode 100644
index 44355c8a0..000000000
--- a/src/jabber_whiteboard/internal-constants.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Whiteboard session manager
- * Internal constants
- *
- * Authors:
- * David Yip <yipdw@rose-hulman.edu>
- *
- * Copyright (c) 2005 Authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "jabber_whiteboard/internal-constants.h"
-
-namespace Inkscape {
-
-namespace Whiteboard {
-// Protocol versions
-char const* MESSAGE_PROTOCOL_V1 = "1";
-char const* MESSAGE_PROTOCOL_V2 = "2";
-int const HIGHEST_SUPPORTED = 1;
-
-// Node types (as strings)
-char const* NODETYPE_DOCUMENT_STR = "document";
-char const* NODETYPE_ELEMENT_STR = "element";
-char const* NODETYPE_TEXT_STR = "text";
-char const* NODETYPE_COMMENT_STR = "comment";
-
-// Number of chars to allocate for type field (in SessionManager::sendMessage)
-int const TYPE_FIELD_SIZE = 5;
-
-// Number of chars to allocate for sequence number field (in SessionManager::sendMessage)
-int const SEQNUM_FIELD_SIZE = 70;
-
-// Designators for certain "special" nodes in the document
-// These nodes are "special" because they are generally present in all documents,
-// and we generally only want one copy of them
-char const* DOCUMENT_ROOT_NODE = "ROOT";
-char const* DOCUMENT_NAMEDVIEW_NODE = "NAMEDVIEW";
-
-// Names of these special nodes
-char const* DOCUMENT_ROOT_NAME = "svg:svg";
-char const* DOCUMENT_NAMEDVIEW_NAME = "sodipodi:namedview";
-
-// Inkboard client states
-int const IN_WHITEBOARD = 0;
-int const LOGGED_IN = 1;
-int const IN_CHATROOM = 2;
-int const WAITING_FOR_INVITE_RESPONSE = 3;
-int const CONNECTING_TO_CHAT = 4;
-int const WAITING_TO_SYNC_TO_CHAT = 5;
-int const SYNCHRONIZING_WITH_CHAT = 6;
-int const OPEN_FOR_DOC = 7;
-int const PLAYING_SESSION_FILE = 8;
-
-// TODO: make this user-configurable, within sane limits
-// ("sane" limits being roughly in the range (10, 100], from personal testing)
-// Based on discussions with Ted, it seems that we're going to make the Jabber guys
-// accomodate Inkscape, not the other way around...
-// Dispatch interval (in milliseconds)
-int const SEND_TIMEOUT = 35;
-}
-
-}
-
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/jabber_whiteboard/internal-constants.h b/src/jabber_whiteboard/internal-constants.h
deleted file mode 100644
index 737eacdc7..000000000
--- a/src/jabber_whiteboard/internal-constants.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Whiteboard session manager
- * Internal constants
- *
- * Authors:
- * David Yip <yipdw@rose-hulman.edu>
- *
- * Copyright (c) 2005 Authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#ifndef __WHITEBOARD_INTERNAL_CONSTANTS_H__
-#define __WHITEBOARD_INTERNAL_CONSTANTS_H__
-
-namespace Inkscape {
-
-namespace Whiteboard {
-
-// TODO: breaking these up into namespaces would be nice, but it's too much typing
-// for now
-
-// Protocol versions
-extern char const* MESSAGE_PROTOCOL_V1;
-extern int const HIGHEST_SUPPORTED;
-
-// Node types (as strings)
-extern char const* NODETYPE_DOCUMENT_STR;
-extern char const* NODETYPE_ELEMENT_STR;
-extern char const* NODETYPE_TEXT_STR;
-extern char const* NODETYPE_COMMENT_STR;
-
-// Number of chars to allocate for type field (in SessionManager::sendMessage)
-extern int const TYPE_FIELD_SIZE;
-
-// Number of chars to allocate for sequence number field (in SessionManager::sendMessage)
-extern int const SEQNUM_FIELD_SIZE;
-
-// Designators for certain "special" nodes in the document
-// These nodes are "special" because they are generally present in all documents
-extern char const* DOCUMENT_ROOT_NODE;
-extern char const* DOCUMENT_NAMEDVIEW_NODE;
-
-// Names of these special nodes
-extern char const* DOCUMENT_ROOT_NAME;
-extern char const* DOCUMENT_NAMEDVIEW_NAME;
-
-// Inkboard client states
-extern int const IN_WHITEBOARD;
-extern int const LOGGED_IN;
-extern int const IN_CHATROOM;
-extern int const WAITING_FOR_INVITE_RESPONSE;
-extern int const CONNECTING_TO_CHAT;
-extern int const WAITING_TO_SYNC_TO_CHAT;
-extern int const SYNCHRONIZING_WITH_CHAT;
-extern int const OPEN_FOR_DOC;
-extern int const PLAYING_SESSION_FILE;
-
-// update this if any other status flags are added
-#define NUM_FLAGS 9
-
-// TODO: make this user-configurable, within sane limits
-// ("sane" limits being roughly in the range (10, 100], from personal testing)
-// Based on discussions with Ted, it seems that we're going to make the Jabber guys
-// accomodate Inkscape, not the other way around...
-// Dispatch interval (in milliseconds)
-extern int const SEND_TIMEOUT;
-
-}
-
-}
-
-#endif
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/jabber_whiteboard/invitation-handlers.cpp b/src/jabber_whiteboard/invitation-handlers.cpp
index 124b9515b..69d46f6d1 100644
--- a/src/jabber_whiteboard/invitation-handlers.cpp
+++ b/src/jabber_whiteboard/invitation-handlers.cpp
@@ -21,7 +21,7 @@
#include "jabber_whiteboard/inkboard-document.h"
#include "jabber_whiteboard/session-manager.h"
#include "jabber_whiteboard/invitation-confirm-dialog.h"
-
+#include "jabber_whiteboard/defines.h"
namespace Inkscape {
@@ -58,7 +58,7 @@ SessionManager::_checkInvitationQueue()
{
SPDesktop* dt = createInkboardDesktop(from, INKBOARD_PRIVATE);
InkboardDocument* idoc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
- send(from, CONNECT_REQUEST_RESPONSE_USER, " ");
+ send(from, Message::PROTOCOL, " ");
break;
}
case DECLINE_INVITATION:
@@ -66,7 +66,7 @@ SessionManager::_checkInvitationQueue()
break;
}
default:
- send(from, CONNECT_REQUEST_REFUSED_BY_PEER, " ");
+ send(from, Message::PROTOCOL, " ");
break;
}
diff --git a/src/jabber_whiteboard/message-utilities.cpp b/src/jabber_whiteboard/message-utilities.cpp
index c259af735..e18f27ae4 100644
--- a/src/jabber_whiteboard/message-utilities.cpp
+++ b/src/jabber_whiteboard/message-utilities.cpp
@@ -20,7 +20,6 @@
#include "xml/repr.h"
#include "jabber_whiteboard/defines.h"
-#include "jabber_whiteboard/typedefs.h"
#include "jabber_whiteboard/node-utilities.h"
#include "jabber_whiteboard/message-utilities.h"
#include "jabber_whiteboard/node-tracker.h"
diff --git a/src/jabber_whiteboard/message-utilities.h b/src/jabber_whiteboard/message-utilities.h
index dad805c41..2ea65acb8 100644
--- a/src/jabber_whiteboard/message-utilities.h
+++ b/src/jabber_whiteboard/message-utilities.h
@@ -18,7 +18,7 @@
#include "xml/repr.h"
#include "xml/node.h"
-#include "jabber_whiteboard/typedefs.h"
+#include "jabber_whiteboard/defines.h"
using Glib::ustring;
diff --git a/src/jabber_whiteboard/node-tracker.h b/src/jabber_whiteboard/node-tracker.h
index 660b784fb..2bb61f5a5 100644
--- a/src/jabber_whiteboard/node-tracker.h
+++ b/src/jabber_whiteboard/node-tracker.h
@@ -14,7 +14,7 @@
#define __WHITEBOARD_XML_NODE_TRACKER_H__
#include "jabber_whiteboard/tracker-node.h"
-#include "jabber_whiteboard/typedefs.h"
+#include "jabber_whiteboard/defines.h"
#include <bitset>
#include <cstring>
diff --git a/src/jabber_whiteboard/node-utilities.cpp b/src/jabber_whiteboard/node-utilities.cpp
index cbf4b6ea1..06e19f825 100644
--- a/src/jabber_whiteboard/node-utilities.cpp
+++ b/src/jabber_whiteboard/node-utilities.cpp
@@ -18,7 +18,6 @@
#include "xml/repr.h"
#include "jabber_whiteboard/defines.h"
-#include "jabber_whiteboard/typedefs.h"
#include "jabber_whiteboard/node-utilities.h"
#include "jabber_whiteboard/node-tracker.h"
//#include "jabber_whiteboard/node-observer.h"
diff --git a/src/jabber_whiteboard/node-utilities.h b/src/jabber_whiteboard/node-utilities.h
index 4a025f149..8f8646328 100644
--- a/src/jabber_whiteboard/node-utilities.h
+++ b/src/jabber_whiteboard/node-utilities.h
@@ -11,7 +11,7 @@
#ifndef __WHITEBOARD_NODE_UTILITIES_H__
#define __WHITEBOARD_NODE_UTILITIES_H__
-#include "jabber_whiteboard/typedefs.h"
+#include "jabber_whiteboard/defines.h"
#include "xml/node.h"
#include <glibmm.h>
diff --git a/src/jabber_whiteboard/session-manager.cpp b/src/jabber_whiteboard/session-manager.cpp
index 3c982c4df..acb661caf 100644
--- a/src/jabber_whiteboard/session-manager.cpp
+++ b/src/jabber_whiteboard/session-manager.cpp
@@ -80,7 +80,7 @@ unsigned long SessionManager::getSequenceNumber()
bool
SessionManager::send(const Glib::ustring &destJid,
- const MessageType type,
+ const Message::Wrapper type,
const Glib::ustring &data)
{
Pedro::DOMString xmlData = Pedro::Parser::encode(data);
@@ -108,33 +108,8 @@ SessionManager::send(const Glib::ustring &destJid,
}
bool
-SessionManager::sendProtocol(const Glib::ustring &destJid,
- const MessageType type)
-{
- char *fmt=
- "<message type='chat' from='%s' to='%s'>"
- "<wb xmlns='%s'>"
- "<protocol>"
- "<%s />"
- "</protocol>"
- "</wb>"
- "</message>";
- if (!getClient().write(fmt,
- getClient().getJid().c_str(),
- destJid.c_str(),
- INKBOARD_XMLNS,
- MessageString[type]
- ))
- {
- return false;
- }
-
- return true;
-}
-
-bool
SessionManager::sendGroup(const Glib::ustring &groupJid,
- const MessageType type,
+ const Message::Wrapper type,
const Glib::ustring &data)
{
Pedro::DOMString xmlData = Pedro::Parser::encode(data);
@@ -414,19 +389,12 @@ SessionManager::_processInkboardEvent(Pedro::XmppEvent const& event)
// MessageValidityTestResult res = MessageVerifier::verifyMessageValidity(event, mtype, doc);
MessageValidityTestResult res = RESULT_INVALID;
-
+ /*
switch (res) {
case RESULT_VALID:
{
switch (mtype) {
- case CONNECT_REQUEST_USER:
- case CONNECT_REQUEST_REFUSED_BY_PEER:
- case UNSUPPORTED_PROTOCOL_VERSION:
- case ALREADY_IN_SESSION:
- _handleSessionEvent(mtype, event);
- break;
- case DISCONNECTED_FROM_USER_SIGNAL:
- break;
+ case CONNECT_REQUEST:
default:
if (doc != NULL) {
unsigned int seqnum = atoi(seq.c_str());
@@ -442,27 +410,24 @@ SessionManager::_processInkboardEvent(Pedro::XmppEvent const& event)
g_warning("Received message in invalid context.");
break;
}
+ */
}
void
-SessionManager::_handleSessionEvent(MessageType mtype, Pedro::XmppEvent const& event)
+SessionManager::_handleSessionEvent(Message::Wrapper mtype, Pedro::XmppEvent const& event)
{
+ /*
switch (mtype) {
- case CONNECT_REQUEST_USER:
+ case CONNECT_REQUEST:
_handleIncomingInvitation(event.getFrom());
break;
- case CONNECT_REQUEST_REFUSED_BY_PEER:
+ case INVITATION_DECLINE:
_handleInvitationResponse(event.getFrom(), DECLINE_INVITATION);
break;
- case ALREADY_IN_SESSION:
- _handleInvitationResponse(event.getFrom(), PEER_ALREADY_IN_SESSION);
- break;
- case UNSUPPORTED_PROTOCOL_VERSION:
- _handleInvitationResponse(event.getFrom(), UNSUPPORTED_PROTOCOL);
- break;
default:
break;
}
+ */
}
void
diff --git a/src/jabber_whiteboard/session-manager.h b/src/jabber_whiteboard/session-manager.h
index b07b64906..49909a39b 100644
--- a/src/jabber_whiteboard/session-manager.h
+++ b/src/jabber_whiteboard/session-manager.h
@@ -13,16 +13,14 @@
#ifndef __INKSCAPE_WHITEBOARD_SESSION_MANAGER_H__
#define __INKSCAPE_WHITEBOARD_SESSION_MANAGER_H__
-#include "jabber_whiteboard/pedrogui.h"
-
#include <glibmm.h>
#include <list>
#include <bitset>
+#include "jabber_whiteboard/pedrogui.h"
#include "jabber_whiteboard/message-queue.h"
#include "jabber_whiteboard/defines.h"
-#include "jabber_whiteboard/internal-constants.h"
#include "jabber_whiteboard/inkboard-session.h"
#include "gc-alloc.h"
@@ -48,16 +46,16 @@ public:
*
*/
SessionManager();
-
+
/**
*
*/
virtual ~SessionManager();
-
-
+
+
static void showClient();
static SessionManager& instance();
-
+
/**
*
*/
@@ -73,19 +71,14 @@ public:
*
*/
virtual bool send(const Glib::ustring &destJid,
- const MessageType type,
+ const Message::Wrapper type,
const Glib::ustring &data);
- /**
- *
- */
- virtual bool sendProtocol(const Glib::ustring &destJid,
- const MessageType type);
/**
*
*/
virtual bool sendGroup(const Glib::ustring &destJid,
- const MessageType type,
+ const Message::Wrapper type,
const Glib::ustring &data);
/**
*
@@ -209,7 +202,7 @@ private:
// methods
void _processInkboardEvent(Pedro::XmppEvent const& event);
- void _handleSessionEvent(MessageType mtype, Pedro::XmppEvent const& event);
+ void _handleSessionEvent(Message::Wrapper mtype, Pedro::XmppEvent const& event);
void _handleIncomingInvitation(Glib::ustring const& from);
void _handleInvitationResponse(Glib::ustring const& from, InvitationResponses resp);