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);