http://packetstormsecurity.org/UNIX/admin/xscreensaver-3.32.tar.gz
[xscreensaver] / driver / prefs.c
index 71ed252aa5741793d25d6a46126366f74429b6b2..629b1b31196c824e4f8e6b19462eaab70dfb32a7 100644 (file)
@@ -222,6 +222,10 @@ static const char * const prefs[] = {
   "dpmsStandby",
   "dpmsSuspend",
   "dpmsOff",
+  "grabDesktopImages",
+  "grabVideoFrames",
+  "chooseRandomImages",
+  "imageDirectory",
   "",
   "programs",
   "",
@@ -495,6 +499,9 @@ write_entry (FILE *out, const char *key, const char *value)
   fprintf(out, "%s:", key);
   col = strlen(key) + 1;
 
+  if (strlen(key) > 14)
+    col = tab_to (out, col, 20);
+
   while (1)
     {
       if (!programs_p)
@@ -724,10 +731,17 @@ write_init_file (saver_preferences *p, const char *version_string,
       CHECK("captureStderr")   type = pref_bool, b = p->capture_stderr_p;
       CHECK("captureStdout")   continue;  /* don't save */
       CHECK("font")            type = pref_str,  s =    stderr_font;
+
       CHECK("dpmsEnabled")     type = pref_bool, b = p->dpms_enabled_p;
       CHECK("dpmsStandby")     type = pref_time, t = p->dpms_standby;
       CHECK("dpmsSuspend")     type = pref_time, t = p->dpms_suspend;
       CHECK("dpmsOff")         type = pref_time, t = p->dpms_off;
+
+      CHECK("grabDesktopImages") type =pref_bool, b = p->grab_desktop_p;
+      CHECK("grabVideoFrames")   type =pref_bool, b = p->grab_video_p;
+      CHECK("chooseRandomImages")type =pref_bool, b = p->random_image_p;
+      CHECK("imageDirectory")    type =pref_str,  s = p->image_directory;
+
       CHECK("programs")                type = pref_str,  s =    programs;
       CHECK("pointerPollTime") type = pref_time, t = p->pointer_timeout;
       CHECK("windowCreationTimeout")type=pref_time,t= p->notice_events_timeout;
@@ -924,9 +938,15 @@ load_init_file (saver_preferences *p)
                                                       "Time");
 
   p->dpms_enabled_p  = get_boolean_resource ("dpmsEnabled", "Boolean");
-  p->dpms_standby    = 1000 * get_seconds_resource ("dpmsStandby", "Time");
-  p->dpms_suspend    = 1000 * get_seconds_resource ("dpmsSuspend", "Time");
-  p->dpms_off        = 1000 * get_seconds_resource ("dpmsOff",     "Time");
+  p->dpms_standby    = 1000 * get_minutes_resource ("dpmsStandby", "Time");
+  p->dpms_suspend    = 1000 * get_minutes_resource ("dpmsSuspend", "Time");
+  p->dpms_off        = 1000 * get_minutes_resource ("dpmsOff",     "Time");
+
+  p->grab_desktop_p  = get_boolean_resource ("grabDesktopImages",  "Boolean");
+  p->grab_video_p    = get_boolean_resource ("grabVideoFrames",    "Boolean");
+  p->random_image_p  = get_boolean_resource ("chooseRandomImages", "Boolean");
+  p->image_directory = get_string_resource  ("imageDirectory",
+                                             "ImageDirectory");
 
   p->shell = get_string_resource ("bourneShell", "BourneShell");
 
@@ -945,6 +965,15 @@ load_init_file (saver_preferences *p)
       p->splash_p = True;
   }
 
+  /* If "*grabDesktopImages" is unset, default to true. */
+  {
+    char *s = get_string_resource ("grabDesktopImages", "Boolean");
+    if (s)
+      free (s);
+    else
+      p->grab_desktop_p = True;
+  }
+
   p->use_xidle_extension = get_boolean_resource ("xidleExtension","Boolean");
   p->use_mit_saver_extension = get_boolean_resource ("mitSaverExtension",
                                                     "Boolean");
@@ -964,12 +993,25 @@ load_init_file (saver_preferences *p)
     p->fade_p = False;
   if (! p->fade_p) p->unfade_p = False;
 
-  if (p->dpms_standby <= 0 || p->dpms_suspend <= 0 || p->dpms_off <= 0)
+  /* The DPMS settings may have the value 0.
+     But if they are negative, or are a range less than 10 seconds,
+     reset them to sensible defaults.  (Since that must be a mistake.)
+   */
+  if (p->dpms_standby != 0 &&
+      p->dpms_standby < 10 * 1000)
+    p->dpms_standby =  2 * 60 * 60 * 1000;                      /* 2 hours */
+  if (p->dpms_suspend != 0 &&
+      p->dpms_suspend < 10 * 1000)
+    p->dpms_suspend =  2 * 60 * 60 * 1000;                      /* 2 hours */
+  if (p->dpms_off != 0 &&
+      p->dpms_off < 10 * 1000)
+    p->dpms_off      = 4 * 60 * 60 * 1000;                      /* 4 hours */
+
+  if (p->dpms_standby == 0 &&     /* if *all* are 0, then DPMS is disabled */
+      p->dpms_suspend == 0 &&
+      p->dpms_off     == 0)
     p->dpms_enabled_p = False;
 
-  if (p->dpms_standby <= 10000) p->dpms_standby = 10000;        /* 10 secs */
-  if (p->dpms_suspend <= 10000) p->dpms_suspend = 10000;        /* 10 secs */
-  if (p->dpms_off     <= 10000) p->dpms_off     = 10000;        /* 10 secs */
 
   p->watchdog_timeout = p->cycle * 0.6;
   if (p->watchdog_timeout < 30000) p->watchdog_timeout = 30000;          /* 30 secs */