comparison cinst/mozilla.c @ 985:1743895b39b8

(issue86) Install into default profile folders on windows.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 29 Aug 2014 17:13:30 +0200
parents b3695a3399de
children 66f6361fba1b
comparison
equal deleted inserted replaced
984:faf58e9f518b 985:1743895b39b8
82 /* Default installation directory of ubuntu 14.4 is respected */ 82 /* Default installation directory of ubuntu 14.4 is respected */
83 #define MOZILLA_DEFAULTS "/etc/thunderbird", "/etc/firefox" 83 #define MOZILLA_DEFAULTS "/etc/thunderbird", "/etc/firefox"
84 #define NSSSHARED ".pki/nssdb" 84 #define NSSSHARED ".pki/nssdb"
85 #define NSSSHARED_GLOBAL "/etc/pki/nssdb" 85 #define NSSSHARED_GLOBAL "/etc/pki/nssdb"
86 #define TARGET_LINUX 1 86 #define TARGET_LINUX 1
87 #define DIRSEP "/"
87 #else 88 #else
88 #define MOZILLA_DEFAULTS 0 89 #define MOZILLA_DEFAULTS "Mozilla Firefox\\browser\\defaults", "Mozilla Thunderbird\\defaults"
89 #define CONFDIRS "Mozilla", "Thunderbird" 90 #define CONFDIRS "Mozilla", "Thunderbird"
90 #define NSSSHARED "" 91 #define NSSSHARED ""
91 #define TARGET_LINUX 0 92 #define TARGET_LINUX 0
93 #define DIRSEP "\\"
92 #endif 94 #endif
93 95
94 /** 96 /**
95 * @brief Length of string buffers used 97 * @brief Length of string buffers used
96 * 98 *
316 { 318 {
317 char **retval = NULL; 319 char **retval = NULL;
318 320
319 const char *confdirs[] = { MOZILLA_DEFAULTS, NULL }; 321 const char *confdirs[] = { MOZILLA_DEFAULTS, NULL };
320 322
323 #ifdef _WIN32
324 char *program_files = get_program_files_folder();
325 if (!program_files)
326 {
327 ERRORPRINTF ("Failed to look up program files folder.\n");
328 return NULL;
329 }
330 #endif
331
321 for (int i=0; confdirs[i] != NULL; i++) 332 for (int i=0; confdirs[i] != NULL; i++)
322 { 333 {
323 char * realpath = port_realpath(confdirs[i]); 334 char *realpath = NULL,
324 char * profile_dir = NULL; 335 *profile_dir = NULL;
336 #ifndef _WIN32
337 realpath = port_realpath(confdirs[i]);
338 #else
339 /* As on linux we only respect the default installation directory
340 mozilla firefox and thunderbird change their registry key with
341 each version as the key includes the version number. It would
342 be error prone to search the system for every instance. So we
343 only check the default installation directories. */
344 xasprintf(&realpath, "%s" DIRSEP "%s", program_files, confdirs[i]);
345 #endif
325 if (realpath == NULL) 346 if (realpath == NULL)
326 { 347 {
327 DEBUGPRINTF ("Did not find directory: '%s'\n", confdirs[i]); 348 DEBUGPRINTF ("Did not find directory: '%s'\n", confdirs[i]);
328 continue; 349 continue;
329 } 350 }
330 xasprintf(&profile_dir, "%s/profile", realpath); 351 xasprintf(&profile_dir, "%s" DIRSEP "profile", realpath);
352 xfree(realpath);
331 if (port_isdir(profile_dir)) 353 if (port_isdir(profile_dir))
332 { 354 {
333 DEBUGPRINTF("Found default directory: '%s'\n", profile_dir); 355 DEBUGPRINTF("Found default directory: '%s'\n", profile_dir);
334 /* All is well */ 356 /* All is well */
335 strv_append (&retval, profile_dir, strlen(profile_dir)); 357 strv_append (&retval, profile_dir, strlen(profile_dir));
349 continue; 371 continue;
350 } 372 }
351 else 373 else
352 { 374 {
353 /* Lets create it */ 375 /* Lets create it */
354 if (!port_mkdir(profile_dir)) 376 if (!port_mkdir_p(profile_dir))
355 { 377 {
356 ERRORPRINTF ("Failed to create directory: '%s'\n", profile_dir); 378 ERRORPRINTF ("Failed to create directory: '%s'\n", profile_dir);
357 xfree(profile_dir); 379 xfree(profile_dir);
358 profile_dir = NULL; 380 profile_dir = NULL;
359 continue; 381 continue;
362 xfree(profile_dir); 384 xfree(profile_dir);
363 profile_dir = NULL; 385 profile_dir = NULL;
364 } 386 }
365 } 387 }
366 } 388 }
389 xfree (program_files);
367 return retval; 390 return retval;
368 } 391 }
369 392
370 /** 393 /**
371 * @brief Collect all mozilla profile directories of current user. 394 * @brief Collect all mozilla profile directories of current user.

http://wald.intevation.org/projects/trustbridge/