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