@Override
 protected void populateChildren(List<IMediaResource> list) {
   Object folders[] = UserRecordAPI.GetAllUserRecords(getId());
   if (folders != null && folders.length > 0) {
     for (Object f : folders) {
       list.add(
           new CustomFolder(
               this,
               UserRecordAPI.GetUserRecordData(f, FIELD_TABLE),
               UserRecordAPI.GetUserRecordData(f, FIELD_TITLE)));
     }
   }
 }
예제 #2
0
  // Sets a configuration value for this plugin.
  @Override
  public void setConfigValue(String setting, String value) {
    Log.getInstance()
        .write(
            Log.LOGLEVEL_ALL,
            "PlugIn: setConfigValue received from Plugin Manager. Setting = "
                + setting
                + ":"
                + value);

    if (setting.startsWith(SETTING_LOGLEVEL)) {
      if (value.startsWith("None")) Log.getInstance().SetLogLevel(Log.LOGLEVEL_NONE);
      else if (value.startsWith("Error")) Log.getInstance().SetLogLevel(Log.LOGLEVEL_ERROR);
      else if (value.startsWith("Warn")) Log.getInstance().SetLogLevel(Log.LOGLEVEL_WARN);
      else if (value.startsWith("Trace")) Log.getInstance().SetLogLevel(Log.LOGLEVEL_TRACE);
      else if (value.startsWith("Verbose")) Log.getInstance().SetLogLevel(Log.LOGLEVEL_VERBOSE);
      else if (value.startsWith("Maximum")) Log.getInstance().SetLogLevel(Log.LOGLEVEL_ALL);
      else Log.getInstance().SetLogLevel(Log.LOGLEVEL_ERROR);
    } else if (setting.startsWith(SETTING_DEFAULT_MAX)) {
      if (value.equalsIgnoreCase("5309")) {
        System.out.println("LIR:: Deleting all user records.");
        UserRecordAPI.DeleteAllUserRecords(DataStore.STORE);
        showInFocus = null;
      } else Configuration.SetServerProperty(PROPERTY_DEFAULT_MAX, verifyMax(value));
    } else if (setting.startsWith(SETTING_REDUCE_TO_MAX)) {
      Configuration.SetServerProperty(PROPERTY_REDUCE_TO_MAX, value);
    } else if (setting.startsWith(SETTING_KEEP_OLDEST)) {
      Configuration.SetServerProperty(PROPERTY_KEEP_OLDEST, value);
    } else if (setting.startsWith(SETTING_PICK_SHOW)) {

      // The user just selected a show.  Put it in focus.
      showInFocus = Util.removeNumberMax(value);

    } else if (setting.startsWith(SETTING_HAVE_SHOW)) {

      // The user just selected a different show.  Put it in focus.
      showInFocus = Util.removeNumberMax(value);

    } else if (setting.startsWith(SETTING_SHOW_MAX)) {

      // The user just entered a new max for this show. If it's non null add it.
      if (value == null || value.trim().length() == 0) return;

      try {
        Integer.parseInt(value);
      } catch (NumberFormatException e) {
        return;
      }

      DataStore store = new DataStore(showInFocus);
      store.addRecord(showInFocus);
      store.setMax(verifyMax(value));
    } else if (setting.startsWith(SETTING_RESET_SHOW)) {

      // The user wants to reset this show so just delete the User Record.
      DataStore store = new DataStore(showInFocus);
      if (store.deleteRecord()) showInFocus = null;
      else Log.getInstance().write(Log.LOGLEVEL_WARN, "Plugin: Could not delete the User Record.");
    }
  }
  public CustomFolder newCustomFolder(String table, String title) {
    IMediaResource res = getChildById(CustomFolder.CustomFolderPrefix + table);
    if (res != null) return (CustomFolder) res;

    Object rec = UserRecordAPI.GetUserRecord(getId(), table);
    if (rec == null) {
      CustomFolder f = new CustomFolder(this, table, title);
      Object cust = UserRecordAPI.AddUserRecord(getId(), table);
      UserRecordAPI.SetUserRecordData(cust, FIELD_TABLE, table);
      UserRecordAPI.SetUserRecordData(cust, FIELD_TITLE, title);
      addMediaResource(f);
      return f;
    } else {
      CustomFolder f = new CustomFolder(this, table, title);
      UserRecordAPI.SetUserRecordData(rec, FIELD_TITLE, title);
      addMediaResource(f);
      return f;
    }
  }
 @Override
 public boolean delete(Hints hints) {
   UserRecordAPI.DeleteAllUserRecords(getId());
   setChanged(true);
   return true;
 }