1 /**
2 * Whiteboard session manager - invitation handling methods
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 #include <gtkmm.h>
14 #include <glibmm/i18n.h>
16 #include "util/ucompose.hpp"
18 #include "document.h"
19 #include "desktop-handles.h"
21 #include "jabber_whiteboard/inkboard-document.h"
22 #include "jabber_whiteboard/session-manager.h"
23 #include "jabber_whiteboard/invitation-confirm-dialog.h"
24 #include "jabber_whiteboard/defines.h"
26 namespace Inkscape {
28 namespace Whiteboard {
30 bool
31 SessionManager::_checkInvitationQueue()
32 {
33 int x, y;
34 Gdk::ModifierType mt;
35 Gdk::Display::get_default()->get_pointer(x, y, mt);
36 if (mt & GDK_BUTTON1_MASK) {
37 // The user is currently busy with an action. Defer invitation processing
38 // until the user is free.
39 return true;
40 }
42 if (_pending_invitations.size() > 0) {
43 // There's an invitation to process; process it.
44 Glib::ustring from = _pending_invitations.front();
46 Glib::ustring primary = "<span weight=\"bold\" size=\"larger\">" + String::ucompose(_("<b>%1</b> has invited you to a whiteboard session."), from) + "</span>\n\n";
47 primary += String::ucompose(_("Do you wish to accept <b>%1</b>'s whiteboard session invitation?"), from);
49 InvitationConfirmDialog dialog(primary);
51 dialog.add_button(_("Accept invitation"), ACCEPT_INVITATION);
52 dialog.add_button(_("Decline invitation"), DECLINE_INVITATION);
54 InvitationResponses resp = static_cast< InvitationResponses >(dialog.run());
56 switch (resp) {
57 case ACCEPT_INVITATION:
58 {
59 SPDesktop* dt = createInkboardDesktop(from, State::WHITEBOARD_PEER);
60 InkboardDocument* idoc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
61 send(from, Message::PROTOCOL, " ");
62 break;
63 }
64 case DECLINE_INVITATION:
65 {
66 break;
67 }
68 default:
69 send(from, Message::PROTOCOL, " ");
70 break;
71 }
73 _pending_invitations.pop_front();
74 }
76 return true;
77 }
80 bool
81 SessionManager::_checkInvitationResponseQueue()
82 {
83 int x, y;
84 Gdk::ModifierType mt;
85 Gdk::Display::get_default()->get_pointer(x, y, mt);
86 if (mt & GDK_BUTTON1_MASK) {
87 // The user is currently busy with an action. Defer invitation response processing
88 // until the user is free.
89 return true;
90 }
92 if (_invitation_responses.size() > 0) {
93 Invitation_response_type response = _invitation_responses.front();
95 switch (response.second) {
96 case ACCEPT_INVITATION:
97 {
98 break;
99 }
100 case DECLINE_INVITATION:
101 {
102 Glib::ustring primary = String::ucompose(_("<span weight=\"bold\" size=\"larger\">The user <b>%1</b> has refused your whiteboard invitation.</span>\n\n"), response.first);
104 // TRANSLATORS: %1 is the peer whom refused our invitation, %2 is our Jabber identity.
105 Glib::ustring secondary = String::ucompose(_("You are still connected to a Jabber server as <b>%2</b>, and may send an invitation to <b>%1</b> again, or you may send an invitation to a different user."), response.first, this->getClient().getJid());
107 Gtk::MessageDialog dialog(primary + secondary, true, Gtk::MESSAGE_INFO, Gtk::BUTTONS_CLOSE, false);
108 dialog.run();
109 terminateInkboardSession(response.first);
110 break;
111 }
112 case PEER_ALREADY_IN_SESSION:
113 break;
115 case UNSUPPORTED_PROTOCOL:
116 {
117 Glib::ustring primary = String::ucompose(_("<span weight=\"bold\" size=\"larger\">The user <b>%1</b> is using an incompatible version of Inkboard.</span>\n\n"), response.first);
119 // TRANSLATORS: %1 is the peer whom refused our invitation, %2 is our Jabber identity.
120 Glib::ustring secondary = String::ucompose(_("Inkscape cannot connect to <b>%1</b>.\n\nYou are still connected to a Jabber server as <b>%2</b>."), response.first, this->getClient().getJid());
122 Gtk::MessageDialog dialog(primary + secondary, true, Gtk::MESSAGE_INFO, Gtk::BUTTONS_CLOSE, false);
123 dialog.run();
124 terminateInkboardSession(response.first);
125 break;
126 }
127 default:
128 break;
129 }
131 _invitation_responses.pop_front();
132 }
134 return true;
135 }
137 }
139 }
141 /*
142 Local Variables:
143 mode:c++
144 c-file-style:"stroustrup"
145 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
146 indent-tabs-mode:nil
147 fill-column:99
148 End:
149 */
150 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :