comparison 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
comparison
equal deleted inserted replaced
656:4035041996d8 657:ce0b3f2eff35
38 #include "dialog.h" 38 #include "dialog.h"
39 #include "version.h" 39 #include "version.h"
40 #include "reginfo.h" 40 #include "reginfo.h"
41 #include "regedit.h" 41 #include "regedit.h"
42 #include "port.h" 42 #include "port.h"
43 #include "log.h"
43 44
44 extern "C" { 45 extern "C" {
45 void make_link_2 (char *exepath, char *args, char *icon, char *lname); 46 void make_link_2 (char *exepath, char *args, char *icon, char *lname);
46 }; 47 };
47 48
121 else 122 else
122 return strdup ("xemacs.exe"); 123 return strdup ("xemacs.exe");
123 } 124 }
124 125
125 static void 126 static void
126 start_menu (char *title, char *target) 127 remove_link (char *linkpath, char* title)
128 {
129 char *fname = concat (linkpath, "/", title, ".lnk", 0);
130
131 if (_access (fname, 0) != 0)
132 return; /* doesn't exist */
133
134 msg ("remove_link %s, %s, %s\n", fname, title);
135 _unlink (fname);
136 }
137
138 static void
139 start_menu (char *title, char *target, int remove)
127 { 140 {
128 char path[_MAX_PATH]; 141 char path[_MAX_PATH];
129 LPITEMIDLIST id; 142 LPITEMIDLIST id;
130 int issystem = (root_scope == IDC_ROOT_SYSTEM) ? 1 : 0; 143 int issystem = (root_scope == IDC_ROOT_SYSTEM) ? 1 : 0;
131 SHGetSpecialFolderLocation (NULL, issystem ? CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS, &id); 144 SHGetSpecialFolderLocation (NULL, issystem ? CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS, &id);
139 msg("Program directory for program link changed to: %s",path); 152 msg("Program directory for program link changed to: %s",path);
140 } 153 }
141 // end of Win95 addition 154 // end of Win95 addition
142 strcat (path, "/"); 155 strcat (path, "/");
143 strcat (path, XEMACS_INFO_XEMACS_ORG_REGISTRY_NAME); 156 strcat (path, XEMACS_INFO_XEMACS_ORG_REGISTRY_NAME);
144 make_link (path, title, target); 157 if (remove == 0)
145 } 158 make_link (path, title, target);
146 159 else
147 static void 160 remove_link (path, title);
148 desktop_icon (char *title, char *target) 161 }
162
163 static void
164 desktop_icon (char *title, char *target, int remove)
149 { 165 {
150 char path[_MAX_PATH]; 166 char path[_MAX_PATH];
151 LPITEMIDLIST id; 167 LPITEMIDLIST id;
152 int issystem = (root_scope == IDC_ROOT_SYSTEM) ? 1 : 0; 168 int issystem = (root_scope == IDC_ROOT_SYSTEM) ? 1 : 0;
153 //SHGetSpecialFolderLocation (NULL, issystem ? CSIDL_DESKTOP : CSIDL_COMMON_DESKTOPDIRECTORY, &id); 169 //SHGetSpecialFolderLocation (NULL, issystem ? CSIDL_DESKTOP : CSIDL_COMMON_DESKTOPDIRECTORY, &id);
160 SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id); 176 SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id);
161 SHGetPathFromIDList (id, path); 177 SHGetPathFromIDList (id, path);
162 msg("Desktop directory for deskop link changed to: %s",path); 178 msg("Desktop directory for deskop link changed to: %s",path);
163 } 179 }
164 // end of Win95 addition 180 // end of Win95 addition
165 make_link (path, title, target); 181 if (remove == 0)
166 } 182 make_link (path, title, target);
167 183 else
168 static int 184 remove_link (path, title);
169 uexists (char *path)
170 {
171 char *f = concat (root_dir, path, 0);
172 int a = _access (f, 0);
173 free (f);
174 if (a == 0)
175 return 1;
176 return 0;
177 }
178
179 static void
180 make_passwd_group ()
181 {
182 if (verinfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
183 {
184 int i;
185
186 LOOP_PACKAGES
187 {
188 if (!strcmp (package[i].name, "cygwin"))
189 {
190 /* mkpasswd and mkgroup are not working on 9x/ME up to 1.1.5-4 */
191 char *border_version = canonicalize_version ("1.1.5-4");
192 char *inst_version = canonicalize_version (pi.version);
193
194 if (strcmp (inst_version, border_version) <= 0)
195 return;
196
197 break;
198 }
199 }
200 }
201
202 if (uexists ("/etc/passwd") && uexists ("/etc/group"))
203 return;
204
205 char *fname = concat (root_dir, "/etc/postinstall/passwd-grp.bat", 0);
206 mkdir_p (0, fname);
207
208 FILE *p = fopen (fname, "wb");
209 if (!p)
210 return;
211
212 if (!uexists ("/etc/passwd"))
213 fprintf (p, "bin\\mkpasswd -l > etc\\passwd\n");
214 if (!uexists ("/etc/group"))
215 fprintf (p, "bin\\mkgroup -l > etc\\group\n");
216
217 fclose (p);
218 } 185 }
219 186
220 static void 187 static void
221 save_icon () 188 save_icon ()
222 { 189 {
238 fwrite (data, 1, len, f); 205 fwrite (data, 1, len, f);
239 fclose (f); 206 fclose (f);
240 } 207 }
241 } 208 }
242 209
210 void
211 remove_desktop_setup()
212 {
213 start_menu ("XEmacs", 0, 1);
214 desktop_icon ("XEmacs", 0, 1);
215
216 if (xemacs_package != 0)
217 {
218 int issystem = (root_scope == IDC_ROOT_SYSTEM ? 1 : 0);
219 #define FROB(exe) remove_app_path ((exe), \
220 issystem)
221 /* FROB (find_xemacs_exe_name ()); */
222 FROB ("runemacs.exe");
223 FROB ("xemacs.exe");
224 #undef FROB
225 }
226 }
227
243 static void 228 static void
244 do_desktop_setup() 229 do_desktop_setup()
245 { 230 {
246 save_icon (); 231 save_icon ();
247 232
248 if (root_menu && batname) { 233 if (root_menu && batname) {
249 start_menu ("XEmacs", batname); 234 start_menu ("XEmacs", batname, 0);
250 } 235 }
251 236
252 if (root_desktop && batname) { 237 if (root_desktop && batname) {
253 desktop_icon ("XEmacs", batname); 238 desktop_icon ("XEmacs", batname, 0);
254 } 239 }
255 240
256 // set regkeys for the application 241 // set regkeys for the application
257 if (xemacs_package != 0) 242 if (xemacs_package != 0)
258 { 243 {
259 int issystem = (root_scope == IDC_ROOT_SYSTEM ? 1 : 0); 244 int issystem = (root_scope == IDC_ROOT_SYSTEM ? 1 : 0);
260 if (xemacs_package->type == TY_NATIVE) 245 if (xemacs_package->type == TY_NATIVE
246 || xemacs_package->type == TY_CYGWIN)
261 { 247 {
248 if (xemacs_package->type == TY_NATIVE)
249 {
262 #define FROB(exe) set_app_path ((exe), \ 250 #define FROB(exe) set_app_path ((exe), \
263 find_xemacs_exe_path (), \ 251 find_xemacs_exe_path (), \
264 issystem) 252 issystem)
265 FROB (find_xemacs_exe_name ()); 253 FROB (find_xemacs_exe_name ());
266 FROB ("runemacs.exe"); 254 FROB ("runemacs.exe");
267 FROB ("xemacs.exe"); 255 FROB ("xemacs.exe");
268 #undef FROB 256 #undef FROB
269 } 257 }
270 else if (xemacs_package->type == TY_CYGWIN) 258 else if (xemacs_package->type == TY_CYGWIN)
271 { 259 {
272 int junk; 260 int junk;
273 char* root = find_cygwin_root (&junk); 261 char* root = find_cygwin_root (&junk);
274 #define FROB(exe) set_app_path ((exe), \ 262 #define FROB(exe) set_app_path ((exe), \
275 concat (find_xemacs_exe_path (), ";", \ 263 concat (find_xemacs_exe_path (), ";", \
276 root, "\\bin;", \ 264 root, "\\bin;", \
277 root, "\\usr\\bin", 0), \ 265 root, "\\usr\\bin", 0), \
278 issystem) 266 issystem)
279 FROB (find_xemacs_exe_name ()); 267 FROB (find_xemacs_exe_name ());
280 FROB ("runemacs.exe"); 268 FROB ("runemacs.exe");
281 FROB ("xemacs.exe"); 269 FROB ("xemacs.exe");
282 #undef FROB 270 #undef FROB
271 }
272 set_install_path (find_xemacs_exe_path(), issystem);
273 }
274 // Register file types
275 if (batname)
276 {
277 if (reg_java)
278 {
279 log (0, "Registering .java files");
280 setup_explorer ("java", "Java Source file", batname);
281 setup_explorer ("jav", "Java Source file", batname);
282 }
283 if (reg_cpp)
284 {
285 log (0, "Registering .cpp files");
286 setup_explorer ("cpp", "C++ Source file", batname);
287 setup_explorer ("cc", "C++ Source file", batname);
288 setup_explorer ("hh", "C++ Header file", batname);
289 }
290 if (reg_c)
291 {
292 log (0, "Registering .c files");
293 setup_explorer ("c", "C Source file", batname);
294 setup_explorer ("h", "C Header file", batname);
295 }
296 if (reg_elisp)
297 {
298 log (0, "Registering .el files");
299 setup_explorer ("el", "E-Lisp Source file", batname);
300 }
301 if (reg_txt)
302 {
303 log (0, "Registering .txt files");
304 setup_explorer ("txt", "Text file", batname);
305 }
283 } 306 }
284 } 307 }
285 } 308 }
286 309
287 static int da[] = { IDC_ROOT_DESKTOP, 0 }; 310 static int da[] = { IDC_ROOT_DESKTOP, 0 };
288 static int ma[] = { IDC_ROOT_MENU, 0 }; 311 static int ma[] = { IDC_ROOT_MENU, 0 };
289 312
313 static int ct[] = { IDC_C_TYPE, 0 };
314 static int javat[] = { IDC_JAVA_TYPE, 0 };
315 static int cppt[] = { IDC_CPP_TYPE, 0 };
316 static int elispt[] = { IDC_ELISP_TYPE, 0 };
317 static int txtt[] = { IDC_TXT_TYPE, 0 };
318
290 static void 319 static void
291 check_if_enable_next (HWND h) 320 check_if_enable_next (HWND h)
292 { 321 {
293 EnableWindow (GetDlgItem (h, IDOK), 1); 322 EnableWindow (GetDlgItem (h, IDOK), 1);
294 } 323 }
296 static void 325 static void
297 load_dialog (HWND h) 326 load_dialog (HWND h)
298 { 327 {
299 rbset (h, da, root_desktop); 328 rbset (h, da, root_desktop);
300 rbset (h, ma, root_menu); 329 rbset (h, ma, root_menu);
330 rbset (h, ct, reg_c);
331 rbset (h, javat, reg_java);
332 rbset (h, cppt, reg_cpp);
333 rbset (h, elispt, reg_elisp);
334 rbset (h, txtt, reg_txt);
301 check_if_enable_next (h); 335 check_if_enable_next (h);
302 } 336 }
303 337
304 static int check_desktop (char *title, char *target) 338 static int check_desktop (char *title, char *target)
305 { 339 {
364 static void 398 static void
365 save_dialog (HWND h) 399 save_dialog (HWND h)
366 { 400 {
367 root_desktop= rbget (h, da); 401 root_desktop= rbget (h, da);
368 root_menu = rbget (h, ma); 402 root_menu = rbget (h, ma);
403 reg_c = rbget (h, ct);
404 reg_java = rbget (h, javat);
405 reg_cpp = rbget (h, cppt);
406 reg_elisp = rbget (h, elispt);
407 reg_txt = rbget (h, txtt);
369 } 408 }
370 409
371 static BOOL 410 static BOOL
372 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code) 411 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
373 { 412 {
426 batname = concat (find_xemacs_exe_path (), "\\", 465 batname = concat (find_xemacs_exe_path (), "\\",
427 find_xemacs_exe_name (), 466 find_xemacs_exe_name (),
428 0); 467 0);
429 root_desktop = check_desktop ("XEmacs", batname); 468 root_desktop = check_desktop ("XEmacs", batname);
430 root_menu = check_startmenu ("XEmacs", batname); 469 root_menu = check_startmenu ("XEmacs", batname);
470 reg_c = IDC_C_TYPE;
471 reg_cpp = IDC_CPP_TYPE;
472 reg_java = IDC_JAVA_TYPE;
473 reg_elisp = IDC_ELISP_TYPE;
474 reg_txt = IDC_TXT_TYPE;
431 } 475 }
432 else 476 else
433 { 477 {
434 root_desktop = 0; 478 root_desktop = 0;
435 root_menu = 0; 479 root_menu = 0;
480 reg_c = 0;
481 reg_cpp = 0;
482 reg_java = 0;
483 reg_elisp = 0;
484 reg_txt = 0;
436 } 485 }
437 486
438 int rv = 0; 487 int rv = 0;
439 488
440 rv = DialogBox (h, MAKEINTRESOURCE (IDD_DESKTOP), 0, dialog_proc); 489 rv = DialogBox (h, MAKEINTRESOURCE (IDD_DESKTOP), 0, dialog_proc);