~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to src/release.c

  • Committer: dann frazier
  • Date: 2020-02-04 02:27:07 UTC
  • Revision ID: dannf@ubuntu.com-20200204022707-37vu1ltkpx2m2t5x
tests/test_motd.py: Fix cut & paste error in comment.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
   va_end(va);
23
23
}
24
24
 
25
 
// actually show the notification 
 
25
// actually show the notification
26
26
static gboolean
27
27
check_new_release(gpointer user_data)
28
28
{
29
29
   g_debug_release ("check_new_release");
30
30
 
31
 
   GError *error = NULL;
32
 
   GConfClient *client = (GConfClient*)user_data;
33
 
   
 
31
   GSettings *settings = (GSettings*)user_data;
 
32
 
34
33
   time_t now = time(NULL);
35
 
   time_t last_check = gconf_client_get_int(client, GCONF_KEY_LAST_RELEASE_CHECK, &error);
36
 
   if ( error != NULL ) {
37
 
      g_warning ("could not get %s", GCONF_KEY_LAST_RELEASE_CHECK);
38
 
      return FALSE;
39
 
   }
 
34
   time_t last_check = (time_t)g_settings_get_uint(settings,
 
35
                                                   SETTINGS_KEY_LAST_RELEASE_CHECK);
40
36
 
41
37
   // test if we need to run
42
38
   if ( (last_check + RELEASE_UPGRADE_CHECK_WAIT) > now ) {
45
41
   }
46
42
 
47
43
   // run the checker
48
 
   gchar *argv[10] = { RELEASE_UPGRADE_CHECKER, };
 
44
   gchar *argv[10] = { "/bin/sh", "-c", RELEASE_UPGRADE_CHECKER, };
49
45
   if (DEVEL_RELEASE) {
50
46
      g_debug_release ("running the release upgrade checker %s in devel mode", RELEASE_UPGRADE_CHECKER);
51
 
      argv[1] = "--devel-release";
52
 
      argv[2] = NULL;
 
47
      argv[3] = "--devel-release";
 
48
      argv[4] = NULL;
53
49
   } else {
54
50
      g_debug_release ("running the release upgrade checker %s", RELEASE_UPGRADE_CHECKER);
55
 
      argv[1] = NULL;
 
51
      argv[3] = NULL;
56
52
   }
57
53
   g_spawn_async ("/", argv, NULL, 0, NULL, NULL, NULL, NULL);
58
54
 
59
55
   // and update the timestamp so we don't check again too soon
60
 
   gconf_client_set_int(client, GCONF_KEY_LAST_RELEASE_CHECK, now, NULL);
 
56
   g_settings_set_uint(settings, SETTINGS_KEY_LAST_RELEASE_CHECK, (guint)now);
61
57
 
62
58
   return TRUE;
63
59
}
67
63
{
68
64
   g_debug_release ("release_checker_init");
69
65
 
70
 
   GConfClient *client = gconf_client_get_default();
71
 
   
72
66
   // check once at startup
73
 
   check_new_release (client);
 
67
   check_new_release (un->settings);
74
68
   // release upgrades happen not that frequently, we use two timers
75
69
   // check every 10 min if 48h are reached and then run 
76
70
   // "check-release-upgrade-gtk" again
77
 
   g_timeout_add_seconds (60*10, check_new_release, client);
 
71
   g_timeout_add_seconds (60*10, check_new_release, un->settings);
78
72
 
79
73
   return TRUE;
80
74
}