From 474789340bace1ca955b6d5f367e4ab01056dfe7 Mon Sep 17 00:00:00 2001 From: jcli Date: Wed, 20 Jul 2016 14:05:24 -0700 Subject: [PATCH] added hooks for netflix app manager --- server/dial_options.h | 9 +++++++++ server/main.c | 26 +++++++++++++++++++++++++- server/makefile | 2 +- server/nf_appmanager.c | 28 ++++++++++++++++++++++++++++ server/nf_appmanager.h | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 server/nf_appmanager.c create mode 100644 server/nf_appmanager.h diff --git a/server/dial_options.h b/server/dial_options.h index 6f6b970..1a587c5 100644 --- a/server/dial_options.h +++ b/server/dial_options.h @@ -50,6 +50,10 @@ #define WAKE_OPTION_LONG "--wake-on-wifi-len" #define WAKE_DESCRIPTION "Enable wake on wifi/len. Value: on/off. Default (on)" +#define NFMANAGER_OPTION "-A" +#define NFMANAGER_OPTION_LONG "--netflix-app-manager" +#define NFMANAGER_DESCRIPTION "Enable interface to netflix app manager." + struct dial_options { const char * pOption; @@ -88,6 +92,11 @@ struct dial_options gDialOptions[] = WAKE_OPTION, WAKE_OPTION_LONG, WAKE_DESCRIPTION + }, + { + NFMANAGER_OPTION, + NFMANAGER_OPTION_LONG, + NFMANAGER_DESCRIPTION } }; diff --git a/server/main.c b/server/main.c index f66b858..802c48c 100644 --- a/server/main.c +++ b/server/main.c @@ -40,6 +40,10 @@ #include #include +#include "nf_appmanager.h" + +#define NF_APP_MANAGER + #define BUFSIZE 256 static char *spAppNetflix = "netflix"; // name of the netflix executable @@ -58,6 +62,8 @@ static char spUuid[BUFSIZE]; extern bool wakeOnWifiLan; static int gDialPort; +static bool sUseNFAppManager=false; + static char *spAppYouTube = "chrome"; static char *spAppYouTubeMatch = "chrome.*google-chrome-dial"; static char *spAppYouTubeExecutable = "/opt/google/chrome/google-chrome"; @@ -388,7 +394,18 @@ void runDial(void) { DIALServer *ds; ds = DIAL_create(); - struct DIALAppCallbacks cb_nf = {netflix_start, netflix_hide, netflix_stop, netflix_status}; + struct DIALAppCallbacks cb_nf; + if (sUseNFAppManager){ + cb_nf.start_cb = am_netflix_start; + cb_nf.hide_cb = am_netflix_hide; + cb_nf.stop_cb = am_netflix_stop; + cb_nf.status_cb = am_netflix_status; + }else{ + cb_nf.start_cb = netflix_start; + cb_nf.hide_cb = netflix_hide; + cb_nf.stop_cb = netflix_stop; + cb_nf.status_cb = 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"); @@ -434,6 +451,13 @@ static void processOption( int index, char * pOption ) exit(1); } break; + case 6: + if (strcmp(pOption, "true")==0){ + sUseNFAppManager=true; + }else{ + sUseNFAppManager=false; + } + break; default: // Should not get here fprintf( stderr, "Option %d not valid\n", index); diff --git a/server/makefile b/server/makefile index ec9cd95..480c58d 100644 --- a/server/makefile +++ b/server/makefile @@ -3,7 +3,7 @@ CC=$(TARGET)gcc .PHONY: clean .DEFAULT_GOAL=all -OBJS := main.o dial_server.o mongoose.o quick_ssdp.o url_lib.o dial_data.o LinuxInterfaces.o +OBJS := main.o dial_server.o mongoose.o quick_ssdp.o url_lib.o dial_data.o LinuxInterfaces.o nf_appmanager.o HEADERS := $(wildcard *.h) %.c: $(HEADERS) diff --git a/server/nf_appmanager.c b/server/nf_appmanager.c new file mode 100644 index 0000000..1b622b8 --- /dev/null +++ b/server/nf_appmanager.c @@ -0,0 +1,28 @@ +#include +#include +#include "nf_appmanager.h" + +DIALStatus am_netflix_start(DIALServer *ds, const char *appname, + const char *payload, const char *additionalDataUrl, + DIAL_run_t *run_id, void *callback_data) +{ + printf ("it's all wired..\n"); + return kDIALStatusRunning; +} + +DIALStatus am_netflix_hide(DIALServer *ds, const char *app_name, + DIAL_run_t *run_id, void *callback_data) +{ + return kDIALStatusHide; +} + +DIALStatus am_netflix_status(DIALServer *ds, const char *appname, + DIAL_run_t run_id, int* pCanStop, void *callback_data) +{ + return kDIALStatusStopped; +} + +void am_netflix_stop(DIALServer *ds, const char *appname, DIAL_run_t run_id, + void *callback_data) +{ +} diff --git a/server/nf_appmanager.h b/server/nf_appmanager.h new file mode 100644 index 0000000..35c5cbb --- /dev/null +++ b/server/nf_appmanager.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Netflix, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETFLIX, INC. AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NETFLIX OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "dial_server.h" + +DIALStatus am_netflix_start(DIALServer *ds, const char *appname, + const char *payload, const char *additionalDataUrl, + DIAL_run_t *run_id, void *callback_data); + + +DIALStatus am_netflix_hide(DIALServer *ds, const char *app_name, + DIAL_run_t *run_id, void *callback_data); + +DIALStatus am_netflix_status(DIALServer *ds, const char *appname, + DIAL_run_t run_id, int* pCanStop, void *callback_data); + +void am_netflix_stop(DIALServer *ds, const char *appname, DIAL_run_t run_id, + void *callback_data);