| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* GATE PROJECT LICENSE: | ||
| 2 | +----------------------------------------------------------------------------+ | ||
| 3 | | Copyright(c) 2018-2025, Stefan Meislinger | | ||
| 4 | | All rights reserved. | | ||
| 5 | | | | ||
| 6 | | Redistribution and use in source and binary forms, with or without | | ||
| 7 | | modification, are permitted provided that the following conditions are met:| | ||
| 8 | | | | ||
| 9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
| 10 | | this list of conditions and the following disclaimer. | | ||
| 11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
| 12 | | notice, this list of conditions and the following disclaimer in the | | ||
| 13 | | documentation and/or other materials provided with the distribution. | | ||
| 14 | | | | ||
| 15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
| 16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
| 17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
| 18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
| 19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
| 20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
| 21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
| 22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
| 23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
| 24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
| 25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
| 26 | +----------------------------------------------------------------------------+ | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include "gate/system/accounts.hpp" | ||
| 30 | #include "gate/memalloc.hpp" | ||
| 31 | #include "gate/exceptions.hpp" | ||
| 32 | #include "gate/wrappers.hpp" | ||
| 33 | |||
| 34 | namespace gate | ||
| 35 | { | ||
| 36 | namespace sys | ||
| 37 | { | ||
| 38 | |||
| 39 | 2 | Accounts::User::User() noexcept | |
| 40 | { | ||
| 41 | 2 | Mem::clear(this->impl); | |
| 42 | 2 | this->impl.short_id = GATE_ACCOUNT_INVALID_SHORT_ID; | |
| 43 | 2 | } | |
| 44 | |||
| 45 | 45 | Accounts::User::User(gate_account_user_t const& user) | |
| 46 | { | ||
| 47 | 45 | Mem::copy(this->impl, user); | |
| 48 | 45 | } | |
| 49 | 38 | Accounts::User::User(User const& src) | |
| 50 | { | ||
| 51 | 38 | Mem::copy(this->impl, src.impl); | |
| 52 | 38 | } | |
| 53 | 3 | Accounts::User& Accounts::User::operator=(User const& src) | |
| 54 | { | ||
| 55 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (this != &src) |
| 56 | { | ||
| 57 | 3 | this->id_shadow = String(); | |
| 58 | 3 | this->name_shadow = String(); | |
| 59 | 3 | this->info_shadow = String(); | |
| 60 | 3 | this->descr_shadow = String(); | |
| 61 | 3 | Mem::copy(this->impl, src.impl); | |
| 62 | } | ||
| 63 | 3 | return *this; | |
| 64 | } | ||
| 65 | |||
| 66 | 85 | Accounts::User::~User() noexcept | |
| 67 | { | ||
| 68 | 85 | Mem::clear(this->impl); | |
| 69 | 85 | } | |
| 70 | |||
| 71 | 11 | static String& shadow_update(char const* src, String& dst) | |
| 72 | { | ||
| 73 |
6/6✓ Branch 1 taken 7 times.
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 6 times.
|
11 | if (dst.empty() && !gate_str_is_empty(src)) |
| 74 | { | ||
| 75 | 5 | dst = String(src); | |
| 76 | } | ||
| 77 | 11 | return dst; | |
| 78 | } | ||
| 79 | |||
| 80 | 2 | String Accounts::User::Id() | |
| 81 | { | ||
| 82 | 2 | return shadow_update(this->impl.id, this->id_shadow); | |
| 83 | } | ||
| 84 | 1 | uint64_t Accounts::User::ShortId() const | |
| 85 | { | ||
| 86 | 1 | return this->impl.short_id; | |
| 87 | } | ||
| 88 | 2 | String Accounts::User::Name() | |
| 89 | { | ||
| 90 | 2 | return shadow_update(this->impl.name, this->name_shadow); | |
| 91 | } | ||
| 92 | 1 | String Accounts::User::Info() | |
| 93 | { | ||
| 94 | 1 | return shadow_update(this->impl.info, this->info_shadow); | |
| 95 | } | ||
| 96 | 1 | String Accounts::User::Description() | |
| 97 | { | ||
| 98 | 1 | return shadow_update(this->impl.description, this->descr_shadow); | |
| 99 | } | ||
| 100 | 1 | uint32_t Accounts::User::Flags() const | |
| 101 | { | ||
| 102 | 1 | return this->impl.flags; | |
| 103 | } | ||
| 104 | 88 | gate_account_user_t const* Accounts::User::c_impl() const | |
| 105 | { | ||
| 106 | 88 | return &this->impl; | |
| 107 | } | ||
| 108 | |||
| 109 | 1 | Accounts::Group::Group() noexcept | |
| 110 | { | ||
| 111 | 1 | Mem::clear(this->impl); | |
| 112 | 1 | } | |
| 113 | 127 | Accounts::Group::Group(gate_account_group_t const& group) | |
| 114 | { | ||
| 115 | 127 | Mem::copy(this->impl, group); | |
| 116 | 127 | } | |
| 117 | 105 | Accounts::Group::Group(Group const& src) | |
| 118 | { | ||
| 119 | 105 | Mem::copy(this->impl, src.impl); | |
| 120 | 105 | } | |
| 121 | 1 | Accounts::Group& Accounts::Group::operator=(Group const& src) | |
| 122 | { | ||
| 123 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (this != &src) |
| 124 | { | ||
| 125 | 1 | this->id_shadow = String(); | |
| 126 | 1 | this->name_shadow = String(); | |
| 127 | 1 | this->descr_shadow = String(); | |
| 128 | 1 | Mem::copy(this->impl, src.impl); | |
| 129 | } | ||
| 130 | 1 | return *this; | |
| 131 | } | ||
| 132 | 233 | Accounts::Group::~Group() noexcept | |
| 133 | { | ||
| 134 | 233 | Mem::clear(this->impl); | |
| 135 | 233 | } | |
| 136 | |||
| 137 | 2 | String Accounts::Group::Id() | |
| 138 | { | ||
| 139 | 2 | return shadow_update(this->impl.id, this->id_shadow); | |
| 140 | } | ||
| 141 | 1 | uint64_t Accounts::Group::ShortId() const | |
| 142 | { | ||
| 143 | 1 | return this->impl.short_id; | |
| 144 | } | ||
| 145 | 2 | String Accounts::Group::Name() | |
| 146 | { | ||
| 147 | 2 | return shadow_update(this->impl.name, this->name_shadow); | |
| 148 | } | ||
| 149 | 1 | String Accounts::Group::Description() | |
| 150 | { | ||
| 151 | 1 | return shadow_update(this->impl.description, this->descr_shadow); | |
| 152 | } | ||
| 153 | 1 | uint32_t Accounts::Group::Flags() const | |
| 154 | { | ||
| 155 | 1 | return this->impl.flags; | |
| 156 | } | ||
| 157 | 147 | gate_account_group_t const* Accounts::Group::c_impl() const | |
| 158 | { | ||
| 159 | 147 | return &this->impl; | |
| 160 | } | ||
| 161 | |||
| 162 | |||
| 163 | |||
| 164 | |||
| 165 | struct GATE_API_LOCAL enumUsers_callback_dispatcher_param | ||
| 166 | { | ||
| 167 | Accounts::EnumUserCallback const* callback; | ||
| 168 | void* original_param; | ||
| 169 | Optional<Exception> error; | ||
| 170 | |||
| 171 | 42 | enumUsers_callback_dispatcher_param() | |
| 172 | 42 | : callback(NULL), original_param(NULL) | |
| 173 | { | ||
| 174 | 42 | } | |
| 175 | }; | ||
| 176 | |||
| 177 | 21 | static gate_bool_t Accounts_enumUsers_callback_dispatcher(gate_account_user_t const* account_user, void* param) | |
| 178 | { | ||
| 179 |
2/4✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | if (account_user && param) |
| 180 | { | ||
| 181 | 21 | enumUsers_callback_dispatcher_param* disp_param = static_cast<enumUsers_callback_dispatcher_param*>(param); | |
| 182 | try | ||
| 183 | { | ||
| 184 | 42 | Accounts::User user(*account_user); | |
| 185 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | disp_param->callback->invoke(user, disp_param->original_param); |
| 186 | } | ||
| 187 | ✗ | catch (Exception const& xcpt) | |
| 188 | { | ||
| 189 | ✗ | disp_param->error.create(xcpt); | |
| 190 | ✗ | return false; | |
| 191 | } | ||
| 192 | ✗ | catch (...) | |
| 193 | { | ||
| 194 | ✗ | disp_param->error.create(Exception(results::UnknownException, "Unsupported exception type", "Accounts_enumUsers_callback_dispatcher")); | |
| 195 | ✗ | return false; | |
| 196 | } | ||
| 197 | } | ||
| 198 | 21 | return true; | |
| 199 | } | ||
| 200 | |||
| 201 | struct GATE_API_LOCAL enumGroups_callback_dispatcher_param | ||
| 202 | { | ||
| 203 | Accounts::EnumGroupCallback const* callback; | ||
| 204 | void* original_param; | ||
| 205 | Optional<Exception> error; | ||
| 206 | |||
| 207 | 22 | enumGroups_callback_dispatcher_param() | |
| 208 | 22 | : callback(NULL), original_param(NULL) | |
| 209 | { | ||
| 210 | 22 | } | |
| 211 | }; | ||
| 212 | |||
| 213 | 62 | static gate_bool_t Accounts_enumGroups_callback_dispatcher(gate_account_group_t const* account_group, void* param) | |
| 214 | { | ||
| 215 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
|
62 | if (account_group && param) |
| 216 | { | ||
| 217 | 62 | enumGroups_callback_dispatcher_param* disp_param = static_cast<enumGroups_callback_dispatcher_param*>(param); | |
| 218 | try | ||
| 219 | { | ||
| 220 | 124 | Accounts::Group group(*account_group); | |
| 221 |
1/2✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
|
62 | disp_param->callback->invoke(group, disp_param->original_param); |
| 222 | } | ||
| 223 | ✗ | catch (Exception const& xcpt) | |
| 224 | { | ||
| 225 | ✗ | disp_param->error.create(xcpt); | |
| 226 | ✗ | return false; | |
| 227 | } | ||
| 228 | ✗ | catch (...) | |
| 229 | { | ||
| 230 | ✗ | disp_param->error.create(Exception(results::UnknownException, "Unsupported exception type", "Accounts_enumGroups_callback_dispatcher")); | |
| 231 | ✗ | return false; | |
| 232 | } | ||
| 233 | } | ||
| 234 | 62 | return true; | |
| 235 | } | ||
| 236 | |||
| 237 | 21 | static gate_bool_t Accounts_listUsers_callback(gate_account_user_t const* account_user, void* param) | |
| 238 | { | ||
| 239 |
2/4✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | if (account_user && param) |
| 240 | { | ||
| 241 | 21 | ArrayList<Accounts::User>* list = static_cast<ArrayList<Accounts::User>*>(param); | |
| 242 | try | ||
| 243 | { | ||
| 244 | 42 | Accounts::User user(*account_user); | |
| 245 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | list->add(user); |
| 246 | } | ||
| 247 | ✗ | catch (...) | |
| 248 | { | ||
| 249 | } | ||
| 250 | } | ||
| 251 | 21 | return true; | |
| 252 | } | ||
| 253 | |||
| 254 | 62 | static gate_bool_t Accounts_listGroups_callback(gate_account_group_t const* account_group, void* param) | |
| 255 | { | ||
| 256 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
|
62 | if (account_group && param) |
| 257 | { | ||
| 258 | 62 | ArrayList<Accounts::Group>* list = static_cast<ArrayList<Accounts::Group>*>(param); | |
| 259 | try | ||
| 260 | { | ||
| 261 | 124 | Accounts::Group user(*account_group); | |
| 262 |
1/2✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
|
62 | list->add(user); |
| 263 | } | ||
| 264 | ✗ | catch (...) | |
| 265 | { | ||
| 266 | } | ||
| 267 | } | ||
| 268 | 62 | return true; | |
| 269 | } | ||
| 270 | 1 | void Accounts::enumUsers(EnumUserCallback const& callback, void* param) | |
| 271 | { | ||
| 272 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | enumUsers_callback_dispatcher_param disp_param; |
| 273 | 1 | disp_param.callback = &callback; | |
| 274 | 1 | disp_param.original_param = param; | |
| 275 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_account_enum_users(&Accounts_enumUsers_callback_dispatcher, &disp_param); |
| 276 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 277 | |||
| 278 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (!disp_param.error.empty()) |
| 279 | { | ||
| 280 | ✗ | if (disp_param.error->getResult() != results::Canceled) | |
| 281 | { | ||
| 282 | ✗ | Exception xcpt(*disp_param.error); | |
| 283 | ✗ | throw xcpt; | |
| 284 | } | ||
| 285 | } | ||
| 286 | 1 | } | |
| 287 | |||
| 288 | 1 | Array<Accounts::User> Accounts::listUsers() | |
| 289 | { | ||
| 290 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ArrayList<User> list(16); |
| 291 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_account_enum_users(&Accounts_listUsers_callback, &list); |
| 292 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 293 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return list.toArray(); |
| 294 | } | ||
| 295 | 1 | Accounts::User Accounts::getUser(String const& id) | |
| 296 | { | ||
| 297 | gate_account_user_t user; | ||
| 298 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | result_t result = gate_account_get_user(id.c_impl(), &user); |
| 299 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 300 | 2 | return User(user); | |
| 301 | } | ||
| 302 | 2 | Accounts::User Accounts::resolveUser(String const& name) | |
| 303 | { | ||
| 304 | gate_account_user_t user; | ||
| 305 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | result_t result = gate_account_resolve_user(name.c_impl(), &user); |
| 306 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
2 | GATEXX_CHECK_EXCEPTION(result); |
| 307 | 4 | return User(user); | |
| 308 | } | ||
| 309 | 1 | void Accounts::createUser(String const& name, String const& password) | |
| 310 | { | ||
| 311 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_account_create_user(name.c_impl(), password.empty() ? NULL : password.c_impl()); |
| 312 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 313 | 1 | } | |
| 314 | 1 | void Accounts::deleteUser(User const& user) | |
| 315 | { | ||
| 316 | 1 | result_t result = gate_account_delete_user(user.c_impl()); | |
| 317 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 318 | 1 | } | |
| 319 | 21 | void Accounts::enumUserMemberships(User const& user, EnumGroupCallback const& callback, void* param) | |
| 320 | { | ||
| 321 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
42 | enumGroups_callback_dispatcher_param disp_param; |
| 322 | 21 | disp_param.callback = &callback; | |
| 323 | 21 | disp_param.original_param = param; | |
| 324 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | result_t result = gate_account_enum_user_memberships(user.c_impl(), &Accounts_enumGroups_callback_dispatcher, &disp_param); |
| 325 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
21 | GATEXX_CHECK_EXCEPTION(result); |
| 326 | |||
| 327 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
|
21 | if (!disp_param.error.empty()) |
| 328 | { | ||
| 329 | ✗ | if (disp_param.error->getResult() != results::Canceled) | |
| 330 | { | ||
| 331 | ✗ | Exception xcpt(*disp_param.error); | |
| 332 | ✗ | throw xcpt; | |
| 333 | } | ||
| 334 | } | ||
| 335 | 21 | } | |
| 336 | 21 | Array<Accounts::Group> Accounts::listUserMemberships(User const& user) | |
| 337 | { | ||
| 338 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
42 | ArrayList<Group> list(16); |
| 339 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | result_t result = gate_account_enum_user_memberships(user.c_impl(), &Accounts_listGroups_callback, &list); |
| 340 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
21 | GATEXX_CHECK_EXCEPTION(result); |
| 341 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
42 | return list.toArray(); |
| 342 | } | ||
| 343 | 21 | Property Accounts::getUserProperties(User const& user) | |
| 344 | { | ||
| 345 | 21 | gate_property_t prop = GATE_INIT_EMPTY; | |
| 346 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | result_t result = gate_account_get_user_properties(user.c_impl(), &prop); |
| 347 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
21 | GATEXX_CHECK_EXCEPTION(result); |
| 348 | try | ||
| 349 | { | ||
| 350 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
42 | Property propObj(prop); |
| 351 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | gate_property_destroy(&prop); |
| 352 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
42 | return propObj; |
| 353 | } | ||
| 354 | ✗ | catch (...) | |
| 355 | { | ||
| 356 | ✗ | gate_property_destroy(&prop); | |
| 357 | ✗ | throw; | |
| 358 | } | ||
| 359 | } | ||
| 360 | ✗ | void Accounts::setUserProperty(User const& user, String const& propName, Property const& propValue) | |
| 361 | { | ||
| 362 | ✗ | result_t result = gate_account_set_user_property(user.c_impl(), propName.c_impl(), propValue.c_impl()); | |
| 363 | ✗ | GATEXX_CHECK_EXCEPTION(result); | |
| 364 | ✗ | } | |
| 365 | |||
| 366 | 1 | void Accounts::enumGroups(EnumGroupCallback const& callback, void* param) | |
| 367 | { | ||
| 368 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | enumGroups_callback_dispatcher_param disp_param; |
| 369 | 1 | disp_param.callback = &callback; | |
| 370 | 1 | disp_param.original_param = param; | |
| 371 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_account_enum_groups(&Accounts_enumGroups_callback_dispatcher, &disp_param); |
| 372 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 373 | |||
| 374 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | if (!disp_param.error.empty()) |
| 375 | { | ||
| 376 | ✗ | if (disp_param.error->getResult() != results::Canceled) | |
| 377 | { | ||
| 378 | ✗ | Exception xcpt(*disp_param.error); | |
| 379 | ✗ | throw xcpt; | |
| 380 | } | ||
| 381 | } | ||
| 382 | |||
| 383 | 1 | } | |
| 384 | 1 | Array<Accounts::Group> Accounts::listGroups() | |
| 385 | { | ||
| 386 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | ArrayList<Group> list(16); |
| 387 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_account_enum_groups(&Accounts_listGroups_callback, &list); |
| 388 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 389 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return list.toArray(); |
| 390 | } | ||
| 391 | 1 | Accounts::Group Accounts::getGroup(String const& id) | |
| 392 | { | ||
| 393 | gate_account_group_t group; | ||
| 394 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | result_t result = gate_account_get_group(id.c_impl(), &group); |
| 395 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 396 | 2 | return Group(group); | |
| 397 | } | ||
| 398 | 2 | Accounts::Group Accounts::resolveGroup(String const& name) | |
| 399 | { | ||
| 400 | gate_account_group_t group; | ||
| 401 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | result_t result = gate_account_resolve_group(name.c_impl(), &group); |
| 402 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
2 | GATEXX_CHECK_EXCEPTION(result); |
| 403 | 4 | return Group(group); | |
| 404 | } | ||
| 405 | 1 | void Accounts::createGroup(String const& name) | |
| 406 | { | ||
| 407 | 1 | result_t result = gate_account_create_group(name.c_impl()); | |
| 408 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 409 | 1 | } | |
| 410 | 1 | void Accounts::deleteGroup(Group const& group) | |
| 411 | { | ||
| 412 | 1 | result_t result = gate_account_delete_group(group.c_impl()); | |
| 413 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 414 | 1 | } | |
| 415 | 41 | void Accounts::enumGroupMembers(Group const& group, EnumUserCallback const& callback, void* param) | |
| 416 | { | ||
| 417 |
1/2✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
|
82 | enumUsers_callback_dispatcher_param disp_param; |
| 418 | 41 | disp_param.callback = &callback; | |
| 419 | 41 | disp_param.original_param = param; | |
| 420 |
1/2✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
|
41 | result_t result = gate_account_enum_group_members(group.c_impl(), &Accounts_enumUsers_callback_dispatcher, &disp_param); |
| 421 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
41 | GATEXX_CHECK_EXCEPTION(result); |
| 422 | |||
| 423 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
|
41 | if (!disp_param.error.empty()) |
| 424 | { | ||
| 425 | ✗ | if (disp_param.error->getResult() != results::Canceled) | |
| 426 | { | ||
| 427 | ✗ | Exception xcpt(*disp_param.error); | |
| 428 | ✗ | throw xcpt; | |
| 429 | } | ||
| 430 | } | ||
| 431 | 41 | } | |
| 432 | 41 | Array<Accounts::User> Accounts::listGroupMembers(Group const& group) | |
| 433 | { | ||
| 434 |
1/2✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
|
82 | ArrayList<User> list(16); |
| 435 |
1/2✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
|
41 | result_t result = gate_account_enum_group_members(group.c_impl(), &Accounts_listUsers_callback, &list); |
| 436 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
41 | GATEXX_CHECK_EXCEPTION(result); |
| 437 |
1/2✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
|
82 | return list.toArray(); |
| 438 | } | ||
| 439 | |||
| 440 | |||
| 441 | 1 | void Accounts::addUserToGroup(User const& user, Group const& group) | |
| 442 | { | ||
| 443 | 1 | result_t result = gate_account_add_user_to_group(user.c_impl(), group.c_impl()); | |
| 444 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 445 | 1 | } | |
| 446 | 1 | void Accounts::removeUserFromGroup(User const& user, Group const& group) | |
| 447 | { | ||
| 448 | 1 | result_t result = gate_account_remove_user_from_group(user.c_impl(), group.c_impl()); | |
| 449 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 450 | 1 | } | |
| 451 | |||
| 452 | } // end of namespace sys | ||
| 453 | } // end of namespace gate | ||
| 454 |