Skip to content

Commit a3bc355

Browse files
committed
Try to make package info filter a bit more universally compatible
CC: #63
1 parent 6d0c776 commit a3bc355

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/transactionprivate.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,24 @@ void TransactionPrivate::Package(uint info, const QString &pid, const QString &s
340340
{
341341
Q_Q(Transaction);
342342

343-
const auto infoReal = static_cast<Transaction::Info>(info & 0xFFFF);
344-
const auto updateSeverity = static_cast<Transaction::Info>((info >> 16) & 0xFFFF);
345-
346-
// FIXME: This is band-aid for an API break in PackageKit that should not have happened
347-
// It should likely be fixed in a different way, or we need to wait for PK 2.0
348-
if (infoReal == Transaction::InfoUnknown) {
349-
q->package(updateSeverity, pid, summary);
343+
constexpr quint32 LOW_MASK = 0x0000FFFFu;
344+
constexpr quint32 HIGH_MASK = 0xFFFF0000u;
345+
const auto infoPacked = static_cast<quint32>(info);
346+
347+
if ((infoPacked & HIGH_MASK) != 0) {
348+
// we have packed values
349+
350+
const auto infoReal = static_cast<Transaction::Info>(infoPacked & LOW_MASK);
351+
const auto updateSeverity = static_cast<Transaction::Info>((infoPacked >> 16) & LOW_MASK);
352+
353+
// FIXME: This is band-aid for an API break in PackageKit that should not have happened
354+
// It should likely be fixed in a different way, or we need to wait for PK 2.0
355+
if (infoReal == Transaction::InfoUnknown)
356+
q->package(updateSeverity, pid, summary);
357+
else
358+
q->package(infoReal, pid, summary);
350359
} else {
351-
q->package(infoReal, pid, summary);
360+
q->package(static_cast<Transaction::Info>(info), pid, summary);
352361
}
353362
}
354363

0 commit comments

Comments
 (0)