jjacky avatar jjacky committed 54a3157

config: removed Verbose options, changed how templates work to make things easier.

Now there are 5 templates: template-upgrades, template-watched, template-aur, template-watched-aur and template-news.
If something in a template is not defined it falls back on tpl-upgrades, except tpl-watched-aur which falls back on tpl-aur (which itself can fall back on tpl-upgrades).

Comments (0)

Files changed (3)

                         debug ("config: checks_manual: %d", checks);
                     }
                 }
-                else if (strcmp (key, "Verbose") == 0)
+                else
                 {
-                    verbose = &(config->verbose);
-                }
-                else if (strcmp (key, "VerboseWatched") == 0)
-                {
-                    verbose = &(config->verbose_watched);
-                }
-                else if (strcmp (key, "VerboseAur") == 0)
-                {
-                    verbose = &(config->verbose_aur);
-                }
-                else if (strcmp (key, "VerboseWatchedAur") == 0)
-                {
-                    verbose = &(config->verbose_watched_aur);
-                }
-                
-                /* was this a verbose setting? */
-                if (verbose != NULL)
-                {
-                    if (strcmp (value, "auto") == 0)
-                    {
-                        *verbose = 0;
-                        debug ("config: %s: 0 (auto)", key);
-                    }
-                    else if (strcmp (value, "on") == 0)
-                    {
-                        *verbose = 1;
-                        debug ("config: %s: 1 (on)", key);
-                    }
-                    else if (strcmp (value, "off") == 0)
-                    {
-                        *verbose = 2;
-                        debug ("config: %s: 2 (off)", key);
-                    }
-                    else
-                    {
-                        set_error ("invalid value for %s: %s", key, value);
-                        success = FALSE;
-                        goto cleanup;
-                    }
+                    set_error ("unknown option: %s", key);
+                    success = FALSE;
+                    goto cleanup;
                 }
             }
             else
             {
                 templates_t *t;
-                if (strcmp ("template", section) == 0)
+                if (strcmp ("template-upgrades", section) == 0)
                 {
-                    t = config->tpl;
-                }
-                else if (strcmp ("template-verbose", section) == 0)
-                {
-                    t = config->tpl_verbose;
+                    t = config->tpl_upgrades;
                 }
                 else if (strcmp ("template-watched", section) == 0)
                 {
                     t = config->tpl_watched;
                 }
-                else if (strcmp ("template-watched-verbose", section) == 0)
-                {
-                    t = config->tpl_watched_verbose;
-                }
                 else if (strcmp ("template-aur", section) == 0)
                 {
                     t = config->tpl_aur;
                 }
-                else if (strcmp ("template-aur-verbose", section) == 0)
-                {
-                    t = config->tpl_aur_verbose;
-                }
                 else if (strcmp ("template-watched-aur", section) == 0)
                 {
                     t = config->tpl_watched_aur;
                 }
-                else if (strcmp ("template-watched-aur-verbose", section) == 0)
-                {
-                    t = config->tpl_watched_aur_verbose;
-                }
                 else if (strcmp ("template-news", section) == 0)
                 {
                     t = config->tpl_news;
 
 typedef struct _config_t {
     gboolean         is_debug;
-    unsigned int     verbose;
-    unsigned int     verbose_watched;
-    unsigned int     verbose_aur;
-    unsigned int     verbose_watched_aur;
     char            *pacmanconf;
     unsigned int     checks_manual;
     unsigned int     checks_auto;
     char            *cmdline_aur;
     alpm_list_t     *cmdline_post;
     
-    templates_t     *tpl;
-    templates_t     *tpl_verbose;
+    templates_t     *tpl_upgrades;
     templates_t     *tpl_watched;
-    templates_t     *tpl_watched_verbose;
     templates_t     *tpl_aur;
-    templates_t     *tpl_aur_verbose;
     templates_t     *tpl_watched_aur;
-    templates_t     *tpl_watched_aur_verbose;
     templates_t     *tpl_news;
     
     alpm_list_t     *aur_ignore;
     templates_t template;
     const char *unit;
     double      size_h;
-    unsigned int verbose, *v;
     replacement_t *replacements[6];
     
+    templates_t *t, *tt;
+    /* tpl_upgrades is the ref/fallback for pretty much everything */
+    t = config->tpl_upgrades;
     if (type & CHECK_UPGRADES)
     {
-        v = &(config->verbose);
+        tt = config->tpl_upgrades;
     }
     else if (type & CHECK_WATCHED)
     {
-        v = &(config->verbose_watched);
+        tt = config->tpl_watched;
     }
     else if (type & CHECK_AUR)
     {
-        v = &(config->verbose_aur);
+        tt = config->tpl_aur;
     }
     else if (type & CHECK_WATCHED_AUR)
     {
-        v = &(config->verbose_watched_aur);
-    }
-    
-    if (type & CHECK_NEWS)
-    {
-        verbose = 0;
-    }
-    else
-    {
-        verbose = (*v == 0) ? alpm_verbose : *v;
-    }
-    
-    templates_t *t;
-    t = (verbose == 1) ? config->tpl_verbose : config->tpl;
-    if (type & CHECK_UPGRADES)
-    {
-        template.title = t->title;
-        template.package = t->package;
-        template.sep = t->sep;
-    }
-    else if (type & CHECK_WATCHED)
-    {
-        templates_t *tt = (verbose == 1) ? config->tpl_watched_verbose : config->tpl_watched;
-        template.title = (tt->title) ? tt->title : t->title;
-        template.package = (tt->package) ? tt->package : t->package;
-        template.sep = (tt->sep) ? tt->sep : t->sep;
-    }
-    else if (type & CHECK_AUR)
-    {
-        templates_t *tt = (verbose == 1) ? config->tpl_aur_verbose : config->tpl_aur;
-        template.title = (tt->title) ? tt->title : t->title;
-        template.package = (tt->package) ? tt->package : t->package;
-        template.sep = (tt->sep) ? tt->sep : t->sep;
-    }
-    else if (type & CHECK_WATCHED_AUR)
-    {
-        templates_t *tt = (verbose == 1) ? config->tpl_watched_aur_verbose
-                                         : config->tpl_watched_aur;
-        template.title = (tt->title) ? tt->title : t->title;
-        template.package = (tt->package) ? tt->package : t->package;
-        template.sep = (tt->sep) ? tt->sep : t->sep;
+        tt = config->tpl_watched_aur;
+        /* watched-aur uses aur as fallback */
+        t = config->tpl_aur;
     }
     else if (type & CHECK_NEWS)
     {
-        template.title = config->tpl_news->title;
-        template.package = config->tpl_news->package;
-        template.sep = config->tpl_news->sep;
+        tt = config->tpl_news;
+    }
+    /* set the templates to use */
+    template.title = (tt->title) ? tt->title : t->title;
+    template.package = (tt->package) ? tt->package : t->package;
+    template.sep = (tt->sep) ? tt->sep : t->sep;
+    /* watched-aur might have fallen back to aur, which itself needs to fallback */
+    if (type & CHECK_WATCHED_AUR)
+    {
+        t = config->tpl_upgrades;
+        template.title = (template.title) ? template.title : t->title;
+        template.package = (template.package) ? template.package : t->package;
+        template.sep = (template.sep) ? template.sep : t->sep;
     }
     
     alloc = 1024;
     free (config->pacmanconf);
     
     /* tpl */
-    if (NULL != config->tpl->title)
+    if (NULL != config->tpl_upgrades->title)
     {
-        free (config->tpl->title);
+        free (config->tpl_upgrades->title);
     }
-    if (NULL != config->tpl->package)
+    if (NULL != config->tpl_upgrades->package)
     {
-        free (config->tpl->package);
+        free (config->tpl_upgrades->package);
     }
-    if (NULL != config->tpl->sep)
+    if (NULL != config->tpl_upgrades->sep)
     {
-        free (config->tpl->sep);
+        free (config->tpl_upgrades->sep);
     }
-    free (config->tpl);
-    
-    /* tpl verbose */
-    if (NULL != config->tpl_verbose->title)
-    {
-        free (config->tpl_verbose->title);
-    }
-    if (NULL != config->tpl_verbose->package)
-    {
-        free (config->tpl_verbose->package);
-    }
-    if (NULL != config->tpl_verbose->sep)
-    {
-        free (config->tpl_verbose->sep);
-    }
-    free (config->tpl_verbose);
+    free (config->tpl_upgrades);
     
     /* tpl watched */
     if (NULL != config->tpl_watched->title)
     }
     free (config->tpl_watched);
     
-    /* tpl watched verbose */
-    if (NULL != config->tpl_watched_verbose->title)
-    {
-        free (config->tpl_watched_verbose->title);
-    }
-    if (NULL != config->tpl_watched_verbose->package)
-    {
-        free (config->tpl_watched_verbose->package);
-    }
-    if (NULL != config->tpl_watched_verbose->sep)
-    {
-        free (config->tpl_watched_verbose->sep);
-    }
-    free (config->tpl_watched_verbose);
-    
     /* tpl aur */
     if (NULL != config->tpl_aur->title)
     {
     }
     free (config->tpl_aur);
     
-    /* tpl aur verbose */
-    if (NULL != config->tpl_aur_verbose->title)
-    {
-        free (config->tpl_aur_verbose->title);
-    }
-    if (NULL != config->tpl_aur_verbose->package)
-    {
-        free (config->tpl_aur_verbose->package);
-    }
-    if (NULL != config->tpl_aur_verbose->sep)
-    {
-        free (config->tpl_aur_verbose->sep);
-    }
-    free (config->tpl_aur_verbose);
-    
     /* watched */
     FREE_WATCHED_PACKAGE_LIST (config->watched);
     
                             | CHECK_WATCHED_AUR | CHECK_NEWS;
     config->action = UPGRADE_ACTION_KALU;
     
-    config->tpl = calloc (1, sizeof (templates_t));
-    config->tpl->title = strdup ("$NB updates available");
-    config->tpl->package = strdup ("$PKG $NEW");
-    config->tpl->sep = strdup (", ");
-    config->tpl_verbose = calloc (1, sizeof (templates_t));
-    config->tpl_verbose->title = strdup ("$NB updates available (D: $DL; N: $NET)");
-    config->tpl_verbose->package = strdup ("- <b>$PKG</b> $OLD > <b>$NEW</b> (D: $DL; N: $NET)");
-    config->tpl_verbose->sep = strdup ("\n");
+    config->tpl_upgrades = calloc (1, sizeof (templates_t));
+    config->tpl_upgrades->title = strdup ("$NB updates available (D: $DL; N: $NET)");
+    config->tpl_upgrades->package = strdup ("- <b>$PKG</b> $OLD > <b>$NEW</b> (D: $DL; N: $NET)");
+    config->tpl_upgrades->sep = strdup ("\n");
     
     config->tpl_watched = calloc (1, sizeof (templates_t));
-    config->tpl_watched->title = strdup ("$NB watched packages updated");
-    config->tpl_watched_verbose = calloc (1, sizeof (templates_t));
-    config->tpl_watched_verbose->title = strdup ("$NB watched packages updated (D: $DL; N: $NET)");
+    config->tpl_watched->title = strdup ("$NB watched packages updated (D: $DL; N: $NET)");
     
     config->tpl_aur = calloc (1, sizeof (templates_t));
-    config->tpl_aur->title = strdup ("$NB packages updated in AUR");
-    config->tpl_aur_verbose = calloc (1, sizeof (templates_t));
-    config->tpl_aur_verbose->title = strdup ("$NB packages updated in AUR");
-    config->tpl_aur_verbose->package = strdup ("- <b>$PKG</b> $OLD > <b>$NEW</b>");
+    config->tpl_aur->title = strdup ("AUR: $NB packages updated");
+    config->tpl_aur->package = strdup ("- <b>$PKG</b> $OLD > <b>$NEW</b>");
     
     config->tpl_watched_aur = calloc (1, sizeof (templates_t));
-    config->tpl_watched_aur->title = strdup ("$NB watched packages updated in AUR");
-    config->tpl_watched_aur_verbose = calloc (1, sizeof (templates_t));
-    config->tpl_watched_aur_verbose->title = strdup ("$NB watched packages updated in AUR");
-    config->tpl_watched_aur_verbose->package = strdup ("- <b>$PKG</b> $OLD > <b>$NEW</b>");
+    config->tpl_watched_aur->title = strdup ("AUR: $NB watched packages updated");
     
     config->tpl_news = calloc (1, sizeof (templates_t));
     config->tpl_news->title = strdup ("$NB unread news");
     config->tpl_news->package = strdup ("- $NEWS");
-    config->tpl_news->sep = strdup ("\n");
     
     /* parse config */
     snprintf (conffile, MAX_PATH - 1, "%s/.config/kalu/kalu.conf", g_get_home_dir ());
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.