Permalink
Browse files

Allow for favorites to be disabled

1 parent 996070f commit 2e3a3c1bb5c1db95648e72ddc90933906c9c2a05 @skiingwiz skiingwiz committed Sep 22, 2015
Showing with 47 additions and 5 deletions.
  1. +1 −0 AUTHORS
  2. +1 −0 CONTRIBUTORS
  3. +8 −4 java/sage/Agent.java
  4. +1 −1 java/sage/Carny.java
  5. +36 −0 java/sage/api/FavoriteAPI.java
View
@@ -13,3 +13,4 @@ Sean Stuckless <sean.stuckless@gmail.com>
Raymond Chi <raychi@gmail.com>
Joshua Lewis <josh@joshandmonique.com>
Martin Weber Nissle <webernissle@gmail.com>
+Chris Danser <chris.danser@gmail.com>
View
@@ -23,3 +23,4 @@ Sean Stuckless <sean.stuckless@gmail.com>
Raymond Chi <raychi@gmail.com>
Joshua Lewis <josh@joshandmonique.com>
Martin Weber Nissle <webernissle@gmail.com>
+Chris Danser <chris.danser@gmail.com>
View
@@ -64,6 +64,7 @@
public static final int DONT_AUTODELETE_FLAG = 0x01;
public static final int KEEP_AT_MOST_MASK = 0x7E; // 6 bits
public static final int DELETE_AFTER_CONVERT_FLAG = 0x80;
+ public static final int DISABLED_FLAG = 0x100;
String getNameForType()
{
@@ -325,6 +326,7 @@ public String toString()
int keepAtMost = getAgentFlag(KEEP_AT_MOST_MASK);
if (keepAtMost > 0)
sb.append(" keep=").append(keepAtMost);
+ sb.append(" enabled=").append(!testAgentFlag(DISABLED_FLAG));
sb.append(']');
return sb.toString();
}
@@ -1210,10 +1212,12 @@ public int getAgentFlag(int whichFlag)
return agentFlags & DONT_AUTODELETE_FLAG;
else if (whichFlag == KEEP_AT_MOST_MASK)
return (agentFlags & KEEP_AT_MOST_MASK) >> 1;
- else if (whichFlag == DELETE_AFTER_CONVERT_FLAG)
- return agentFlags & DELETE_AFTER_CONVERT_FLAG;
- else
- return 0;
+ else if (whichFlag == DELETE_AFTER_CONVERT_FLAG)
+ return agentFlags & DELETE_AFTER_CONVERT_FLAG;
+ else if (whichFlag == DISABLED_FLAG)
+ return agentFlags & DISABLED_FLAG;
+ else
+ return 0;
}
void setAgentFlags(int maskBits, int values)
{
@@ -956,7 +956,7 @@ private void stdProcessing()
}
}
Agent currAgent = (Agent) allAgents[i];
- if (currAgent == null)
+ if (currAgent == null || currAgent.testAgentFlag(Agent.DISABLED_FLAG))
continue;
if ((!doneInit && Sage.getBoolean("limited_carny_init", Sage.EMBEDDED)) ||
@@ -113,6 +113,21 @@ public Object runSafely(Catbert.FastStack stack) throws Exception{
public Object runSafely(Catbert.FastStack stack) throws Exception{
return Boolean.valueOf(((Agent) stack.pop()).testAgentFlag(Agent.DELETE_AFTER_CONVERT_FLAG));
}});
+ rft.put(new PredefinedJEPFunction("Favorite", "IsEnabled", 1, new String[] { "Favorite" })
+ {
+ /**
+ * Returns true if SageTV considers this favorite when performing scheduling.
+ * @param Favorite the Favorite object
+ * @return true if this Favorite is enabled, false otherwise
+ * @since 9.0
+ *
+ * @declaration public boolean IsEnabled(Favorite Favorite);
+ */
+ @Override
+ public Object runSafely(Catbert.FastStack stack) throws Exception{
+ //Note here that the value of the test is negated
+ return Boolean.valueOf(!((Agent) stack.pop()).testAgentFlag(Agent.DISABLED_FLAG));
+ }});
rft.put(new PredefinedJEPFunction("Favorite", "GetKeepAtMost", 1, new String[] { "Favorite" })
{
/**
@@ -949,6 +964,27 @@ else if (slotType == BigBrother.FULL_ALIGN)
else
return Boolean.FALSE;
}});
+ rft.put(new PredefinedJEPFunction("Favorite", "SetEnabled", 2, new String[] { "Favorite", "Enabled" }, true)
+ {
+ /**
+ * Sets whether or not SageTV will use this favorite when scheduling recordings
+ * @param Favorite the Favorite object
+ * @param Enabled true if this Favorite is to be used for scheduling, false otherwise
+ * @since 9.0
+ *
+ * @declaration public void SetEnabled(Favorite Favorite, boolean Enabled);
+ */
+ @Override
+ public Object runSafely(Catbert.FastStack stack) throws Exception{
+ boolean b = evalBool(stack.pop());
+ Agent a = (Agent) stack.pop();
+ if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
+ {
+ Carny.getInstance().setAgentFlags(a, Agent.DISABLED_FLAG, b?0:Agent.DISABLED_FLAG);
+ Carny.getInstance().kick();
+ }
+ return null;
+ }});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteForAiring", 1, new String[] { "Airing" })
{
/**

0 comments on commit 2e3a3c1

Please sign in to comment.