mirror of
https://github.com/Netflix/dial-reference.git
synced 2026-06-08 02:49:58 +00:00
Introduce a command line option to pass sleep password.
And fix return code for "launching" system app.
This commit is contained in:
@@ -50,6 +50,10 @@
|
|||||||
#define WAKE_OPTION_LONG "--wake-on-wifi-len"
|
#define WAKE_OPTION_LONG "--wake-on-wifi-len"
|
||||||
#define WAKE_DESCRIPTION "Enable wake on wifi/len. Value: on/off. Default (on)"
|
#define WAKE_DESCRIPTION "Enable wake on wifi/len. Value: on/off. Default (on)"
|
||||||
|
|
||||||
|
#define SLEEP_PASSWORD "-S"
|
||||||
|
#define SLEEP_PASSWORD_LONG "--sleep-password"
|
||||||
|
#define SLEEP_PASSWORD_DESCRIPTION "Password required to put the device to deep sleep"
|
||||||
|
|
||||||
struct dial_options
|
struct dial_options
|
||||||
{
|
{
|
||||||
const char * pOption;
|
const char * pOption;
|
||||||
@@ -88,6 +92,11 @@ struct dial_options gDialOptions[] =
|
|||||||
WAKE_OPTION,
|
WAKE_OPTION,
|
||||||
WAKE_OPTION_LONG,
|
WAKE_OPTION_LONG,
|
||||||
WAKE_DESCRIPTION
|
WAKE_DESCRIPTION
|
||||||
|
},
|
||||||
|
{
|
||||||
|
SLEEP_PASSWORD,
|
||||||
|
SLEEP_PASSWORD_LONG,
|
||||||
|
SLEEP_PASSWORD_DESCRIPTION
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ static char spUuid[BUFSIZE];
|
|||||||
extern bool wakeOnWifiLan;
|
extern bool wakeOnWifiLan;
|
||||||
static int gDialPort;
|
static int gDialPort;
|
||||||
|
|
||||||
|
char spSleepPassword[BUFSIZE];
|
||||||
|
|
||||||
static char *spAppYouTube = "chrome";
|
static char *spAppYouTube = "chrome";
|
||||||
static char *spAppYouTubeMatch = "chrome.*google-chrome-dial";
|
static char *spAppYouTubeMatch = "chrome.*google-chrome-dial";
|
||||||
static char *spAppYouTubeExecutable = "/opt/google/chrome/google-chrome";
|
static char *spAppYouTubeExecutable = "/opt/google/chrome/google-chrome";
|
||||||
@@ -325,6 +327,9 @@ static void processOption( int index, char * pOption )
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 6:
|
||||||
|
setValue( pOption, spSleepPassword );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// Should not get here
|
// Should not get here
|
||||||
fprintf( stderr, "Option %d not valid\n", index);
|
fprintf( stderr, "Option %d not valid\n", index);
|
||||||
|
|||||||
@@ -1,26 +1,39 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "system_callbacks.h"
|
#include "system_callbacks.h"
|
||||||
|
|
||||||
|
extern char spSleepPassword[];
|
||||||
|
|
||||||
DIALStatus system_start(DIALServer *ds, const char *appname, const char *payload, const char* query_string,
|
DIALStatus system_start(DIALServer *ds, const char *appname, const char *payload, const char* query_string,
|
||||||
const char *additionalDataUrl, DIAL_run_t *run_id, void *callback_data) {
|
const char *additionalDataUrl, DIAL_run_t *run_id, void *callback_data) {
|
||||||
|
|
||||||
|
/* Can't launch system app */
|
||||||
|
if (0 == query_string) {
|
||||||
|
return kDIALStatusErrorForbidden;
|
||||||
|
}
|
||||||
|
|
||||||
/* Only sleep is supported action */
|
/* Only sleep is supported action */
|
||||||
if ((0 == query_string) || (0 != strncmp( query_string, "action=sleep", sizeof("action=sleep") - 1))) {
|
if (0 != strncmp( query_string, "action=sleep", sizeof("action=sleep") - 1)) {
|
||||||
return kDIALStatusErrorNotImplemented; // Only "sleep" is valid action
|
return kDIALStatusErrorNotImplemented; // Only "sleep" is valid action
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look for key */
|
if (strlen(spSleepPassword) != 0) {
|
||||||
char *key_value;
|
|
||||||
if ( (key_value = strchr(query_string, '&')) == '\0' ) {
|
|
||||||
return kDIALStatusErrorForbidden; // No key specified.
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Looking for hardcoded "TEST" key */
|
/* Look for key */
|
||||||
*key_value++ = '\0';
|
char *key_value;
|
||||||
if (0 != strncmp( key_value, "key=TEST", sizeof("key=TEST") - 1)) {
|
if ( (key_value = strchr(query_string, '&')) == '\0' ) {
|
||||||
return kDIALStatusErrorUnauth; // Invalid key
|
return kDIALStatusErrorForbidden; // No key specified.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Look for sleep password */
|
||||||
|
*key_value++ = '\0';
|
||||||
|
char str[512];
|
||||||
|
snprintf(str, 512, "key=%s", spSleepPassword);
|
||||||
|
printf(" str: %s \n", str);
|
||||||
|
if (0 != strncmp( key_value, "key=TEST", sizeof("key=TEST") - 1)) {
|
||||||
|
return kDIALStatusErrorUnauth; // Invalid key
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Sleep not implemented in reference implementation */
|
/* Sleep not implemented in reference implementation */
|
||||||
return kDIALStatusErrorNotImplemented;
|
return kDIALStatusErrorNotImplemented;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user