[Redbutton-devel] SF.net SVN: redbutton:[548] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2011-06-02 08:19:57
|
Revision: 548
http://redbutton.svn.sourceforge.net/redbutton/?rev=548&view=rev
Author: skilvington
Date: 2011-06-02 08:19:51 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
spec says we should not activate unknown programs - doesn't fix Freesat ITV sadly
Modified Paths:
--------------
redbutton-browser/trunk/ResidentProgramClass.c
redbutton-browser/trunk/ResidentProgramClass.h
Modified: redbutton-browser/trunk/ResidentProgramClass.c
===================================================================
--- redbutton-browser/trunk/ResidentProgramClass.c 2011-06-02 07:53:55 UTC (rev 547)
+++ redbutton-browser/trunk/ResidentProgramClass.c 2011-06-02 08:19:51 UTC (rev 548)
@@ -24,6 +24,7 @@
#include "si.h"
/* internal functions */
+bool unknown_program(ResidentProgramClass *);
bool run_program(ResidentProgramClass *, LIST_OF(Parameter) *, OctetString *, bool);
bool check_parameters(LIST_OF(Parameter) *, unsigned int, ...);
Parameter *get_parameter(LIST_OF(Parameter) *, unsigned int);
@@ -67,14 +68,18 @@
return;
}
-void
+bool
ResidentProgramClass_Activation(ResidentProgramClass *t)
{
verbose("ResidentProgramClass: %s; Activation", ExternalReference_name(&t->rootClass.inst.ref));
+ /* MHEG spec says if the program is unknown, then disregard this action */
+ if(unknown_program(t))
+ return false;
+
/* has it already been activated */
if(!RootClass_Activation(&t->rootClass))
- return;
+ return true;
/* set RunningStatus */
t->rootClass.inst.RunningStatus = true;
@@ -82,7 +87,7 @@
/* generate IsRunning event */
MHEGEngine_generateEvent(&t->rootClass.inst.ref, EventType_is_running, NULL);
- return;
+ return true;
}
void
@@ -159,8 +164,11 @@
verbose("ResidentProgramClass: %s; Call '%.*s'", ExternalReference_name(&p->rootClass.inst.ref), p->name.size, p->name.data);
+ /* Activation will fail for unknown programs */
+ if(!ResidentProgramClass_Activation(p))
+ return;
+
/* run it and wait for it to complete */
- ResidentProgramClass_Activation(p);
rc = run_program(p, params->parameters, caller_gid, false);
/* store the return value */
@@ -199,11 +207,14 @@
verbose("ResidentProgramClass: %s; Fork '%.*s'", ExternalReference_name(&p->rootClass.inst.ref), p->name.size, p->name.data);
+ /* Activation will fail for unknown programs */
+ if(!ResidentProgramClass_Activation(p))
+ return;
+
/* run it in the background */
/******************************************************************************************/
/* TODO */
printf("TODO: ResidentProgramClass_Fork not yet implemented - running in foreground\n");
- ResidentProgramClass_Activation(p);
rc = run_program(p, params->parameters, caller_gid, true);
/* return immediately */
/******************************************************************************************/
@@ -234,11 +245,7 @@
}
/*
- * run the given program (identified by the name field in the ResidentProgramClass)
- * returns true if the program succeeds
- * sets the parameters to the values described by the UK MHEG Profile
- * caller_gid is used to resolve Generic variables in the parameters
- * if forked is true, return immediately and run the program in the background
+ * programs defined in the UK MHEG Profile
*/
struct
@@ -275,7 +282,37 @@
{ "", "", NULL }
};
+/*
+ * returns true if the program is not found in our list
+ */
+
bool
+unknown_program(ResidentProgramClass *p)
+{
+ unsigned int i;
+
+ for(i=0; resident_progs[i].func!=NULL; i++)
+ {
+ if(OctetString_strcmp(&p->name, resident_progs[i].short_name) == 0
+ || OctetString_strcmp(&p->name, resident_progs[i].long_name) == 0)
+ return false;
+ }
+
+ /* not found */
+ error("Unknown ResidentProgram: '%.*s'", p->name.size, p->name.data);
+
+ return true;
+}
+
+/*
+ * run the given program (identified by the name field in the ResidentProgramClass)
+ * returns true if the program succeeds
+ * sets the parameters to the values described by the UK MHEG Profile
+ * caller_gid is used to resolve Generic variables in the parameters
+ * if forked is true, return immediately and run the program in the background
+ */
+
+bool
run_program(ResidentProgramClass *p, LIST_OF(Parameter) *params, OctetString *caller_gid, bool forked)
{
bool rc;
Modified: redbutton-browser/trunk/ResidentProgramClass.h
===================================================================
--- redbutton-browser/trunk/ResidentProgramClass.h 2011-06-02 07:53:55 UTC (rev 547)
+++ redbutton-browser/trunk/ResidentProgramClass.h 2011-06-02 08:19:51 UTC (rev 548)
@@ -8,7 +8,7 @@
#include "ISO13522-MHEG-5.h"
void ResidentProgramClass_Preparation(ResidentProgramClass *);
-void ResidentProgramClass_Activation(ResidentProgramClass *);
+bool ResidentProgramClass_Activation(ResidentProgramClass *);
void ResidentProgramClass_Deactivation(ResidentProgramClass *);
void ResidentProgramClass_Destruction(ResidentProgramClass *);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|