1/* 2 * Copyright 2013-2015, 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 */ 9#ifndef PACKAGE_MANAGER_H 10#define PACKAGE_MANAGER_H 11 12 13#include <package/DaemonClient.h> 14#include <package/manager/PackageManager.h> 15 16#include <NumberFormat.h> 17 18#include "DecisionProvider.h" 19 20 21using namespace BPackageKit; 22using BPackageKit::BPrivate::BDaemonClient; 23using BManager::BPrivate::BPackageManager; 24 25 26class PackageManager : public BPackageManager, 27 private BPackageManager::UserInteractionHandler { 28public: 29 PackageManager( 30 BPackageInstallationLocation location, 31 bool interactive = true); 32 ~PackageManager(); 33 34 void SetInteractive(bool interactive); 35 36 virtual void JobFailed(BSupportKit::BJob* job); 37 38private: 39 // UserInteractionHandler 40 virtual void HandleProblems(); 41 virtual void ConfirmChanges(bool fromMostSpecific); 42 43 virtual void Warn(status_t error, const char* format, ...); 44 45 46 virtual void ProgressPackageDownloadStarted( 47 const char* packageName); 48 virtual void ProgressPackageDownloadActive( 49 const char* packageName, 50 float completionPercentage, 51 off_t bytes, off_t totalBytes); 52 virtual void ProgressPackageDownloadComplete( 53 const char* packageName); 54 virtual void ProgressPackageChecksumStarted( 55 const char* packageName); 56 virtual void ProgressPackageChecksumComplete( 57 const char* packageName); 58 59 virtual void ProgressStartApplyingChanges( 60 InstalledRepository& repository); 61 virtual void ProgressTransactionCommitted( 62 InstalledRepository& repository, 63 const BCommitTransactionResult& result); 64 virtual void ProgressApplyingChangesDone( 65 InstalledRepository& repository); 66 67private: 68 void _PrintResult(InstalledRepository& 69 installationRepository); 70 71private: 72 DecisionProvider fDecisionProvider; 73 BNumberFormat fNumberFormat; 74 BPackageManager::ClientInstallationInterface 75 fClientInstallationInterface; 76 bool fInteractive; 77 78 bool fShowProgress; 79 off_t fLastBytes; 80 bigtime_t fLastRateCalcTime; 81 float fDownloadRate; 82}; 83 84 85#endif // PACKAGE_MANAGER_H 86