Add support for FiberTV

Change-Id: Ied44b6ac98ecc46652da992c61db93c646e691cd
diff --git a/src/server/main.c b/src/server/main.c
index 8de2f45..3a8afbd 100644
--- a/src/server/main.c
+++ b/src/server/main.c
@@ -54,6 +54,9 @@
 static char *spAppYouTube = "content_shell";
 static char *spAppYouTubeMatch = "www.youtube.com/tv";
 
+static char *spAppFiberTV = "miniclient";
+static char *spAppFiberTVMatch = NULL;
+
 // Adding 20 bytes for prepended source_type for Netflix
 static char sQueryParam[DIAL_MAX_PAYLOAD+20];
 
@@ -347,6 +350,33 @@
     }
 }
 
+static DIALStatus fibertv_start(DIALServer *ds, const char *appname,
+                                const char *args, size_t arglen,
+                                DIAL_run_t *run_id, void *callback_data) {
+    printf("** LAUNCH FiberTV **\n");
+
+    const char * const miniclient_args[] = { "miniclient", NULL };
+    runApplication( miniclient_args, run_id );
+
+    return kDIALStatusRunning;
+}
+
+static DIALStatus fibertv_status(DIALServer *ds, const char *appname,
+                                 DIAL_run_t run_id, int *pCanStop, void *callback_data) {
+    // FiberTV can stop
+    *pCanStop = 1;
+    return isAppRunning( spAppFiberTV, spAppFiberTVMatch ) ? kDIALStatusRunning : kDIALStatusStopped;
+}
+
+static void fibertv_stop(DIALServer *ds, const char *appname, DIAL_run_t run_id,
+                         void *callback_data) {
+    printf("** KILL FiberTV **\n");
+    pid_t pid;
+    if ((pid = isAppRunning( spAppFiberTV, spAppFiberTVMatch ))) {
+        kill(pid, SIGTERM);
+    }
+}
+
 void run_ssdp(int port, const char *pFriendlyName, const char * pModelName, const char *pUuid);
 
 static void printUsage()
@@ -376,9 +406,11 @@
     ds = DIAL_start();
     struct DIALAppCallbacks cb_nf = {netflix_start, netflix_stop, netflix_status};
     struct DIALAppCallbacks cb_yt = {youtube_start, youtube_stop, youtube_status};
+    struct DIALAppCallbacks cb_ft = {fibertv_start, fibertv_stop, fibertv_status};
 
     DIAL_register_app(ds, "Netflix", &cb_nf, NULL);
     DIAL_register_app(ds, "YouTube", &cb_yt, NULL);
+    DIAL_register_app(ds, "FiberTV", &cb_ft, NULL);
     gDialPort = DIAL_get_port(ds);
     printf("launcher listening on gDialPort %d\n", gDialPort);
     run_ssdp(gDialPort, spFriendlyName, spModelName, spUuid);
@@ -413,6 +445,8 @@
     printf("Netflix is %s\n", i ? "Running":"Not Running");
     i = isAppRunning( spAppYouTube, spAppYouTubeMatch );
     printf("YouTube is %s\n", i ? "Running":"Not Running");
+    i = isAppRunning( spAppFiberTV, spAppFiberTVMatch );
+    printf("FiberTV is %s\n", i ? "Running":"Not Running");
 
     // set all defaults
     setValue(spDefaultFriendlyName, spFriendlyName );