summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6274659)
raw | patch | inline | side by side (parent: 6274659)
author | daleharvey <daleharvey@users.sourceforge.net> | |
Sun, 30 Jul 2006 13:29:30 +0000 (13:29 +0000) | ||
committer | daleharvey <daleharvey@users.sourceforge.net> | |
Sun, 30 Jul 2006 13:29:30 +0000 (13:29 +0000) |
index cef369056e4a6ccdbb89a163e3f0a55f21974742..05e4b9b7651056bd585f853bd6957adcffae690a 100644 (file)
extern SessionType WHITEBOARD_MUC;
extern SessionType WHITEBOARD_PEER;
+ typedef char const* SessionState;
}
// message types
diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp
index 9477399e5e5e2a0c237a720fb370115884c3ea0e..e53b7ec800b71b72856814535d087defd455c4cf 100644 (file)
namespace Whiteboard {
-InkboardDocument::InkboardDocument(int code, SessionType type, Glib::ustring const& to) :
+InkboardDocument::InkboardDocument(int code, State::SessionType type, Glib::ustring const& to) :
XML::SimpleNode(code), _type(type), _recipient(to)
{
_initBindings();
void
InkboardDocument::_initBindings()
{
+ this->sm = &SessionManager::instance();
_bindDocument(*this);
_bindLogger(*(new XML::SimpleSession()));
}
void
InkboardDocument::startSessionNegotiation()
{
- SessionManager& sm = SessionManager::instance();
- switch (_type) {
- case INKBOARD_MUC:
- sm.sendGroup(_recipient, Message::PROTOCOL, " ");
- break;
- case INKBOARD_PRIVATE:
- default:
- sm.send(_recipient, Message::PROTOCOL," ");
- break;
- }
+ send(_recipient, Message::PROTOCOL,Message::CONNECT_REQUEST);
}
void
InkboardDocument::send(const Glib::ustring &destJid, Message::Wrapper wrapper, Message::Message message)
{
char *fmt=
- "<message type='chat' from='%s' to='%s'>"
+ "<message type='%s' 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;
+ if (!sm->getClient().write(
+ fmt,_type,sm->getClient().getJid().c_str(),
+ destJid.c_str(),Vars::INKBOARD_XMLNS,message))
+ return false;
return true;
}
index aa726b1f912751f262d331ad3537bb2b5545c4b2..1249c42f89f74ceb3e98aff05faffd93c69042d8 100644 (file)
class InkboardDocument : public XML::SimpleNode, public XML::Document {
public:
- explicit InkboardDocument(int code, SessionType type, Glib::ustring const& to);
+ explicit InkboardDocument(int code, State::SessionType type, Glib::ustring const& to);
XML::NodeType type() const
{
return Inkscape::XML::DOCUMENT_NODE;
}
+ SessionManager *sm;
+
void setRecipient(Glib::ustring const& val);
Glib::ustring getRecipient() const;
+ void setSession();
+
void startSessionNegotiation();
void terminateSession();
void processInkboardEvent(Message::Wrapper mtype, unsigned int seqnum, Glib::ustring const& data);
void _initBindings();
- SessionType _type;
+ State::SessionType _type;
Glib::ustring _recipient;
KeyNodeTable _tracker;
diff --git a/src/jabber_whiteboard/invitation-handlers.cpp b/src/jabber_whiteboard/invitation-handlers.cpp
index 69d46f6d1c6400265e6677bf6d4afe162ad14d21..f304d095e04d9d976e9efb1e1c3855e799ad3a48 100644 (file)
switch (resp) {
case ACCEPT_INVITATION:
{
- SPDesktop* dt = createInkboardDesktop(from, INKBOARD_PRIVATE);
+ SPDesktop* dt = createInkboardDesktop(from, State::WHITEBOARD_PEER);
InkboardDocument* idoc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
send(from, Message::PROTOCOL, " ");
break;
diff --git a/src/jabber_whiteboard/new-inkboard-document.cpp b/src/jabber_whiteboard/new-inkboard-document.cpp
index e67a3c88e999d034b13bdf516a28db2779cbb0bf..3e47554bb44e8317922174965c77b9f3beabab32 100644 (file)
namespace Whiteboard {
SPDocument*
-makeInkboardDocument(int code, gchar const* rootname, SessionType type, Glib::ustring const& to)
+makeInkboardDocument(int code, gchar const* rootname, State::SessionType type, Glib::ustring const& to)
{
SPDocument* doc;
InkboardDocument* rdoc = new InkboardDocument(g_quark_from_static_string("xml"), type, to);
diff --git a/src/jabber_whiteboard/new-inkboard-document.h b/src/jabber_whiteboard/new-inkboard-document.h
index d55cfe73da2254747c24de33b0e433a78da7d7a9..ead55ef709a6382172adbb5e9b40f44ab47a3bbc 100644 (file)
namespace Whiteboard {
-SPDocument* makeInkboardDocument(int code, gchar const* rootname, SessionType type, Glib::ustring const& to);
+SPDocument* makeInkboardDocument(int code, gchar const* rootname, State::SessionType type, Glib::ustring const& to);
SPDesktop* makeInkboardDesktop(SPDocument* doc);
}
index 6aff31ccaf335d39948a6dc7d21f4b747db4f844..3b689b395ef393b1bafbf2c62b045a4025138a0b 100644 (file)
void PedroGui::doShare(const DOMString &jid)
{
- Inkscape::Whiteboard::SessionManager& sm = Inkscape::Whiteboard::SessionManager::instance();
- sm.doShare(jid, Inkscape::Whiteboard::INKBOARD_PRIVATE);
+ Inkscape::Whiteboard::SessionManager& sm =
+ Inkscape::Whiteboard::SessionManager::instance();
+ sm.doShare(jid, Inkscape::Whiteboard::State::WHITEBOARD_PEER);
// Inkscape::Whiteboard::SessionManager::instance().createInkboardDesktop(jid, Inkscape::Whiteboard::INKBOARD_PRIVATE);
}
void PedroGui::doGroupShare(const DOMString &groupJid)
{
- Inkscape::Whiteboard::SessionManager& sm = Inkscape::Whiteboard::SessionManager::instance();
- sm.doShare(groupJid, Inkscape::Whiteboard::INKBOARD_MUC);
+ Inkscape::Whiteboard::SessionManager& sm =
+ Inkscape::Whiteboard::SessionManager::instance();
+ sm.doShare(groupJid, Inkscape::Whiteboard::State::WHITEBOARD_MUC);
// Inkscape::Whiteboard::SessionManager::instance().createInkboardDesktop(groupJid, Inkscape::Whiteboard::INKBOARD_MUC);
}
index acb661cafd13d36afe0e2b5b0850cc3d003e44d4..daab6bcbe72c20146be99fdc1597d4c378de829f 100644 (file)
* \param type Type of the session; i.e. private message or group chat.
*/
void
-SessionManager::doShare(Glib::ustring const& to, SessionType type)
+SessionManager::doShare(Glib::ustring const& to, State::SessionType type)
{
InkboardDocument* doc;
SPDesktop* dt;
- switch (type)
+ // Just create a new blank canvas for MUC sessions
+ if(type == State::WHITEBOARD_MUC)
{
- // Just create a new blank canvas for MUC sessions
- case INKBOARD_MUC:
+ dt = createInkboardDesktop(to, type);
- dt = createInkboardDesktop(to, type);
+ if (dt != NULL)
+ {
+ doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
- if (dt != NULL)
+ if (doc != NULL)
{
- doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
-
- if (doc != NULL)
- {
- doc->startSessionNegotiation();
- }
+ doc->startSessionNegotiation();
}
- break;
+ }
+
// Let the user pick the document which to start a peer ro peer session
// with, or a blank one, then create a blank document, copy over the contents
// and initialise session
- case INKBOARD_PRIVATE:
- default:
+ } else if (type== State::WHITEBOARD_PEER) {
- ChooseDesktop dialog;
- int result = dialog.run();
+ ChooseDesktop dialog;
+ int result = dialog.run();
- if(result == Gtk::RESPONSE_OK)
+ if(result == Gtk::RESPONSE_OK)
+ {
+ SPDesktop *desktop = dialog.getDesktop();
+ dt = createInkboardDesktop(to, type);
+
+ if (dt != NULL)
{
- SPDesktop *desktop = dialog.getDesktop();
- dt = createInkboardDesktop(to, type);
+ doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
- if (dt != NULL)
+ if (doc != NULL)
{
- doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
-
- if (doc != NULL)
+ if(desktop != NULL)
{
- if(desktop != NULL)
- {
- Inkscape::XML::Document *old_doc = sp_desktop_document(desktop)->rdoc;
- doc->root()->mergeFrom(old_doc->root(),"id");
- }
-
- doc->startSessionNegotiation();
+ Inkscape::XML::Document *old_doc =
+ sp_desktop_document(desktop)->rdoc;
+ doc->root()->mergeFrom(old_doc->root(),"id");
}
+
+ doc->startSessionNegotiation();
}
}
- break;
+ }
}
}
* \return A pointer to the created desktop, or NULL if a new desktop could not be created.
*/
SPDesktop*
-SessionManager::createInkboardDesktop(Glib::ustring const& to, SessionType type)
+SessionManager::createInkboardDesktop(Glib::ustring const& to, State::SessionType type)
{
// Create document (sp_repr_document_new clone)
SPDocument* doc = makeInkboardDocument(g_quark_from_static_string("xml"), "svg:svg", type, to);
index 49909a39b4f9925716e2aa3ee39de390a509bd57..d6e600fe448c108301ca9e113e58d179a39ccb1f 100644 (file)
* \param to The recipient to which this desktop will be linked, specified as a JID.
* \param type Type of the session; i.e. private message or group chat.
*/
- virtual void doShare(Glib::ustring const& to, SessionType type);
+ virtual void doShare(Glib::ustring const& to, State::SessionType type);
/**
* Creates a new desktop with an InkboardDocument.
* \param type Type of the session; i.e. private message or group chat.
* \return A pointer to the created SPDesktop.
*/
- virtual SPDesktop* createInkboardDesktop(Glib::ustring const& to, SessionType type);
+ virtual SPDesktop* createInkboardDesktop(Glib::ustring const& to, State::SessionType type);
/**
* Terminates an Inkboard session to a given recipient. If the session to be