From 5f52e82c0019f24d6aec91605f7f3600654f5d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 26 Oct 2014 00:09:59 +0200 Subject: [PATCH] HaikuDepot: Some work in progress to prepare "opening" packages The idea is to parse packages for Deskbar links and offer to "open" them once they are installed. The added functionality is not yet complete and will eventually figure out the file system location of a package and parse the contents. I am mainly pushing this since my git-foo is limited and I want to push the fix for the discovered deadlock. --- src/apps/haikudepot/model/PackageInfo.cpp | 40 +++++++++++++++++++++++ src/apps/haikudepot/model/PackageInfo.h | 8 +++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/apps/haikudepot/model/PackageInfo.cpp b/src/apps/haikudepot/model/PackageInfo.cpp index 2825a57058..cbf9085e84 100644 --- a/src/apps/haikudepot/model/PackageInfo.cpp +++ b/src/apps/haikudepot/model/PackageInfo.cpp @@ -8,7 +8,10 @@ #include +#include +#include #include +#include @@ -727,6 +730,43 @@ PackageInfo::SetLocalFilePath(const char* path) } +bool +PackageInfo::IsLocalFile() const +{ + return !fLocalFilePath.IsEmpty() && fInstallationLocations.empty(); +} + + +BPath +PackageInfo::FindAppToLaunch() const +{ + BPath path; + if (fLocalFilePath.IsEmpty() || fInstallationLocations.empty()) + return path; + + BPath packagePath; + if (fInstallationLocations.find( + BPackageKit::B_PACKAGE_INSTALLATION_LOCATION_SYSTEM) + != fInstallationLocations.end()) { + if (find_directory(B_SYSTEM_PACKAGES_DIRECTORY, &packagePath) != B_OK) + return path; + } else if (fInstallationLocations.find( + BPackageKit::B_PACKAGE_INSTALLATION_LOCATION_HOME) + != fInstallationLocations.end()) { + if (find_directory(B_USER_PACKAGES_DIRECTORY, &packagePath) != B_OK) + return path; + } else { + return path; + } + + packagePath.Append(fLocalFilePath); + + // TODO: Scan package contents for Deskbar links + + return path; +} + + void PackageInfo::ClearUserRatings() { diff --git a/src/apps/haikudepot/model/PackageInfo.h b/src/apps/haikudepot/model/PackageInfo.h index 3bc50cfaea..63d1ef8139 100644 --- a/src/apps/haikudepot/model/PackageInfo.h +++ b/src/apps/haikudepot/model/PackageInfo.h @@ -16,6 +16,9 @@ #include "SharedBitmap.h" +class BPath; + + class UserInfo { public: UserInfo(); @@ -298,8 +301,9 @@ public: void SetLocalFilePath(const char* path); const BString& LocalFilePath() const { return fLocalFilePath; } - bool IsLocalFile() const - { return !fLocalFilePath.IsEmpty(); } + bool IsLocalFile() const; + + BPath FindAppToLaunch() const; void ClearCategories(); bool AddCategory(const CategoryRef& category);