Changeset View
Changeset View
Standalone View
Standalone View
src/kauthaction.h
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 85 | public: | |||
---|---|---|---|---|---|
98 | 98 | | |||
99 | enum ExecutionMode { | 99 | enum ExecutionMode { | ||
100 | ExecuteMode, | 100 | ExecuteMode, | ||
101 | AuthorizeOnlyMode | 101 | AuthorizeOnlyMode | ||
102 | }; | 102 | }; | ||
103 | Q_ENUM(ExecutionMode) | 103 | Q_ENUM(ExecutionMode) | ||
104 | 104 | | |||
105 | /** | 105 | /** | ||
106 | * The backend specific details. | ||||
107 | */ | ||||
108 | enum class AuthDetail { | ||||
sitter: consider enum class | |||||
109 | DetailOther = 0, | ||||
110 | DetailMessage, ///< The message to show in authentication dialog. | ||||
111 | }; | ||||
112 | Q_ENUM(AuthDetail) | ||||
113 | | ||||
114 | typedef QMap<AuthDetail, QVariant> DetailsMap; | ||||
115 | | ||||
116 | /** | ||||
106 | * @brief Default constructor | 117 | * @brief Default constructor | ||
107 | * | 118 | * | ||
108 | * This constructor sets the name to the empty string. | 119 | * This constructor sets the name to the empty string. | ||
109 | * Such an action is invalid and cannot be authorized nor executed, so | 120 | * Such an action is invalid and cannot be authorized nor executed, so | ||
110 | * you need to call setName() before you can use the object. | 121 | * you need to call setName() before you can use the object. | ||
111 | */ | 122 | */ | ||
112 | Action(); | 123 | Action(); | ||
113 | 124 | | |||
114 | /** Copy constructor */ | 125 | /** Copy constructor */ | ||
115 | Action(const Action &action); | 126 | Action(const Action &action); | ||
116 | 127 | | |||
117 | /** | 128 | /** | ||
118 | * This creates a new action object with this name | 129 | * This creates a new action object with this name | ||
119 | * @param name The name of the new action | 130 | * @param name The name of the new action | ||
120 | */ | 131 | */ | ||
121 | Action(const QString &name); | 132 | Action(const QString &name); | ||
122 | 133 | | |||
123 | /** | 134 | /** | ||
124 | * This creates a new action object with this name and details | 135 | * This creates a new action object with this name and details | ||
125 | * @param name The name of the new action | 136 | * @param name The name of the new action | ||
126 | * @param details The details of the action | 137 | * @param details The details of the action | ||
127 | * | 138 | * | ||
128 | * @see setDetails | 139 | * @see setDetails | ||
140 | * @deprecated since 5.68 | ||||
141 | */ | ||||
142 | #ifndef KAUTHCORE_NO_DEPRECATED | ||||
143 | KAUTHCORE_DEPRECATED Action(const QString &name, const QString &details); | ||||
144 | #endif | ||||
145 | | ||||
146 | /** | ||||
147 | * This creates a new action object with this name and details | ||||
148 | * @param name The name of the new action | ||||
149 | * @param details The details of the action | ||||
150 | * | ||||
151 | * @see setDetails | ||||
152 | * @since 5.68 | ||||
129 | */ | 153 | */ | ||
130 | Action(const QString &name, const QString &details); | 154 | Action(const QString &name, const DetailsMap &details); | ||
131 | 155 | | |||
132 | /// Virtual destructor | 156 | /// Virtual destructor | ||
133 | ~Action(); | 157 | ~Action(); | ||
134 | 158 | | |||
135 | /// Assignment operator | 159 | /// Assignment operator | ||
136 | Action &operator=(const Action &action); | 160 | Action &operator=(const Action &action); | ||
137 | 161 | | |||
138 | /** | 162 | /** | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
202 | void setTimeout(int timeout); | 226 | void setTimeout(int timeout); | ||
203 | 227 | | |||
204 | /** | 228 | /** | ||
205 | * @brief Sets the action's details | 229 | * @brief Sets the action's details | ||
206 | * | 230 | * | ||
207 | * You can use this function to provide the user more details | 231 | * You can use this function to provide the user more details | ||
208 | * (if the backend supports it) on the action being authorized in | 232 | * (if the backend supports it) on the action being authorized in | ||
209 | * the authorization dialog | 233 | * the authorization dialog | ||
234 | * | ||||
235 | * @deprecated since 5.68, use setDetails() with DetailsMap. | ||||
236 | */ | ||||
237 | #ifndef KAUTHCORE_NO_DEPRECATED | ||||
238 | KAUTHCORE_DEPRECATED void setDetails(const QString &details); | ||||
239 | #endif | ||||
240 | | ||||
241 | /** | ||||
242 | * @brief Sets the action's details | ||||
243 | * | ||||
244 | * You can use this function to provide the user more details | ||||
245 | * (if the backend supports it) on the action being authorized in | ||||
246 | * the authorization dialog | ||||
247 | * | ||||
248 | * @param details the details describing the action. For e.g, "DetailMessage" key can | ||||
249 | * be used to give a customized authentication message. | ||||
250 | * | ||||
251 | * @since 5.68 | ||||
252 | */ | ||||
253 | void setDetailsV2(const DetailsMap &details); | ||||
For consistency with the associated getter I would actually call this setDetailsV2 even though technically not necessary. sitter: For consistency with the associated getter I would actually call this setDetailsV2 even though… | |||||
254 | | ||||
255 | /** | ||||
256 | * @brief Gets the action's details | ||||
257 | * | ||||
258 | * The details that will be shown in the authorization dialog, if the | ||||
259 | * backend supports it. | ||||
260 | * | ||||
261 | * @return The action's details | ||||
262 | * @deprecated since 5.68, use detailsV2() with DetailsMap. | ||||
sitter: should say V2 | |||||
210 | */ | 263 | */ | ||
211 | void setDetails(const QString &details); | 264 | #ifndef KAUTHCORE_NO_DEPRECATED | ||
265 | KAUTHCORE_DEPRECATED QString details() const; | ||||
266 | #endif | ||||
212 | 267 | | |||
213 | /** | 268 | /** | ||
214 | * @brief Gets the action's details | 269 | * @brief Gets the action's details | ||
215 | * | 270 | * | ||
216 | * The details that will be shown in the authorization dialog, if the | 271 | * The details that will be shown in the authorization dialog, if the | ||
217 | * backend supports it. | 272 | * backend supports it. | ||
218 | * | 273 | * | ||
219 | * @return The action's details | 274 | * @return The action's details | ||
275 | * @since 5.68 | ||||
220 | */ | 276 | */ | ||
221 | QString details() const; | 277 | DetailsMap detailsV2() const; | ||
222 | 278 | | |||
this seems like super leaky abstraction. you are allowing the caller to set backend specific stuff here. I think it'd be much better to make an enum for detail types, and have this be a QMap of enum,QVariant. if the caller sets polkit.message then that won't apply to the mac backend even if someone were to implement the relevant functionality there. if it is a general purpose enum key each backend can easily implement or ignore as necessary sitter: this seems like super leaky abstraction. you are allowing the caller to set backend specific… | |||||
223 | /** | 279 | /** | ||
224 | * @brief Returns if the object represents a valid action | 280 | * @brief Returns if the object represents a valid action | ||
225 | * | 281 | * | ||
226 | * Action names have to respect a simple syntax. | 282 | * Action names have to respect a simple syntax. | ||
227 | * They have to be all in lowercase characters, separated | 283 | * They have to be all in lowercase characters, separated | ||
228 | * by dots. Dots can't appear at the beginning and at the end of | 284 | * by dots. Dots can't appear at the beginning and at the end of | ||
229 | * the name. | 285 | * the name. | ||
230 | * | 286 | * | ||
231 | * In other words, the action name has to match this perl-like | 287 | * In other words, the action name has to match this perl-like | ||
232 | * regular expression: | 288 | * regular expression: | ||
sitter: Should the old functions maybe be marked deprecated? | |||||
I deprecated it. Except the unit tests this isn't used anywhere in the backend. chinmoyr: I deprecated it. Except the unit tests this isn't used anywhere in the backend. | |||||
233 | * @verbatim | 289 | * @verbatim | ||
234 | * /^[a-z]+(\.[a-z]+)*$/ | 290 | * /^[a-z]+(\.[a-z]+)*$/ | ||
235 | * @endverbatim | 291 | * @endverbatim | ||
236 | * | 292 | * | ||
237 | * This method returns false if the action name doesn't match the | 293 | * This method returns false if the action name doesn't match the | ||
238 | * valid syntax. | 294 | * valid syntax. | ||
239 | * | 295 | * | ||
240 | * If the backend supports it, this method also checks if the action is | 296 | * If the backend supports it, this method also checks if the action is | ||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |
consider enum class