Пример #1
0
        public bool registerKey(string path, string key, int type, string title, string description, string defaultValue, bool advanced)
        {
            SettingsRequestMessage newMessage = new SettingsRequestMessage();

            SettingsRequestMessage.Types.Request.Types.Registration registration_builder = new SettingsRequestMessage.Types.Request.Types.Registration();
            registration_builder.Node             = new Node();
            registration_builder.Node.Path        = path;
            registration_builder.Node.Key         = key;
            registration_builder.Info             = new PB.Settings.Information();
            registration_builder.Info.Title       = title;
            registration_builder.Info.Description = description;
            NSCP.Core.Result res = core.settings(newMessage.ToByteArray());
            if (!res.result)
            {
                log.error("Failed to describe path: " + path);
                return(false);
            }
            SettingsResponseMessage response_message = SettingsResponseMessage.Parser.ParseFrom(res.data);

            if (response_message.Payload[0].Result.Code != PB.Common.Result.Types.StatusCodeType.StatusOk)
            {
                log.error("Failed to describe path: " + path);
                return(false);
            }
            return(true);
        }
Пример #2
0
        public bool reload(string context)
        {
            SettingsRequestMessage newMessage = new SettingsRequestMessage();

            SettingsRequestMessage.Types.Request.Types.Control registration_builder = new SettingsRequestMessage.Types.Request.Types.Control();
            registration_builder.Context = context;
            registration_builder.Command = PB.Settings.Command.Reload;
            SettingsRequestMessage.Types.Request request = new SettingsRequestMessage.Types.Request();
            request.PluginId = plugin_id;
            request.Control  = registration_builder;
            newMessage.Payload.Add(request);
            NSCP.Core.Result res = core.settings(newMessage.ToByteArray());
            if (!res.result)
            {
                log.error("Failed to reload: " + context);
                return(false);
            }
            SettingsResponseMessage response_message = SettingsResponseMessage.Parser.ParseFrom(res.data);

            if (response_message.Payload[0].Result.Code != PB.Common.Result.Types.StatusCodeType.StatusOk)
            {
                log.error("Failed to reload: " + context);
                return(false);
            }
            return(true);
        }
Пример #3
0
        public void setString(string path, string key, string value)
        {
            SettingsRequestMessage newMessage = new SettingsRequestMessage();

            SettingsRequestMessage.Types.Request.Types.Update newQuery = new SettingsRequestMessage.Types.Request.Types.Update();
            newQuery.Node       = new Node();
            newQuery.Node.Path  = path;
            newQuery.Node.Key   = key;
            newQuery.Node.Value = value;
            SettingsRequestMessage.Types.Request request = new SettingsRequestMessage.Types.Request();
            request.PluginId = plugin_id;
            request.Update   = newQuery;
            newMessage.Payload.Add(request);
            NSCP.Core.Result res = core.settings(newMessage.ToByteArray());
            if (!res.result)
            {
                log.error("Failed to set value: " + path);
                return;
            }
            SettingsResponseMessage response_message = SettingsResponseMessage.Parser.ParseFrom(res.data);

            if (response_message.Payload[0].Result.Code != PB.Common.Result.Types.StatusCodeType.StatusOk)
            {
                log.error("Failed to set value: " + path);
                return;
            }
        }
Пример #4
0
        public List <string> getKeys(string path)
        {
            List <string>          ret        = new List <string>();
            SettingsRequestMessage newMessage = new SettingsRequestMessage();

            SettingsRequestMessage.Types.Request.Types.Query newQuery = new SettingsRequestMessage.Types.Request.Types.Query();
            newQuery.Node      = new Node();
            newQuery.Node.Path = path;
            newQuery.Recursive = false;
            SettingsRequestMessage.Types.Request request = new SettingsRequestMessage.Types.Request();
            request.PluginId = plugin_id;
            request.Query    = newQuery;
            newMessage.Payload.Add(request);

            NSCP.Core.Result res = core.settings(newMessage.ToByteArray());

            if (!res.result)
            {
                log.error("Failed to get value: " + path);
                return(ret);
            }
            SettingsResponseMessage response_message = SettingsResponseMessage.Parser.ParseFrom(res.data);

            if (response_message.Payload == null || response_message.Payload.Count == 0 || response_message.Payload[0].Result == null)
            {
                log.error("Failed to get value: " + path);
                return(ret);
            }

            if (response_message.Payload[0].Result.Code != PB.Common.Result.Types.StatusCodeType.StatusOk)
            {
                log.error("Failed to get value: " + path);
                return(ret);
            }
            foreach (Node node in response_message.Payload[0].Query.Nodes)
            {
                ret.Add(node.Value);
            }
            return(ret);
        }
Пример #5
0
        public bool registerPath(string path, string title, string description, bool advanced)
        {
            SettingsRequestMessage newMessage = new SettingsRequestMessage();

            SettingsRequestMessage.Types.Request.Types.Registration registration_builder = new SettingsRequestMessage.Types.Request.Types.Registration();
            registration_builder.Node             = new Node();
            registration_builder.Node.Path        = path;
            registration_builder.Info             = new PB.Settings.Information();
            registration_builder.Info.Title       = title;
            registration_builder.Info.Description = description;

            SettingsRequestMessage.Types.Request request = new SettingsRequestMessage.Types.Request();
            request.PluginId     = plugin_id;
            request.Registration = registration_builder;
            newMessage.Payload.Add(request);

            NSCP.Core.Result res = core.settings(newMessage.ToByteArray());
            if (!res.result)
            {
                log.error("Failed to describe path: " + path);
                return(false);
            }
            SettingsResponseMessage response_message = SettingsResponseMessage.Parser.ParseFrom(res.data);

            if (response_message.Payload == null || response_message.Payload.Count == 0 || response_message.Payload[0].Result == null)
            {
                log.error("Failed to describe path: " + path);
                return(false);
            }

            if (response_message.Payload[0].Result.Code != PB.Common.Result.Types.StatusCodeType.StatusOk)
            {
                return(false);
            }
            return(true);
        }