Skip to content

Commit

Permalink
Add a Pkg.PrdHasLicenseConfirmed
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Aug 21, 2017
1 parent cd2f04c commit 855cfb7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
48 changes: 38 additions & 10 deletions src/Package.cc
Expand Up @@ -736,6 +736,20 @@ static zypp::Package::constPtr find_package(const string &name)
return NULL;
}

static zypp::ui::Selectable::Ptr find_selectable_product(const string &name)
{
if (name.empty())
return NULL;

using zypp::ui::Selectable;
Selectable::Ptr selectable = Selectable::get( zypp::ResKind::product, name );

if (!selectable)
y2warning("Product '%s' not found", name.c_str());

return selectable;
}

/**
@builtin PkgSummary
Expand Down Expand Up @@ -2733,8 +2747,7 @@ YCPBoolean PkgFunctions::PkgMarkLicenseConfirmed (const YCPString & package)
@short Return the product's license to confirm
@param string name of a product
@return string license to confirm. It returns the empty string if the license was already
confirmed.
@return string license to confirm
*/
YCPValue
PkgFunctions::PrdGetLicenseToConfirm(const YCPString& product)
Expand All @@ -2749,20 +2762,15 @@ PkgFunctions::PrdGetLicenseToConfirm(const YCPString& product)
return YCPVoid();
}

if (!selectable->hasLicenceConfirmed())
{
return YCPString(selectable->candidateObj().licenseToConfirm());
} else {
return YCPString("");
}
return YCPString(selectable->candidateObj().licenseToConfirm());
}

/**
@builtin PrdMarkLicenseConfirmed
@short Mark a product's license as confirmed
@param string name of a product
@return boolean true if the license was confirmed.
@return boolean true if the license was confirmed
*/
YCPValue
PkgFunctions::PrdMarkLicenseConfirmed(const YCPString& product)
Expand Down Expand Up @@ -2794,6 +2802,26 @@ PkgFunctions::PrdMarkLicenseConfirmed(const YCPString& product)
*/
YCPValue
PkgFunctions::PrdNeedToAcceptLicense(const YCPString& product)
{
zypp::ui::Selectable::Ptr selectable = find_selectable_product(product->value());

if (!selectable)
{
return YCPVoid();
}

return YCPBoolean(selectable->candidateObj().needToAcceptLicense());
}

/**
@builtin PrdHasLicenseConfirmed
@short Product license to confirm
@param string name of a product
@return boolean true if the license is confirmed
*/
YCPValue
PkgFunctions::PrdHasLicenseConfirmed(const YCPString& product)
{
using zypp::ui::Selectable;
std::string productName(product->value());
Expand All @@ -2805,7 +2833,7 @@ PkgFunctions::PrdNeedToAcceptLicense(const YCPString& product)
return YCPVoid();
}

return YCPBoolean(selectable->candidateObj().needToAcceptLicense());
return YCPBoolean(selectable->hasLicenceConfirmed());
}


Expand Down
2 changes: 2 additions & 0 deletions src/PkgFunctions.h
Expand Up @@ -738,6 +738,8 @@ class PkgFunctions
YCPValue PrdMarkLicenseConfirmed (const YCPString& product);
/* TYPEINFO: boolean(string)*/
YCPValue PrdNeedToAcceptLicense (const YCPString& product);
/* TYPEINFO: boolean(string)*/
YCPValue PrdHasLicenseConfirmed(const YCPString& product);

/* TYPEINFO: boolean(string)*/
YCPBoolean RpmChecksig( const YCPString & filename );
Expand Down

0 comments on commit 855cfb7

Please sign in to comment.