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"
26 #include "jabber_whiteboard/inkboard-session.h"
28 #include "gc-alloc.h"
30 class SPDocument;
31 class SPDesktop;
34 namespace Inkscape {
36 namespace Whiteboard {
38 class InkboardDocument;
40 typedef Glib::ustring from,sessionId;
41 typedef std::pair< Glib::ustring, InkboardDocument* > WhiteboardRecord;
42 typedef std::vector< WhiteboardRecord, GC::Alloc< WhiteboardRecord, GC::MANUAL > > WhiteboardList;
44 typedef std::pair< from, sessionId > Invitation;
45 typedef std::list< Invitation > InvitationList;
47 class SessionManager : public Pedro::XmppEventListener
48 {
50 public:
52 SessionManager();
54 virtual ~SessionManager();
57 static void showClient();
58 static SessionManager& instance();
60 virtual Pedro::XmppClient &getClient()
61 { return gui.client; }
63 /**
64 * Handles all incoming XMPP events associated with this document
65 * apart from CONNECT_REQUEST, which is handled in SessionManager
66 */
67 virtual void processXmppEvent(const Pedro::XmppEvent &event);
70 /**
71 * Initiates a shared session with a user or conference room.
72 *
73 * \param to The recipient to which this desktop will be linked, specified as a JID.
74 * \param type Type of the session; i.e. private message or group chat.
75 */
76 virtual void initialiseSession(Glib::ustring const& to, State::SessionType type);
78 /**
79 * Terminates an Inkboard session to a given recipient. If the session to be
80 * terminated does not exist, does nothing.
81 *
82 * \param sessionId The session identifier to be terminated.
83 */
84 virtual void terminateSession(Glib::ustring const& sessionId);
86 /**
87 * Adds a session to whiteboard
88 *
89 * \param sessionId The session identifier to be terminated.
90 */
91 virtual void addSession(WhiteboardRecord whiteboard);
93 /**
94 * Locates an Inkboard session by recipient JID.
95 *
96 * \param to The recipient JID identifying the session to be located.
97 * \return A pointer to the InkboardDocument associated with the Inkboard session,
98 * or NULL if no such session exists.
99 */
100 InkboardDocument* getInkboardSession(Glib::ustring const& to);
103 void operator=(XmppEventListener const& other) {}
105 private:
107 Pedro::PedroGui gui;
108 WhiteboardList whiteboards;
109 InvitationList invitations;
110 sigc::connection CheckPendingInvitations;
112 void processWhiteboardEvent(Pedro::XmppEvent const& event);
114 void handleIncomingInvitation(Invitation invitation);
116 bool checkInvitationQueue();
118 char* createSessionId(int size);
120 };
122 SPDocument* makeInkboardDocument(int code, gchar const* rootname, State::SessionType type, Glib::ustring const& to);
123 SPDesktop* makeInkboardDesktop(SPDocument* doc);
125 } // namespace Whiteboard
127 } // namespace Inkscape
129 #endif /* __SESSION_MANAGER_H__ */
131 /*
132 Local Variables:
133 mode:c++
134 c-file-style:"stroustrup"
135 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
136 indent-tabs-mode:nil
137 fill-column:99
138 End:
139 */
140 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :