aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--root_commands.c4
-rw-r--r--set.h1
-rw-r--r--storage_xml.c11
3 files changed, 16 insertions, 0 deletions
diff --git a/root_commands.c b/root_commands.c
index f9c6e8e9..80873c79 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -339,6 +339,10 @@ static int cmd_set_real(irc_t *irc, char **cmd, set_t **head, cmd_set_checkflags
set_t *s = set_find(head, set_name);
int st;
+ if (s && s->flags & SET_LOCKED) {
+ irc_rootmsg(irc, "This setting can not be changed");
+ return 0;
+ }
if (s && checkflags && checkflags(irc, s) == 0) {
return 0;
}
diff --git a/set.h b/set.h
index 3735d797..f0a51136 100644
--- a/set.h
+++ b/set.h
@@ -48,6 +48,7 @@ typedef enum {
SET_HIDDEN = 0x0200, /* Don't show up in setting lists. Mostly for internal storage. */
SET_PASSWORD = 0x0400, /* Value shows up in settings list as "********". */
SET_HIDDEN_DEFAULT = 0x0800, /* Hide unless changed from default. */
+ SET_LOCKED = 0x1000 /* Setting is locked, don't allow changing it */
} set_flags_t;
typedef struct set {
diff --git a/storage_xml.c b/storage_xml.c
index 107983cf..dbdd151d 100644
--- a/storage_xml.c
+++ b/storage_xml.c
@@ -64,9 +64,11 @@ static void xml_init(void)
static void handle_settings(struct xt_node *node, set_t **head)
{
struct xt_node *c;
+ struct set *s;
for (c = node->children; (c = xt_find_node(c, "setting")); c = c->next) {
char *name = xt_find_attr(c, "name");
+ char *locked = xt_find_attr(c, "locked");
if (!name) {
continue;
@@ -79,6 +81,12 @@ static void handle_settings(struct xt_node *node, set_t **head)
}
}
set_setstr(head, name, c->text);
+ if (locked && !g_strcasecmp(locked, "true")) {
+ s = set_find(head, name);
+ if (s) {
+ s->flags |= SET_LOCKED;
+ }
+ }
}
}
@@ -370,6 +378,9 @@ static void xml_generate_settings(struct xt_node *cur, set_t **head)
struct xt_node *xset;
xt_add_child(cur, xset = xt_new_node("setting", set->value, NULL));
xt_add_attr(xset, "name", set->key);
+ if (set->flags & SET_LOCKED) {
+ xt_add_attr(xset, "locked", "true");
+ }
}
}
}