Andrew Overholt f521f4b
### Eclipse Workspace Patch 1.0
Andrew Overholt f521f4b
#P platform-launcher
Andrew Overholt f521f4b
Index: library/gtk/eclipseGtk.c
Andrew Overholt f521f4b
===================================================================
Andrew Overholt f521f4b
RCS file: /cvsroot/eclipse/platform-launcher/library/gtk/eclipseGtk.c,v
Andrew Overholt f521f4b
retrieving revision 1.27
Andrew Overholt f521f4b
diff -u -r1.27 eclipseGtk.c
Andrew Overholt f521f4b
--- library/gtk/eclipseGtk.c	27 Mar 2006 18:25:42 -0000	1.27
Andrew Overholt f521f4b
+++ library/gtk/eclipseGtk.c	28 Nov 2006 19:50:03 -0000
Andrew Overholt f521f4b
@@ -335,3 +335,73 @@
Andrew Overholt f521f4b
   	gtk_main_quit();
Andrew Overholt f521f4b
   	return FALSE;
Andrew Overholt f521f4b
 }
Andrew Overholt f521f4b
+
Andrew Overholt f521f4b
+/* Add the platform to ~/.eclipse/org.eclipse.platform_3.2.0/configuration/org.eclipse.update/platform.xml */
Andrew Overholt f521f4b
+void addPlatformToTildeDotEclipse()
Andrew Overholt f521f4b
+{
Andrew Overholt f521f4b
+	gchar *platform_xml, *touched;
Andrew Overholt f521f4b
+	gchar *config_end_position;
Andrew Overholt f521f4b
+    gsize old_length;
Andrew Overholt f521f4b
+    gchar *old_contents, *new_contents;
Andrew Overholt f521f4b
+    GError *error = NULL;
Andrew Overholt f521f4b
+	const gchar *site_element = "<site url=\"platform:/base/\" enabled=\"true\" updateable=\"true\" policy=\"USER-EXCLUDE\">\n<feature id=\"org.eclipse.rcp\" version=\"3.2.1.r321_v20060801-clWbqCmjexIWDqg\" url=\"features/org.eclipse.rcp_3.2.1.r321_v20060801-clWbqCmjexIWDqg/\">\n</feature>\n</site>\n\0";
Andrew Overholt f521f4b
+	
Andrew Overholt f521f4b
+	platform_xml = g_strconcat(g_get_home_dir(), "/.eclipse/org.eclipse.platform_3.2.0/configuration/org.eclipse.update/platform.xml", NULL);
Andrew Overholt f521f4b
+    touched = g_strconcat(g_get_home_dir(), "/.eclipse/.homedirmodified-fedora", NULL);
Andrew Overholt f521f4b
+	
Andrew Overholt f521f4b
+	/* If platform.xml doesn't exist, Eclipse has yet to be started 
Andrew Overholt f521f4b
+	 * so don't worry about doing anything.  Also, guard against doing 
Andrew Overholt f521f4b
+	 * this more than once with a dot file. */
Andrew Overholt f521f4b
+	if (!g_file_test(platform_xml, G_FILE_TEST_EXISTS) || \
Andrew Overholt f521f4b
+	     g_file_test(touched, G_FILE_TEST_EXISTS)) {
Andrew Overholt f521f4b
+	    g_free(platform_xml);
Andrew Overholt f521f4b
+	    g_free(touched);
Andrew Overholt f521f4b
+		return;
Andrew Overholt f521f4b
+	}
Andrew Overholt f521f4b
+	
Andrew Overholt f521f4b
+
Andrew Overholt f521f4b
+    if (g_file_get_contents (platform_xml,
Andrew Overholt f521f4b
+                             &old_contents, &old_length, &error) == FALSE)
Andrew Overholt f521f4b
+    {
Andrew Overholt f521f4b
+    	g_print("Error reading platform.xml in ~/.eclipse.\
Andrew Overholt f521f4b
+		         You should remove ~/.eclipse before restarting Eclipse:\0");
Andrew Overholt f521f4b
+		g_print(g_strconcat(error->message, "\n\0", NULL));
Andrew Overholt f521f4b
+        g_free(error);
Andrew Overholt f521f4b
+       	g_free(platform_xml);
Andrew Overholt f521f4b
+	    g_free(touched);
Andrew Overholt f521f4b
+        return;
Andrew Overholt f521f4b
+    }
Andrew Overholt f521f4b
+
Andrew Overholt f521f4b
+    config_end_position = g_strrstr_len(old_contents, old_length, "</config>");
Andrew Overholt f521f4b
+    *config_end_position = '\0';
Andrew Overholt f521f4b
+    new_contents = g_strconcat(old_contents, site_element, "</config>\n\0", NULL);
Andrew Overholt f521f4b
+
Andrew Overholt f521f4b
+    if (g_file_set_contents(platform_xml,
Andrew Overholt f521f4b
+                            new_contents, -1, &error) == FALSE)
Andrew Overholt f521f4b
+    {
Andrew Overholt f521f4b
+        g_print("Error writing platform.xml in ~/.eclipse.\
Andrew Overholt f521f4b
+		         You should remove ~/.eclipse before restarting Eclipse:\0");
Andrew Overholt f521f4b
+		g_print(g_strconcat(error->message, "\n\0", NULL));
Andrew Overholt f521f4b
+        g_free(error);
Andrew Overholt f521f4b
+        g_free(touched);
Andrew Overholt f521f4b
+        g_free(platform_xml);
Andrew Overholt f521f4b
+        g_free(new_contents);
Andrew Overholt f521f4b
+        g_free(old_contents);
Andrew Overholt f521f4b
+        return;
Andrew Overholt f521f4b
+    }
Andrew Overholt f521f4b
+
Andrew Overholt f521f4b
+	if (g_file_set_contents(touched, "\0", -1, &error) == FALSE)
Andrew Overholt f521f4b
+	{
Andrew Overholt f521f4b
+		g_print("Error touching ~/.eclipse/.homedirmodified-fedora.\
Andrew Overholt f521f4b
+		         You should remove ~/.eclipse before restarting Eclipse:\0");
Andrew Overholt f521f4b
+		g_print(g_strconcat(error->message, "\n\0", NULL));
Andrew Overholt f521f4b
+		g_free(error);
Andrew Overholt f521f4b
+	}
Andrew Overholt f521f4b
+
Andrew Overholt f521f4b
+    g_free(platform_xml);
Andrew Overholt f521f4b
+    g_free(touched);
Andrew Overholt f521f4b
+    g_free(new_contents);
Andrew Overholt f521f4b
+    g_free(old_contents);
Andrew Overholt f521f4b
+    
Andrew Overholt f521f4b
+    return;
Andrew Overholt f521f4b
+}
Andrew Overholt f521f4b
Index: library/eclipse.c
Andrew Overholt f521f4b
===================================================================
Andrew Overholt f521f4b
RCS file: /cvsroot/eclipse/platform-launcher/library/eclipse.c,v
Andrew Overholt f521f4b
retrieving revision 1.71
Andrew Overholt f521f4b
diff -u -r1.71 eclipse.c
Andrew Overholt f521f4b
--- library/eclipse.c	25 Apr 2006 14:31:50 -0000	1.71
Andrew Overholt f521f4b
+++ library/eclipse.c	28 Nov 2006 19:50:03 -0000
Andrew Overholt f521f4b
@@ -512,6 +512,8 @@
Andrew Overholt f521f4b
     /* Get the command to start the Java VM. */
Andrew Overholt f521f4b
     vmCommandArgs = getVMCommand( argc, argv );
Andrew Overholt f521f4b
 
Andrew Overholt f521f4b
+    addPlatformToTildeDotEclipse();
Andrew Overholt f521f4b
+
Andrew Overholt f521f4b
     /* While the Java VM should be restarted */
Andrew Overholt f521f4b
     vmCommand = vmCommandArgs;
Andrew Overholt f521f4b
     while (vmCommand != NULL)