Ben Konrath 6243123
Index: library/eclipse.c
Ben Konrath 6243123
===================================================================
Ben Konrath 6243123
RCS file: /cvsroot/eclipse/platform-launcher/library/eclipse.c,v
Ben Konrath 6243123
retrieving revision 1.71
Ben Konrath 6243123
diff -u -r1.71 eclipse.c
Ben Konrath 6243123
--- library/eclipse.c	25 Apr 2006 14:31:50 -0000	1.71
Ben Konrath 6243123
+++ library/eclipse.c	30 Apr 2007 17:43:21 -0000
Ben Konrath 6243123
@@ -512,6 +513,8 @@
Ben Konrath 6243123
     /* Get the command to start the Java VM. */
Ben Konrath 6243123
     vmCommandArgs = getVMCommand( argc, argv );
Ben Konrath 6243123
 
Ben Konrath 6243123
+    addPlatformToTildeDotEclipse();
Ben Konrath 6243123
+
Ben Konrath 6243123
     /* While the Java VM should be restarted */
Ben Konrath 6243123
     vmCommand = vmCommandArgs;
Ben Konrath 6243123
     while (vmCommand != NULL)
Andrew Overholt f6a5ec5
Index: library/gtk/eclipseGtk.c
Andrew Overholt f6a5ec5
===================================================================
Andrew Overholt f6a5ec5
RCS file: /cvsroot/eclipse/platform-launcher/library/gtk/eclipseGtk.c,v
Andrew Overholt f6a5ec5
retrieving revision 1.27
Andrew Overholt f6a5ec5
diff -u -r1.27 eclipseGtk.c
Andrew Overholt f6a5ec5
--- library/gtk/eclipseGtk.c	27 Mar 2006 18:25:42 -0000	1.27
Ben Konrath 6243123
+++ library/gtk/eclipseGtk.c	30 Apr 2007 17:43:21 -0000
Ben Konrath 6243123
@@ -335,3 +335,95 @@
Andrew Overholt f6a5ec5
   	gtk_main_quit();
Andrew Overholt f6a5ec5
   	return FALSE;
Andrew Overholt f6a5ec5
 }
Andrew Overholt f6a5ec5
+
Andrew Overholt f6a5ec5
+/* Add the platform to ~/.eclipse/org.eclipse.platform_3.2.0/configuration/org.eclipse.update/platform.xml */
Andrew Overholt f6a5ec5
+void addPlatformToTildeDotEclipse()
Andrew Overholt f6a5ec5
+{
Andrew Overholt f6a5ec5
+	gchar *platform_xml, *touched;
Ben Konrath 6243123
+	gchar *rcp321_position;
Ben Konrath 6243123
+	gchar *platform_xml_contents;
Ben Konrath 6243123
+	GError *error = NULL;
Andrew Overholt f6a5ec5
+	
Andrew Overholt f6a5ec5
+	platform_xml = g_strconcat(g_get_home_dir(), "/.eclipse/org.eclipse.platform_3.2.0/configuration/org.eclipse.update/platform.xml", NULL);
Ben Konrath 6243123
+	touched = g_strconcat(g_get_home_dir(), "/.eclipse/.homedirmodified-fedora", NULL);
Andrew Overholt f6a5ec5
+	
Ben Konrath af1c56d
+
Ben Konrath af1c56d
+	if (!g_file_test(platform_xml, G_FILE_TEST_EXISTS))
Ben Konrath af1c56d
+	{
Ben Konrath af1c56d
+		/* If platform.xml doesn't exist, Eclipse has yet to be started.
Ben Konrath af1c56d
+	 	 * We don't have worry about doing anything now and in the future 
Ben Konrath af1c56d
+	 	 * so add the appropriate file to ~/.eclipse. */
Ben Konrath af1c56d
+	   	if (g_file_set_contents(touched, "\0", -1, &error) == FALSE)
Ben Konrath af1c56d
+		{
Ben Konrath 6243123
+			g_print("Error touching ~/.eclipse/.homedirmodified-fedora.");
Ben Konrath af1c56d
+			g_print(g_strconcat(error->message, "\n\0", NULL));
Ben Konrath af1c56d
+			g_free(error);
Ben Konrath af1c56d
+		}
Ben Konrath 6243123
+		g_free(platform_xml);
Ben Konrath 6243123
+		g_free(touched);
Andrew Overholt f6a5ec5
+		return;
Ben Konrath af1c56d
+		
Ben Konrath 6243123
+	} else {
Ben Konrath 6243123
+		/* platform_xml exists, workaround these two bugs:
Ben Konrath 6243123
+		 * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=238107
Ben Konrath 6243123
+		 * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=238109
Ben Konrath 6243123
+		 * 
Ben Konrath 6243123
+		 * remove the unwanted feature if its in platform.xml */
Ben Konrath 6243123
+
Ben Konrath 6243123
+		 if (g_file_get_contents(platform_xml, &platform_xml_contents, NULL, &error) == FALSE) {
Ben Konrath 6243123
+		 	g_print("Error reading platform.xml in ~/.eclipse.\
Ben Konrath 6243123
+					You should remove ~/.eclipse before restarting Eclipse:\0");
Ben Konrath 6243123
+			g_print(g_strconcat(error->message, "\n\0", NULL));
Ben Konrath 6243123
+        		g_free(error);
Ben Konrath 6243123
+       			g_free(platform_xml);
Ben Konrath 6243123
+	    		g_free(touched);
Ben Konrath 6243123
+        		return;
Ben Konrath 6243123
+		 }
Ben Konrath 6243123
+		 
Ben Konrath 6243123
+		 gchar *unwanted_feature = "<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>\0";
Ben Konrath 6243123
+		 rcp321_position = g_strrstr(platform_xml_contents, unwanted_feature);
Ben Konrath 6243123
+
Ben Konrath 6243123
+		 if (rcp321_position != NULL) 
Ben Konrath 6243123
+		 {
Ben Konrath 6243123
+		 	int i;
Ben Konrath 6243123
+		 	for (i = 0; i < strlen(unwanted_feature); i++) {
Ben Konrath 6243123
+				rcp321_position[i] = ' ';
Ben Konrath 6243123
+		 	}
Ben Konrath 6243123
+		 }
Ben Konrath 6243123
+		 
Ben Konrath 6243123
+		if (g_file_set_contents(platform_xml, platform_xml_contents, -1, &error) == FALSE)
Ben Konrath 6243123
+		{
Ben Konrath 6243123
+        		g_print("Error writing platform.xml in ~/.eclipse.\
Ben Konrath 6243123
+		         	You should remove ~/.eclipse before restarting Eclipse:\0");
Ben Konrath 6243123
+			g_print(g_strconcat(error->message, "\n\0", NULL));
Ben Konrath 6243123
+        		g_free(error);
Ben Konrath 6243123
+        		g_free(touched);
Ben Konrath 6243123
+        		g_free(platform_xml);
Ben Konrath 6243123
+        		g_free(platform_xml_contents);
Ben Konrath 6243123
+        		return;
Ben Konrath 6243123
+    		}
Ben Konrath 6243123
+    	
Ben Konrath 6243123
+        	g_free(platform_xml_contents);
Ben Konrath 6243123
+	}
Ben Konrath 6243123
+	
Ben Konrath 6243123
+	
Ben Konrath 6243123
+	if (g_file_test(touched, G_FILE_TEST_EXISTS)) {
Ben Konrath af1c56d
+		/* touched exists, we don't need to do anything */ 
Ben Konrath af1c56d
+		g_free(platform_xml);
Ben Konrath 6243123
+		g_free(touched);
Ben Konrath af1c56d
+		return;
Andrew Overholt f6a5ec5
+	}
Andrew Overholt f6a5ec5
+
Ben Konrath 6243123
+	/* At this point platform_xml exists and touched does not exist. */
Ben Konrath 6243123
+	if (g_remove (platform_xml) < 0) 
Andrew Overholt f6a5ec5
+	{
Ben Konrath 6243123
+       		g_print("Error writing platform.xml in ~/.eclipse.\
Andrew Overholt f6a5ec5
+		         You should remove ~/.eclipse before restarting Eclipse:\0");
Andrew Overholt f6a5ec5
+		g_print(g_strconcat(error->message, "\n\0", NULL));
Ben Konrath 6243123
+        	g_free(error);
Andrew Overholt f6a5ec5
+	}
Andrew Overholt f6a5ec5
+
Ben Konrath 6243123
+	g_free(platform_xml);
Ben Konrath 6243123
+	g_free(touched);
Ben Konrath 6243123
+	return;
Andrew Overholt f6a5ec5
+}