void PackageListView::display() { QDictIterator<PackageList> list( PackageLists ); PackageList *packlist; OipkgPackage *pack; PackageListItem *item; ListViewItemOipkg *rootItem; QListViewItem* it; QListViewItem* itdel; while ( list.current() ) { packlist = list.current(); rootItem = rootItems.find( list.currentKey() ); //rootItem->clear(); it=rootItem->firstChild(); while ( it ) { itdel = it; it = it->nextSibling(); delete itdel; } pack = packlist->first(); while( pack ) { item = new PackageListItem( rootItem, pack, settings ); pack = packlist->next(); } ++list; } }
void PackageService::compact() { LOG_TIMESCOPE(0, "-- PackageService::Compact"); PackageList packages; while (true) { packages.clear(); // prepare current set of linked packages to unload for safe iteration for (PackageNameMap::iterator itr = _linkedPackages.begin(), end = _linkedPackages.end(); itr != end; ++itr) { Ref<Package> package = itr->second; if (package->getUseCount() > 0) continue; if (package->isStayResident()) continue; if (package->isStayForCurrent()) continue; if (package->isStayForNext()) continue; packages.push_back(package); } if (packages.empty()) break; // unlink all in current set for (uint i=0; i<packages.size(); ++i) { Ref<Package> pack = packages[i]; pack->unlink(); } } }
void BPackageManager::_AnalyzeResult() { BSolverResult result; status_t error = fSolver->GetResult(result); if (error != B_OK) DIE(error, "failed to compute packages to un/-install"); InstalledRepository& installationRepository = InstallationRepository(); PackageList& packagesToActivate = installationRepository.PackagesToActivate(); PackageList& packagesToDeactivate = installationRepository.PackagesToDeactivate(); PackageList potentialBasePackages; for (int32 i = 0; const BSolverResultElement* element = result.ElementAt(i); i++) { BSolverPackage* package = element->Package(); switch (element->Type()) { case BSolverResultElement::B_TYPE_INSTALL: { PackageList& packageList = dynamic_cast<InstalledRepository*>(package->Repository()) != NULL ? potentialBasePackages : packagesToActivate; if (!packageList.AddItem(package)) throw std::bad_alloc(); break; } case BSolverResultElement::B_TYPE_UNINSTALL: if (!packagesToDeactivate.AddItem(package)) throw std::bad_alloc(); break; } } // Make sure base packages are installed in the same location. for (int32 i = 0; i < packagesToActivate.CountItems(); i++) { BSolverPackage* package = packagesToActivate.ItemAt(i); int32 index = _FindBasePackage(potentialBasePackages, package->Info()); if (index < 0) continue; BSolverPackage* basePackage = potentialBasePackages.RemoveItemAt(index); if (!packagesToActivate.AddItem(basePackage)) throw std::bad_alloc(); } fInstallationInterface->ResultComputed(installationRepository); }
bool ResultWindow::_AddPackages(BGroupLayout* packagesGroup, const PackageList& packages, const PackageSet& ignorePackages, bool install) { bool packagesAdded = false; for (int32 i = 0; BSolverPackage* package = packages.ItemAt(i); i++) { if (ignorePackages.find(package) != ignorePackages.end()) continue; BString text; if (install) { text.SetToFormat("install package %s from repository %s\n", package->Info().FileName().String(), package->Repository()->Name().String()); } else { text.SetToFormat("uninstall package %s\n", package->VersionedName().String()); } BStringView* packageView = new BStringView(NULL, text); packagesGroup->AddView(packageView); packageView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); packagesAdded = true; } return packagesAdded; }
status_t ServerIconExportUpdateProcess::PopulateForDepot(const DepotInfo& depot) { printf("[%s] will populate icons for depot [%s]\n", Name(), depot.Name().String()); status_t result = B_OK; PackageList packages = depot.Packages(); for(int32 j = 0; (j < packages.CountItems()) && !WasStopped() && (result == B_OK); j++) { const PackageInfoRef& packageInfoRef = packages.ItemAtFast(j); result = PopulateForPkg(packageInfoRef); if (result == B_FILE_NOT_FOUND) result = B_OK; } return result; }
int32 BPackageManager::_FindBasePackage(const PackageList& packages, const BPackageInfo& info) { if (info.BasePackage().IsEmpty()) return -1; // find the requirement matching the base package BPackageResolvableExpression* basePackage = NULL; int32 count = info.RequiresList().CountItems(); for (int32 i = 0; i < count; i++) { BPackageResolvableExpression* requires = info.RequiresList().ItemAt(i); if (requires->Name() == info.BasePackage()) { basePackage = requires; break; } } if (basePackage == NULL) { fUserInteractionHandler->Warn(B_OK, "package %s-%s doesn't have a " "matching requires for its base package \"%s\"", info.Name().String(), info.Version().ToString().String(), info.BasePackage().String()); return -1; } // find the first package matching the base package requires count = packages.CountItems(); for (int32 i = 0; i < count; i++) { BSolverPackage* package = packages.ItemAt(i); if (package->Name() == basePackage->Name() && package->Info().Matches(*basePackage)) { return i; } } return -1; }
void BPackageManager::Uninstall(const BSolverPackageSpecifierList& packages) { Init(B_ADD_INSTALLED_REPOSITORIES); // find the packages that match the specification const BSolverPackageSpecifier* unmatchedSpecifier; PackageList foundPackages; status_t error = fSolver->FindPackages(packages, BSolver::B_FIND_INSTALLED_ONLY, foundPackages, &unmatchedSpecifier); if (error != B_OK) { if (unmatchedSpecifier != NULL) { DIE(error, "failed to find a match for \"%s\"", unmatchedSpecifier->SelectString().String()); } else DIE(error, "failed to compute packages to uninstall"); } // determine the inverse base package closure for the found packages // TODO: Optimize! InstalledRepository& installationRepository = InstallationRepository(); bool foundAnotherPackage; do { foundAnotherPackage = false; int32 count = installationRepository.CountPackages(); for (int32 i = 0; i < count; i++) { BSolverPackage* package = installationRepository.PackageAt(i); if (foundPackages.HasItem(package)) continue; if (_FindBasePackage(foundPackages, package->Info()) >= 0) { foundPackages.AddItem(package); foundAnotherPackage = true; } } } while (foundAnotherPackage); // remove the packages from the repository for (int32 i = 0; BSolverPackage* package = foundPackages.ItemAt(i); i++) installationRepository.DisablePackage(package); for (;;) { error = fSolver->VerifyInstallation(BSolver::B_VERIFY_ALLOW_UNINSTALL); if (error != B_OK) DIE(error, "failed to compute packages to uninstall"); _HandleProblems(); // (virtually) apply the result to this repository _AnalyzeResult(); for (int32 i = foundPackages.CountItems() - 1; i >= 0; i--) { if (!installationRepository.PackagesToDeactivate() .AddItem(foundPackages.ItemAt(i))) { throw std::bad_alloc(); } } installationRepository.ApplyChanges(); // verify the next specific respository if (!_NextSpecificInstallationLocation()) break; foundPackages.MakeEmpty(); // NOTE: In theory, after verifying a more specific location, it would // be more correct to compute the inverse base package closure for the // packages we need to uninstall and (if anything changed) verify again. // In practice, however, base packages are always required with an exact // version (ATM). If that base package still exist in a more general // location (the only reason why the package requiring the base package // wouldn't be marked to be uninstalled as well) there shouldn't have // been any reason to remove it from the more specific location in the // first place. } _ConfirmChanges(true); _ApplyPackageChanges(true); }
void MainWindow::MessageReceived(BMessage* message) { switch (message->what) { case MSG_MODEL_WORKER_DONE: { fModelWorker = B_BAD_THREAD_ID; _AdoptModel(); fFilterView->AdoptModel(fModel); break; } case B_SIMPLE_DATA: case B_REFS_RECEIVED: // TODO: ? break; case B_PACKAGE_UPDATE: // TODO: We should do a more selective update depending on the // "event", "location", and "change count" fields! _StartRefreshWorker(false); break; case MSG_REFRESH_DEPOTS: _StartRefreshWorker(true); break; case MSG_LOG_IN: _OpenLoginWindow(BMessage()); break; case MSG_LOG_OUT: fModel.SetUsername(""); break; case MSG_AUTHORIZATION_CHANGED: _UpdateAuthorization(); break; case MSG_SHOW_FEATURED_PACKAGES: { BAutolock locker(fModel.Lock()); fModel.SetShowFeaturedPackages( !fModel.ShowFeaturedPackages()); } _AdoptModel(); break; case MSG_SHOW_AVAILABLE_PACKAGES: { BAutolock locker(fModel.Lock()); fModel.SetShowAvailablePackages( !fModel.ShowAvailablePackages()); } _AdoptModel(); break; case MSG_SHOW_INSTALLED_PACKAGES: { BAutolock locker(fModel.Lock()); fModel.SetShowInstalledPackages( !fModel.ShowInstalledPackages()); } _AdoptModel(); break; case MSG_SHOW_SOURCE_PACKAGES: { BAutolock locker(fModel.Lock()); fModel.SetShowSourcePackages(!fModel.ShowSourcePackages()); } _AdoptModel(); break; case MSG_SHOW_DEVELOP_PACKAGES: { BAutolock locker(fModel.Lock()); fModel.SetShowDevelopPackages(!fModel.ShowDevelopPackages()); } _AdoptModel(); break; case MSG_PACKAGE_SELECTED: { BString name; if (message->FindString("name", &name) == B_OK) { BAutolock locker(fModel.Lock()); int count = fVisiblePackages.CountItems(); for (int i = 0; i < count; i++) { const PackageInfoRef& package = fVisiblePackages.ItemAtFast(i); if (package.Get() != NULL && package->Name() == name) { locker.Unlock(); _AdoptPackage(package); break; } } } else { _ClearPackage(); } break; } case MSG_CATEGORY_SELECTED: { BString name; if (message->FindString("name", &name) != B_OK) name = ""; { BAutolock locker(fModel.Lock()); fModel.SetCategory(name); } _AdoptModel(); break; } case MSG_DEPOT_SELECTED: { BString name; if (message->FindString("name", &name) != B_OK) name = ""; { BAutolock locker(fModel.Lock()); fModel.SetDepot(name); } _AdoptModel(); break; } case MSG_SEARCH_TERMS_MODIFIED: { // TODO: Do this with a delay! BString searchTerms; if (message->FindString("search terms", &searchTerms) != B_OK) searchTerms = ""; { BAutolock locker(fModel.Lock()); fModel.SetSearchTerms(searchTerms); } _AdoptModel(); break; } case MSG_PACKAGE_CHANGED: { PackageInfo* info; if (message->FindPointer("package", (void**)&info) == B_OK) { PackageInfoRef ref(info, true); uint32 changes; if (message->FindUInt32("changes", &changes) != B_OK) changes = 0; if ((changes & PKG_CHANGED_STATE) != 0) { BAutolock locker(fModel.Lock()); fModel.SetPackageState(ref, ref->State()); } // Asynchronous updates to the package information // can mean that the package needs to be added or // removed to/from the visible packages when the current // filter parameters are re-evaluated on this package. bool wasVisible = fVisiblePackages.Contains(ref); bool isVisible; { BAutolock locker(fModel.Lock()); // The package didn't get a chance yet to be in the // visible package list PackageList visiblePackages = fModel.CreatePackageList(); isVisible = visiblePackages.Contains(ref); // Transfer this single package, otherwise we miss // other packages if they appear or disappear along // with this one before receive a notification for // them. if (isVisible) { fVisiblePackages.Add(ref); } else if (wasVisible) fVisiblePackages.Remove(ref); } if (wasVisible != isVisible) { if (!isVisible) { fPackageListView->RemovePackage(ref); fFeaturedPackagesView->RemovePackage(ref); } else { fPackageListView->AddPackage(ref); if (ref->IsProminent()) fFeaturedPackagesView->AddPackage(ref); } } } break; } case MSG_RATE_PACKAGE: _RatePackage(); break; case MSG_SHOW_SCREENSHOT: _ShowScreenshot(); break; default: BWindow::MessageReceived(message); break; } }
WRAPPEDPARAM::WrappedParam(const string& fromType, const string& fromName, vector& wrappedParams, const Type* paramType, PackageList& packageList) : mFromType(fromType), mFromName(toJavaName(fromName, true, true, false)) { wrappedParams.push_back(this); if (mFromType == "NativeLong") { mToName = mFromName + "2long"; mToType = "long"; packageList.addImport("com.sun.jna.NativeLong"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "new NativeLong(%FROMNAME%);\n"; } else if (mFromType.length() > 11 && mFromType.substr(mFromType.length() - 11) == "ByReference" && paramType != NULL && paramType->isStructPtr()) { mToName = mFromName + "Ref"; mToType = mFromType.substr(0, mFromType.length() - 11); packageList.addType(paramType, false); string packageName = paramType->getImport(); packageName.erase(packageName.length() - 11); packageList.addImport(packageName); mConvertCommand = " final %FROMTYPE% %TONAME% = new %FROMTYPE%();\n"; mAfterCommand = " %FROMNAME%.setFromNative(Pointer.nativeValue(%TONAME%.getValue().getPointer()));\n"; } else if (mFromType == "$Buffer") { mFromType = "ByteBuffer"; mToName = mFromName + "2ByteBuffer"; mToType = "byte[]"; packageList.addImport("java.nio.ByteBuffer"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "%FROMTYPE%.wrap(%FROMNAME%);\n"; } else if (mFromType == "$BufferWithOffset") { mFromType = "ByteBuffer"; mToName = mFromName + "2ByteBuffer"; mToType = "byte[]"; packageList.addImport("java.nio.ByteBuffer"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "%FROMTYPE%.wrap(%FROMNAME%, " "%FROMNAME%Offset, %FROMNAME%Length).slice();\n"; } else if (mFromType == "$Size") { mFromType = "NativeLong"; mToName = mFromName + "2NativeLong"; mToType = ""; packageList.addImport("com.sun.jna.NativeLong"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "new NativeLong(%FROMNAME%.length);\n"; } else if (mFromType == "$BufferOffset") { mFromType = ""; mFromName = mFromName + "Offset"; mToName = ""; mToType = "int"; mConvertCommand = ""; } else if (mFromType == "$BufferLength") { mFromType = "NativeLong"; mFromName = mFromName + "Length"; mToName = mFromName + "2NativeLong"; mToType = "int"; packageList.addImport("com.sun.jna.NativeLong"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "new NativeLong(%FROMNAME%);\n"; } else if (mFromType == "$StructureSize") { mFromType = "NativeLong"; mToName = mFromName + "Size2NativeLong"; mToType = ""; packageList.addImport("com.sun.jna.NativeLong"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "new NativeLong(%FROMNAME%.size());\n"; } else { mToName = mFromName; mToType = mFromType; } stringReplace(mConvertCommand, "FROMTYPE", mFromType); stringReplace(mConvertCommand, "FROMNAME", mFromName); stringReplace(mConvertCommand, "TONAME", mToName); stringReplace(mConvertCommand, "TOTYPE", mToType); stringReplace(mAfterCommand, "FROMTYPE", mFromType); stringReplace(mAfterCommand, "FROMNAME", mFromName); stringReplace(mAfterCommand, "TONAME", mToName); stringReplace(mAfterCommand, "TOTYPE", mToType); }