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