1 /**
2 * Whiteboard session manager
3 *
4 * Authors:
5 * David Yip <yipdw@rose-hulman.edu>
6 * Bob Jamison (Pedro port)
7 *
8 * Copyright (c) 2005 Authors
9 *
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
13 #ifndef __INKSCAPE_WHITEBOARD_SESSION_MANAGER_H__
14 #define __INKSCAPE_WHITEBOARD_SESSION_MANAGER_H__
16 #include <glibmm.h>
18 #include <list>
19 #include <bitset>
21 #include "desktop.h"
23 #include "jabber_whiteboard/pedrogui.h"
24 #include "jabber_whiteboard/message-queue.h"
25 #include "jabber_whiteboard/defines.h"
27 #include "gc-alloc.h"
29 class SPDocument;
30 class SPDesktop;
33 namespace Inkscape {
35 namespace Whiteboard {
37 class InkboardDocument;
39 typedef Glib::ustring from,sessionId;
40 typedef std::pair< Glib::ustring, InkboardDocument* > WhiteboardRecord;
41 typedef std::vector< WhiteboardRecord, GC::Alloc< WhiteboardRecord, GC::MANUAL > > WhiteboardList;
43 typedef std::pair< from, sessionId > Invitation;
44 typedef std::list< Invitation > InvitationList;
46 class SessionManager : public Pedro::XmppEventListener
47 {
49 public:
51 SessionManager();
53 virtual ~SessionManager();
55 static void showClient();
56 static SessionManager& instance();
58 virtual Pedro::XmppClient &getClient()
59 { return gui.client; }
61 /**
62 * Handles all incoming XMPP events associated with this document
63 * apart from CONNECT_REQUEST, which is handled in SessionManager
64 */
65 virtual void processXmppEvent(const Pedro::XmppEvent &event);
68 /**
69 * Initiates a shared session with a user or conference room.
70 *
71 * \param to The recipient to which this desktop will be linked, specified as a JID.
72 * \param type Type of the session; i.e. private message or group chat.
73 */
74 virtual void initialiseSession(Glib::ustring const& to, State::SessionType type);
76 /**
77 * Terminates an Inkboard session to a given recipient. If the session to be
78 * terminated does not exist, does nothing.
79 *
80 * \param sessionId The session identifier to be terminated.
81 */
82 virtual void terminateSession(Glib::ustring const& sessionId);
84 /**
85 * Adds a session to whiteboard
86 *
87 * \param sessionId The session identifier to be terminated.
88 */
89 virtual void addSession(WhiteboardRecord whiteboard);
91 /**
92 * Locates an Inkboard session by recipient JID.
93 *
94 * \param to The recipient JID identifying the session to be located.
95 * \return A pointer to the InkboardDocument associated with the Inkboard session,
96 * or NULL if no such session exists.
97 */
98 InkboardDocument* getInkboardSession(Glib::ustring const& to);
101 void operator=(XmppEventListener const& /*other*/)
102 {}
104 private:
106 Pedro::PedroGui gui;
107 WhiteboardList whiteboards;
108 InvitationList invitations;
109 sigc::connection CheckPendingInvitations;
111 void processWhiteboardEvent(Pedro::XmppEvent const& event);
113 void handleIncomingInvitation(Invitation invitation);
115 bool checkInvitationQueue();
117 char* createSessionId(int size);
119 };
121 SPDocument* makeInkboardDocument(int code, gchar const* rootname,
122 State::SessionType type, Glib::ustring const& to);
124 SPDesktop* makeInkboardDesktop(SPDocument* doc);
126 } // namespace Whiteboard
128 } // namespace Inkscape
130 #endif /* __SESSION_MANAGER_H__ */
132 /*
133 Local Variables:
134 mode:c++
135 c-file-style:"stroustrup"
136 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
137 indent-tabs-mode:nil
138 fill-column:99
139 End:
140 */
141 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :