Code

session can be initlialised with a current document which is copied into the inkboard...
authordaleharvey <daleharvey@users.sourceforge.net>
Tue, 25 Jul 2006 19:18:09 +0000 (19:18 +0000)
committerdaleharvey <daleharvey@users.sourceforge.net>
Tue, 25 Jul 2006 19:18:09 +0000 (19:18 +0000)
src/jabber_whiteboard/session-manager.cpp

index c8b2420e620223bedd231e621831d83692ec47a6..536bc8db47020bd3eaae0288777808eba8be9f4d 100644 (file)
@@ -218,30 +218,58 @@ SessionManager::processXmppEvent(const Pedro::XmppEvent &event)
 void
 SessionManager::doShare(Glib::ustring const& to, SessionType type)
 {
-    ChooseDesktop dialog;
-    int result = dialog.run();
+    InkboardDocument* doc;
+    SPDesktop* dt;
 
-    if(result == Gtk::RESPONSE_OK)
+    switch (type) 
     {
-        InkboardDocument* doc;
-        SPDesktop *desktop = dialog.getDesktop();
+        // Just create a new blank canvas for MUC sessions
+        case INKBOARD_MUC:
+
+            dt = createInkboardDesktop(to, type);
 
-        if(desktop == NULL)
-        {
-            SPDesktop* dt = createInkboardDesktop(to, type);
             if (dt != NULL) 
             {
-                 doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
+                doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
+
+                if (doc != NULL) 
+                {
+                    doc->startSessionNegotiation();
+                }
             }
-        }else 
-        {
-            doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(desktop)->rdoc);
-        }
+            break;
 
-        if (doc != NULL) 
-        {
-            doc->startSessionNegotiation();
-        }
+        // 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:
+
+            ChooseDesktop dialog;
+            int result = dialog.run();
+
+            if(result == Gtk::RESPONSE_OK)
+            {
+                SPDesktop *desktop = dialog.getDesktop();
+                dt = createInkboardDesktop(to, type);
+
+                if (dt != NULL) 
+                {
+                    doc = dynamic_cast< InkboardDocument* >(sp_desktop_document(dt)->rdoc);
+
+                    if (doc != NULL) 
+                    {
+                        if(desktop != NULL)
+                        {
+                            Inkscape::XML::Document *old_doc = sp_desktop_document(desktop)->rdoc;
+                            doc->root()->mergeFrom(old_doc->root(),"id");
+                        }
+
+                        doc->startSessionNegotiation();
+                    }
+                }
+            }
+        break;
     }
 }