summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fa1b6db)
raw | patch | inline | side by side (parent: fa1b6db)
author | daleharvey <daleharvey@users.sourceforge.net> | |
Mon, 31 Jul 2006 02:19:44 +0000 (02:19 +0000) | ||
committer | daleharvey <daleharvey@users.sourceforge.net> | |
Mon, 31 Jul 2006 02:19:44 +0000 (02:19 +0000) |
diff --git a/src/jabber_whiteboard/inkboard-document.cpp b/src/jabber_whiteboard/inkboard-document.cpp
index e6bd4371396d6e7360a8781d906ade4ea60a0c9c..e2bba2fc02329766c7012d4a7bd3642d5003b967 100644 (file)
InkboardDocument::InkboardDocument(int code, State::SessionType type, Glib::ustring const& to) :
XML::SimpleNode(code), _type(type), _recipient(to)
{
- _initBindings();
+ _initBindings();
}
void
InkboardDocument::_initBindings()
{
- this->sm = &SessionManager::instance();
- _bindDocument(*this);
- _bindLogger(*(new XML::SimpleSession()));
+ this->_sm = &SessionManager::instance();
+ _bindDocument(*this);
+ _bindLogger(*(new XML::SimpleSession()));
}
void
InkboardDocument::setRecipient(Glib::ustring const& val)
{
- this->_recipient = val;
+ this->_recipient = val;
}
Glib::ustring
InkboardDocument::getRecipient() const
{
- return this->_recipient;
+ return this->_recipient;
+}
+
+void
+InkboardDocument::setSessionIdent(Glib::ustring const& val)
+{
+ this->_session = val;
+}
+
+Glib::ustring
+InkboardDocument::getSessionIdent() const
+{
+ return this->_session;
}
void
void
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());
+ g_log(NULL, G_LOG_LEVEL_DEBUG, "Processing Inkboard event: mtype=%s seqnum=%d data=%s\n", mtype, seqnum, data.c_str());
}
bool
@@ -73,15 +85,15 @@ InkboardDocument::sendProtocol(const Glib::ustring &destJid, Message::Wrapper wr
{
char *fmt=
"<message type='%s' from='%s' to='%s'>"
- "<wb xmlns='%s'>"
+ "<wb xmlns='%s' session='%s'>"
"<%s>"
"%s"
"</%s>"
"</wb>"
"</message>";
- if (!sm->getClient().write(
- fmt,_type,sm->getClient().getJid().c_str(),
- destJid.c_str(),wrapper,Vars::INKBOARD_XMLNS,message,wrapper))
+ if (!_sm->getClient().write(
+ fmt,_type,_sm->getClient().getJid().c_str(),destJid.c_str(),
+ Vars::INKBOARD_XMLNS,this->getSessionIdent().c_str(),wrapper,message,wrapper))
return false;
return true;
index 6e04fddac9ac8fe44b9a733b8069c5bc80e8dcfb..0b0e5baed2790b2dad9d6e59b41674a452b533e9 100644 (file)
void setRecipient(Glib::ustring const& val);
Glib::ustring getRecipient() const;
+ void setSessionIdent(Glib::ustring const& val);
+ Glib::ustring getSessionIdent() const;
+
void startSessionNegotiation();
void terminateSession();
void processInkboardEvent(Message::Wrapper mtype, unsigned int seqnum, Glib::ustring const& data);
void _initBindings();
- SessionManager *sm;
+ SessionManager *_sm;
State::SessionType _type;
+
+ Glib::ustring _session;
Glib::ustring _recipient;
KeyNodeTable _tracker;
index a64efbdb33efe821fd8be87c0695cadbd849b310..72bddcee4bb42c2335b994dd9eadd6d9e3078145 100644 (file)
#include <functional>
#include <algorithm>
#include <iostream>
+#include <time.h>
#include <gtkmm.h>
#include <glibmm/i18n.h>
#include "jabber_whiteboard/dialog/choose-desktop.h"
-#define INKBOARD_XMLNS "http://inkscape.org/inkboard"
-
namespace Inkscape {
namespace Whiteboard {
{
int type = event.getType();
- g_warning("recieved pedro");
-
switch (type) {
case Pedro::XmppEvent::EVENT_STATUS:
{
}
case Pedro::XmppEvent::EVENT_MESSAGE:
{
- printf("## SM message:%s\n", event.getFrom().c_str());
+ g_warning("## SM message:%s\n", event.getFrom().c_str());
Pedro::Element *root = event.getDOM();
+ g_warning("hey %s",root->getTagAttribute("wb", "xmlns"));
+
if (root)
{
- if (root->getTagAttribute("inkboard", "xmlns") ==
- INKBOARD_XMLNS)
+ if (root->getTagAttribute("inkboard", "xmlns") == Vars::INKBOARD_XMLNS)
{
_processInkboardEvent(event);
}
}
case Pedro::XmppEvent::EVENT_MUC_MESSAGE:
{
- printf("## SM MUC message:%s\n", event.getFrom().c_str());
+ g_warning("## SM MUC message:%s\n", event.getFrom().c_str());
Pedro::Element *root = event.getDOM();
+
+ g_warning("hey %s",root->getTagAttribute("wb", "xmlns"));
+
if (root)
{
- if (root->getTagAttribute("inkboard", "xmlns") ==
- INKBOARD_XMLNS)
+ if (root->getTagAttribute("inkboard", "xmlns") == Vars::INKBOARD_XMLNS)
{
_processInkboardEvent(event);
}
void
SessionManager::doShare(Glib::ustring const& to, State::SessionType type)
{
+ SPDocument* doc = makeInkboardDocument(g_quark_from_static_string("xml"), "svg:svg", type, to);
+ if(doc == NULL) return;
+
+ InkboardDocument* inkdoc = dynamic_cast< InkboardDocument* >(doc->rdoc);
+ if (inkdoc == NULL) return;
+
+
+ if(type == State::WHITEBOARD_PEER)
+ {
+ ChooseDesktop dialog;
+ int result = dialog.run();
+
+ if(result == Gtk::RESPONSE_OK)
+ {
+ SPDesktop *desktop = dialog.getDesktop();
+
+ if(desktop != NULL)
+ {
+ Inkscape::XML::Document *old_doc =
+ sp_desktop_document(desktop)->rdoc;
+ inkdoc->root()->mergeFrom(old_doc->root(),"id");
+ }
+ }
+ }else{ return; }
+
+ // Create a random session identifier
+ char * randomString = (char*) malloc (11);
+ for (int n=0; n<11; n++)
+ randomString[n]=rand()%26+'a';
+ randomString[11]='\0';
+
+ inkdoc->setSessionIdent(randomString);
+
+ _inkboards.push_back(Inkboard_record_type(randomString, inkdoc));
+
+ inkdoc->startSessionNegotiation();
+
+ /*
InkboardDocument* doc;
SPDesktop* dt;
}
}
}
+ */
}
/**
index 7e61c6b91957ad0bcd0afce006a72688815213e6..18f6239bbf03acb3dc4e27a1676770a17f3ca922 100644 (file)
}
private:
+
// types
typedef std::pair< Glib::ustring, InkboardDocument* > Inkboard_record_type;
typedef std::vector< Inkboard_record_type, GC::Alloc< Inkboard_record_type, GC::MANUAL > > Inkboards_type;
- typedef std::list< Glib::ustring > Pending_invitations_type;
+ typedef std::list< Glib::ustring > Pending_invitations_type;
- typedef std::pair< Glib::ustring, InvitationResponses > Invitation_response_type;
- typedef std::list< Invitation_response_type > Invitation_responses_type;
+ typedef std::pair< Glib::ustring, InvitationResponses > Invitation_response_type;
+ typedef std::list< Invitation_response_type > Invitation_responses_type;
- // functors
- struct CheckInvitationSender {
- public:
- CheckInvitationSender(Glib::ustring const& x) : x(x) { }
+ // functors
+ struct CheckInvitationSender {
+ public:
+ CheckInvitationSender(Glib::ustring const& x) : x(x) { }
~CheckInvitationSender() { }
bool operator()(SessionManager::Invitation_response_type const& y) const {
}
private:
Glib::ustring const& x;
- };
+ };
- // objects
+ // objects
Pedro::PedroGui gui;
SendMessageQueue sendMessageQueue;
ReceiveMessageQueue receiveMessageQueue;
- // members
+ // members
unsigned long sequenceNumber;
Inkboards_type _inkboards;
- Pending_invitations_type _pending_invitations;
- Invitation_responses_type _invitation_responses;
+ Pending_invitations_type _pending_invitations;
+ Invitation_responses_type _invitation_responses;
- sigc::connection _check_pending_invitations;
- sigc::connection _check_invitation_responses;
+ sigc::connection _check_pending_invitations;
+ sigc::connection _check_invitation_responses;
// methods
void _processInkboardEvent(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);
+ void _handleInvitationResponse(Glib::ustring const& from, InvitationResponses resp);
- // methods handled externally
- bool _checkInvitationQueue();
- bool _checkInvitationResponseQueue();
+ // methods handled externally
+ bool _checkInvitationQueue();
+ bool _checkInvitationResponseQueue();
};
} // namespace Whiteboard