public bool registerKey(string path, string key, int type, string title, string description, string defaultValue, bool advanced) { SettingsRequestMessage.Builder newMessage = SettingsRequestMessage.CreateBuilder(); SettingsRequestMessage.Types.Request.Types.Registration.Builder registration_builder = SettingsRequestMessage.Types.Request.Types.Registration.CreateBuilder(); registration_builder.SetNode(Settings.Types.Node.CreateBuilder().SetPath(path).SetKey(key).Build()); registration_builder.SetInfo(Settings.Types.Information.CreateBuilder().SetTitle(title).SetDescription(description).Build()); newMessage.AddPayload(SettingsRequestMessage.Types.Request.CreateBuilder().SetPluginId(plugin_id).SetRegistration(registration_builder.Build()).Build()); SettingsRequestMessage message = newMessage.Build(); System.IO.MemoryStream stream = new System.IO.MemoryStream(); message.WriteTo(stream); NSCP.Core.Result res = core.settings(stream.ToArray()); if (!res.result) { log.error("Failed to describe key: " + path); return(false); } SettingsResponseMessage response_message = SettingsResponseMessage.ParseFrom(res.data); if (response_message.GetPayload(0).Result.Code != Common.Types.Result.Types.StatusCodeType.STATUS_OK) { log.error("Failed to describe key: " + path); return(false); } return(true); }
public bool reload(string context) { SettingsRequestMessage.Builder newMessage = SettingsRequestMessage.CreateBuilder(); SettingsRequestMessage.Types.Request.Types.Control.Builder registration_builder = SettingsRequestMessage.Types.Request.Types.Control.CreateBuilder(); registration_builder.SetContext(context); registration_builder.SetCommand(Settings.Types.Command.RELOAD); newMessage.AddPayload(SettingsRequestMessage.Types.Request.CreateBuilder().SetPluginId(plugin_id).SetControl(registration_builder.Build()).Build()); SettingsRequestMessage message = newMessage.Build(); System.IO.MemoryStream stream = new System.IO.MemoryStream(); message.WriteTo(stream); NSCP.Core.Result res = core.settings(stream.ToArray()); if (!res.result) { log.error("Failed to save: " + context); return(false); } SettingsResponseMessage response_message = SettingsResponseMessage.ParseFrom(res.data); if (response_message.GetPayload(0).Result.Code != Common.Types.Result.Types.StatusCodeType.STATUS_OK) { log.error("Failed to save: " + context); return(false); } return(true); }