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