projects/package-update-indicator

changeset 10:adba37525ee5

Notify about required session or system restarts

Follow all PackageKit transactions and indicate when a session or system
restart is required.
Generate enum types with glib-mkenums.
author Guido Berhoerster <guido+pui@berhoerster.name>
date Fri Jul 06 14:12:46 2018 +0200 (23 months ago)
parents b571e7ade208
children 7f995e958703
files Makefile po/POTFILES.in po/de.po po/en.po po/id.po pui-application.c pui-application.h pui-backend.c pui-backend.h pui-types.c pui-types.c.in pui-types.h pui-types.h.in
line diff
     1.1 --- a/Makefile	Wed Jul 04 17:08:47 2018 +0200
     1.2 +++ b/Makefile	Fri Jul 06 14:12:46 2018 +0200
     1.3 @@ -50,6 +50,7 @@
     1.4  SED :=		sed
     1.5  GLIB_COMPILE_SCHEMAS := $(shell pkg-config --variable=glib_compile_schemas gio-2.0)
     1.6  GLIB_COMPILE_RESOURCES := $(shell pkg-config --variable=glib_compile_resources gio-2.0)
     1.7 +GLIB_MKENUMS :=	$(shell pkg-config --variable=glib_mkenums glib-2.0)
     1.8  XSLTPROC :=	xsltproc
     1.9  DOCBOOK5_MANPAGES_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
    1.10  DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \
    1.11 @@ -113,6 +114,14 @@
    1.12  
    1.13  OBJS = $($(PACKAGE)_OBJS) $($(PACKAGE)-prefs_OBJS)
    1.14  
    1.15 +ENUM_DEPS =	pui-backend.h \
    1.16 +		pui-application.h
    1.17 +
    1.18 +ENUM_HEADER =	pui-types.h
    1.19 +
    1.20 +ENUM_FILES =	$(ENUM_HEADER) \
    1.21 +		pui-types.c
    1.22 +
    1.23  GSETTINGS_SCHEMAS = $(APPLICATION_ID).gschema.xml
    1.24  
    1.25  GRESOURCE_FILES = pui-prefs.gresource.xml
    1.26 @@ -176,6 +185,14 @@
    1.27  $(PACKAGE)-prefs: $($(PACKAGE)-prefs_OBJS)
    1.28  	$(LINK.o) $^ $(LDLIBS) -o $@
    1.29  
    1.30 +$(OBJS): $(ENUM_HEADER)
    1.31 +
    1.32 +%-types.h: %-types.h.in $(ENUM_DEPS)
    1.33 +	$(GLIB_MKENUMS) --template $< >$@ $(filter-out $<,$^)
    1.34 +
    1.35 +%-types.c: %-types.c.in $(ENUM_DEPS)
    1.36 +	$(GLIB_MKENUMS) --template $< >$@ $(filter-out $<,$^)
    1.37 +
    1.38  %-resources.c: %.gresource.xml
    1.39  	$(GLIB_COMPILE_RESOURCES) --generate-dependencies $< | \
    1.40  	    while read -r resource_file; do \
    1.41 @@ -231,8 +248,8 @@
    1.42  	done
    1.43  
    1.44  clean:
    1.45 -	rm -f $(PACKAGE) $(OBJS) $(AUTOSTART_FILE) $(DESKTOP_FILES) $(POTFILE) \
    1.46 -	    $(MOFILES) $(MANPAGES)
    1.47 +	rm -f $(PACKAGE) $(OBJS) $(ENUM_FILES) $(AUTOSTART_FILE) \
    1.48 +	    $(DESKTOP_FILES) $(POTFILE) $(MOFILES) $(MANPAGES)
    1.49  
    1.50  clobber: clean
    1.51  	rm -f $(patsubst %.o,%.d,$(OBJS))
     2.1 --- a/po/POTFILES.in	Wed Jul 04 17:08:47 2018 +0200
     2.2 +++ b/po/POTFILES.in	Fri Jul 06 14:12:46 2018 +0200
     2.3 @@ -11,4 +11,4 @@
     2.4  pui-prefs-application.c
     2.5  pui-prefs-window.ui
     2.6  pui-settings.c
     2.7 -pui-types.c
     2.8 +pui-types.c.in
     3.1 --- a/po/de.po	Wed Jul 04 17:08:47 2018 +0200
     3.2 +++ b/po/de.po	Fri Jul 06 14:12:46 2018 +0200
     3.3 @@ -8,7 +8,7 @@
     3.4  "Project-Id-Version: package-update-indicator 1\n"
     3.5  "Report-Msgid-Bugs-To: guido+pui@berhoerster.name\n"
     3.6  "POT-Creation-Date: 2018-07-04 13:39+0000\n"
     3.7 -"PO-Revision-Date: 2018-07-04 13:39+0000\n"
     3.8 +"PO-Revision-Date: 2018-07-06 12:10+0000\n"
     3.9  "Last-Translator: Guido Berhoerster <guido+pui@berhoerster.name>\n"
    3.10  "Language-Team: none\n"
    3.11  "Language: de\n"
    3.12 @@ -85,71 +85,88 @@
    3.13  msgid "Translator"
    3.14  msgstr "Guido Berhörster"
    3.15  
    3.16 -#: pui-application.c:71
    3.17 +#: pui-application.c:73
    3.18  msgid "Enable debugging messages"
    3.19  msgstr "Debugging-Nachrichten aktivieren"
    3.20  
    3.21 -#: pui-application.c:73
    3.22 +#: pui-application.c:75
    3.23  msgid "Quit running instance of Package Update Indicator"
    3.24  msgstr "Beende laufende Instanz der Paketaktualisierungsanzeige"
    3.25  
    3.26 -#: pui-application.c:75
    3.27 +#: pui-application.c:77
    3.28  msgid "Print the version number and quit"
    3.29  msgstr "Versionsnummer zeigen und beenden"
    3.30  
    3.31 -#: pui-application.c:228
    3.32 +#: pui-application.c:232
    3.33  msgid "Up to Date"
    3.34  msgstr "Auf dem neuesten Stand"
    3.35  
    3.36 -#: pui-application.c:229
    3.37 +#: pui-application.c:233
    3.38  msgid "The system is up to date."
    3.39  msgstr "Das System ist auf dem neuesten Stand"
    3.40  
    3.41 -#: pui-application.c:232
    3.42 +#: pui-application.c:236
    3.43  msgid "Software Update"
    3.44  msgid_plural "Software Updates"
    3.45  msgstr[0] "Softwareaktualisierung"
    3.46  msgstr[1] "Softwareaktualisierungen"
    3.47  
    3.48 -#: pui-application.c:235
    3.49 +#: pui-application.c:239
    3.50  msgid "There is a software update avaliable."
    3.51  msgstr "Es ist eine Softwareaktualisierung verfügbar."
    3.52  
    3.53 -#: pui-application.c:238
    3.54 +#: pui-application.c:242
    3.55  #, c-format
    3.56  msgid "There are %u software updates avaliable."
    3.57  msgstr "Es sind %u Softwareaktualisierungen verfügbar."
    3.58  
    3.59 -#: pui-application.c:243
    3.60 +#: pui-application.c:247
    3.61  msgid "Important Software Update"
    3.62  msgid_plural "Important Software Updates"
    3.63  msgstr[0] "Wichtige Softwareaktualisierung"
    3.64  msgstr[1] "Wichtige Softwareaktualisierungen"
    3.65  
    3.66 -#: pui-application.c:246
    3.67 +#: pui-application.c:250
    3.68  msgid "There is an important software update available."
    3.69  msgstr "Es ist eine wichtige Softwareaktualisierung verfügbar."
    3.70  
    3.71 -#: pui-application.c:249
    3.72 +#: pui-application.c:253
    3.73  #, c-format
    3.74  msgid "There are %u important software updates available."
    3.75  msgstr "Es sind %u wichtige Softwareaktualisierungen verfügbar."
    3.76  
    3.77 -#: pui-application.c:253
    3.78 +#: pui-application.c:257
    3.79  #, c-format
    3.80  msgid "There are %u software updates available, one of them is important."
    3.81  msgstr "Es sind %u Softwareaktualisierungen verfügbar, eine davon ist wichtig."
    3.82  
    3.83 -#: pui-application.c:258
    3.84 +#: pui-application.c:262
    3.85  #, c-format
    3.86  msgid "There are %u software updates available, %u of them are important."
    3.87  msgstr "Es sind %u Softwareaktualisierungen verfügbar, %u davon sind wichtig."
    3.88  
    3.89 -#: pui-application.c:306
    3.90 +#: pui-application.c:270
    3.91 +msgid "Logout Required"
    3.92 +msgstr "Abmeldung erforderlich"
    3.93 +
    3.94 +#: pui-application.c:271
    3.95 +msgid "You need to log out and back in for the update to take effect."
    3.96 +msgstr ""
    3.97 +"Sie müssen sich aus- und wieder einloggen, damit das Update wirksam wird."
    3.98 +
    3.99 +#: pui-application.c:275
   3.100 +msgid "Restart Required"
   3.101 +msgstr "Neutstart Erforderlich"
   3.102 +
   3.103 +#: pui-application.c:276
   3.104 +msgid "The computer has to be restarted for the updates to take effect."
   3.105 +msgstr "Der Computer muss neu gestarte werden damit die Updates wirksam werden."
   3.106 +
   3.107 +#: pui-application.c:324
   3.108  msgid "Install Updates"
   3.109  msgstr "Installiere Updates"
   3.110  
   3.111 -#: pui-application.c:403
   3.112 +#: pui-application.c:434
   3.113  msgid "Update notifications are not supported."
   3.114  msgstr "Aktualisierungsbenachrichtigungen werden nicht unterstützt."
   3.115  
     4.1 --- a/po/en.po	Wed Jul 04 17:08:47 2018 +0200
     4.2 +++ b/po/en.po	Fri Jul 06 14:12:46 2018 +0200
     4.3 @@ -8,7 +8,7 @@
     4.4  "Project-Id-Version: package-update-indicator 1\n"
     4.5  "Report-Msgid-Bugs-To: guido+pui@berhoerster.name\n"
     4.6  "POT-Creation-Date: 2018-07-04 13:39+0000\n"
     4.7 -"PO-Revision-Date: 2018-07-04 13:39+0000\n"
     4.8 +"PO-Revision-Date: 2018-07-06 12:10+0000\n"
     4.9  "Last-Translator: Guido Berhoerster <guido+pui@berhoerster.name>\n"
    4.10  "Language-Team: none\n"
    4.11  "Language: en\n"
    4.12 @@ -83,71 +83,87 @@
    4.13  msgid "Translator"
    4.14  msgstr "Translator"
    4.15  
    4.16 -#: pui-application.c:71
    4.17 +#: pui-application.c:73
    4.18  msgid "Enable debugging messages"
    4.19  msgstr "Enable debugging messages"
    4.20  
    4.21 -#: pui-application.c:73
    4.22 +#: pui-application.c:75
    4.23  msgid "Quit running instance of Package Update Indicator"
    4.24  msgstr "Quit running instance of Package Update Indicator"
    4.25  
    4.26 -#: pui-application.c:75
    4.27 +#: pui-application.c:77
    4.28  msgid "Print the version number and quit"
    4.29  msgstr "Print the version number and quit"
    4.30  
    4.31 -#: pui-application.c:228
    4.32 +#: pui-application.c:232
    4.33  msgid "Up to Date"
    4.34  msgstr "Up to Date"
    4.35  
    4.36 -#: pui-application.c:229
    4.37 +#: pui-application.c:233
    4.38  msgid "The system is up to date."
    4.39  msgstr "The system is up to date."
    4.40  
    4.41 -#: pui-application.c:232
    4.42 +#: pui-application.c:236
    4.43  msgid "Software Update"
    4.44  msgid_plural "Software Updates"
    4.45  msgstr[0] "Software Update"
    4.46  msgstr[1] "Software Updates"
    4.47  
    4.48 -#: pui-application.c:235
    4.49 +#: pui-application.c:239
    4.50  msgid "There is a software update avaliable."
    4.51  msgstr "There is a software update avaliable."
    4.52  
    4.53 -#: pui-application.c:238
    4.54 +#: pui-application.c:242
    4.55  #, c-format
    4.56  msgid "There are %u software updates avaliable."
    4.57  msgstr "There are %u software updates avaliable."
    4.58  
    4.59 -#: pui-application.c:243
    4.60 +#: pui-application.c:247
    4.61  msgid "Important Software Update"
    4.62  msgid_plural "Important Software Updates"
    4.63  msgstr[0] "Important Software Update"
    4.64  msgstr[1] "Important Software Updates"
    4.65  
    4.66 -#: pui-application.c:246
    4.67 +#: pui-application.c:250
    4.68  msgid "There is an important software update available."
    4.69  msgstr "There is an important software update available."
    4.70  
    4.71 -#: pui-application.c:249
    4.72 +#: pui-application.c:253
    4.73  #, c-format
    4.74  msgid "There are %u important software updates available."
    4.75  msgstr "There are %u important software updates available."
    4.76  
    4.77 -#: pui-application.c:253
    4.78 +#: pui-application.c:257
    4.79  #, c-format
    4.80  msgid "There are %u software updates available, one of them is important."
    4.81  msgstr "There are %u software updates available, one of them is important."
    4.82  
    4.83 -#: pui-application.c:258
    4.84 +#: pui-application.c:262
    4.85  #, c-format
    4.86  msgid "There are %u software updates available, %u of them are important."
    4.87  msgstr "There are %u software updates available, %u of them are important."
    4.88  
    4.89 -#: pui-application.c:306
    4.90 +#: pui-application.c:270
    4.91 +msgid "Logout Required"
    4.92 +msgstr "Logout Required"
    4.93 +
    4.94 +#: pui-application.c:271
    4.95 +msgid "You need to log out and back in for the update to take effect."
    4.96 +msgstr "You need to log out and back in for the update to take effect."
    4.97 +
    4.98 +#: pui-application.c:275
    4.99 +msgid "Restart Required"
   4.100 +msgstr "Restart Required"
   4.101 +
   4.102 +#: pui-application.c:276
   4.103 +msgid "The computer has to be restarted for the updates to take effect."
   4.104 +msgstr "The computer has to be restarted for the updates to take effect."
   4.105 +
   4.106 +#: pui-application.c:324
   4.107  msgid "Install Updates"
   4.108  msgstr "Install Updates"
   4.109  
   4.110 -#: pui-application.c:403
   4.111 +#: pui-application.c:434
   4.112  msgid "Update notifications are not supported."
   4.113  msgstr "Update notifications are not supported."
   4.114  
     5.1 --- a/po/id.po	Wed Jul 04 17:08:47 2018 +0200
     5.2 +++ b/po/id.po	Fri Jul 06 14:12:46 2018 +0200
     5.3 @@ -8,7 +8,7 @@
     5.4  "Project-Id-Version: package-update-indicator 1\n"
     5.5  "Report-Msgid-Bugs-To: guido+pui@berhoerster.name\n"
     5.6  "POT-Creation-Date: 2018-07-04 13:39+0000\n"
     5.7 -"PO-Revision-Date: 2018-07-04 13:39+0000\n"
     5.8 +"PO-Revision-Date: 2018-07-06 12:10+0000\n"
     5.9  "Last-Translator: Guido Berhoerster <guido+pui@berhoerster.name>\n"
    5.10  "Language-Team: none\n"
    5.11  "Language: id\n"
    5.12 @@ -83,75 +83,91 @@
    5.13  msgid "Translator"
    5.14  msgstr "Guido Berhörster"
    5.15  
    5.16 -#: pui-application.c:71
    5.17 +#: pui-application.c:73
    5.18  msgid "Enable debugging messages"
    5.19  msgstr ""
    5.20  
    5.21 -#: pui-application.c:73
    5.22 +#: pui-application.c:75
    5.23  msgid "Quit running instance of Package Update Indicator"
    5.24  msgstr ""
    5.25  
    5.26 -#: pui-application.c:75
    5.27 +#: pui-application.c:77
    5.28  msgid "Print the version number and quit"
    5.29  msgstr "Tampilkan nomor versi dan keluar"
    5.30  
    5.31 -#: pui-application.c:228
    5.32 +#: pui-application.c:232
    5.33  msgid "Up to Date"
    5.34  msgstr "Up-to-date"
    5.35  
    5.36 -#: pui-application.c:229
    5.37 +#: pui-application.c:233
    5.38  msgid "The system is up to date."
    5.39  msgstr "Sistemnya telah up-to-date."
    5.40  
    5.41 -#: pui-application.c:232
    5.42 +#: pui-application.c:236
    5.43  msgid "Software Update"
    5.44  msgid_plural "Software Updates"
    5.45  msgstr[0] "Pembaharuan Perangkat Lunak"
    5.46  msgstr[1] "Pembaharuan-Pembaharuan Perangkat Lunak"
    5.47  
    5.48 -#: pui-application.c:235
    5.49 +#: pui-application.c:239
    5.50  msgid "There is a software update avaliable."
    5.51  msgstr "Tersedia satu pembaharuan perangkat lunak."
    5.52  
    5.53 -#: pui-application.c:238
    5.54 +#: pui-application.c:242
    5.55  #, c-format
    5.56  msgid "There are %u software updates avaliable."
    5.57  msgstr "Tersedia %u pembaharuan-pembaharuan perangkat lunak."
    5.58  
    5.59 -#: pui-application.c:243
    5.60 +#: pui-application.c:247
    5.61  msgid "Important Software Update"
    5.62  msgid_plural "Important Software Updates"
    5.63  msgstr[0] "Perangkat Lunak Pembaharuan yang penting"
    5.64  msgstr[1] "Perangkat Lunak Pembaharuan-Pembaharuan yang penting"
    5.65  
    5.66 -#: pui-application.c:246
    5.67 +#: pui-application.c:250
    5.68  msgid "There is an important software update available."
    5.69  msgstr "Tersedia satu pembaharuan perangkat lunak yang penting."
    5.70  
    5.71 -#: pui-application.c:249
    5.72 +#: pui-application.c:253
    5.73  #, c-format
    5.74  msgid "There are %u important software updates available."
    5.75  msgstr "Tersedia %u pembaharuan-pembaharuan perangkat lunak yang penting."
    5.76  
    5.77 -#: pui-application.c:253
    5.78 +#: pui-application.c:257
    5.79  #, c-format
    5.80  msgid "There are %u software updates available, one of them is important."
    5.81  msgstr ""
    5.82  "Tersedia %u pembaharuan-pembaharuan perangkat lunak, diantaranya satu yang "
    5.83  "penting."
    5.84  
    5.85 -#: pui-application.c:258
    5.86 +#: pui-application.c:262
    5.87  #, c-format
    5.88  msgid "There are %u software updates available, %u of them are important."
    5.89  msgstr ""
    5.90  "Tersedia %u pembaharuan-pembaharuan perangkat lunak, diantaranya %u yang "
    5.91  "penting."
    5.92  
    5.93 -#: pui-application.c:306
    5.94 +#: pui-application.c:270
    5.95 +msgid "Logout Required"
    5.96 +msgstr "Diperlukan Log Keluar"
    5.97 +
    5.98 +#: pui-application.c:271
    5.99 +msgid "You need to log out and back in for the update to take effect."
   5.100 +msgstr ""
   5.101 +
   5.102 +#: pui-application.c:275
   5.103 +msgid "Restart Required"
   5.104 +msgstr "Diperlukan Reboot"
   5.105 +
   5.106 +#: pui-application.c:276
   5.107 +msgid "The computer has to be restarted for the updates to take effect."
   5.108 +msgstr ""
   5.109 +
   5.110 +#: pui-application.c:324
   5.111  msgid "Install Updates"
   5.112  msgstr "Pasang Perangkat Lunak Pembaharuan-Pembaharuan"
   5.113  
   5.114 -#: pui-application.c:403
   5.115 +#: pui-application.c:434
   5.116  msgid "Update notifications are not supported."
   5.117  msgstr "Pemberitahuan pembaharuan-pembaharuan tidak didukung."
   5.118  
     6.1 --- a/pui-application.c	Wed Jul 04 17:08:47 2018 +0200
     6.2 +++ b/pui-application.c	Fri Jul 06 14:12:46 2018 +0200
     6.3 @@ -63,6 +63,8 @@
     6.4      [PUI_STATE_UP_TO_DATE] = "system-software-update",
     6.5      [PUI_STATE_NORMAL_UPDATES_AVAILABLE] = "software-update-available",
     6.6      [PUI_STATE_IMPORTANT_UPDATES_AVAILABLE] = "software-update-urgent",
     6.7 +    [PUI_STATE_SESSION_RESTART_REQUIRED] = "system-log-out",
     6.8 +    [PUI_STATE_SYSTEM_RESTART_REQUIRED] = "system-reboot",
     6.9      [PUI_STATE_ERROR] = "dialog-warning"
    6.10  };
    6.11  
    6.12 @@ -208,6 +210,8 @@
    6.13  	switch (self->state) {
    6.14  	case PUI_STATE_INITIAL:				/* FALLTHGROUGH */
    6.15  	case PUI_STATE_UP_TO_DATE:			/* FALLTHGROUGH */
    6.16 +	case PUI_STATE_SESSION_RESTART_REQUIRED:	/* FALLTHGROUGH */
    6.17 +	case PUI_STATE_SYSTEM_RESTART_REQUIRED:		/* FALLTHGROUGH */
    6.18  	case PUI_STATE_ERROR:
    6.19  		g_simple_action_set_enabled(install_updates_action, FALSE);
    6.20  		break;
    6.21 @@ -262,6 +266,16 @@
    6.22  			    important_updates);
    6.23  		}
    6.24  		break;
    6.25 +	case PUI_STATE_SESSION_RESTART_REQUIRED:
    6.26 +		title = g_strdup(_("Logout Required"));
    6.27 +		body = g_strdup(_("You need to log out and back in for the "
    6.28 +		    "update to take effect."));
    6.29 +		break;
    6.30 +	case PUI_STATE_SYSTEM_RESTART_REQUIRED:
    6.31 +		title = g_strdup(_("Restart Required"));
    6.32 +		body = g_strdup(_("The computer has to be restarted for the "
    6.33 +		    "updates to take effect."));
    6.34 +		break;
    6.35  	case PUI_STATE_ERROR:
    6.36  		title = g_strdup(self->error_message);
    6.37  		break;
    6.38 @@ -276,6 +290,8 @@
    6.39  	case PUI_STATE_UP_TO_DATE:			/* FALLTHGROUGH */
    6.40  	case PUI_STATE_NORMAL_UPDATES_AVAILABLE:	/* FALLTHGROUGH */
    6.41  	case PUI_STATE_IMPORTANT_UPDATES_AVAILABLE:	/* FALLTHGROUGH */
    6.42 +	case PUI_STATE_SESSION_RESTART_REQUIRED:	/* FALLTHGROUGH */
    6.43 +	case PUI_STATE_SYSTEM_RESTART_REQUIRED:		/* FALLTHGROUGH */
    6.44  	case PUI_STATE_ERROR:
    6.45  		app_indicator_set_status(self->indicator,
    6.46  		    APP_INDICATOR_STATUS_ACTIVE);
    6.47 @@ -291,10 +307,12 @@
    6.48  	case PUI_STATE_ERROR:
    6.49  		/* withdraw exisiting notification */
    6.50  		g_application_withdraw_notification(application,
    6.51 -		    "package-updates");
    6.52 +		    "package-updates-or-restart-required");
    6.53  		break;
    6.54  	case PUI_STATE_NORMAL_UPDATES_AVAILABLE:	/* FALLTHGROUGH */
    6.55 -	case PUI_STATE_IMPORTANT_UPDATES_AVAILABLE:
    6.56 +	case PUI_STATE_IMPORTANT_UPDATES_AVAILABLE:	/* FALLTHGROUGH */
    6.57 +	case PUI_STATE_SESSION_RESTART_REQUIRED:	/* FALLTHGROUGH */
    6.58 +	case PUI_STATE_SYSTEM_RESTART_REQUIRED:
    6.59  		/* create notification */
    6.60  		notification = g_notification_new(title);
    6.61  		g_notification_set_body(notification, body);
    6.62 @@ -306,8 +324,8 @@
    6.63  			    _("Install Updates"),
    6.64  			    "app.install-updates");
    6.65  		}
    6.66 -		g_application_send_notification(application, "package-updates",
    6.67 -		    notification);
    6.68 +		g_application_send_notification(application,
    6.69 +		    "package-updates-or-restart-required", notification);
    6.70  		break;
    6.71  	}
    6.72  
    6.73 @@ -326,6 +344,7 @@
    6.74  transition_state(PuiApplication *self)
    6.75  {
    6.76  	PuiState	state = self->state;
    6.77 +	PuiRestart	restart_type;
    6.78  	guint		important_updates;
    6.79  	guint		normal_updates;
    6.80  	gchar		*old_state;
    6.81 @@ -341,10 +360,14 @@
    6.82  			break;
    6.83  		}
    6.84  
    6.85 -		g_object_get(self->backend,
    6.86 +		g_object_get(self->backend, "restart-type", &restart_type,
    6.87  		    "important-updates", &important_updates,
    6.88  		    "normal-updates", &normal_updates, NULL);
    6.89 -		if (important_updates > 0) {
    6.90 +		if (restart_type == PUI_RESTART_SESSION) {
    6.91 +			state = PUI_STATE_SESSION_RESTART_REQUIRED;
    6.92 +		} else if (restart_type == PUI_RESTART_SYSTEM) {
    6.93 +			state = PUI_STATE_SYSTEM_RESTART_REQUIRED;
    6.94 +		} else if (important_updates > 0) {
    6.95  			state = PUI_STATE_IMPORTANT_UPDATES_AVAILABLE;
    6.96  		} else if (normal_updates > 0) {
    6.97  			state = PUI_STATE_NORMAL_UPDATES_AVAILABLE;
    6.98 @@ -352,6 +375,14 @@
    6.99  			state = PUI_STATE_UP_TO_DATE;
   6.100  		}
   6.101  		break;
   6.102 +	case PUI_STATE_SESSION_RESTART_REQUIRED:
   6.103 +		g_object_get(self->backend, "restart-type", &restart_type,
   6.104 +		    NULL);
   6.105 +		if (restart_type == PUI_RESTART_SYSTEM) {
   6.106 +			state = PUI_STATE_SYSTEM_RESTART_REQUIRED;
   6.107 +		}
   6.108 +		break;
   6.109 +	case PUI_STATE_SYSTEM_RESTART_REQUIRED:		/* FALLTHROUGH */
   6.110  	case PUI_STATE_ERROR:
   6.111  		break;
   6.112  	}
     7.1 --- a/pui-application.h	Wed Jul 04 17:08:47 2018 +0200
     7.2 +++ b/pui-application.h	Fri Jul 06 14:12:46 2018 +0200
     7.3 @@ -34,6 +34,17 @@
     7.4  G_DECLARE_FINAL_TYPE(PuiApplication, pui_application, PUI, APPLICATION,
     7.5      GApplication)
     7.6  
     7.7 +typedef enum {
     7.8 +    PUI_STATE_INITIAL,
     7.9 +    PUI_STATE_UP_TO_DATE,
    7.10 +    PUI_STATE_NORMAL_UPDATES_AVAILABLE,
    7.11 +    PUI_STATE_IMPORTANT_UPDATES_AVAILABLE,
    7.12 +    PUI_STATE_SESSION_RESTART_REQUIRED,
    7.13 +    PUI_STATE_SYSTEM_RESTART_REQUIRED,
    7.14 +    PUI_STATE_ERROR,
    7.15 +    PUI_STATE_LAST
    7.16 +} PuiState;
    7.17 +
    7.18  PuiApplication *	pui_application_new(void);
    7.19  
    7.20  G_END_DECLS
     8.1 --- a/pui-backend.c	Wed Jul 04 17:08:47 2018 +0200
     8.2 +++ b/pui-backend.c	Fri Jul 06 14:12:46 2018 +0200
     8.3 @@ -34,6 +34,7 @@
     8.4  #include "pui-common.h"
     8.5  #include "pui-backend.h"
     8.6  #include "pui-get-updates.h"
     8.7 +#include "pui-types.h"
     8.8  
     8.9  #define	LOW_BATTERY_THRESHOLD	10.0
    8.10  
    8.11 @@ -41,6 +42,8 @@
    8.12  	GObject		parent_instance;
    8.13  	PkControl	*pk_control;
    8.14  	GCancellable	*cancellable;
    8.15 +	PkClient	*pk_client;
    8.16 +	PkTransactionList *transaction_list;
    8.17  	UpClient	*up_client;
    8.18  	UpDevice	*up_device;
    8.19  	gchar		*proxy_http;
    8.20 @@ -58,6 +61,7 @@
    8.21  	gboolean	use_mobile_connection;
    8.22  	guint		important_updates;
    8.23  	guint		normal_updates;
    8.24 +	PuiRestart	restart_type;
    8.25  };
    8.26  
    8.27  static void	pui_backend_async_initable_iface_init(gpointer, gpointer);
    8.28 @@ -76,6 +80,7 @@
    8.29      PROP_0,
    8.30      PROP_IMPORTANT_UPDATES,
    8.31      PROP_NORMAL_UPDATES,
    8.32 +    PROP_RESTART_TYPE,
    8.33      PROP_REFRESH_INTERVAL,
    8.34      PROP_USE_MOBILE_CONNECTION,
    8.35      PROP_LAST
    8.36 @@ -276,6 +281,9 @@
    8.37  	case PROP_NORMAL_UPDATES:
    8.38  		g_value_set_uint(value, self->normal_updates);
    8.39  		break;
    8.40 +	case PROP_RESTART_TYPE:
    8.41 +		g_value_set_enum(value, self->restart_type);
    8.42 +		break;
    8.43  	case PROP_REFRESH_INTERVAL:
    8.44  		g_value_set_uint(value, self->refresh_interval);
    8.45  		break;
    8.46 @@ -298,6 +306,14 @@
    8.47  		self->periodic_check_id = 0;
    8.48  	}
    8.49  
    8.50 +	if (self->transaction_list != NULL) {
    8.51 +		g_clear_object(&self->transaction_list);
    8.52 +	}
    8.53 +
    8.54 +	if (self->pk_client != NULL) {
    8.55 +		g_clear_object(&self->pk_client);
    8.56 +	}
    8.57 +
    8.58  	if (self->cancellable != NULL) {
    8.59  		g_cancellable_cancel(self->cancellable);
    8.60  		g_clear_object(&self->cancellable);
    8.61 @@ -353,6 +369,11 @@
    8.62  	    "Number of available normal updates", 0, G_MAXUINT, 0,
    8.63  	    G_PARAM_READABLE);
    8.64  
    8.65 +	properties[PROP_RESTART_TYPE] =
    8.66 +	    g_param_spec_enum("restart-type", "Type of restart required",
    8.67 +	    "The Type of restart required", PUI_TYPE_RESTART, PUI_RESTART_NONE,
    8.68 +	    G_PARAM_READABLE);
    8.69 +
    8.70  	properties[PROP_REFRESH_INTERVAL] =
    8.71  	    g_param_spec_uint("refresh-interval", "Refresh interval",
    8.72  	    "Interval in seconds for refreshing the package cache", 0,
    8.73 @@ -382,6 +403,8 @@
    8.74  {
    8.75  	self->pk_control = pk_control_new();
    8.76  
    8.77 +	self->pk_client = pk_client_new();
    8.78 +
    8.79  	self->inhibited = TRUE;
    8.80  
    8.81  	self->up_client = up_client_new();
    8.82 @@ -470,6 +493,8 @@
    8.83  {
    8.84  	PuiBackend	*self = user_data;
    8.85  
    8.86 +	g_debug("number of updates changed");
    8.87 +
    8.88  	/*
    8.89  	 * schedule a check after a short delay so that a rapid succession of
    8.90  	 * signals is coalesced
    8.91 @@ -489,11 +514,85 @@
    8.92  {
    8.93  	PuiBackend	*self = user_data;
    8.94  
    8.95 +	/*
    8.96 +	 * do not restart package-update-indicator if a session or system
    8.97 +	 * restart is required since that iformation would be lost across the
    8.98 +	 * restart, rather keep running and risk errors when interacting with
    8.99 +	 * a newer version of the PackageKit daemon
   8.100 +	 */
   8.101 +	if (self->restart_type > PUI_RESTART_NONE) {
   8.102 +		return;
   8.103 +	}
   8.104 +
   8.105  	g_debug("emitting signal restart-required");
   8.106  	g_signal_emit(self, signals[RESTART_REQUIRED], 0);
   8.107  }
   8.108  
   8.109  static void
   8.110 +on_transaction_adopt_finish(GObject *source_object, GAsyncResult *result,
   8.111 +    gpointer user_data)
   8.112 +{
   8.113 +	PuiBackend	*self = user_data;
   8.114 +	PkClient	*pk_client = PK_CLIENT(source_object);
   8.115 +	PkResults	*results;
   8.116 +	GError		*error = NULL;
   8.117 +	PkRestartEnum	restart;
   8.118 +
   8.119 +	results = pk_client_generic_finish(pk_client, result, &error);
   8.120 +	if (results == NULL) {
   8.121 +		g_warning("failed to get transaction results: %s",
   8.122 +		    error->message);
   8.123 +		g_error_free(error);
   8.124 +		goto out;
   8.125 +	}
   8.126 +
   8.127 +	/* check if transaction requires a restart */
   8.128 +	restart = pk_results_get_require_restart_worst(results);
   8.129 +	switch (restart) {
   8.130 +	case PK_RESTART_ENUM_SESSION:		/* FALLTHROUGH */
   8.131 +	case PK_RESTART_ENUM_SECURITY_SESSION:
   8.132 +		if (self->restart_type < PUI_RESTART_SESSION) {
   8.133 +			self->restart_type = PUI_RESTART_SESSION;
   8.134 +			g_object_notify_by_pspec(G_OBJECT(self),
   8.135 +			    properties[PROP_RESTART_TYPE]);
   8.136 +			g_signal_emit(self, signals[STATE_CHANGED], 0);
   8.137 +		}
   8.138 +		break;
   8.139 +	case PK_RESTART_ENUM_SYSTEM:		/* FALLTHROUGH */
   8.140 +	case PK_RESTART_ENUM_SECURITY_SYSTEM:
   8.141 +		if (self->restart_type < PUI_RESTART_SYSTEM) {
   8.142 +			self->restart_type = PUI_RESTART_SYSTEM;
   8.143 +			g_object_notify_by_pspec(G_OBJECT(self),
   8.144 +			    properties[PROP_RESTART_TYPE]);
   8.145 +			g_signal_emit(self, signals[STATE_CHANGED], 0);
   8.146 +		}
   8.147 +		break;
   8.148 +	default:
   8.149 +		/* do nothing */
   8.150 +		break;
   8.151 +	}
   8.152 +
   8.153 +	g_debug("transaction finished, required restart: %s",
   8.154 +	    pk_restart_enum_to_string(restart));
   8.155 +
   8.156 +out:
   8.157 +	if (results != NULL) {
   8.158 +		g_object_unref(results);
   8.159 +	}
   8.160 +}
   8.161 +
   8.162 +static void
   8.163 +on_transaction_list_added(PkTransactionList *transaction_list,
   8.164 +    const gchar *transaction_id, gpointer user_data)
   8.165 +{
   8.166 +	PuiBackend	*self = user_data;
   8.167 +
   8.168 +	/* adopt transaction in order to monitor it for restart requirements */
   8.169 +	pk_client_adopt_async(self->pk_client, transaction_id, NULL, NULL,
   8.170 +	    NULL, on_transaction_adopt_finish, user_data);
   8.171 +}
   8.172 +
   8.173 +static void
   8.174  pui_backend_init_async(GAsyncInitable *initable, int io_priority,
   8.175      GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
   8.176  {
   8.177 @@ -546,6 +645,10 @@
   8.178  	/* get notifications when an application restart is required */
   8.179  	g_signal_connect(self->pk_control, "restart-schedule",
   8.180  	    G_CALLBACK(on_restart_schedule), self);
   8.181 +	/* get notifications when a transactions are added */
   8.182 +	self->transaction_list = pk_transaction_list_new();
   8.183 +	g_signal_connect(self->transaction_list, "added",
   8.184 +	    G_CALLBACK(on_transaction_list_added), self);
   8.185  
   8.186  	check_inhibit(self);
   8.187  
     9.1 --- a/pui-backend.h	Wed Jul 04 17:08:47 2018 +0200
     9.2 +++ b/pui-backend.h	Fri Jul 06 14:12:46 2018 +0200
     9.3 @@ -39,6 +39,13 @@
     9.4      PUI_BACKEND_ERROR_GET_UPDATES_NOT_IMPLEMENTED
     9.5  };
     9.6  
     9.7 +typedef enum {
     9.8 +    PUI_RESTART_NONE,
     9.9 +    PUI_RESTART_SESSION,
    9.10 +    PUI_RESTART_SYSTEM,
    9.11 +    PUI_RESTART_LAST
    9.12 +} PuiRestart;
    9.13 +
    9.14  GQuark		pui_backend_error_quark(void);
    9.15  void		pui_backend_new_async(GCancellable *, GAsyncReadyCallback,
    9.16      gpointer);
    10.1 --- a/pui-types.c	Wed Jul 04 17:08:47 2018 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,72 +0,0 @@
    10.4 -/*
    10.5 - * Copyright (C) 2018 Guido Berhoerster <guido+pui@berhoerster.name>
    10.6 - *
    10.7 - * Permission is hereby granted, free of charge, to any person obtaining
    10.8 - * a copy of this software and associated documentation files (the
    10.9 - * "Software"), to deal in the Software without restriction, including
   10.10 - * without limitation the rights to use, copy, modify, merge, publish,
   10.11 - * distribute, sublicense, and/or sell copies of the Software, and to
   10.12 - * permit persons to whom the Software is furnished to do so, subject to
   10.13 - * the following conditions:
   10.14 - *
   10.15 - * The above copyright notice and this permission notice shall be included
   10.16 - * in all copies or substantial portions of the Software.
   10.17 - *
   10.18 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   10.19 - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   10.20 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   10.21 - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   10.22 - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   10.23 - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   10.24 - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   10.25 - */
   10.26 -
   10.27 -#include "pui-types.h"
   10.28 -
   10.29 -#define	PUI_DEFINE_ENUM_VALUE(valuename, valuenick) \
   10.30 -    { valuename, #valuename, #valuenick },
   10.31 -#define PUI_DEFINE_ENUM_TYPE(EnumName, enum_name, values) \
   10.32 -    GType                                                                     \
   10.33 -    enum_name##_get_type(void)                                                \
   10.34 -    {                                                                         \
   10.35 -    	static volatile gsize g_define_type_id__volatile = 0;                 \
   10.36 -    	static const GEnumValue v[] = {                                       \
   10.37 -    	    values                                                            \
   10.38 -    	    { 0 }                                                             \
   10.39 -    	};                                                                    \
   10.40 -    	GType		g_define_type_id;                                     \
   10.41 -    	if (g_once_init_enter(&g_define_type_id__volatile)) {                 \
   10.42 -    		g_define_type_id =                                            \
   10.43 -    		    g_enum_register_static(g_intern_static_string(#EnumName), \
   10.44 -    		    v);                                                       \
   10.45 -    		g_once_init_leave(&g_define_type_id__volatile,                \
   10.46 -    		    g_define_type_id);                                        \
   10.47 -    	}                                                                     \
   10.48 -    	return (g_define_type_id__volatile);                                  \
   10.49 -    }
   10.50 -
   10.51 -PUI_DEFINE_ENUM_TYPE(PuiState, pui_state,
   10.52 -    PUI_DEFINE_ENUM_VALUE(PUI_STATE_UP_TO_DATE, "up-to-date")
   10.53 -    PUI_DEFINE_ENUM_VALUE(PUI_STATE_NORMAL_UPDATES_AVAILABLE,
   10.54 -    "normal-updates-available")
   10.55 -    PUI_DEFINE_ENUM_VALUE(PUI_STATE_IMPORTANT_UPDATES_AVAILABLE,
   10.56 -    "important-updates-available")
   10.57 -    PUI_DEFINE_ENUM_VALUE(PUI_STATE_ERROR, "error"))
   10.58 -
   10.59 -gchar *
   10.60 -pui_types_enum_to_string(GType type, gint value)
   10.61 -{
   10.62 -	GTypeClass	*type_class;
   10.63 -	GEnumValue	*enum_value;
   10.64 -
   10.65 -	type_class = g_type_class_ref(type);
   10.66 -
   10.67 -	g_return_val_if_fail(G_IS_ENUM_CLASS(type_class), NULL);
   10.68 -
   10.69 -	enum_value = g_enum_get_value(G_ENUM_CLASS(type_class), value);
   10.70 -	if (enum_value == NULL) {
   10.71 -		return (g_strdup_printf("%d", value));
   10.72 -	}
   10.73 -
   10.74 -	return (g_strdup(enum_value->value_nick));
   10.75 -}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/pui-types.c.in	Fri Jul 06 14:12:46 2018 +0200
    11.3 @@ -0,0 +1,61 @@
    11.4 +/*** BEGIN file-header ***/
    11.5 +#include "pui-types.h"
    11.6 +/*** END file-header ***/
    11.7 +
    11.8 +/*** BEGIN file-production ***/
    11.9 +
   11.10 +/* enumerations from "@filename@" */
   11.11 +#include "@filename@"
   11.12 +/*** END file-production ***/
   11.13 +
   11.14 +/*** BEGIN value-header ***/
   11.15 +
   11.16 +GType
   11.17 +@enum_name@_get_type (void)
   11.18 +{
   11.19 +	static volatile gsize g_define_type_id__volatile;
   11.20 +	GType		g_@type@_type_id;
   11.21 +
   11.22 +	if (g_once_init_enter(&g_define_type_id__volatile)) {
   11.23 +		static const G@Type@Value values[] = {
   11.24 +/*** END value-header ***/
   11.25 +
   11.26 +/*** BEGIN value-production ***/
   11.27 +		    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
   11.28 +/*** END value-production ***/
   11.29 +
   11.30 +/*** BEGIN value-tail ***/
   11.31 +		    { 0 }
   11.32 +		};
   11.33 +
   11.34 +		g_@type@_type_id = g_@type@_register_static(
   11.35 +		    g_intern_static_string("@EnumName@"), values);
   11.36 +
   11.37 +		g_once_init_leave(&g_define_type_id__volatile,
   11.38 +		    g_@type@_type_id);
   11.39 +	}
   11.40 +
   11.41 +	return (g_define_type_id__volatile);
   11.42 +}
   11.43 +/*** END value-tail ***/
   11.44 +
   11.45 +/*** BEGIN file-tail ***/
   11.46 +
   11.47 +gchar *
   11.48 +pui_types_enum_to_string(GType type, gint value)
   11.49 +{
   11.50 +	GTypeClass	*type_class;
   11.51 +	GEnumValue	*enum_value;
   11.52 +
   11.53 +	type_class = g_type_class_ref(type);
   11.54 +
   11.55 +	g_return_val_if_fail(G_IS_ENUM_CLASS(type_class), NULL);
   11.56 +
   11.57 +	enum_value = g_enum_get_value(G_ENUM_CLASS(type_class), value);
   11.58 +	if (enum_value == NULL) {
   11.59 +		return (g_strdup_printf("%d", value));
   11.60 +	}
   11.61 +
   11.62 +	return (g_strdup(enum_value->value_nick));
   11.63 +}
   11.64 +/*** END file-tail ***/
    12.1 --- a/pui-types.h	Wed Jul 04 17:08:47 2018 +0200
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,47 +0,0 @@
    12.4 -/*
    12.5 - * Copyright (C) 2018 Guido Berhoerster <guido+pui@berhoerster.name>
    12.6 - *
    12.7 - * Permission is hereby granted, free of charge, to any person obtaining
    12.8 - * a copy of this software and associated documentation files (the
    12.9 - * "Software"), to deal in the Software without restriction, including
   12.10 - * without limitation the rights to use, copy, modify, merge, publish,
   12.11 - * distribute, sublicense, and/or sell copies of the Software, and to
   12.12 - * permit persons to whom the Software is furnished to do so, subject to
   12.13 - * the following conditions:
   12.14 - *
   12.15 - * The above copyright notice and this permission notice shall be included
   12.16 - * in all copies or substantial portions of the Software.
   12.17 - *
   12.18 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   12.19 - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   12.20 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   12.21 - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   12.22 - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   12.23 - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   12.24 - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   12.25 - */
   12.26 -
   12.27 -#ifndef	PUI_TYPES_H
   12.28 -#define	PUI_TYPES_H
   12.29 -
   12.30 -#include <glib-object.h>
   12.31 -
   12.32 -G_BEGIN_DECLS
   12.33 -
   12.34 -#define	PUI_TYPE_STATE	(pui_state_get_type())
   12.35 -
   12.36 -typedef enum {
   12.37 -    PUI_STATE_INITIAL,
   12.38 -    PUI_STATE_UP_TO_DATE,
   12.39 -    PUI_STATE_NORMAL_UPDATES_AVAILABLE,
   12.40 -    PUI_STATE_IMPORTANT_UPDATES_AVAILABLE,
   12.41 -    PUI_STATE_ERROR,
   12.42 -    PUI_STATE_LAST
   12.43 -} PuiState;
   12.44 -
   12.45 -GType	pui_state_get_type(void);
   12.46 -gchar *	pui_types_enum_to_string(GType, gint);
   12.47 -
   12.48 -G_END_DECLS
   12.49 -
   12.50 -#endif /* !PUI_TYPES_H */
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/pui-types.h.in	Fri Jul 06 14:12:46 2018 +0200
    13.3 @@ -0,0 +1,28 @@
    13.4 +/*** BEGIN file-header ***/
    13.5 +#ifndef	PUI_TYPES_H
    13.6 +#define	PUI_TYPES_H
    13.7 +
    13.8 +#include <glib-object.h>
    13.9 +
   13.10 +G_BEGIN_DECLS
   13.11 +/*** END file-header ***/
   13.12 +
   13.13 +/*** BEGIN file-production ***/
   13.14 +
   13.15 +/* enumerations from "@filename@" */
   13.16 +/*** END file-production ***/
   13.17 +
   13.18 +/*** BEGIN value-header ***/
   13.19 +
   13.20 +#define	@ENUMPREFIX@_TYPE_@ENUMSHORT@	(@enum_name@_get_type())
   13.21 +GType	@enum_name@_get_type(void) G_GNUC_CONST;
   13.22 +/*** END value-header ***/
   13.23 +
   13.24 +/*** BEGIN file-tail ***/
   13.25 +
   13.26 +gchar *	pui_types_enum_to_string(GType, gint);
   13.27 +
   13.28 +G_END_DECLS
   13.29 +
   13.30 +#endif /* !PUI_TYPES_H */
   13.31 +/*** END file-tail ***/