Better messages in gmyth-ls trunk
authorali@juiblex.co.uk
Sun Dec 13 23:02:37 2009 +0000 (2009-12-13)
branchtrunk
changeset 94970e24f6fea25
parent 948 0399d9ea8b7b
child 950 6308269b026e
Better messages in gmyth-ls
gmyth/samples/gmyth_ls.c
     1.1 --- a/gmyth/samples/gmyth_ls.c	Sun Dec 13 22:42:34 2009 +0000
     1.2 +++ b/gmyth/samples/gmyth_ls.c	Sun Dec 13 23:02:37 2009 +0000
     1.3 @@ -118,7 +118,8 @@
     1.4      GMythScheduler *scheduler;
     1.5      GList          *list,
     1.6                     *iter;
     1.7 -    gint            res = 0;
     1.8 +    gint            res = 0,
     1.9 +                    count = 0;
    1.10  
    1.11      g_return_val_if_fail(options != NULL, FALSE);
    1.12      g_return_val_if_fail(options->b_info != NULL, FALSE);
    1.13 @@ -128,26 +129,19 @@
    1.14      if (gmyth_scheduler_connect_with_timeout(scheduler,
    1.15                                               options->b_info, 10) == FALSE)
    1.16      {
    1.17 -        g_warning("Could not connect to backend db");
    1.18 +        g_print("Could not connect to database server.\n");
    1.19          g_object_unref(scheduler);
    1.20          return FALSE;
    1.21      }
    1.22  
    1.23      res = gmyth_scheduler_get_recorded_list(scheduler, &list);
    1.24 -    if (res < 0) {
    1.25 -        gmyth_scheduler_disconnect(scheduler);
    1.26 -        g_object_unref(scheduler);
    1.27 -        g_warning("Could not retrieve recorded list");
    1.28 -        return FALSE;
    1.29 -    }
    1.30  
    1.31      gmyth_scheduler_disconnect(scheduler);
    1.32 +    g_object_unref(scheduler);
    1.33  
    1.34 -    if (res == 0) {
    1.35 -        g_print("None file was found in the backend.\n");
    1.36 -        gmyth_scheduler_disconnect(scheduler);
    1.37 -        g_object_unref(scheduler);
    1.38 -        return TRUE;
    1.39 +    if (res < 0) {
    1.40 +        g_print("Could not retrieve list of recorded programs.\n");
    1.41 +        return FALSE;
    1.42      }
    1.43  
    1.44      iter = list;
    1.45 @@ -156,17 +150,18 @@
    1.46  
    1.47          if (gmyth_util_file_exists
    1.48              (options->b_info, recorded_info->basename->str)) {
    1.49 +            count++;
    1.50              g_print("%s\n", recorded_info->basename->str);
    1.51          }
    1.52          gmyth_recorded_info_free(recorded_info);
    1.53          iter = g_list_next(iter);
    1.54      }
    1.55  
    1.56 +    if (!count)
    1.57 +        g_print("No recorded programs.\n");
    1.58 +
    1.59      g_list_free(list);
    1.60  
    1.61 -    gmyth_scheduler_disconnect(scheduler);
    1.62 -    g_object_unref(scheduler);
    1.63 -
    1.64      return TRUE;
    1.65  }
    1.66