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

« back to all changes in this revision

Viewing changes to src/release.c

  • Committer: Michael Terry
  • Date: 2011-07-13 14:54:42 UTC
  • mto: This revision was merged to the branch mainline in revision 631.
  • Revision ID: michael.terry@canonical.com-20110713145442-4b0pkrbebadn99h6
convert to gsettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
{
29
29
   g_debug_release ("check_new_release");
30
30
 
31
 
   GError *error = NULL;
32
 
   GConfClient *client = (GConfClient*)user_data;
 
31
   GSettings *settings = (GSettings*)user_data;
33
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 ) {
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();
 
66
   GSettings *settings = g_settings_new(SETTINGS_SCHEMA);
71
67
   
72
68
   // check once at startup
73
 
   check_new_release (client);
 
69
   check_new_release (settings);
74
70
   // release upgrades happen not that frequently, we use two timers
75
71
   // check every 10 min if 48h are reached and then run 
76
72
   // "check-release-upgrade-gtk" again
77
 
   g_timeout_add_seconds (60*10, check_new_release, client);
 
73
   g_timeout_add_seconds (60*10, check_new_release, settings);
78
74
 
79
75
   return TRUE;
80
76
}