Code

e2bba2fc02329766c7012d4a7bd3642d5003b967
[inkscape.git] / src / jabber_whiteboard / inkboard-document.cpp
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, unsigned int seqnum, Glib::ustring const& data)
78 {
79     g_log(NULL, G_LOG_LEVEL_DEBUG, "Processing Inkboard event: mtype=%s seqnum=%d data=%s\n", mtype, seqnum, 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         "</message>";
94     if (!_sm->getClient().write(
95         fmt,_type,_sm->getClient().getJid().c_str(),destJid.c_str(),
96         Vars::INKBOARD_XMLNS,this->getSessionIdent().c_str(),wrapper,message,wrapper))
97         return false;
99     return true;
102 } // namespace Whiteboard
103 } // namespace Inkscape
106 /*
107   Local Variables:
108   mode:c++
109   c-file-style:"stroustrup"
110   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
111   indent-tabs-mode:nil
112   fill-column:99
113   End:
114 */
115 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :