From: dwyip Date: Fri, 10 Feb 2006 19:13:32 +0000 (+0000) Subject: Fix for bug #1352522 (Inkboard: problem when invited person invites you back). I... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=00932f84f4975c39da2358f3addc52dbc46d9e9c;p=inkscape.git Fix for bug #1352522 (Inkboard: problem when invited person invites you back). I'm not marking it as CLOSED because there's still some testing left to do, but I think this should nail it. --- diff --git a/src/jabber_whiteboard/connection-establishment.cpp b/src/jabber_whiteboard/connection-establishment.cpp index 9382227fb..eba75d9a4 100644 --- a/src/jabber_whiteboard/connection-establishment.cpp +++ b/src/jabber_whiteboard/connection-establishment.cpp @@ -121,8 +121,45 @@ SessionManager::receiveConnectRequest(gchar const* requesterJID) return; } + if (this->session_data->status[WAITING_FOR_INVITE_RESPONSE]) { + // Whoops. Someone tried to invite us while we were inviting someone else + // (maybe it was the someone we were trying to invite, maybe it was someone else). + // + // Our response is to reject the second request, as we can only handle one + // invitation at a time. Also, we notify the user (who is waiting for an invitation + // response) of the rejection event. + this->sendMessage(CONNECT_REQUEST_REFUSED_BY_PEER, 0, "", requesterJID, false); + + Glib::ustring primary = ""; + + // TRANSLATORS: This string is used to inform an Inkboard user that the following + // scenario has occurred: + // 1. Alice invites Bob to an Inkboard session. + // 2. While Alice's invitation is en route, Bob invites Alice to an Inkboard session. + // + // Or, we might have the following scenario: + // 1. Alice invites Bob to an Inkboard session. + // 2. While Alice is waiting for Bob's response, Carol sends Alice an invitation. + // + // In the current implementation, we can only handle one invitation at a time, + // so we reject all others. + // + // This is a fix for bug #1352522. Probably not the friendliest, but it's about + // the best we can do without changing the protocol. + primary += _("An invitation conflict has occurred."); + primary += "\n\n"; + + // TRANSLATORS: %1 is the JID of the user who sent us the invitation request. + primary += String::ucompose(_("The Jabber user %1 attempted to invite you to a whiteboard session while you were waiting on an invitation response.\n\nThe invitation from %1 has been rejected."), requesterJID); + + Gtk::MessageDialog dialog(primary, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, false); + dialog.run(); + return; + } + if (this->session_data->status[IN_WHITEBOARD]) { this->sendMessage(ALREADY_IN_SESSION, 0, "", requesterJID, false); + return; } // Check to see if the user made any modifications to this document. If so, diff --git a/src/jabber_whiteboard/message-contexts.cpp b/src/jabber_whiteboard/message-contexts.cpp index 1b5ea12fd..70983bad0 100644 --- a/src/jabber_whiteboard/message-contexts.cpp +++ b/src/jabber_whiteboard/message-contexts.cpp @@ -68,6 +68,11 @@ initialize_received_message_contexts(MessageContextMap& mcm) // Message: CONNECT_REQUEST_USER std::bitset< NUM_FLAGS > m5; m5.set(LOGGED_IN); + + // We should still _accept_ CONNECT_REQUEST_USER messages even if we're already + // waiting for a response. It is up to the higher-level handler (i.e. the connection + // request handler) to properly handle it. + m5.set(WAITING_FOR_INVITE_RESPONSE); mcm[CONNECT_REQUEST_USER] = m5; // Message: CONNECT_REQUEST_RESPONSE_USER diff --git a/src/jabber_whiteboard/message-handler.cpp b/src/jabber_whiteboard/message-handler.cpp index cdcef74b8..031ed7348 100644 --- a/src/jabber_whiteboard/message-handler.cpp +++ b/src/jabber_whiteboard/message-handler.cpp @@ -86,11 +86,10 @@ MessageHandler::_hasValidReceiveContext(LmMessage* message) // TODO: remove this debug block if ((status & recvcontext).to_ulong() < status.to_ulong()) { - g_warning("Received message in incorrect context (current is not a subset of required); discarding message."); + g_warning("Received message in incorrect context; discarding message."); std::string s2 = recvcontext.to_string< char, std::char_traits< char >, std::allocator< char > >(); - g_warning("current context=%s required context=%s (msgtype %s)", s1.c_str(), s2.c_str(), MessageHandler::ink_type_to_string(type)); }