23
23
#include <gtk/gtk.h>
24
24
#include <glib/gi18n.h>
25
#include <gconf/gconf.h>
26
#include <gconf/gconf-client.h>
28
#ifdef HAVE_APP_INDICATOR
29
#include <libappindicator/app-indicator.h>
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"
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"
42
#define SETTINGS_UM_SCHEMA "com.ubuntu.update-manager"
43
#define SETTINGS_UM_KEY_LAST_LAUNCH "launch-time"
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"
46
55
// security update autolaunch minimal time (12h)
47
56
#define AUTOLAUNCH_MINIMAL_SECURITY_INTERVAL 12*60*60
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
52
61
// this is the time we wait when we found outdated information for
54
63
#define OUTDATED_NAG_WAIT 60*60*2
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
69
// cache-changed plugin dir
70
#define CACHE_CHANGED_PLUGIN_DIR "/usr/share/update-notifier/plugins/cache-changed"
63
75
#define OUTDATED_NAG_WAIT 6
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);
70
82
typedef struct _TrayApplet TrayApplet;
83
typedef struct _UpgradeNotifier UpgradeNotifier;
89
#ifdef HAVE_APP_INDICATOR
90
AppIndicator *indicator;
73
92
GtkStatusIcon *tray_icon;
79
typedef struct _UpgradeNotifier UpgradeNotifier;
80
99
struct _UpgradeNotifier
82
103
TrayApplet *update;
85
105
TrayApplet *crashreport;
89
guint update_finished_timer;
106
TrayApplet *livepatch;
108
guint update_finished_timer;
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;
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;