| 1 | /* |
| 2 | * This file is part of DisOrder |
| 3 | * Copyright (C) 2007 Richard Kettlewell |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | /** @file lib/rights.h |
| 19 | * @brief User rights |
| 20 | */ |
| 21 | |
| 22 | #ifndef RIGHTS_H |
| 23 | #define RIGHTS_H |
| 24 | |
| 25 | struct queue_entry; |
| 26 | |
| 27 | /** @brief User can perform read-only operations */ |
| 28 | #define RIGHT_READ 0x00000001 |
| 29 | |
| 30 | /** @brief User can add tracks to the queue */ |
| 31 | #define RIGHT_PLAY 0x00000002 |
| 32 | |
| 33 | /** @brief User can move any track */ |
| 34 | #define RIGHT_MOVE_ANY 0x00000004 |
| 35 | |
| 36 | /** @brief User can move their own tracks */ |
| 37 | #define RIGHT_MOVE_MINE 0x00000008 |
| 38 | |
| 39 | /** @brief User can move randomly chosen tracks */ |
| 40 | #define RIGHT_MOVE_RANDOM 0x00000010 |
| 41 | |
| 42 | #define RIGHT_MOVE__MASK 0x0000001c |
| 43 | |
| 44 | /** @brief User can remove any track */ |
| 45 | #define RIGHT_REMOVE_ANY 0x00000020 |
| 46 | |
| 47 | /** @brief User can remove their own tracks */ |
| 48 | #define RIGHT_REMOVE_MINE 0x00000040 |
| 49 | |
| 50 | /** @brief User can remove randomly chosen tracks */ |
| 51 | #define RIGHT_REMOVE_RANDOM 0x00000080 |
| 52 | |
| 53 | #define RIGHT_REMOVE__MASK 0x000000e0 |
| 54 | |
| 55 | /** @brief User can scratch any track */ |
| 56 | #define RIGHT_SCRATCH_ANY 0x00000100 |
| 57 | |
| 58 | /** @brief User can scratch their own tracks */ |
| 59 | #define RIGHT_SCRATCH_MINE 0x00000200 |
| 60 | |
| 61 | /** @brief User can scratch randomly chosen tracks */ |
| 62 | #define RIGHT_SCRATCH_RANDOM 0x00000400 |
| 63 | |
| 64 | #define RIGHT_SCRATCH__MASK 0x00000700 |
| 65 | |
| 66 | /** @brief User can change the volume */ |
| 67 | #define RIGHT_VOLUME 0x00000800 |
| 68 | |
| 69 | /** @brief User can perform admin operations */ |
| 70 | #define RIGHT_ADMIN 0x00001000 |
| 71 | |
| 72 | /** @brief User can initiate a rescan */ |
| 73 | #define RIGHT_RESCAN 0x00002000 |
| 74 | |
| 75 | /** @brief User can register new users */ |
| 76 | #define RIGHT_REGISTER 0x00004000 |
| 77 | |
| 78 | /** @brief User can edit their own userinfo */ |
| 79 | #define RIGHT_USERINFO 0x00008000 |
| 80 | |
| 81 | /** @brief User can modify track preferences */ |
| 82 | #define RIGHT_PREFS 0x00010000 |
| 83 | |
| 84 | /** @brief User can modify global preferences */ |
| 85 | #define RIGHT_GLOBAL_PREFS 0x00020000 |
| 86 | |
| 87 | /** @brief User can pause/resume */ |
| 88 | #define RIGHT_PAUSE 0x00040000 |
| 89 | |
| 90 | /** @brief Current rights mask */ |
| 91 | #define RIGHTS__MASK 0x0007ffff |
| 92 | |
| 93 | /** @brief Connection is local |
| 94 | * |
| 95 | * This isn't a rights bit, it's used in @file server.c to limit |
| 96 | * certain commands to local connections. |
| 97 | */ |
| 98 | #define RIGHT__LOCAL 0x80000000 |
| 99 | |
| 100 | /** @brief Unsigned type big enough for rights */ |
| 101 | typedef uint32_t rights_type; |
| 102 | |
| 103 | char *rights_string(rights_type r); |
| 104 | int parse_rights(const char *s, rights_type *rp, int report); |
| 105 | int right_scratchable(rights_type rights, const char *who, |
| 106 | const struct queue_entry *q); |
| 107 | int right_movable(rights_type rights, const char *who, |
| 108 | const struct queue_entry *q); |
| 109 | int right_removable(rights_type rights, const char *who, |
| 110 | const struct queue_entry *q); |
| 111 | |
| 112 | #endif /* RIGHTS_H */ |
| 113 | |
| 114 | /* |
| 115 | Local Variables: |
| 116 | c-basic-offset:2 |
| 117 | comment-column:40 |
| 118 | fill-column:79 |
| 119 | indent-tabs-mode:nil |
| 120 | End: |
| 121 | */ |