Changeset View
Changeset View
Standalone View
Standalone View
src/core/slavebase.cpp
Show First 20 Lines • Show All 1451 Lines • ▼ Show 20 Line(s) | 1435 | { | |||
---|---|---|---|---|---|
1452 | 1452 | | |||
1453 | info.setHostName(hostName); | 1453 | info.setHostName(hostName); | ||
1454 | info.setAddresses(addresses); | 1454 | info.setAddresses(addresses); | ||
1455 | info.setError(QHostInfo::HostInfoError(error)); | 1455 | info.setError(QHostInfo::HostInfoError(error)); | ||
1456 | info.setErrorString(errorString); | 1456 | info.setErrorString(errorString); | ||
1457 | 1457 | | |||
1458 | return result; | 1458 | return result; | ||
1459 | } | 1459 | } | ||
1460 | | ||||
1461 | PrivilegeOperationStatus SlaveBase::privilegeOperationStatus() | ||||
dfaure: Oh, indeed, can't be const, because it's not a getter, it's a method that asks for the status… | |||||
1462 | { | ||||
1463 | QByteArray buffer; | ||||
1464 | send(MSG_PRIVILEGE_EXEC); | ||||
dfaure: Better in one line: const QByteArray buffer = "0"; | |||||
1465 | waitForAnswer(MSG_PRIVILEGE_EXEC, 0, buffer); | ||||
1466 | | ||||
1467 | KIO::PrivilegeOperationStatus currentOperationStatus; | ||||
1468 | switch (buffer.toInt()) { | ||||
Not needed, just return KIO::PrivilegeOperationStatus(buffer.toInt()) (constructor-like syntax - or static_cast if that doesn't work). If you think casting is evil, hardcoding 1/2/3 is even more evil ;-) And in this case casting is not evil at all, we simply serialize/deserialize the enum using its integral value. dfaure: Not needed, just return KIO::PrivilegeOperationStatus(buffer.toInt()) (constructor-like… | |||||
1469 | case 1: | ||||
1470 | currentOperationStatus = KIO::OperationAllowed; | ||||
1471 | break; | ||||
1472 | case 2: | ||||
1473 | currentOperationStatus = KIO::OperationCanceled; | ||||
1474 | break; | ||||
1475 | case 3: | ||||
1476 | default: | ||||
1477 | currentOperationStatus = KIO::OperationNotAllowed; | ||||
1478 | }; | ||||
1479 | return currentOperationStatus; | ||||
1480 | } |
Oh, indeed, can't be const, because it's not a getter, it's a method that asks for the status via communication with the app.
That means the naming could be improved.
Maybe something like queryPrivilegeOperationStatus() or requestPrivilegeOperation().