Changeset View
Changeset View
Standalone View
Standalone View
src/ioslaves/file/file_unix.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | |||||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | static const QString socketPath() | 75 | static const QString socketPath() | ||
76 | { | 76 | { | ||
77 | const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); | 77 | const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); | ||
78 | return QStringLiteral("%1/filehelper%2%3").arg(runtimeDir).arg(KRandom::randomString(6)).arg(getpid()); | 78 | return QStringLiteral("%1/filehelper%2%3").arg(runtimeDir).arg(KRandom::randomString(6)).arg(getpid()); | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | static QString actionDetails(ActionType actionType, QVariantList args) | ||||
dfaure: `const QVariantList &` | |||||
dfaure: marked as done, but not done | |||||
82 | { | ||||
83 | QString action, detail; | ||||
84 | switch(actionType) { | ||||
dfaure: missing space after `switch` (same rule as `if`, `for` etc.) | |||||
85 | case CHMOD: { | ||||
all those { ... } braces are unnecessary in this switch, which doesn't define any new variables dfaure: all those { ... } braces are unnecessary in this switch, which doesn't define any new variables | |||||
86 | action = i18n("Change File Permissions"); | ||||
87 | detail = i18n("New Permissions : %1", args[1].toInt()); | ||||
dfaure: no space before ':' in English | |||||
dfaure: Not done | |||||
88 | break; | ||||
89 | } | ||||
90 | case CHOWN: { | ||||
91 | action = i18n("Change File Owner"); | ||||
dfaure: same | |||||
dfaure: same | |||||
92 | detail = i18n("New Owner : UID=%1, GID=%2", args[1].toInt(), args[2].toInt()); | ||||
93 | break; | ||||
94 | } | ||||
95 | case DEL: { | ||||
96 | action = i18n("Remove File"); | ||||
97 | break; | ||||
98 | } | ||||
99 | case RMDIR: { | ||||
100 | action = i18n("Remove Directory"); | ||||
101 | break; | ||||
102 | } | ||||
103 | case MKDIR: { | ||||
104 | action = i18n("Create Directory"); | ||||
105 | detail = i18n("Directory Permissions: %1", args[1].toInt()); | ||||
106 | break; | ||||
107 | } | ||||
108 | case OPEN: { | ||||
109 | action = i18n("Open File"); | ||||
110 | break; | ||||
111 | } | ||||
112 | case OPENDIR: { | ||||
113 | action = i18n("Open Directory"); | ||||
114 | break; | ||||
115 | } | ||||
116 | | ||||
117 | case RENAME: { | ||||
118 | action = i18n("Rename"); | ||||
119 | detail = i18n("New Filename: %1", args[1].toString()); | ||||
120 | break; | ||||
121 | } | ||||
dfaure: weird indentation | |||||
dfaure: still there | |||||
122 | case SYMLINK: { | ||||
123 | action = i18n("Create Symlink"); | ||||
124 | detail = i18n("Target: %1", args[1].toString()); | ||||
125 | break; | ||||
126 | } | ||||
127 | case UTIME: { | ||||
128 | action = i18n("Change Timestamp"); | ||||
129 | break; | ||||
130 | } | ||||
131 | default: { | ||||
132 | action = i18n("Unknown Action"); | ||||
133 | break; | ||||
134 | } | ||||
135 | } | ||||
136 | | ||||
137 | const QString metadata = i18n("Action: %1\n" | ||||
138 | "Source: %2\n" | ||||
139 | "%3", action, args[0].toString(), detail); | ||||
140 | return metadata; | ||||
141 | } | ||||
142 | | ||||
81 | bool FileProtocol::privilegeOperationUnitTestMode() | 143 | bool FileProtocol::privilegeOperationUnitTestMode() | ||
82 | { | 144 | { | ||
83 | return (metaData(QStringLiteral("UnitTesting")) == QLatin1String("true")) | 145 | return (metaData(QStringLiteral("UnitTesting")) == QLatin1String("true")) | ||
84 | && (requestPrivilegeOperation() == KIO::OperationAllowed); | 146 | && (requestPrivilegeOperation() == KIO::OperationAllowed); | ||
85 | } | 147 | } | ||
86 | 148 | | |||
87 | PrivilegeOperationReturnValue FileProtocol::tryOpen(QFile &f, const QByteArray &path, int flags, int mode, int errcode) | 149 | PrivilegeOperationReturnValue FileProtocol::tryOpen(QFile &f, const QByteArray &path, int flags, int mode, int errcode) | ||
88 | { | 150 | { | ||
▲ Show 20 Lines • Show All 748 Lines • ▼ Show 20 Line(s) | 893 | { | |||
837 | if (true) { | 899 | if (true) { | ||
838 | return PrivilegeOperationReturnValue::failure(errcode); | 900 | return PrivilegeOperationReturnValue::failure(errcode); | ||
839 | } | 901 | } | ||
840 | 902 | | |||
841 | if (!(errcode == EACCES || errcode == EPERM)) { | 903 | if (!(errcode == EACCES || errcode == EPERM)) { | ||
842 | return PrivilegeOperationReturnValue::failure(errcode); | 904 | return PrivilegeOperationReturnValue::failure(errcode); | ||
843 | } | 905 | } | ||
844 | 906 | | |||
907 | if (privilegeOperationDetails.isEmpty()) { | ||||
908 | privilegeOperationDetails = actionDetails(action, args); | ||||
909 | } | ||||
910 | | ||||
845 | KIO::PrivilegeOperationStatus opStatus = requestPrivilegeOperation(); | 911 | KIO::PrivilegeOperationStatus opStatus = requestPrivilegeOperation(); | ||
846 | if (opStatus != KIO::OperationAllowed) { | 912 | if (opStatus != KIO::OperationAllowed) { | ||
847 | if (opStatus == KIO::OperationCanceled) { | 913 | if (opStatus == KIO::OperationCanceled) { | ||
848 | error(KIO::ERR_USER_CANCELED, QString()); | 914 | error(KIO::ERR_USER_CANCELED, QString()); | ||
849 | return PrivilegeOperationReturnValue::canceled(); | 915 | return PrivilegeOperationReturnValue::canceled(); | ||
850 | } | 916 | } | ||
851 | return PrivilegeOperationReturnValue::failure(errcode); | 917 | return PrivilegeOperationReturnValue::failure(errcode); | ||
852 | } | 918 | } | ||
Show All 37 Lines |
const QVariantList &