Added reboot button for after successful update

Change-Id: Ia444132bd8ffc2ccde53efcdbcbd9f31c3f2a439
Reviewed-on: https://review.haiku-os.org/c/968
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
CodeforEvolution
2019-03-26 20:39:44 +00:00
committed by waddlesplash
parent e1b41d44a3
commit 134abee09e
7 changed files with 92 additions and 42 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src apps softwareupdater ; SubDir HAIKU_TOP src apps softwareupdater ;
UsePrivateHeaders interface shared package ; UsePrivateHeaders app interface shared package ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src servers package ] ; SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src servers package ] ;
@@ -9,7 +9,7 @@ resource app_version {
variety = B_APPV_BETA, variety = B_APPV_BETA,
internal = 0, internal = 0,
short_info = "SoftwareUpdater", short_info = "SoftwareUpdater",
long_info = "Software Updater ©2008-2017 Haiku" long_info = "Software Updater ©2008-2019 Haiku"
}; };
resource vector_icon { resource vector_icon {
@@ -1,10 +1,11 @@
/* /*
* Copyright 2016-2017 Haiku, Inc. All rights reserved. * Copyright 2016-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT license * Distributed under the terms of the MIT license
* *
* Authors: * Authors:
* Alexander von Gluck IV <[email protected]> * Alexander von Gluck IV <[email protected]>
* Brian Hill <[email protected]> * Brian Hill <[email protected]>
* Jacob Secunda
*/ */
@@ -20,6 +21,7 @@
#include <LayoutUtils.h> #include <LayoutUtils.h>
#include <Message.h> #include <Message.h>
#include <Roster.h> #include <Roster.h>
#include <RosterPrivate.h>
#include <Screen.h> #include <Screen.h>
#include <String.h> #include <String.h>
@@ -60,6 +62,8 @@ SoftwareUpdaterWindow::SoftwareUpdaterWindow()
fUpdateButton->MakeDefault(true); fUpdateButton->MakeDefault(true);
fCancelButton = new BButton(B_TRANSLATE("Cancel"), fCancelButton = new BButton(B_TRANSLATE("Cancel"),
new BMessage(kMsgCancel)); new BMessage(kMsgCancel));
fRebootButton = new BButton(B_TRANSLATE("Reboot"),
new BMessage(kMsgReboot));
fHeaderView = new BStringView("header", fHeaderView = new BStringView("header",
B_TRANSLATE("Checking for updates"), B_WILL_DRAW); B_TRANSLATE("Checking for updates"), B_WILL_DRAW);
@@ -104,6 +108,7 @@ SoftwareUpdaterWindow::SoftwareUpdaterWindow()
.AddGlue() .AddGlue()
.Add(fCancelButton) .Add(fCancelButton)
.Add(fUpdateButton) .Add(fUpdateButton)
.Add(fRebootButton)
.End() .End()
.End() .End()
.End(); .End();
@@ -113,6 +118,7 @@ SoftwareUpdaterWindow::SoftwareUpdaterWindow()
fPackagesLayoutItem = layout_item_for(fScrollView); fPackagesLayoutItem = layout_item_for(fScrollView);
fCancelButtonLayoutItem = layout_item_for(fCancelButton); fCancelButtonLayoutItem = layout_item_for(fCancelButton);
fUpdateButtonLayoutItem = layout_item_for(fUpdateButton); fUpdateButtonLayoutItem = layout_item_for(fUpdateButton);
fRebootButtonLayoutItem = layout_item_for(fRebootButton);
fDetailsCheckboxLayoutItem = layout_item_for(fDetailsCheckbox); fDetailsCheckboxLayoutItem = layout_item_for(fDetailsCheckbox);
_SetState(STATE_DISPLAY_STATUS); _SetState(STATE_DISPLAY_STATUS);
@@ -307,6 +313,33 @@ SoftwareUpdaterWindow::MessageReceived(BMessage* message)
break; break;
} }
case kMsgShowReboot:
{
fRebootButtonLayoutItem->SetVisible(true);
fRebootButton->SetLabel(B_TRANSLATE_COMMENT("Reboot",
"Button label"));
fRebootButton->MakeDefault(true);
break;
}
case kMsgReboot:
{
if (_GetState() != STATE_FINAL_MESSAGE)
break;
BRoster roster;
BRoster::Private rosterPrivate(roster);
status_t error = rosterPrivate.ShutDown(true, true, false);
if (error != B_OK) {
BAlert* alert = new BAlert("reboot request", B_TRANSLATE(
"For some reason, we could not reboot your computer."),
B_TRANSLATE("Ok"), NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
}
break;
}
case kMsgCancelResponse: case kMsgCancelResponse:
{ {
// Verify whether the cancel alert was confirmed // Verify whether the cancel alert was confirmed
@@ -567,6 +600,7 @@ SoftwareUpdaterWindow::_SetState(uint32 state)
fPackagesLayoutItem->SetVisible(false); fPackagesLayoutItem->SetVisible(false);
fDetailsCheckboxLayoutItem->SetVisible(false); fDetailsCheckboxLayoutItem->SetVisible(false);
fCancelButtonLayoutItem->SetVisible(false); fCancelButtonLayoutItem->SetVisible(false);
fRebootButtonLayoutItem->SetVisible(false);
} }
fCurrentState = state; fCurrentState = state;
@@ -1,10 +1,11 @@
/* /*
* Copyright 2016-2017 Haiku, Inc. All rights reserved. * Copyright 2016-2019 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT license * Distributed under the terms of the MIT license
* *
* Authors: * Authors:
* Alexander von Gluck IV <kallisti5@unixzen.com> * Alexander von Gluck IV <kallisti5@unixzen.com>
* Brian Hill <supernova@tycho.email> * Brian Hill <supernova@tycho.email>
* Jacob Secunda
*/ */
#ifndef _SOFTWARE_UPDATER_WINDOW_H #ifndef _SOFTWARE_UPDATER_WINDOW_H
#define _SOFTWARE_UPDATER_WINDOW_H #define _SOFTWARE_UPDATER_WINDOW_H
@@ -179,6 +180,7 @@ private:
BStringView* fDetailView; BStringView* fDetailView;
BButton* fUpdateButton; BButton* fUpdateButton;
BButton* fCancelButton; BButton* fCancelButton;
BButton* fRebootButton;
BStatusBar* fStatusBar; BStatusBar* fStatusBar;
PackageListView* fListView; PackageListView* fListView;
BScrollView* fScrollView; BScrollView* fScrollView;
@@ -188,6 +190,7 @@ private:
BLayoutItem* fProgressLayoutItem; BLayoutItem* fProgressLayoutItem;
BLayoutItem* fCancelButtonLayoutItem; BLayoutItem* fCancelButtonLayoutItem;
BLayoutItem* fUpdateButtonLayoutItem; BLayoutItem* fUpdateButtonLayoutItem;
BLayoutItem* fRebootButtonLayoutItem;
BLayoutItem* fDetailsCheckboxLayoutItem; BLayoutItem* fDetailsCheckboxLayoutItem;
uint32 fCurrentState; uint32 fCurrentState;
+12 -3
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2013-2017, Haiku, Inc. All Rights Reserved. * Copyright 2013-2019, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -7,6 +7,7 @@
* Rene Gollent <rene@gollent.com> * Rene Gollent <rene@gollent.com>
* Ingo Weinhold <ingo_weinhold@gmx.de> * Ingo Weinhold <ingo_weinhold@gmx.de>
* Brian Hill <supernova@tycho.email> * Brian Hill <supernova@tycho.email>
* Jacob Secunda
*/ */
@@ -376,8 +377,16 @@ UpdateManager::ProgressTransactionCommitted(InstalledRepository& repository,
{ {
_SetCurrentStep(ACTION_STEP_COMPLETE); _SetCurrentStep(ACTION_STEP_COMPLETE);
BString header(B_TRANSLATE("Updates completed")); BString header(B_TRANSLATE("Updates completed"));
BString detail(B_TRANSLATE("A reboot may be necessary to complete some "
"updates.")); BString detail;
if (BPackageRoster().IsRebootNeeded()) {
detail = B_TRANSLATE("A reboot is necessary to complete the "
"update process.");
fStatusWindow->PostMessage(kMsgShowReboot);
} else {
detail = B_TRANSLATE("Updates have been successfully installed.");
}
_FinalUpdate(header.String(), detail.String()); _FinalUpdate(header.String(), detail.String());
if (fVerbose) { if (fVerbose) {
+2 -1
View File
@@ -1,11 +1,12 @@
/* /*
* Copyright 2013-2017, Haiku, Inc. All Rights Reserved. * Copyright 2013-2019, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Ingo Weinhold <ingo_weinhold@gmx.de> * Ingo Weinhold <ingo_weinhold@gmx.de>
* Rene Gollent <rene@gollent.com> * Rene Gollent <rene@gollent.com>
* Brian Hill <supernova@tycho.email> * Brian Hill <supernova@tycho.email>
* Jacob Secunda
*/ */
#ifndef UPDATE_MANAGER_H #ifndef UPDATE_MANAGER_H
#define UPDATE_MANAGER_H #define UPDATE_MANAGER_H
+4 -1
View File
@@ -1,9 +1,10 @@
/* /*
* Copyright 2017, Haiku, Inc. All Rights Reserved. * Copyright 2017-2019, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Brian Hill <supernova@tycho.email> * Brian Hill <supernova@tycho.email>
* Jacob Secunda
*/ */
#ifndef CONSTANTS_H #ifndef CONSTANTS_H
#define CONSTANTS_H #define CONSTANTS_H
@@ -54,6 +55,8 @@ static const uint32 kMsgFinalQuit = 'iFIN';
static const uint32 kMsgMoreDetailsToggle = 'iDTO'; static const uint32 kMsgMoreDetailsToggle = 'iDTO';
static const uint32 kMsgWindowFrameChanged = 'iWFC'; static const uint32 kMsgWindowFrameChanged = 'iWFC';
static const uint32 kMsgSetZoomLimits = 'iSZL'; static const uint32 kMsgSetZoomLimits = 'iSZL';
static const uint32 kMsgReboot = 'iREB';
static const uint32 kMsgShowReboot = 'iSRB';
// Message data keys // Message data keys
#define kKeyHeader "key_header" #define kKeyHeader "key_header"