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.
This commit is contained in:
Stephan Aßmus
2014-10-26 00:13:48 +02:00
parent 6b147523f1
commit 5f52e82c00
2 changed files with 46 additions and 2 deletions
+40
View File
@@ -8,7 +8,10 @@
#include <stdio.h>
#include <FindDirectory.h>
#include <package/PackageDefs.h>
#include <package/PackageFlags.h>
#include <Path.h>
@@ -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()
{
+6 -2
View File
@@ -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);