Skip to content

Commit

Permalink
no need to test each value before using them
Browse files Browse the repository at this point in the history
Undefined values are filtered later.
  • Loading branch information
guillomovitch committed Nov 7, 2012
1 parent 5aa99eb commit 461ee7c
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Win32/License.pm
Expand Up @@ -42,34 +42,23 @@ sub doInventory {
sub _scanOffice {
my ($currentKey) = @_;

my %license;
if ($currentKey->{ProductID}) {
$license{PRODUCTID} = $currentKey->{ProductID};
} if ($currentKey->{DigitalProductID}) {
my %license = {
PRODUCTID => $currentKey->{ProductID},
UPDATE => $currentKey->{SPLevel},
OEM => $currentKey->{OEM},
FULLNAME => encodeFromRegistry($currentKey->{ProductName}) ||
encodeFromRegistry($currentKey->{ConvertToEdition}),
NAME => encodeFromRegistry($currentKey->{ProductNameNonQualified}) ||
encodeFromRegistry($currentKey->{ProductNameVersion})
};

if ($currentKey->{DigitalProductID}) {
$license{KEY} = parseProductKey($currentKey->{DigitalProductID});
}
if ($currentKey->{ConvertToEdition}) {
$license{FULLNAME} = encodeFromRegistry($currentKey->{ConvertToEdition});
}
if ($currentKey->{ProductNameNonQualified}) {
$license{NAME} = encodeFromRegistry($currentKey->{ProductNameNonQualified});
} elsif ($currentKey->{ProductNameVersion}) {
$license{NAME} = encodeFromRegistry($currentKey->{ProductNameVersion});
}

if ($currentKey->{ProductName}) {
$license{FULLNAME} = encodeFromRegistry($currentKey->{ProductName});
}

if ($currentKey->{TrialType} && $currentKey->{TrialType} =~ /(\d+)$/) {
$license{TRIAL} = int($1);
}
if ($currentKey->{SPLevel}) {
$license{UPDATE} = $currentKey->{SPLevel};
}
if ($currentKey->{OEM}) {
$license{OEM} = $currentKey->{OEM};
}

my @products;
foreach(keys %$currentKey) {
Expand Down

0 comments on commit 461ee7c

Please sign in to comment.