Skip to content

Commit

Permalink
Allow for favorites to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
skiingwiz committed Sep 22, 2015
1 parent 996070f commit 2e3a3c1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -13,3 +13,4 @@ Sean Stuckless <sean.stuckless@gmail.com>
Raymond Chi <raychi@gmail.com> Raymond Chi <raychi@gmail.com>
Joshua Lewis <josh@joshandmonique.com> Joshua Lewis <josh@joshandmonique.com>
Martin Weber Nissle <webernissle@gmail.com> Martin Weber Nissle <webernissle@gmail.com>
Chris Danser <chris.danser@gmail.com>
1 change: 1 addition & 0 deletions CONTRIBUTORS
Expand Up @@ -23,3 +23,4 @@ Sean Stuckless <sean.stuckless@gmail.com>
Raymond Chi <raychi@gmail.com> Raymond Chi <raychi@gmail.com>
Joshua Lewis <josh@joshandmonique.com> Joshua Lewis <josh@joshandmonique.com>
Martin Weber Nissle <webernissle@gmail.com> Martin Weber Nissle <webernissle@gmail.com>
Chris Danser <chris.danser@gmail.com>
12 changes: 8 additions & 4 deletions java/sage/Agent.java
Expand Up @@ -64,6 +64,7 @@ public class Agent extends DBObject implements Favorite
public static final int DONT_AUTODELETE_FLAG = 0x01; public static final int DONT_AUTODELETE_FLAG = 0x01;
public static final int KEEP_AT_MOST_MASK = 0x7E; // 6 bits public static final int KEEP_AT_MOST_MASK = 0x7E; // 6 bits
public static final int DELETE_AFTER_CONVERT_FLAG = 0x80; public static final int DELETE_AFTER_CONVERT_FLAG = 0x80;
public static final int DISABLED_FLAG = 0x100;


String getNameForType() String getNameForType()
{ {
Expand Down Expand Up @@ -325,6 +326,7 @@ public String toString()
int keepAtMost = getAgentFlag(KEEP_AT_MOST_MASK); int keepAtMost = getAgentFlag(KEEP_AT_MOST_MASK);
if (keepAtMost > 0) if (keepAtMost > 0)
sb.append(" keep=").append(keepAtMost); sb.append(" keep=").append(keepAtMost);
sb.append(" enabled=").append(!testAgentFlag(DISABLED_FLAG));
sb.append(']'); sb.append(']');
return sb.toString(); return sb.toString();
} }
Expand Down Expand Up @@ -1210,10 +1212,12 @@ public int getAgentFlag(int whichFlag)
return agentFlags & DONT_AUTODELETE_FLAG; return agentFlags & DONT_AUTODELETE_FLAG;
else if (whichFlag == KEEP_AT_MOST_MASK) else if (whichFlag == KEEP_AT_MOST_MASK)
return (agentFlags & KEEP_AT_MOST_MASK) >> 1; return (agentFlags & KEEP_AT_MOST_MASK) >> 1;
else if (whichFlag == DELETE_AFTER_CONVERT_FLAG) else if (whichFlag == DELETE_AFTER_CONVERT_FLAG)
return agentFlags & DELETE_AFTER_CONVERT_FLAG; return agentFlags & DELETE_AFTER_CONVERT_FLAG;
else else if (whichFlag == DISABLED_FLAG)
return 0; return agentFlags & DISABLED_FLAG;
else
return 0;
} }
void setAgentFlags(int maskBits, int values) void setAgentFlags(int maskBits, int values)
{ {
Expand Down
2 changes: 1 addition & 1 deletion java/sage/Carny.java
Expand Up @@ -956,7 +956,7 @@ private void stdProcessing()
} }
} }
Agent currAgent = (Agent) allAgents[i]; Agent currAgent = (Agent) allAgents[i];
if (currAgent == null) if (currAgent == null || currAgent.testAgentFlag(Agent.DISABLED_FLAG))
continue; continue;


if ((!doneInit && Sage.getBoolean("limited_carny_init", Sage.EMBEDDED)) || if ((!doneInit && Sage.getBoolean("limited_carny_init", Sage.EMBEDDED)) ||
Expand Down
36 changes: 36 additions & 0 deletions java/sage/api/FavoriteAPI.java
Expand Up @@ -113,6 +113,21 @@ public Object runSafely(Catbert.FastStack stack) throws Exception{
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)); 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" }) rft.put(new PredefinedJEPFunction("Favorite", "GetKeepAtMost", 1, new String[] { "Favorite" })
{ {
/** /**
Expand Down Expand Up @@ -949,6 +964,27 @@ else if (slotType == BigBrother.FULL_ALIGN)
else else
return Boolean.FALSE; 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" }) rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteForAiring", 1, new String[] { "Airing" })
{ {
/** /**
Expand Down

0 comments on commit 2e3a3c1

Please sign in to comment.