1 /**
2 * Inkscape::Whiteboard::InkboardDocument - Inkboard document implementation
3 *
4 * Authors:
5 * David Yip <yipdw@rose-hulman.edu>
6 *
7 * Copyright (c) 2005 Authors
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #include <glib.h>
13 #include <glibmm.h>
15 #include "jabber_whiteboard/inkboard-document.h"
17 #include "xml/simple-session.h"
18 #include "jabber_whiteboard/inkboard-session.h"
19 #include "jabber_whiteboard/defines.h"
20 #include "jabber_whiteboard/session-manager.h"
22 namespace Inkscape {
24 namespace Whiteboard {
26 InkboardDocument::InkboardDocument(int code, State::SessionType type, Glib::ustring const& to) :
27 XML::SimpleNode(code), _type(type), _recipient(to)
28 {
29 _initBindings();
30 }
32 void
33 InkboardDocument::_initBindings()
34 {
35 this->sm = &SessionManager::instance();
36 _bindDocument(*this);
37 _bindLogger(*(new XML::SimpleSession()));
38 }
40 void
41 InkboardDocument::setRecipient(Glib::ustring const& val)
42 {
43 this->_recipient = val;
44 }
46 Glib::ustring
47 InkboardDocument::getRecipient() const
48 {
49 return this->_recipient;
50 }
52 void
53 InkboardDocument::startSessionNegotiation()
54 {
55 send(_recipient, Message::PROTOCOL,Message::CONNECT_REQUEST);
56 }
58 void
59 InkboardDocument::terminateSession()
60 {
62 }
64 void
65 InkboardDocument::processInkboardEvent(Message::Wrapper mtype, unsigned int seqnum, Glib::ustring const& data)
66 {
67 g_log(NULL, G_LOG_LEVEL_DEBUG, "Processing Inkboard event: mtype=%d seqnum=%d data=%s\n", mtype, seqnum, data.c_str());
68 }
70 bool
71 InkboardDocument::send(const Glib::ustring &destJid, Message::Wrapper wrapper, Message::Message message)
72 {
73 char *fmt=
74 "<message type='%s' from='%s' to='%s'>"
75 "<wb xmlns='%s'>"
76 "<protocol>"
77 "%s"
78 "</protocol>"
79 "</wb>"
80 "</message>";
81 if (!sm->getClient().write(
82 fmt,_type,sm->getClient().getJid().c_str(),
83 destJid.c_str(),Vars::INKBOARD_XMLNS,message))
84 return false;
86 return true;
87 }
89 } // namespace Whiteboard
90 } // namespace Inkscape
93 /*
94 Local Variables:
95 mode:c++
96 c-file-style:"stroustrup"
97 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
98 indent-tabs-mode:nil
99 fill-column:99
100 End:
101 */
102 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :