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

« back to all changes in this revision

Viewing changes to src/update-notifier.h

  • Committer: Julian Andres Klode
  • Date: 2020-01-28 09:54:52 UTC
  • Revision ID: juliank@ubuntu.com-20200128095452-g0q3a1xg75a7k56j
Replace pep8 with pycodestyle

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <gtk/gtk.h>
24
24
#include <glib/gi18n.h>
25
 
#include <gconf/gconf.h>
26
 
#include <gconf/gconf-client.h>
 
25
 
 
26
#include "config.h"
 
27
 
 
28
#ifdef HAVE_APP_INDICATOR
 
29
#include <libappindicator/app-indicator.h>
 
30
#endif
27
31
 
28
32
#define CLIPBOARD_NAME  "UPGRADE_NOTIFIER_SELECTION"
29
 
#define GCONF_KEY_DEFAULT_ACTION "/apps/update-notifier/default_action"
30
 
#define GCONF_KEY_NO_UPDATE_NOTIFICATIONS "/apps/update-notifier/no_show_notifications"
31
 
#define GCONF_KEY_APPORT_NOTIFICATIONS "/apps/update-notifier/show_apport_crashes"
32
 
#define GCONF_KEY_END_SYSTEM_UIDS "/apps/update-notifier/end_system_uids"
33
 
#define GCONF_KEY_AUTO_LAUNCH "/apps/update-notifier/auto_launch"
34
 
#define GCONF_KEY_AUTO_LAUNCH_INTERVAL "/apps/update-notifier/regular_auto_launch_interval"
35
 
#define GCONF_KEY_HIDE_REBOOT "/apps/update-notifier/hide_reboot_notification"
36
 
#define GCONF_KEY_LAST_LAUNCH "/apps/update-manager/launch_time"
37
 
#define GCONF_KEY_LAST_RELEASE_CHECK "/apps/update-notifier/release_check_time"
 
33
 
 
34
#define SETTINGS_SCHEMA "com.ubuntu.update-notifier"
 
35
#define SETTINGS_KEY_NO_UPDATE_NOTIFICATIONS "no-show-notifications"
 
36
#define SETTINGS_KEY_APPORT_NOTIFICATIONS "show-apport-crashes"
 
37
#define SETTINGS_KEY_END_SYSTEM_UIDS "end-system-uids"
 
38
#define SETTINGS_KEY_AUTO_LAUNCH_INTERVAL "regular-auto-launch-interval"
 
39
#define SETTINGS_KEY_LAST_RELEASE_CHECK "release-check-time"
 
40
#define SETTINGS_KEY_SHOW_LIVEPATCH_ICON "show-livepatch-status-icon"
 
41
 
 
42
#define SETTINGS_UM_SCHEMA "com.ubuntu.update-manager"
 
43
#define SETTINGS_UM_KEY_LAST_LAUNCH "launch-time"
38
44
 
39
45
#define HOOKS_DIR "/var/lib/update-notifier/user.d/"
40
46
#define CRASHREPORT_HELPER "/usr/share/apport/apport-checkreports"
41
47
#define CRASHREPORT_REPORT_APP "/usr/share/apport/apport-gtk"
42
48
#define CRASHREPORT_DIR "/var/crash/"
43
 
#define REBOOT_FILE "/var/run/reboot-required"
44
 
#define UNICAST_LOCAL_AVAHI_FILE "/var/run/avahi-daemon/disabled-for-unicast-local"
 
49
#define CRASHREPORT_AUTOREPORT "/var/lib/apport/autoreport"
 
50
#define CRASHREPORT_WHOOPSIE_EXEC "/usr/bin/whoopsie"
 
51
#define CRASHREPORT_WHOOPSIE_SERVICE "whoopsie"
 
52
#define UNICAST_LOCAL_AVAHI_FILE "/run/avahi-daemon/disabled-for-unicast-local"
 
53
#define LIVEPATCH_FILE "/var/snap/canonical-livepatch/current/status"
45
54
 
46
55
// security update autolaunch minimal time (12h)
47
56
#define AUTOLAUNCH_MINIMAL_SECURITY_INTERVAL 12*60*60
48
57
 
49
 
// this is the age that we tolerate for updates (7 dayd)
 
58
// this is the age that we tolerate for updates (7 days)
50
59
#define OUTDATED_NAG_AGE 60*60*24*7
51
60
 
52
61
// this is the time we wait when we found outdated information for 
54
63
#define OUTDATED_NAG_WAIT 60*60*2
55
64
 
56
65
// this is the script and the time to run the release-upgrades checker
57
 
#define RELEASE_UPGRADE_CHECKER "/usr/lib/update-manager/check-new-release-gtk"
58
 
#define RELEASE_UPGRADE_CHECK_WAIT 60*60*24*2
 
66
#define RELEASE_UPGRADE_CHECKER "/usr/lib/ubuntu-release-upgrader/check-new-release-gtk"
 
67
#define RELEASE_UPGRADE_CHECK_WAIT 60*60*24*14
 
68
 
 
69
// cache-changed plugin dir
 
70
#define CACHE_CHANGED_PLUGIN_DIR "/usr/share/update-notifier/plugins/cache-changed"
59
71
 
60
72
#if 0
61
73
// testing
63
75
#define OUTDATED_NAG_WAIT 6
64
76
#endif
65
77
 
66
 
void invoke_with_gksu(const gchar *cmd, const gchar *descr, gboolean whole_message);
67
 
void invoke(const gchar *cmd, const gchar *desktop, gboolean with_gksu);
68
 
gboolean in_admin_group();
 
78
void invoke_with_pkexec(const gchar *cmd);
 
79
void invoke(const gchar *cmd, const gchar *desktop, gboolean with_pkexec);
 
80
gboolean in_admin_group(void);
69
81
 
70
82
typedef struct _TrayApplet TrayApplet;
 
83
typedef struct _UpgradeNotifier UpgradeNotifier;
 
84
 
71
85
struct _TrayApplet 
72
86
{
 
87
   GObject me;
 
88
   UpgradeNotifier *un;
 
89
#ifdef HAVE_APP_INDICATOR
 
90
   AppIndicator *indicator;
 
91
#else
73
92
   GtkStatusIcon *tray_icon;
 
93
#endif
74
94
   GtkWidget *menu;
75
95
   char *name;
76
96
   void *user_data;
77
97
};
78
98
 
79
 
typedef struct _UpgradeNotifier UpgradeNotifier;
80
99
struct _UpgradeNotifier
81
100
{
 
101
   GSettings *settings;
 
102
 
82
103
   TrayApplet *update;
83
 
   TrayApplet *reboot;
84
104
   TrayApplet *hook;
85
105
   TrayApplet *crashreport;
86
 
 
87
 
   GConfClient *gconf;
88
 
 
89
 
   guint update_finished_timer; 
90
 
 
91
 
   
 
106
   TrayApplet *livepatch;
 
107
 
 
108
   guint update_finished_timer;
 
109
 
92
110
   // some states for the file montioring (these field
93
111
   // are the state for the current "time-slice")
94
112
   gboolean dpkg_was_run;
95
 
   gboolean apt_get_runing;
 
113
   gboolean apt_get_running;
96
114
 
97
115
   // these field are "global" (time-wise)
98
 
   gboolean reboot_pending;
99
116
   gboolean hook_pending;
100
117
   gboolean crashreport_pending;
101
118
   gboolean unicast_local_avahi_pending;
 
119
   gboolean livepatch_pending;
102
120
   time_t last_apt_action;
103
121
 
104
122
};