#include #include #include #include "nf_appmanager.h" #include "mq_ipc.h" #include "jsmn.h" #include "url_lib.h" static char *defaultLaunchParam = "source_type=12"; static char * mq_send_ch = "/fromAppManager"; static char * mq_receive_ch = "/toAppManager"; static char * mq_tx_msg_base = " {\"args\":\"%s\",\"message\":%d}"; static int s_run_id = 0; typedef enum ControllerCommand { //----------------------------------- // Commands sent to AM //----------------------------------- CMD_CNT_START, // Launch the app CMD_CNT_HIDE, // Suspend app CMD_CNT_START_FROM_HIDE, // Resume app CMD_CNT_STOP=6, // Terminate app nicely because the user killed Netflix. CMD_CNT_GET_STATUS=8, // Provide status of the app }ControllerCommand_t; typedef enum ControllerResp { //----------------------------------- // Resp sent from AM //----------------------------------- RESP_OK, RESP_ERR, }ControllerResp_t; typedef enum NetflixStatus { //----------------------------------- // Netflix status //----------------------------------- STATUS_NETFLIX_RUNNING, STATUS_NETFLIX_HIDE1, STATUS_NETFLIX_HIDE2, STATUS_NETFLIX_STOPPED, }NetflixStatus_t; void errorMsg() { printf("\nIn this mode, a matching application manager must be started and listen on the appropriate IPC.\n\n"); exit(1); } static int jsoneq(const char *json, jsmntok_t *tok, const char *s) { if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start && strncmp(json + tok->start, s, tok->end - tok->start) == 0) { return 0; } return -1; } NetflixStatus_t parse_nf_state(char* json_str, jsmntok_t* tokens, int num_tokens) { for (int i=0; i