Code

working on session establishment
[inkscape.git] / src / jabber_whiteboard / session-manager.cpp
index acb661cafd13d36afe0e2b5b0850cc3d003e44d4..daab6bcbe72c20146be99fdc1597d4c378de829f 100644 (file)
@@ -217,60 +217,57 @@ SessionManager::processXmppEvent(const Pedro::XmppEvent &event)
  * \param type Type of the session; i.e. private message or group chat.
  */
 void
-SessionManager::doShare(Glib::ustring const& to, SessionType type)
+SessionManager::doShare(Glib::ustring const& to, State::SessionType type)
 {
     InkboardDocument* doc;
     SPDesktop* dt;
 
-    switch (type) 
+    // Just create a new blank canvas for MUC sessions
+    if(type == State::WHITEBOARD_MUC) 
     {
-        // Just create a new blank canvas for MUC sessions
-        case INKBOARD_MUC:
+        dt = createInkboardDesktop(to, type);
 
-            dt = createInkboardDesktop(to, type);
+        if (dt != NULL) 
+        {
+            doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
 
-            if (dt != NULL) 
+            if (doc != NULL) 
             {
-                doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
-
-                if (doc != NULL) 
-                {
-                    doc->startSessionNegotiation();
-                }
+                doc->startSessionNegotiation();
             }
-            break;
+        }
+           
 
         // Let the user pick the document which to start a peer ro peer session
         // with, or a blank one, then create a blank document, copy over the contents
         // and initialise session
-        case INKBOARD_PRIVATE:
-        default:
+    } else if (type== State::WHITEBOARD_PEER) {
 
-            ChooseDesktop dialog;
-            int result = dialog.run();
+        ChooseDesktop dialog;
+        int result = dialog.run();
 
-            if(result == Gtk::RESPONSE_OK)
+        if(result == Gtk::RESPONSE_OK)
+        {
+            SPDesktop *desktop = dialog.getDesktop();
+            dt = createInkboardDesktop(to, type);
+
+            if (dt != NULL) 
             {
-                SPDesktop *desktop = dialog.getDesktop();
-                dt = createInkboardDesktop(to, type);
+                doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
 
-                if (dt != NULL) 
+                if (doc != NULL) 
                 {
-                    doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
-
-                    if (doc != NULL) 
+                    if(desktop != NULL)
                     {
-                        if(desktop != NULL)
-                        {
-                            Inkscape::XML::Document *old_doc = sp_desktop_document(desktop)->rdoc;
-                            doc->root()->mergeFrom(old_doc->root(),"id");
-                        }
-
-                        doc->startSessionNegotiation();
+                        Inkscape::XML::Document *old_doc =
+                            sp_desktop_document(desktop)->rdoc;
+                        doc->root()->mergeFrom(old_doc->root(),"id");
                     }
+
+                    doc->startSessionNegotiation();
                 }
             }
-        break;
+        }
     }
 }
 
@@ -282,7 +279,7 @@ SessionManager::doShare(Glib::ustring const& to, SessionType type)
  * \return A pointer to the created desktop, or NULL if a new desktop could not be created.
  */
 SPDesktop*
-SessionManager::createInkboardDesktop(Glib::ustring const& to, SessionType type)
+SessionManager::createInkboardDesktop(Glib::ustring const& to, State::SessionType type)
 {
 // Create document (sp_repr_document_new clone)
     SPDocument* doc = makeInkboardDocument(g_quark_from_static_string("xml"), "svg:svg", type, to);