Code

update to whiteboard, merged typedefs / defines and constants
authordaleharvey <daleharvey@users.sourceforge.net>
Sat, 29 Jul 2006 23:29:11 +0000 (23:29 +0000)
committerdaleharvey <daleharvey@users.sourceforge.net>
Sat, 29 Jul 2006 23:29:11 +0000 (23:29 +0000)
16 files changed:
src/jabber_whiteboard/Makefile_insert
src/jabber_whiteboard/defines.cpp
src/jabber_whiteboard/defines.h
src/jabber_whiteboard/inkboard-document.cpp
src/jabber_whiteboard/inkboard-document.h
src/jabber_whiteboard/inkboard-session.h
src/jabber_whiteboard/internal-constants.cpp [deleted file]
src/jabber_whiteboard/internal-constants.h [deleted file]
src/jabber_whiteboard/invitation-handlers.cpp
src/jabber_whiteboard/message-utilities.cpp
src/jabber_whiteboard/message-utilities.h
src/jabber_whiteboard/node-tracker.h
src/jabber_whiteboard/node-utilities.cpp
src/jabber_whiteboard/node-utilities.h
src/jabber_whiteboard/session-manager.cpp
src/jabber_whiteboard/session-manager.h

index 252ec49805e522f7d10ff886657454b4561cab0f..1f2d2667163549de71a5d84ddfcb58227dc1b659 100644 (file)
@@ -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
index 7e06cd625cac3555c0d8e1ad0b7161a6c741f908..d97520d55892fe7999698915a7a7cf387a03d4e5 100644 (file)
@@ -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;
 
 }
 }
index 587e293762740a645143703abcdd4e18362c18d8..cef369056e4a6ccdbb89a163e3f0a55f21974742 100644 (file)
 #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;
+
 }
 
 }
index c7e86a5276760db937913e712db974b7655f6f8b..9477399e5e5e2a0c237a720fb370115884c3ea0e 100644 (file)
@@ -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:
index 0c147d35e38e6b4fd924d5f98441f8ce2995a4ee..aa726b1f912751f262d331ad3537bb2b5545c4b2 100644 (file)
@@ -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;
 };
index 7ac5e4a90b4afa3198df698951be4b19da5997ff..28e844f23c2eef13d7f128107636fc78ef05f271 100644 (file)
@@ -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 (file)
index 44355c8..0000000
+++ /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 (file)
index 737eacd..0000000
+++ /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 :
index 124b9515be23e95aca88c5ed25606082232a7e68..69d46f6d1c6400265e6677bf6d4afe162ad14d21 100644 (file)
@@ -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;
                }
 
index c259af735a67418477640f833034357769e6483c..e18f27ae412cec9b2549cbaedfa049f8a95d559c 100644 (file)
@@ -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"
index dad805c41a51011a81d3760501541004fafed031..2ea65acb85af84bca56ff23ec9cf733332899d2d 100644 (file)
@@ -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;
 
index 660b784fbf589f6be71c83343f873b527d92bf4d..2bb61f5a533f253d4ba4f6db51c93c09764e3b78 100644 (file)
@@ -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>
index cbf4b6ea1c56a8a988f4974597769913f4e4ffa9..06e19f825bd94ef41efff4d5f7dc042326c3fa5e 100644 (file)
@@ -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"
index 4a025f14949a264b6bb84d27e3fa0021d5a5ab84..8f86463282f093b7cf392655356d33b34ed5e243 100644 (file)
@@ -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>
 
index 3c982c4df80676738504691dea423d8c931fccc5..acb661cafd13d36afe0e2b5b0850cc3d003e44d4 100644 (file)
@@ -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);
@@ -107,34 +107,9 @@ SessionManager::send(const Glib::ustring &destJid,
     return true;
 }
 
-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
index b07b64906401e090867e77d26c09c1ad3e6605b8..49909a39b4f9925716e2aa3ee39de390a509bd57 100644 (file)
 #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);