1 /* 2 * Copyright 2013-2019, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold <ingo_weinhold@gmx.de> 7 * Rene Gollent <rene@gollent.com> 8 * Brian Hill <supernova@tycho.email> 9 * Jacob Secunda 10 */ 11 #ifndef UPDATE_MANAGER_H 12 #define UPDATE_MANAGER_H 13 14 15 #include <package/DaemonClient.h> 16 #include <package/manager/PackageManager.h> 17 18 #include "constants.h" 19 #include "SoftwareUpdaterWindow.h" 20 21 class ProblemWindow; 22 23 //using namespace BPackageKit; 24 using BPackageKit::BPackageInstallationLocation; 25 using BPackageKit::BPrivate::BDaemonClient; 26 using BPackageKit::BManager::BPrivate::BPackageManager; 27 28 29 class UpdateManager : public BPackageManager, 30 private BPackageManager::UserInteractionHandler { 31 public: 32 UpdateManager( 33 BPackageInstallationLocation location, 34 bool verbose); 35 ~UpdateManager(); 36 37 void CheckNetworkConnection(); 38 update_type GetUpdateType(); 39 void CheckRepositories(); 40 virtual void JobFailed(BSupportKit::BJob* job); 41 virtual void JobAborted(BSupportKit::BJob* job); 42 void FinalUpdate(const char* header, 43 const char* text); 44 private: 45 // UserInteractionHandler 46 virtual void HandleProblems(); 47 virtual void ConfirmChanges(bool fromMostSpecific); 48 virtual void Warn(status_t error, const char* format, ...); 49 50 virtual void ProgressPackageDownloadStarted( 51 const char* packageName); 52 virtual void ProgressPackageDownloadActive( 53 const char* packageName, 54 float completionValue, 55 off_t bytes, off_t totalBytes); 56 virtual void ProgressPackageDownloadComplete( 57 const char* packageName); 58 virtual void ProgressPackageChecksumStarted( 59 const char* packageName); 60 virtual void ProgressPackageChecksumComplete( 61 const char* packageName); 62 63 virtual void ProgressStartApplyingChanges( 64 InstalledRepository& repository); 65 virtual void ProgressTransactionCommitted( 66 InstalledRepository& repository, 67 const BPackageKit::BCommitTransactionResult& result); 68 virtual void ProgressApplyingChangesDone( 69 InstalledRepository& repository); 70 71 private: 72 void _PrintResult(InstalledRepository& 73 installationRepository, 74 int32& upgradeCount, 75 int32& installCount, 76 int32& uninstallCount); 77 void _UpdateStatusWindow(const char* header, 78 const char* detail); 79 void _UpdateDownloadProgress(const char* header, 80 const char* packageName, 81 float percentageComplete); 82 void _FinalUpdate(const char* header, 83 const char* text); 84 void _SetCurrentStep(int32 step); 85 86 private: 87 BPackageManager::ClientInstallationInterface 88 fClientInstallationInterface; 89 90 SoftwareUpdaterWindow* fStatusWindow; 91 BMessenger fStatusWindowMessenger; 92 ProblemWindow* fProblemWindow; 93 BMessenger fProblemWindowMessenger; 94 uint32 fCurrentStep; 95 bool fChangesConfirmed; 96 bool fNewDownloadStarted; 97 int32 fPackageDownloadsTotal; 98 int32 fPackageDownloadsCount; 99 bool fVerbose; 100 }; 101 102 103 #endif // UPDATE_MANAGER_H 104