summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a679bd)
raw | patch | inline | side by side (parent: 6a679bd)
author | daleharvey <daleharvey@users.sourceforge.net> | |
Thu, 3 Aug 2006 17:52:16 +0000 (17:52 +0000) | ||
committer | daleharvey <daleharvey@users.sourceforge.net> | |
Thu, 3 Aug 2006 17:52:16 +0000 (17:52 +0000) |
src/jabber_whiteboard/inkboard-document.cpp | patch | blob | history | |
src/jabber_whiteboard/inkboard-document.h | patch | blob | history | |
src/jabber_whiteboard/session-manager.cpp | patch | blob | history |
diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp
index 514b3acc414dc936de84292ec2b868e7cae2e299..c46546ebc47822ac4d5f32f310c6c9c8e8a36ef2 100644 (file)
}
void
-InkboardDocument::processInkboardEvent(Message::Wrapper mtype, Glib::ustring const& data)
+InkboardDocument::processInkboardEvent(Message::Wrapper &wrapper, Pedro::Element* data)
{
- g_log(NULL, G_LOG_LEVEL_DEBUG, "Processing Inkboard event: mtype=%s data=%s\n",mtype,data.c_str());
-
+ if(this->handleIncomingState(wrapper,data))
+ {
+ if(wrapper == Message::PROTOCOL)
+ {
+ if(data->exists(Message::ACCEPT_INVITATION));
+ {
+ // TODO : Would be nice to create the desktop here
+
+ sendProtocol(getRecipient(),Message::PROTOCOL, Message::CONNECTED);
+ sendProtocol(getRecipient(),Message::PROTOCOL, Message::DOCUMENT_BEGIN);
+ sendProtocol(getRecipient(),Message::PROTOCOL, Message::DOCUMENT_END);
+ }
+ }
+ }else{
+ g_warning("Recieved Message in invalid state = %d", this->state);
+ data->print();
+ }
}
bool
-InkboardDocument::sendProtocol(const Glib::ustring &destJid, Message::Wrapper wrapper,
+InkboardDocument::sendProtocol(const Glib::ustring &destJid, Message::Wrapper &wrapper,
Message::Message message)
{
if(this->handleOutgoingState(wrapper,message))
@@ -99,19 +114,22 @@ InkboardDocument::sendProtocol(const Glib::ustring &destJid, Message::Wrapper wr
if (!_sm->getClient().write(fmt,
_type,_sm->getClient().getJid().c_str(),destJid.c_str(),Vars::INKBOARD_XMLNS,
- this->getSessionId().c_str(),wrapper,message,wrapper))
- return false;
+ this->getSessionId().c_str(),wrapper,message,wrapper))
+ { return false; }
- return true;
+ else
+ { return true; }
- }else
- return false;
+ }else
+ {
+ g_warning("Sending Message in invalid state message=%s , state=%d",message,this->state);
+ return false;
+ }
}
bool
-InkboardDocument::handleOutgoingState(Message::Wrapper wrapper,Message::Message message)
+InkboardDocument::handleOutgoingState(Message::Wrapper &wrapper, Glib::ustring const& message)
{
- g_warning("state %d, message %s",this->state,message);
if(wrapper == Message::PROTOCOL)
{
if(message == Message::CONNECT_REQUEST)
else if(message == Message::DOCUMENT_BEGIN)
return this->handleState(State::CONNECTED,State::SYNCHRONISING);
- else if(message == Message::DOCUMENT_END)
+ else if(message == Message::DOCUMENT_END) {
return this->handleState(State::SYNCHRONISING,State::IN_WHITEBOARD);
+ }
else
return false;
@@ -140,10 +159,12 @@ InkboardDocument::handleOutgoingState(Message::Wrapper wrapper,Message::Message
}
bool
-InkboardDocument::handleIncomingState(Message::Wrapper wrapper,Glib::ustring const& message)
+InkboardDocument::handleIncomingState(Message::Wrapper &wrapper, Pedro::Element* data)
{
if(wrapper == Message::PROTOCOL)
{
+ Glib::ustring message = data->getFirstChild()->getFirstChild()->getFirstChild()->getName();
+
// Connect Requests are handled in SessionManager
if(message == Message::ACCEPT_INVITATION)
return this->handleState(State::AWAITING_INVITATION_REPLY,State::INVITATION_RECIEVED);
index c09640852f3550abb8c03caf7245922feaa177fc..4f0f05e0786c3e6d0a30ff20db3d64df4c700981 100644 (file)
#include <glibmm.h>
+#include "document.h"
#include "xml/document.h"
#include "xml/simple-node.h"
#include "jabber_whiteboard/defines.h"
void startSessionNegotiation();
void terminateSession();
- void processInkboardEvent(Message::Wrapper mtype, Glib::ustring const& data);
+ void processInkboardEvent(Message::Wrapper &wrapper, Pedro::Element* data);
- bool sendProtocol(const Glib::ustring &destJid, Message::Wrapper mwrapper,
+ bool sendProtocol(const Glib::ustring &destJid, Message::Wrapper &mwrapper,
Message::Message message);
- bool handleOutgoingState(Message::Wrapper wrapper,Message::Message message);
- bool handleIncomingState(Message::Wrapper wrapper,Glib::ustring const& message);
+ bool handleOutgoingState(Message::Wrapper &wrapper,Glib::ustring const& message);
+ bool handleIncomingState(Message::Wrapper &wrapper,Pedro::Element* data);
bool handleState(State::SessionState expectedState, State::SessionState newstate);
index 7ca4902121fc08fe3d8cd3ac0710d3dd8856a09c..ef842e339e39363164ab71b430db139fa19f8db1 100644 (file)
getClient().disconnect();
}
-void
-SessionManager::processXmppEvent(const Pedro::XmppEvent &event)
-{
- int type = event.getType();
-
- switch (type) {
- case Pedro::XmppEvent::EVENT_STATUS:
- {
- break;
- }
- case Pedro::XmppEvent::EVENT_ERROR:
- {
- break;
- }
- case Pedro::XmppEvent::EVENT_CONNECTED:
- {
- break;
- }
- case Pedro::XmppEvent::EVENT_DISCONNECTED:
- {
- break;
- }
- case Pedro::XmppEvent::EVENT_MUC_MESSAGE:
- case Pedro::XmppEvent::EVENT_MESSAGE:
- {
- g_warning("## SM message:%s\n", event.getFrom().c_str());
- Pedro::Element *root = event.getDOM();
-
- if (root && root->getTagAttribute("wb", "xmlns") == Vars::INKBOARD_XMLNS)
- processWhiteboardEvent(event);
-
- break;
- }
- case Pedro::XmppEvent::EVENT_PRESENCE:
- {
- break;
- }
- case Pedro::XmppEvent::EVENT_MUC_JOIN:
- {
- break;
- }
- case Pedro::XmppEvent::EVENT_MUC_LEAVE:
- {
- break;
- }
- case Pedro::XmppEvent::EVENT_MUC_PRESENCE:
- {
- break;
- }
- default:
- {
- break;
- }
- }
-}
-
/**
* Initiates a shared session with a user or conference room.
*
@@ -177,6 +121,7 @@ SessionManager::initialiseSession(Glib::ustring const& to, State::SessionType ty
inkdoc->setSessionId(sessionId);
+ makeInkboardDesktop(doc);
addSession(WhiteboardRecord(sessionId, inkdoc));
inkdoc->startSessionNegotiation();
return NULL;
}
+void
+SessionManager::processXmppEvent(const Pedro::XmppEvent &event)
+{
+ int type = event.getType();
+
+ switch (type) {
+ case Pedro::XmppEvent::EVENT_STATUS:
+ {
+ break;
+ }
+ case Pedro::XmppEvent::EVENT_ERROR:
+ {
+ break;
+ }
+ case Pedro::XmppEvent::EVENT_CONNECTED:
+ {
+ break;
+ }
+ case Pedro::XmppEvent::EVENT_DISCONNECTED:
+ {
+ break;
+ }
+ case Pedro::XmppEvent::EVENT_MUC_MESSAGE:
+ case Pedro::XmppEvent::EVENT_MESSAGE:
+ {
+ Pedro::Element *root = event.getDOM();
+
+ if (root && root->getTagAttribute("wb", "xmlns") == Vars::INKBOARD_XMLNS)
+ processWhiteboardEvent(event);
+
+ break;
+ }
+ case Pedro::XmppEvent::EVENT_PRESENCE:
+ {
+ break;
+ }
+ case Pedro::XmppEvent::EVENT_MUC_JOIN:
+ {
+ break;
+ }
+ case Pedro::XmppEvent::EVENT_MUC_LEAVE:
+ {
+ break;
+ }
+ case Pedro::XmppEvent::EVENT_MUC_PRESENCE:
+ {
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+}
/**
* Handles all incoming messages from pedro within a valid namespace, CONNECT_REQUEST messages
else
{
- Message::Wrapper wrapper = domwrapper.c_str();
+ Message::Wrapper wrapper = static_cast< Message::Wrapper >("protocol");
InkboardDocument* doc = getInkboardSession(session);
- doc->processInkboardEvent(wrapper, event.getData());
+ doc->processInkboardEvent(wrapper, root->getFirstChild());
}
}
Dialog::DialogReply reply = static_cast< Dialog::DialogReply >(dialog.run());
-
- SPDocument* doc = makeInkboardDocument(g_quark_from_static_string("xml"), "svg:svg", State::WHITEBOARD_PEER, from);
+ SPDocument* doc = makeInkboardDocument(
+ g_quark_from_static_string("xml"), "svg:svg", State::WHITEBOARD_PEER, from);
InkboardDocument* inkdoc = dynamic_cast< InkboardDocument* >(doc->rdoc);
if(inkdoc == NULL) return true;