diff netinstall/desktop.cc @ 657:ce0b3f2eff35

[xemacs-hg @ 2001-09-09 04:37:41 by andyp] DDE, netinstall and cygwin file fixes
author andyp
date Sun, 09 Sep 2001 04:37:48 +0000
parents 0784d089fdc9
children 146d342ff859
line wrap: on
line diff
--- a/netinstall/desktop.cc	Sat Sep 08 09:12:09 2001 +0000
+++ b/netinstall/desktop.cc	Sun Sep 09 04:37:48 2001 +0000
@@ -40,6 +40,7 @@
 #include "reginfo.h"
 #include "regedit.h"
 #include "port.h"
+#include "log.h"
 
 extern "C" {
   void make_link_2 (char *exepath, char *args, char *icon, char *lname);
@@ -123,7 +124,19 @@
 }
 
 static void
-start_menu (char *title, char *target)
+remove_link (char *linkpath, char* title)
+{
+  char *fname = concat (linkpath, "/", title, ".lnk", 0);
+
+  if (_access (fname, 0) != 0)
+    return; /* doesn't exist */
+
+  msg ("remove_link %s, %s, %s\n", fname, title);
+  _unlink (fname);
+}
+
+static void
+start_menu (char *title, char *target, int remove)
 {
   char path[_MAX_PATH];
   LPITEMIDLIST id;
@@ -141,11 +154,14 @@
 // end of Win95 addition
   strcat (path, "/");
   strcat (path, XEMACS_INFO_XEMACS_ORG_REGISTRY_NAME);
-  make_link (path, title, target);
+  if (remove == 0)
+    make_link (path, title, target);
+  else
+    remove_link (path, title);
 }
 
 static void
-desktop_icon (char *title, char *target)
+desktop_icon (char *title, char *target, int remove)
 {
   char path[_MAX_PATH];
   LPITEMIDLIST id;
@@ -162,59 +178,10 @@
      msg("Desktop directory for deskop link changed to: %s",path);
   }
 // end of Win95 addition
-  make_link (path, title, target);
-}
-
-static int
-uexists (char *path)
-{
-  char *f = concat (root_dir, path, 0);
-  int a = _access (f, 0);
-  free (f);
-  if (a == 0)
-    return 1;
-  return 0;
-}
-
-static void
-make_passwd_group ()
-{
-  if (verinfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
-    {
-      int i;
-
-      LOOP_PACKAGES
-	{
-	  if (!strcmp (package[i].name, "cygwin"))
-	    {
-	      /* mkpasswd and mkgroup are not working on 9x/ME up to 1.1.5-4 */
-	      char *border_version = canonicalize_version ("1.1.5-4");
-	      char *inst_version = canonicalize_version (pi.version);
-
-	      if (strcmp (inst_version, border_version) <= 0)
-		return;
-
-	      break;
-	    }
-	}
-    }
-
-  if (uexists ("/etc/passwd") && uexists ("/etc/group"))
-    return;
-
-  char *fname = concat (root_dir, "/etc/postinstall/passwd-grp.bat", 0);
-  mkdir_p (0, fname);
-
-  FILE *p = fopen (fname, "wb");
-  if (!p)
-    return;
-
-  if (!uexists ("/etc/passwd"))
-    fprintf (p, "bin\\mkpasswd -l > etc\\passwd\n");
-  if (!uexists ("/etc/group"))
-    fprintf (p, "bin\\mkgroup -l > etc\\group\n");
-
-  fclose (p);
+  if (remove == 0)
+    make_link (path, title, target);
+  else
+    remove_link (path, title);
 }
 
 static void
@@ -240,46 +207,102 @@
     }
 }
 
+void
+remove_desktop_setup()
+{
+  start_menu ("XEmacs", 0, 1);
+  desktop_icon ("XEmacs", 0, 1);
+
+  if (xemacs_package != 0)
+    {
+      int issystem = (root_scope == IDC_ROOT_SYSTEM ? 1 : 0);
+#define FROB(exe)	  remove_app_path ((exe), \
+			issystem)
+      /*      FROB (find_xemacs_exe_name ()); */
+      FROB ("runemacs.exe");
+      FROB ("xemacs.exe");
+#undef FROB
+    }
+}
+
 static void
 do_desktop_setup()
 {
   save_icon ();
 
   if (root_menu && batname) {
-    start_menu ("XEmacs", batname);
+    start_menu ("XEmacs", batname, 0);
   }
 
   if (root_desktop && batname) {
-    desktop_icon ("XEmacs", batname);
+    desktop_icon ("XEmacs", batname, 0);
   }
 
   // set regkeys for the application
   if (xemacs_package != 0)
     {
       int issystem = (root_scope == IDC_ROOT_SYSTEM ? 1 : 0);
-      if (xemacs_package->type == TY_NATIVE)
+      if (xemacs_package->type == TY_NATIVE
+	  || xemacs_package->type == TY_CYGWIN)
 	{
+	  if (xemacs_package->type == TY_NATIVE)
+	    {
 #define FROB(exe)	  set_app_path ((exe), \
 			find_xemacs_exe_path (), \
 			issystem)
-	  FROB (find_xemacs_exe_name ());
-	  FROB ("runemacs.exe");
-	  FROB ("xemacs.exe");
+	      FROB (find_xemacs_exe_name ());
+	      FROB ("runemacs.exe");
+	      FROB ("xemacs.exe");
 #undef FROB
-	}
-      else if (xemacs_package->type == TY_CYGWIN)
-	{
-	  int junk;
-	  char* root = find_cygwin_root (&junk);
+	    }
+	  else if (xemacs_package->type == TY_CYGWIN)
+	    {
+	      int junk;
+	      char* root = find_cygwin_root (&junk);
 #define FROB(exe)	set_app_path ((exe), \
 			concat (find_xemacs_exe_path (), ";", \
 				root, "\\bin;", \
 				root, "\\usr\\bin", 0), \
 			issystem)
-	  FROB (find_xemacs_exe_name ());
-	  FROB ("runemacs.exe");
-	  FROB ("xemacs.exe");
+	      FROB (find_xemacs_exe_name ());
+	      FROB ("runemacs.exe");
+	      FROB ("xemacs.exe");
 #undef FROB
+	    }
+	  set_install_path (find_xemacs_exe_path(), issystem);
+	}
+      // Register file types
+      if (batname)
+	{
+	  if (reg_java)
+	    {
+	      log (0, "Registering .java files");
+	      setup_explorer ("java", "Java Source file", batname);
+	      setup_explorer ("jav", "Java Source file", batname);
+	    }
+	  if (reg_cpp)
+	    {
+	      log (0, "Registering .cpp files");
+	      setup_explorer ("cpp", "C++ Source file", batname);
+	      setup_explorer ("cc", "C++ Source file", batname);
+	      setup_explorer ("hh", "C++ Header file", batname);
+	    }
+	  if (reg_c)
+	    {
+	      log (0, "Registering .c files");
+	      setup_explorer ("c", "C Source file", batname);
+	      setup_explorer ("h", "C Header file", batname);
+	    }
+	  if (reg_elisp)
+	    {
+	      log (0, "Registering .el files");
+	      setup_explorer ("el", "E-Lisp Source file", batname);
+	    }
+	  if (reg_txt)
+	    {
+	      log (0, "Registering .txt files");
+	      setup_explorer ("txt", "Text file", batname);
+	    }
 	}
     }
 }
@@ -287,6 +310,12 @@
 static int da[] = { IDC_ROOT_DESKTOP, 0 };
 static int ma[] = { IDC_ROOT_MENU, 0 };
 
+static int ct[] = { IDC_C_TYPE, 0 };
+static int javat[] = { IDC_JAVA_TYPE, 0 };
+static int cppt[] = { IDC_CPP_TYPE, 0 };
+static int elispt[] = { IDC_ELISP_TYPE, 0 };
+static int txtt[] = { IDC_TXT_TYPE, 0 };
+
 static void
 check_if_enable_next (HWND h)
 {
@@ -298,6 +327,11 @@
 {
   rbset (h, da, root_desktop);
   rbset (h, ma, root_menu);
+  rbset (h, ct, reg_c);
+  rbset (h, javat, reg_java);
+  rbset (h, cppt, reg_cpp);
+  rbset (h, elispt, reg_elisp);
+  rbset (h, txtt, reg_txt);
   check_if_enable_next (h);
 }
 
@@ -366,6 +400,11 @@
 {
   root_desktop= rbget (h, da);
   root_menu = rbget (h, ma);
+  reg_c = rbget (h, ct);
+  reg_java = rbget (h, javat);
+  reg_cpp = rbget (h, cppt);
+  reg_elisp = rbget (h, elispt);
+  reg_txt = rbget (h, txtt);
 }
 
 static BOOL
@@ -428,11 +467,21 @@
 			0);
       root_desktop = check_desktop ("XEmacs", batname);
       root_menu = check_startmenu ("XEmacs", batname);
+      reg_c = IDC_C_TYPE;
+      reg_cpp = IDC_CPP_TYPE;
+      reg_java = IDC_JAVA_TYPE;
+      reg_elisp = IDC_ELISP_TYPE;
+      reg_txt = IDC_TXT_TYPE;
     }
   else
     {
       root_desktop = 0;
       root_menu = 0;
+      reg_c = 0;
+      reg_cpp = 0;
+      reg_java = 0;
+      reg_elisp = 0;
+      reg_txt = 0;
     }
   
   int rv = 0;