本文整理汇总了C++中PackageInfoRef类的典型用法代码示例。如果您正苦于以下问题:C++ PackageInfoRef类的具体用法?C++ PackageInfoRef怎么用?C++ PackageInfoRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackageInfoRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
PackageRow::PackageRow(const PackageInfoRef& packageRef,
PackageListener* packageListener)
:
Inherited(ceilf(be_plain_font->Size() * 1.8f)),
fPackage(packageRef),
fPackageListener(packageListener)
{
if (packageRef.Get() == NULL)
return;
PackageInfo& package = *packageRef.Get();
// Package icon and title
// NOTE: The icon BBitmap is referenced by the fPackage member.
UpdateTitle();
// Rating
UpdateRating();
// Summary
UpdateSummary();
// Size
UpdateSize();
// Status
UpdateState();
package.AddListener(fPackageListener);
}
示例2: UninstallPackageAction
PackageActionList
PackageManager::GetPackageActions(PackageInfoRef package, Model* model)
{
PackageActionList actionList;
if (package->IsSystemPackage() || package->IsSystemDependency())
return actionList;
int32 state = package->State();
if (state == ACTIVATED || state == INSTALLED) {
actionList.Add(PackageActionRef(new UninstallPackageAction(
package, model), true));
// Add OpenPackageActions for each deskbar link found in the
// package
DeskbarLinkList foundLinks;
if (OpenPackageAction::FindAppToLaunch(package, foundLinks)
&& foundLinks.CountItems() < 4) {
for (int32 i = 0; i < foundLinks.CountItems(); i++) {
const DeskbarLink& link = foundLinks.ItemAtFast(i);
actionList.Add(PackageActionRef(new OpenPackageAction(
package, model, link), true));
}
}
} else if (state == NONE || state == UNINSTALLED) {
actionList.Add(PackageActionRef(new InstallPackageAction(package,
model), true));
}
// TODO: activation status
return actionList;
}
示例3: bestIconFile
status_t
ServerIconExportUpdateProcess::PopulateForPkg(const PackageInfoRef& package)
{
BPath bestIconPath;
if ( fLocalIconStore->TryFindIconPath(
package->Name(), bestIconPath) == B_OK) {
BFile bestIconFile(bestIconPath.Path(), O_RDONLY);
BitmapRef bitmapRef(new(std::nothrow)SharedBitmap(bestIconFile), true);
package->SetIcon(bitmapRef);
if (Logger::IsDebugEnabled()) {
printf("[%s] have set the package icon for [%s] from [%s]\n",
Name(), package->Name().String(), bestIconPath.Path());
}
fCountIconsSet++;
return B_OK;
}
if (Logger::IsDebugEnabled()) {
printf("[%s] did not set the package icon for [%s]; no data\n",
Name(), package->Name().String());
}
return B_FILE_NOT_FOUND;
}
示例4: FindAppToLaunch
static bool FindAppToLaunch(const PackageInfoRef& package,
DeskbarLinkList& foundLinks)
{
if (package.Get() == NULL)
return false;
int32 installLocation = InstallLocation(package);
BPath packagePath;
if (installLocation == B_PACKAGE_INSTALLATION_LOCATION_SYSTEM) {
if (find_directory(B_SYSTEM_PACKAGES_DIRECTORY, &packagePath)
!= B_OK) {
return false;
}
} else if (installLocation == B_PACKAGE_INSTALLATION_LOCATION_HOME) {
if (find_directory(B_USER_PACKAGES_DIRECTORY, &packagePath)
!= B_OK) {
return false;
}
} else {
printf("OpenPackageAction::FindAppToLaunch(): "
"unknown install location");
return false;
}
packagePath.Append(package->FileName());
BNoErrorOutput errorOutput;
BPackageReader reader(&errorOutput);
status_t status = reader.Init(packagePath.Path());
if (status != B_OK) {
printf("OpenPackageAction::FindAppToLaunch(): "
"failed to init BPackageReader(%s): %s\n",
packagePath.Path(), strerror(status));
return false;
}
// Scan package contents for Deskbar links
DeskbarLinkFinder contentHandler(foundLinks);
status = reader.ParseContent(&contentHandler);
if (status != B_OK) {
printf("OpenPackageAction::FindAppToLaunch(): "
"failed parse package contents (%s): %s\n",
packagePath.Path(), strerror(status));
return false;
}
return foundLinks.CountItems() > 0;
}
示例5:
void
ScreenshotWindow::SetPackage(const PackageInfoRef& package)
{
if (fPackage == package)
return;
fPackage = package;
BString title = B_TRANSLATE("Screenshot");
if (package.Get() != NULL) {
title = package->Title();
_DownloadScreenshot();
}
SetTitle(title);
}
示例6: AcceptsPackage
virtual bool AcceptsPackage(const PackageInfoRef& package) const
{
if (package.Get() == NULL)
return false;
const CategoryList& categories = package->Categories();
for (int i = categories.CountItems() - 1; i >= 0; i--) {
const CategoryRef& category = categories.ItemAtFast(i);
if (category.Get() == NULL)
continue;
if (category->Name() == fCategory)
return true;
}
return false;
}
示例7: GetModel
PackageInfoRef
PackageAction::FindPackageByName(const BString& name)
{
Model* model = GetModel();
const DepotList& depots = model->Depots();
// TODO: optimize!
for (int32 i = 0; i < depots.CountItems(); i++) {
const DepotInfo& depot = depots.ItemAtFast(i);
const PackageList& packages = depot.Packages();
for (int32 j = 0; j < packages.CountItems(); j++) {
PackageInfoRef info = packages.ItemAtFast(j);
if (info->Name() == name)
return info;
}
}
return PackageInfoRef();
}
示例8:
void
ScreenshotWindow::SetPackage(const PackageInfoRef& package)
{
if (fPackage == package)
return;
fPackage = package;
BString title = B_TRANSLATE("Screenshot");
if (package.Get() != NULL) {
title = package->Title();
_DownloadScreenshot();
}
SetTitle(title);
atomic_set(&fCurrentScreenshotIndex, 0);
_UpdateToolBar();
}
示例9: UninstallPackageAction
PackageActionList
PackageManager::GetPackageActions(PackageInfoRef package, Model* model)
{
PackageActionList actionList;
if (package->IsSystemPackage() || package->IsSystemDependency())
return actionList;
int32 state = package->State();
if (state == ACTIVATED || state == INSTALLED) {
actionList.Add(PackageActionRef(new UninstallPackageAction(
package, model), true));
} else {
actionList.Add(PackageActionRef(new InstallPackageAction(package,
model), true));
}
// TODO: activation status
return actionList;
}
示例10: while
status_t
MainWindow::_PopulatePackageWorker(void* arg)
{
MainWindow* window = reinterpret_cast<MainWindow*>(arg);
while (acquire_sem(window->fPackageToPopulateSem) == B_OK) {
PackageInfoRef package;
{
AutoLocker<BLocker> lock(&window->fPackageToPopulateLock);
package = window->fPackageToPopulate;
}
if (package.Get() != NULL) {
window->fModel.PopulatePackage(package,
Model::POPULATE_USER_RATINGS | Model::POPULATE_SCREEN_SHOTS
| Model::POPULATE_CHANGELOG);
}
}
return 0;
}
示例11:
int32
PackageAction::InstallLocation(const PackageInfoRef& package)
{
const PackageInstallationLocationSet& locations
= package->InstallationLocations();
// If the package is already installed, return its first installed location
if (locations.size() != 0)
return *locations.begin();
return B_PACKAGE_INSTALLATION_LOCATION_SYSTEM;
}
示例12: Inherited
PackageRow::PackageRow(const PackageInfoRef& packageRef,
PackageListener* packageListener)
:
Inherited(ceilf(be_plain_font->Size() * 1.8f)),
fPackage(packageRef),
fPackageListener(packageListener)
{
if (packageRef.Get() == NULL)
return;
PackageInfo& package = *packageRef.Get();
// Package icon and title
// NOTE: The icon BBitmap is referenced by the fPackage member.
const BBitmap* icon = NULL;
if (package.Icon().Get() != NULL)
icon = package.Icon()->Bitmap(SharedBitmap::SIZE_16);
SetField(new BBitmapStringField(icon, package.Title()), kTitleColumn);
// Rating
UpdateRating();
// Description
SetField(new BStringField(package.ShortDescription()), kDescriptionColumn);
// Size
// TODO: Store package size
SetField(new BStringField("0 KiB"), kSizeColumn);
// Status
// TODO: Fetch info about installed/deactivated/uninstalled/...
SetField(new BStringField(package_state_to_string(fPackage)),
kStatusColumn);
package.AddListener(fPackageListener);
}
示例13: package_state_to_string
inline BString
package_state_to_string(PackageInfoRef ref)
{
switch (ref->State()) {
case NONE:
return B_TRANSLATE(skPackageStateAvailable);
case INSTALLED:
return B_TRANSLATE(skPackageStateInactive);
case ACTIVATED:
return B_TRANSLATE(skPackageStateActive);
case UNINSTALLED:
return B_TRANSLATE(skPackageStateUninstalled);
case DOWNLOADING:
{
BString data;
data.SetToFormat("%3.2f%%", ref->DownloadProgress() * 100.0);
return data;
}
case PENDING:
return B_TRANSLATE(skPackageStatePending);
}
return B_TRANSLATE("Unknown");
}
示例14: locker
void
RatePackageWindow::SetPackage(const PackageInfoRef& package)
{
BAutolock locker(this);
if (!locker.IsLocked() || fWorkerThread >= 0)
return;
fPackage = package;
BString windowTitle(B_TRANSLATE("Rate %Package%"));
windowTitle.ReplaceAll("%Package%", package->Title());
SetTitle(windowTitle);
// See if the user already made a rating for this package,
// pre-fill the UI with that rating. (When sending the rating, the
// old one will be replaced.)
thread_id thread = spawn_thread(&_QueryRatingThreadEntry,
"Query rating", B_NORMAL_PRIORITY, this);
if (thread >= 0)
_SetWorkerThread(thread);
}
示例15: new
PackageAction::PackageAction(int32 type, PackageInfoRef package, Model* model)
:
fPackage(package),
fType(type),
fModel(model)
{
const PackageInstallationLocationSet& locations
= package->InstallationLocations();
int32 location = B_PACKAGE_INSTALLATION_LOCATION_SYSTEM;
// if the package is already installed, use its first installed location
// to initialize the manager.
// TODO: ideally if the package is installed at multiple locations,
// the user should be able to pick which one to remove.
if (locations.size() != 0)
location = *locations.begin();
// TODO: allow configuring the installation location
fPackageManager = new(std::nothrow) PackageManager(
(BPackageInstallationLocation)location);
}