mirror of
https://github.com/Netflix/dial-reference.git
synced 2026-06-08 10:59:59 +00:00
updated hide
This commit is contained in:
@@ -296,9 +296,19 @@ static void handle_app_hide(struct mg_connection *conn,
|
||||
mg_send_http_error(conn, 404, "Not Found", "Not Found");
|
||||
} else {
|
||||
// not implemented in reference
|
||||
fprintf(stderr, "Hide not implemented for reference.");
|
||||
DIALStatus status = app->callbacks.hide_cb(ds, app_name, app->run_id, app->callback_data);
|
||||
if (status!=kDIALStatusHide){
|
||||
fprintf(stderr, "Hide not implemented for reference.\n");
|
||||
mg_send_http_error(conn, 501, "Not Implemented",
|
||||
"Not Implemented");
|
||||
}else{
|
||||
app->state = kDIALStatusHide;
|
||||
mg_printf(conn, "HTTP/1.1 200 OK\r\n"
|
||||
"Content-Type: text/plain\r\n"
|
||||
"Access-Control-Allow-Origin: %s\r\n"
|
||||
"\r\n",
|
||||
origin_header);
|
||||
}
|
||||
}
|
||||
ds_unlock(ds);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
typedef enum {
|
||||
kDIALStatusStopped,
|
||||
kDIALStatusHide,
|
||||
kDIALStatusRunning
|
||||
} DIALStatus;
|
||||
|
||||
@@ -69,6 +70,13 @@ typedef void * DIAL_run_t;
|
||||
typedef DIALStatus (*DIAL_app_start_cb)(DIALServer *ds, const char *app_name,
|
||||
const char *payload, const char *additionalDataUrl,
|
||||
DIAL_run_t *run_id, void *callback_data);
|
||||
|
||||
/*
|
||||
* DIAL hide callback
|
||||
*/
|
||||
typedef DIALStatus (*DIAL_app_hide_cb)(DIALServer *ds, const char *app_name,
|
||||
DIAL_run_t *run_id, void *callback_data);
|
||||
|
||||
/*
|
||||
* DIAL stop callback
|
||||
*/
|
||||
@@ -86,6 +94,7 @@ typedef DIALStatus (*DIAL_app_status_cb)(DIALServer *ds, const char *app_name,
|
||||
*/
|
||||
struct DIALAppCallbacks {
|
||||
DIAL_app_start_cb start_cb;
|
||||
DIAL_app_hide_cb hide_cb;
|
||||
DIAL_app_stop_cb stop_cb;
|
||||
DIAL_app_status_cb status_cb;
|
||||
};
|
||||
|
||||
@@ -260,6 +260,12 @@ static DIALStatus youtube_start(DIALServer *ds, const char *appname,
|
||||
return kDIALStatusRunning;
|
||||
}
|
||||
|
||||
static DIALStatus youtube_hide(DIALServer *ds, const char *app_name,
|
||||
DIAL_run_t *run_id, void *callback_data)
|
||||
{
|
||||
return (isAppRunning( spAppYouTube, spAppYouTubeMatch )) ? kDIALStatusRunning : kDIALStatusStopped;
|
||||
}
|
||||
|
||||
static DIALStatus youtube_status(DIALServer *ds, const char *appname,
|
||||
DIAL_run_t run_id, int *pCanStop, void *callback_data) {
|
||||
// YouTube can stop
|
||||
@@ -321,6 +327,12 @@ static DIALStatus netflix_start(DIALServer *ds, const char *appname,
|
||||
else return kDIALStatusRunning;
|
||||
}
|
||||
|
||||
static DIALStatus netflix_hide(DIALServer *ds, const char *app_name,
|
||||
DIAL_run_t *run_id, void *callback_data)
|
||||
{
|
||||
return (isAppRunning( spAppNetflix, NULL )) ? kDIALStatusRunning : kDIALStatusStopped;
|
||||
}
|
||||
|
||||
static DIALStatus netflix_status(DIALServer *ds, const char *appname,
|
||||
DIAL_run_t run_id, int* pCanStop, void *callback_data) {
|
||||
// Netflix application can stop
|
||||
@@ -376,8 +388,8 @@ void runDial(void)
|
||||
{
|
||||
DIALServer *ds;
|
||||
ds = DIAL_create();
|
||||
struct DIALAppCallbacks cb_nf = {netflix_start, netflix_stop, netflix_status};
|
||||
struct DIALAppCallbacks cb_yt = {youtube_start, youtube_stop, youtube_status};
|
||||
struct DIALAppCallbacks cb_nf = {netflix_start, netflix_hide, netflix_stop, netflix_status};
|
||||
struct DIALAppCallbacks cb_yt = {youtube_start, youtube_hide, youtube_stop, youtube_status};
|
||||
|
||||
DIAL_register_app(ds, "Netflix", &cb_nf, NULL, 1, ".netflix.com");
|
||||
DIAL_register_app(ds, "YouTube", &cb_yt, NULL, 1, ".youtube.com");
|
||||
|
||||
Reference in New Issue
Block a user