From 9202a719e143ce324d611990d2fb40939cf7e8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 15 Sep 2013 17:24:15 +0200 Subject: [PATCH] HaikuDepot: Add interface for PackageInfoListener. Also defines PackageInfoEvent. --- src/apps/haiku-depot/Jamfile | 1 + src/apps/haiku-depot/PackageInfoListener.cpp | 84 ++++++++++++++++++++ src/apps/haiku-depot/PackageInfoListener.h | 54 +++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 src/apps/haiku-depot/PackageInfoListener.cpp create mode 100644 src/apps/haiku-depot/PackageInfoListener.h diff --git a/src/apps/haiku-depot/Jamfile b/src/apps/haiku-depot/Jamfile index 7788c34840..65196d0261 100644 --- a/src/apps/haiku-depot/Jamfile +++ b/src/apps/haiku-depot/Jamfile @@ -38,6 +38,7 @@ Application HaikuDepot : MainWindow.cpp Model.cpp PackageInfo.cpp + PackageInfoListener.cpp PackageInfoView.cpp PackageListView.cpp PackageManager.cpp diff --git a/src/apps/haiku-depot/PackageInfoListener.cpp b/src/apps/haiku-depot/PackageInfoListener.cpp new file mode 100644 index 0000000000..36a1277476 --- /dev/null +++ b/src/apps/haiku-depot/PackageInfoListener.cpp @@ -0,0 +1,84 @@ +/* + * Copyright 2013, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "PackageInfoListener.h" + +#include + + +// #pragma mark - PackageInfoEvent + + +PackageInfoEvent::PackageInfoEvent() + : + fPackage(), + fChanges(0) +{ +} + + +PackageInfoEvent::PackageInfoEvent(const PackageInfoRef& package, + uint32 changes) + : + fPackage(package), + fChanges(changes) +{ +} + + +PackageInfoEvent::PackageInfoEvent(const PackageInfoEvent& other) + : + fPackage(other.fPackage), + fChanges(other.fChanges) +{ +} + + +PackageInfoEvent::~PackageInfoEvent() +{ +} + + +bool +PackageInfoEvent::operator==(const PackageInfoEvent& other) +{ + if (this == &other) + return true; + + return fPackage == other.fPackage + && fChanges == other.fChanges; +} + + +bool +PackageInfoEvent::operator!=(const PackageInfoEvent& other) +{ + return !(*this == other); +} + + +PackageInfoEvent& +PackageInfoEvent::operator=(const PackageInfoEvent& other) +{ + if (this != &other) { + fPackage = other.fPackage; + fChanges = other.fChanges; + } + + return *this; +} + + +// #pragma mark - PackageInfoListener + + +PackageInfoListener::PackageInfoListener() +{ +} + + +PackageInfoListener::~PackageInfoListener() +{ +} diff --git a/src/apps/haiku-depot/PackageInfoListener.h b/src/apps/haiku-depot/PackageInfoListener.h new file mode 100644 index 0000000000..1dcde5c6b7 --- /dev/null +++ b/src/apps/haiku-depot/PackageInfoListener.h @@ -0,0 +1,54 @@ +/* + * Copyright 2013, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef PACKAGE_INFO_LISTENER_H +#define PACKAGE_INFO_LISTENER_H + + +#include "PackageInfo.h" + + +enum { + PKG_CHANGED_DESCRIPTION = 1 << 0, + PKG_CHANGED_RATINGS = 1 << 1, + PKG_CHANGED_SCREENSHOTS = 1 << 2, + // ... +}; + + +class PackageInfoEvent { +public: + PackageInfoEvent(); + PackageInfoEvent(const PackageInfoRef& package, + uint32 changes); + PackageInfoEvent(const PackageInfoEvent& other); + virtual ~PackageInfoEvent(); + + bool operator==(const PackageInfoEvent& other); + bool operator!=(const PackageInfoEvent& other); + PackageInfoEvent& operator=(const PackageInfoEvent& other); + + inline const PackageInfoRef& Package() const + { return fPackage; } + + inline uint32 Changes() const + { return fChanges; } + +private: + PackageInfoRef fPackage; + uint32 fChanges; +}; + + +class PackageInfoListener { +public: + PackageInfoListener(); + virtual ~PackageInfoListener(); + + virtual void PackageChanged( + const PackageInfoEvent& event) = 0; +}; + + +#endif // PACKAGE_INFO_LISTENER_H