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::setSessionIdent(Glib::ustring const& val)
54 {
55 this->_session = val;
56 }
58 Glib::ustring
59 InkboardDocument::getSessionIdent() const
60 {
61 return this->_session;
62 }
64 void
65 InkboardDocument::startSessionNegotiation()
66 {
67 sendProtocol(_recipient, Message::PROTOCOL,Message::CONNECT_REQUEST);
68 }
70 void
71 InkboardDocument::terminateSession()
72 {
74 }
76 void
77 InkboardDocument::processInkboardEvent(Message::Wrapper mtype, Glib::ustring const& data)
78 {
79 g_log(NULL, G_LOG_LEVEL_DEBUG, "Processing Inkboard event: mtype=%s data=%s\n",mtype,data.c_str());
80 }
82 bool
83 InkboardDocument::sendProtocol(const Glib::ustring &destJid, Message::Wrapper wrapper,
84 Message::Message message)
85 {
86 char *fmt=
87 "<message type='%s' from='%s' to='%s'>"
88 "<wb xmlns='%s' session='%s'>"
89 "<%s>"
90 "<%s />"
91 "</%s>"
92 "</wb>"
93 "<body> </body>"
94 "</message>";
95 if (!_sm->getClient().write(
96 fmt,_type,_sm->getClient().getJid().c_str(),destJid.c_str(),
97 Vars::INKBOARD_XMLNS,this->getSessionIdent().c_str(),wrapper,message,wrapper))
98 return false;
100 return true;
101 }
103 } // namespace Whiteboard
104 } // namespace Inkscape
107 /*
108 Local Variables:
109 mode:c++
110 c-file-style:"stroustrup"
111 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
112 indent-tabs-mode:nil
113 fill-column:99
114 End:
115 */
116 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :